Bug 1319560 Part 3: Change nsDisplayList::HitTest to exit early when HitTestShouldStopAtFirstOpaque() is true. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 28 Nov 2016 13:22:15 -0800
changeset 445480 a42416f1aa0fbf9d539fcdbe669be35618f040e2
parent 445479 d46d96e56d8b8f426be3b65a014c321de5d000fb
child 538520 45ddeaa1d6eefe76fe8ff694dfd6b40ce94911a4
push id37512
push userbwerth@mozilla.com
push dateTue, 29 Nov 2016 18:23:05 +0000
bugs1319560
milestone53.0a1
Bug 1319560 Part 3: Change nsDisplayList::HitTest to exit early when HitTestShouldStopAtFirstOpaque() is true. MozReview-Commit-ID: D8aKGX6z2TV
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2213,16 +2213,23 @@ void nsDisplayList::HitTest(nsDisplayLis
 
       for (uint32_t j = 0; j < outFrames.Length(); j++) {
         nsIFrame *f = outFrames.ElementAt(j);
         // Handle the XUL 'mousethrough' feature and 'pointer-events'.
         if (!GetMouseThrough(f) && IsFrameReceivingPointerEvents(f)) {
           writeFrames->AppendElement(f);
         }
       }
+
+      if (aBuilder->HitTestShouldStopAtFirstOpaque() &&
+          item->GetOpaqueRegion(aBuilder, &snap).Contains(aRect)) {
+        // We're exiting early, so pop the remaining items off the buffer.
+        aState->mItemBuffer.SetLength(itemBufferStart);
+        break;
+      }
     }
   }
   // Clear any remaining preserve-3d transforms.
   FlushFramesArray(temp, aOutFrames);
   NS_ASSERTION(aState->mItemBuffer.Length() == uint32_t(itemBufferStart),
                "How did we forget to pop some elements?");
 }