Bug 1319560 Part 3: Change nsDisplayList::HitTest to exit early when HitTestShouldStopAtFirstOpaque() is true. r=mattwoodrow
authorBrad Werth <bwerth@mozilla.com>
Mon, 28 Nov 2016 13:22:15 -0800
changeset 324873 d643dc8256bf96e54aae56943d8e62f45f36f053
parent 324872 707be7b4ca59f8fa692f12c35f1929c0163d8b0b
child 324874 8355901806763d6fc91abdf2a89a5f563f5966ac
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmattwoodrow
bugs1319560
milestone53.0a1
Bug 1319560 Part 3: Change nsDisplayList::HitTest to exit early when HitTestShouldStopAtFirstOpaque() is true. r=mattwoodrow 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?");
 }