Bug 1134917 - Hoist assertion into the one callsite where it is actually valid. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 24 Jul 2015 14:33:47 -0400
changeset 286222 a157bac2cdae045c2bb361f2a5da6b245b4d5ad5
parent 286221 cac950e9abb461a882c4a1abbb36c8820b4d658c
child 286223 8a1df23b6a3f4f7498ae554dc12d505f5db67628
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1134917
milestone42.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 1134917 - Hoist assertion into the one callsite where it is actually valid. 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
@@ -211,17 +211,17 @@ APZEventState::ProcessLongTap(const nsCO
 {
   APZES_LOG("Handling long tap at %s\n", Stringify(aPoint).c_str());
 
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return;
   }
 
-  SendPendingTouchPreventedResponse(false, aGuid);
+  SendPendingTouchPreventedResponse(false);
 
   // Converting the modifiers to DOM format for the DispatchMouseEvent call
   // is the most useless thing ever because nsDOMWindowUtils::SendMouseEvent
   // just converts them back to widget format, but that API has many callers,
   // including in JS code, so it's not trivial to change.
   bool eventHandled =
       APZCCallbackHelper::DispatchMouseEvent(aPresShell, NS_LITERAL_STRING("contextmenu"),
                          APZCCallbackHelper::ApplyCallbackTransform(aPoint, aGuid),
@@ -285,17 +285,20 @@ APZEventState::ProcessTouchEvent(const W
       mTouchEndCancelled = true;
       mEndTouchIsClick = false;
     }
     // fall through
   case NS_TOUCH_CANCEL:
     mActiveElementManager->HandleTouchEndEvent(mEndTouchIsClick);
     // fall through
   case NS_TOUCH_MOVE: {
-    sentContentResponse = SendPendingTouchPreventedResponse(isTouchPrevented, aGuid);
+    if (mPendingTouchPreventedResponse) {
+      MOZ_ASSERT(aGuid == mPendingTouchPreventedGuid);
+    }
+    sentContentResponse = SendPendingTouchPreventedResponse(isTouchPrevented);
     break;
   }
 
   default:
     NS_WARNING("Unknown touch event type");
   }
 
   if (sentContentResponse &&
@@ -391,21 +394,19 @@ APZEventState::ProcessAPZStateChange(con
   default:
     // APZStateChange has a 'sentinel' value, and the compiler complains
     // if an enumerator is not handled and there is no 'default' case.
     break;
   }
 }
 
 bool
-APZEventState::SendPendingTouchPreventedResponse(bool aPreventDefault,
-                                                 const ScrollableLayerGuid& aGuid)
+APZEventState::SendPendingTouchPreventedResponse(bool aPreventDefault)
 {
   if (mPendingTouchPreventedResponse) {
-    MOZ_ASSERT(aGuid == mPendingTouchPreventedGuid);
     mContentReceivedInputBlockCallback->Run(mPendingTouchPreventedGuid,
         mPendingTouchPreventedBlockId, aPreventDefault);
     mPendingTouchPreventedResponse = false;
     return true;
   }
   return false;
 }
 
--- a/gfx/layers/apz/util/APZEventState.h
+++ b/gfx/layers/apz/util/APZEventState.h
@@ -66,18 +66,17 @@ public:
                          const ScrollableLayerGuid& aGuid,
                          uint64_t aInputBlockId);
   void ProcessAPZStateChange(const nsCOMPtr<nsIDocument>& aDocument,
                              ViewID aViewId,
                              APZStateChange aChange,
                              int aArg);
 private:
   ~APZEventState();
-  bool SendPendingTouchPreventedResponse(bool aPreventDefault,
-                                         const ScrollableLayerGuid& aGuid);
+  bool SendPendingTouchPreventedResponse(bool aPreventDefault);
   already_AddRefed<nsIWidget> GetWidget() const;
 private:
   nsWeakPtr mWidget;
   nsRefPtr<ActiveElementManager> mActiveElementManager;
   nsRefPtr<ContentReceivedInputBlockCallback> mContentReceivedInputBlockCallback;
   bool mPendingTouchPreventedResponse;
   ScrollableLayerGuid mPendingTouchPreventedGuid;
   uint64_t mPendingTouchPreventedBlockId;