Bug 1425573 - Introduce InputBlockState::ShouldDropEvents(). r=kats draft
authorBotond Ballo <botond@mozilla.com>
Fri, 16 Feb 2018 20:15:44 -0500
changeset 758065 9dd8c18183e6656e6f9459a92af4d9659cf421d6
parent 758064 8451db019c2ef3d8f028108e0b2a23b01418cc54
child 758066 5edc6d20150feac46ce1dd70030c677520b41ace
push id99941
push userbballo@mozilla.com
push dateWed, 21 Feb 2018 21:04:27 +0000
reviewerskats
bugs1425573
milestone60.0a1
Bug 1425573 - Introduce InputBlockState::ShouldDropEvents(). r=kats MozReview-Commit-ID: 4bgtFTdTFHz
gfx/layers/apz/src/InputBlockState.cpp
gfx/layers/apz/src/InputBlockState.h
gfx/layers/apz/src/InputQueue.cpp
--- a/gfx/layers/apz/src/InputBlockState.cpp
+++ b/gfx/layers/apz/src/InputBlockState.cpp
@@ -104,16 +104,22 @@ InputBlockState::IsTargetConfirmed() con
 bool
 InputBlockState::HasReceivedRealConfirmedTarget() const
 {
   return mTargetConfirmed == TargetConfirmationState::eConfirmed ||
          mTargetConfirmed == TargetConfirmationState::eTimedOutAndMainThreadResponded;
 }
 
 bool
+InputBlockState::ShouldDropEvents() const
+{
+  return false;
+}
+
+bool
 InputBlockState::IsDownchainOf(AsyncPanZoomController* aA, AsyncPanZoomController* aB) const
 {
   if (aA == aB) {
     return true;
   }
 
   bool seenA = false;
   for (size_t i = 0; i < mOverscrollHandoffChain->Length(); ++i) {
@@ -225,16 +231,22 @@ bool
 CancelableBlockState::IsReadyForHandling() const
 {
   if (!IsTargetConfirmed()) {
     return false;
   }
   return mContentResponded || mContentResponseTimerExpired;
 }
 
+bool
+CancelableBlockState::ShouldDropEvents() const
+{
+  return InputBlockState::ShouldDropEvents() || IsDefaultPrevented();
+}
+
 void
 CancelableBlockState::RecordContentResponseTime()
 {
   if (!mContentResponseTimer) {
     // We might get responses from content even though we didn't wait for them.
     // In that case, ignore the time on them, because they're not relevant for
     // tuning our timeout value. Also this function might get called multiple
     // times on the same input block, so we should only record the time from the
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -78,16 +78,18 @@ public:
                                       InputData* aFirstInput);
   const RefPtr<AsyncPanZoomController>& GetTargetApzc() const;
   const RefPtr<const OverscrollHandoffChain>& GetOverscrollHandoffChain() const;
   uint64_t GetBlockId() const;
 
   bool IsTargetConfirmed() const;
   bool HasReceivedRealConfirmedTarget() const;
 
+  virtual bool ShouldDropEvents() const;
+
   void SetScrolledApzc(AsyncPanZoomController* aApzc);
   AsyncPanZoomController* GetScrolledApzc() const;
   bool IsDownchainOfScrolledApzc(AsyncPanZoomController* aApzc) const;
 
   /**
    * Dispatch the event to the target APZC. Mostly this is a hook for
    * subclasses to do any per-event processing they need to.
    */
@@ -199,16 +201,17 @@ public:
    */
   virtual bool IsReadyForHandling() const;
 
   /**
    * Return a descriptive name for the block kind.
    */
   virtual const char* Type() = 0;
 
+  bool ShouldDropEvents() const override;
 private:
   TimeStamp mContentResponseTimer;
   bool mPreventDefault;
   bool mContentResponded;
   bool mContentResponseTimerExpired;
 };
 
 /**
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -725,24 +725,24 @@ InputQueue::ProcessQueue() {
 
   while (!mQueuedInputs.IsEmpty()) {
     InputBlockState* curBlock = mQueuedInputs[0]->Block();
     CancelableBlockState* cancelable = curBlock->AsCancelableBlock();
     if (cancelable && !cancelable->IsReadyForHandling()) {
       break;
     }
 
-    INPQ_LOG("processing input from block %p; preventDefault %d target %p\n",
+    INPQ_LOG("processing input from block %p; preventDefault %d shouldDropEvents %d target %p\n",
         curBlock, cancelable && cancelable->IsDefaultPrevented(),
-        curBlock->GetTargetApzc().get());
+        curBlock->ShouldDropEvents(), curBlock->GetTargetApzc().get());
     RefPtr<AsyncPanZoomController> target = curBlock->GetTargetApzc();
     // target may be null here if the initial target was unconfirmed and then
     // we later got a confirmed null target. in that case drop the events.
     if (target) {
-      if (cancelable && cancelable->IsDefaultPrevented()) {
+      if (curBlock->ShouldDropEvents()) {
         if (curBlock->AsTouchBlock()) {
           target->ResetTouchInputState();
         }
       } else {
         UpdateActiveApzc(target);
         curBlock->DispatchEvent(*(mQueuedInputs[0]->Input()));
       }
     }