Bug 1192910 - Ensure we flush paints on the main thread during an APZ flush. r=mstange. reland because backout didn't fix the issue
☠☠ backed out by 14838e17cfaf ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 07 Mar 2016 16:27:44 -0500
changeset 287235 9c232821ae5cd4f2f79a12c58c7e290b2f0d7371
parent 287234 8abae773141708595c9f91fe34beff3703f8bb25
child 287236 084c4f8baf4896300db1e6cc999bfbad5bb91145
push idunknown
push userunknown
push dateunknown
reviewersmstange
bugs1192910
milestone47.0a1
Bug 1192910 - Ensure we flush paints on the main thread during an APZ flush. r=mstange. reland because backout didn't fix the issue MozReview-Commit-ID: 61dyeqxxtVP
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/ChromeProcessController.cpp
gfx/layers/ipc/APZChild.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -887,19 +887,29 @@ APZCCallbackHelper::NotifyMozMouseScroll
 
   nsContentUtils::DispatchTrustedEvent(
     ownerDoc, targetContent,
     aEvent,
     true, true);
 }
 
 void
-APZCCallbackHelper::NotifyFlushComplete()
+APZCCallbackHelper::NotifyFlushComplete(nsIPresShell* aShell)
 {
   MOZ_ASSERT(NS_IsMainThread());
+  // In some cases, flushing the APZ state to the main thread doesn't actually
+  // trigger a flush and repaint (this is an intentional optimization - the stuff
+  // visible to the user is still correct). However, reftests update their
+  // snapshot based on invalidation events that are emitted during paints,
+  // so we ensure that we kick off a paint when an APZ flush is done. Note that
+  // only chrome/testing code can trigger this behaviour.
+  if (aShell && aShell->GetRootFrame()) {
+    aShell->GetRootFrame()->SchedulePaint();
+  }
+
   nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
   MOZ_ASSERT(observerService);
   observerService->NotifyObservers(nullptr, "apz-repaints-flushed", nullptr);
 }
 
 static int32_t sActiveSuppressDisplayport = 0;
 
 void
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -156,17 +156,17 @@ public:
                                                          const WidgetTouchEvent& aEvent,
                                                          uint64_t aInputBlockId,
                                                          const SetAllowedTouchBehaviorCallback& aCallback);
 
     /* Notify content of a mouse scroll testing event. */
     static void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent);
 
     /* Notify content that the repaint flush is complete. */
-    static void NotifyFlushComplete();
+    static void NotifyFlushComplete(nsIPresShell* aShell);
 
     /* Temporarily ignore the Displayport for better paint performance. */
     static void SuppressDisplayport(const bool& aEnabled);
     static bool IsDisplayportSuppressed();
 
 private:
   static uint64_t sLastTargetAPZCNotificationInputBlock;
 };
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -227,10 +227,10 @@ ChromeProcessController::NotifyMozMouseS
 
   APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent);
 }
 
 void
 ChromeProcessController::NotifyFlushComplete()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  APZCCallbackHelper::NotifyFlushComplete();
+  APZCCallbackHelper::NotifyFlushComplete(GetPresShell());
 }
--- a/gfx/layers/ipc/APZChild.cpp
+++ b/gfx/layers/ipc/APZChild.cpp
@@ -146,17 +146,21 @@ APZChild::RecvNotifyAPZStateChange(const
                                    const int& aArg)
 {
   return mBrowser->NotifyAPZStateChange(aViewId, aChange, aArg);
 }
 
 bool
 APZChild::RecvNotifyFlushComplete()
 {
-  APZCCallbackHelper::NotifyFlushComplete();
+  nsCOMPtr<nsIPresShell> shell;
+  if (nsCOMPtr<nsIDocument> doc = mBrowser->GetDocument()) {
+    shell = doc->GetShell();
+  }
+  APZCCallbackHelper::NotifyFlushComplete(shell.get());
   return true;
 }
 
 void
 APZChild::SetObserver(nsIObserver* aObserver)
 {
   MOZ_ASSERT(!mBrowser);
   mObserver = aObserver;