Bug 1319560 Part 2: Add a nsLayoutUtils::FrameForPointFlags value to only retrieve visible frames.
MozReview-Commit-ID: 1mNIXdyBkw4
--- 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