Bug 1320587 - Force first paint when (re-)attaching Gecko to Java. r=darchons draft
authorNick Alexander <nalexander@mozilla.com>
Tue, 29 Nov 2016 23:12:53 -0800
changeset 445778 2ffc75df008bb215f2fcc7b32d401af3a99d5cfe
parent 445777 08da09b951ef60e9bdb4f95b1b8a024dbff9f1bb
child 538608 aa3c6aaf1496260a6bd7195d3783bda064d32e98
push id37604
push usernalexander@mozilla.com
push dateWed, 30 Nov 2016 07:13:23 +0000
reviewersdarchons
bugs1320587
milestone53.0a1
Bug 1320587 - Force first paint when (re-)attaching Gecko to Java. r=darchons MozReview-Commit-ID: 6vUbIXTPNLQ
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1062,40 +1062,30 @@ private:
 public:
     void AttachToJava(jni::Object::Param aClient, jni::Object::Param aNPZC)
     {
         MOZ_ASSERT(NS_IsMainThread());
         if (!mWindow) {
             return; // Already shut down.
         }
 
-        const auto& layerClient = GeckoLayerClient::Ref::From(aClient);
-
-        // If resetting is true, Android destroyed our GeckoApp activity and we
-        // had to recreate it, but all the Gecko-side things were not
-        // destroyed.  We therefore need to link up the new java objects to
-        // Gecko, and that's what we do here.
-        const bool resetting = !!mLayerClient;
-        mLayerClient = layerClient;
+        mLayerClient = GeckoLayerClient::Ref::From(aClient);
 
         MOZ_ASSERT(aNPZC);
         auto npzc = NativePanZoomController::LocalRef(
                 jni::GetGeckoThreadEnv(),
                 NativePanZoomController::Ref::From(aNPZC));
         mWindow->mNPZCSupport.Attach(npzc, mWindow, npzc);
 
-        layerClient->OnGeckoReady();
-
-        if (resetting) {
-            // Since we are re-linking the new java objects to Gecko, we need
-            // to get the viewport from the compositor (since the Java copy was
-            // thrown away) and we do that by setting the first-paint flag.
-            if (RefPtr<CompositorBridgeParent> bridge = mWindow->GetCompositorBridgeParent()) {
-                bridge->ForceIsFirstPaint();
-            }
+        mLayerClient->OnGeckoReady();
+
+        // Set the first-paint flag so that we (re-)link any new Java objects
+        // to Gecko, co-ordinate viewports, etc.
+        if (RefPtr<CompositorBridgeParent> bridge = mWindow->GetCompositorBridgeParent()) {
+            bridge->ForceIsFirstPaint();
         }
     }
 
     void OnSizeChanged(int32_t aWindowWidth, int32_t aWindowHeight,
                        int32_t aScreenWidth, int32_t aScreenHeight)
     {
         MOZ_ASSERT(NS_IsMainThread());
         if (!mWindow) {