Bug 1289432 - Update a couple more functions to stop fishing around inside mInputBlockQueue. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 12 Sep 2016 22:42:33 -0400
changeset 412862 30f3663070cb0998b904d167acfb0f3377cfb7e6
parent 412861 f076794d81b97f5ed7be68ff05ecf696970157d0
child 412863 4af799e8d8ce68a45c02997f448b506a6682cb4e
push id29274
push userkgupta@mozilla.com
push dateTue, 13 Sep 2016 02:44:31 +0000
reviewersbotond
bugs1289432
milestone51.0a1
Bug 1289432 - Update a couple more functions to stop fishing around inside mInputBlockQueue. r?botond MozReview-Commit-ID: Bxionzr8bFo
gfx/layers/apz/src/InputQueue.cpp
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -603,23 +603,20 @@ InputQueue::MainThreadTimeout(const uint
 }
 
 void
 InputQueue::ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) {
   APZThreadUtils::AssertOnControllerThread();
 
   INPQ_LOG("got a content response; block=%" PRIu64 "\n", aInputBlockId);
   bool success = false;
-  for (size_t i = 0; i < mInputBlockQueue.Length(); i++) {
-    CancelableBlockState* block = mInputBlockQueue[i].get();
-    if (block->GetBlockId() == aInputBlockId) {
-      success = block->SetContentResponse(aPreventDefault);
-      block->RecordContentResponseTime();
-      break;
-    }
+  CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr);
+  if (block) {
+    success = block->SetContentResponse(aPreventDefault);
+    block->RecordContentResponseTime();
   }
   if (success) {
     ProcessInputBlocks();
   }
 }
 
 void
 InputQueue::SetConfirmedTargetApzc(uint64_t aInputBlockId, const RefPtr<AsyncPanZoomController>& aTargetApzc) {
@@ -665,27 +662,22 @@ InputQueue::ConfirmDragBlock(uint64_t aI
 }
 
 void
 InputQueue::SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors) {
   APZThreadUtils::AssertOnControllerThread();
 
   INPQ_LOG("got allowed touch behaviours; block=%" PRIu64 "\n", aInputBlockId);
   bool success = false;
-  for (size_t i = 0; i < mInputBlockQueue.Length(); i++) {
-    if (mInputBlockQueue[i]->GetBlockId() == aInputBlockId) {
-      TouchBlockState *block = mInputBlockQueue[i]->AsTouchBlock();
-      if (block) {
-        success = block->SetAllowedTouchBehaviors(aBehaviors);
-        block->RecordContentResponseTime();
-      } else {
-        NS_WARNING("input block is not a touch block");
-      }
-      break;
-    }
+  CancelableBlockState* block = FindBlockForId(aInputBlockId, nullptr);
+  if (block && block->AsTouchBlock()) {
+    success = block->AsTouchBlock()->SetAllowedTouchBehaviors(aBehaviors);
+    block->RecordContentResponseTime();
+  } else if (block) {
+    NS_WARNING("input block is not a touch block");
   }
   if (success) {
     ProcessInputBlocks();
   }
 }
 
 void
 InputQueue::ProcessInputBlocks() {