Bug 1142926 - Only notify the docshell of state changes when moving in and out of a transforming state across all APZCs. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 16 Mar 2015 14:52:52 -0400
changeset 233950 71c85590ab177beae5ad4875fd5ee3ef5f428330
parent 233949 631d6d97081018af78a02c2dfc1490e0d6ef61bf
child 233951 a666d175b1574ed2a2b972202e4581bbf22e0ab3
push id28426
push usercbook@mozilla.com
push dateTue, 17 Mar 2015 10:46:54 +0000
treeherdermozilla-central@008b3f65a7e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1142926
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1142926 - Only notify the docshell of state changes when moving in and out of a transforming state across all APZCs. r=botond
gfx/layers/apz/util/APZEventState.cpp
gfx/layers/apz/util/APZEventState.h
--- a/gfx/layers/apz/util/APZEventState.cpp
+++ b/gfx/layers/apz/util/APZEventState.cpp
@@ -80,16 +80,17 @@ APZEventState::APZEventState(nsIWidget* 
                              const nsRefPtr<ContentReceivedInputBlockCallback>& aCallback)
   : mWidget(nullptr)  // initialized in constructor body
   , mActiveElementManager(new ActiveElementManager())
   , mContentReceivedInputBlockCallback(aCallback)
   , mPendingTouchPreventedResponse(false)
   , mPendingTouchPreventedBlockId(0)
   , mEndTouchIsClick(false)
   , mTouchEndCancelled(false)
+  , mActiveAPZTransforms(0)
 {
   nsresult rv;
   mWidget = do_GetWeakReference(aWidget, &rv);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "APZEventState constructed with a widget that"
       " does not support weak references. APZ will NOT work!");
 
   if (!sActiveDurationMsSet) {
     Preferences::AddIntVarCache(&sActiveDurationMs,
@@ -315,37 +316,39 @@ APZEventState::ProcessAPZStateChange(con
     if (sf) {
       sf->SetTransformingByAPZ(true);
     }
     nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
     if (scrollbarMediator) {
       scrollbarMediator->ScrollbarActivityStarted();
     }
 
-    if (aDocument) {
+    if (aDocument && mActiveAPZTransforms == 0) {
       nsCOMPtr<nsIDocShell> docshell(aDocument->GetDocShell());
       if (docshell && sf) {
         nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
         nsdocshell->NotifyAsyncPanZoomStarted(sf->GetScrollPositionCSSPixels());
       }
     }
+    mActiveAPZTransforms++;
     break;
   }
   case APZStateChange::TransformEnd:
   {
+    mActiveAPZTransforms--;
     nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
     if (sf) {
       sf->SetTransformingByAPZ(false);
     }
     nsIScrollbarMediator* scrollbarMediator = do_QueryFrame(sf);
     if (scrollbarMediator) {
       scrollbarMediator->ScrollbarActivityStopped();
     }
 
-    if (aDocument) {
+    if (aDocument && mActiveAPZTransforms == 0) {
       nsCOMPtr<nsIDocShell> docshell(aDocument->GetDocShell());
       if (docshell && sf) {
         nsDocShell* nsdocshell = static_cast<nsDocShell*>(docshell.get());
         nsdocshell->NotifyAsyncPanZoomStopped(sf->GetScrollPositionCSSPixels());
       }
     }
     break;
   }
--- a/gfx/layers/apz/util/APZEventState.h
+++ b/gfx/layers/apz/util/APZEventState.h
@@ -82,14 +82,15 @@ private:
   nsWeakPtr mWidget;
   nsRefPtr<ActiveElementManager> mActiveElementManager;
   nsRefPtr<ContentReceivedInputBlockCallback> mContentReceivedInputBlockCallback;
   bool mPendingTouchPreventedResponse;
   ScrollableLayerGuid mPendingTouchPreventedGuid;
   uint64_t mPendingTouchPreventedBlockId;
   bool mEndTouchIsClick;
   bool mTouchEndCancelled;
+  int mActiveAPZTransforms;
 };
 
 }
 }
 
 #endif /* mozilla_layers_APZEventState_h */