Bug 1319560 Part 2: Add a nsLayoutUtils::FrameForPointFlags value to only retrieve visible frames. r=mattwoodrow
authorBrad Werth <bwerth@mozilla.com>
Mon, 28 Nov 2016 14:50:34 -0800
changeset 324872 707be7b4ca59f8fa692f12c35f1929c0163d8b0b
parent 324871 c396937ada0f756403e473b580c36a05eedf2231
child 324873 d643dc8256bf96e54aae56943d8e62f45f36f053
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmattwoodrow
bugs1319560
milestone53.0a1
Bug 1319560 Part 2: Add a nsLayoutUtils::FrameForPointFlags value to only retrieve visible frames. r=mattwoodrow MozReview-Commit-ID: 1mNIXdyBkw4
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3162,16 +3162,17 @@ nsLayoutUtils::GetFramesForArea(nsIFrame
 
     std::stringstream ss;
     nsFrame::PrintDisplayList(&builder, list, ss);
     print_stderr(ss);
   }
 #endif
 
   nsDisplayItem::HitTestState hitTestState;
+  builder.SetHitTestShouldStopAtFirstOpaque(aFlags & ONLY_VISIBLE);
   list.HitTest(&builder, aRect, &hitTestState, &aOutFrames);
   list.DeleteAll();
   return NS_OK;
 }
 
 // aScrollFrameAsScrollable must be non-nullptr and queryable to an nsIFrame
 FrameMetrics
 nsLayoutUtils::CalculateBasicFrameMetrics(nsIScrollableFrame* aScrollFrame) {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -798,17 +798,21 @@ public:
     /**
      * When set, clipping due to the root scroll frame (and any other viewport-
      * related clipping) is ignored.
      */
     IGNORE_ROOT_SCROLL_FRAME = 0x02,
     /**
      * When set, return only content in the same document as aFrame.
      */
-    IGNORE_CROSS_DOC = 0x04
+    IGNORE_CROSS_DOC = 0x04,
+    /**
+     * When set, return only content that is actually visible.
+     */
+    ONLY_VISIBLE = 0x08
   };
 
   /**
    * Given aFrame, the root frame of a stacking context, find its descendant
    * frame under the point aPt that receives a mouse event at that location,
    * or nullptr if there is no such frame.
    * @param aPt the point, relative to the frame origin
    * @param aFlags some combination of FrameForPointFlags