diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 4a9c8a70139..65f50a7f955 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3137,8 +3137,9 @@ nsDocument::ElementFromPointHelper(float aX, float aY, return nullptr; // return null to premature XUL callers as a reminder to wait } - nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, pt, true, - aIgnoreRootScrollFrame); + nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, pt, + nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | + (aIgnoreRootScrollFrame ? nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME : 0)); if (!ptFrame) { return nullptr; } @@ -3192,7 +3193,8 @@ nsDocument::NodesFromRectHelper(float aX, float aY, nsAutoTArray outFrames; nsLayoutUtils::GetFramesForArea(rootFrame, rect, outFrames, - true, aIgnoreRootScrollFrame); + nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | + (aIgnoreRootScrollFrame ? nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME : 0)); // Used to filter out repeated elements in sequence. nsIContent* lastAdded = nullptr; @@ -9323,8 +9325,8 @@ nsIDocument::CaretPositionFromPoint(float aX, float aY) return nullptr; } - nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, pt, true, - false); + nsIFrame *ptFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, pt, + nsLayoutUtils::IGNORE_PAINT_SUPPRESSION); if (!ptFrame) { return nullptr; } diff --git a/layout/base/PositionedEventTargeting.cpp b/layout/base/PositionedEventTargeting.cpp index c1f77d1bcbb..2072a4e5779 100644 --- a/layout/base/PositionedEventTargeting.cpp +++ b/layout/base/PositionedEventTargeting.cpp @@ -249,10 +249,10 @@ FindFrameTargetedByInputEvent(const nsGUIEvent *aEvent, const nsPoint& aPointRelativeToRootFrame, uint32_t aFlags) { - bool ignoreRootScrollFrame = (aFlags & INPUT_IGNORE_ROOT_SCROLL_FRAME) != 0; + uint32_t flags = (aFlags & INPUT_IGNORE_ROOT_SCROLL_FRAME) ? + nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME : 0; nsIFrame* target = - nsLayoutUtils::GetFrameForPoint(aRootFrame, aPointRelativeToRootFrame, - false, ignoreRootScrollFrame); + nsLayoutUtils::GetFrameForPoint(aRootFrame, aPointRelativeToRootFrame, flags); const EventRadiusPrefs* prefs = GetPrefsFor(aEvent->eventStructType); if (!prefs || !prefs->mEnabled || (target && IsElementClickable(target))) { @@ -271,7 +271,7 @@ FindFrameTargetedByInputEvent(const nsGUIEvent *aEvent, nsRect targetRect = GetTargetRect(aRootFrame, aPointRelativeToRootFrame, prefs); nsAutoTArray candidates; nsresult rv = nsLayoutUtils::GetFramesForArea(aRootFrame, targetRect, candidates, - false, ignoreRootScrollFrame); + flags | nsLayoutUtils::EXCLUDE_COVERED_FRAMES); if (NS_FAILED(rv)) { return target; } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index dddbf7941f4..8162ea3da6e 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1802,15 +1802,12 @@ nsLayoutUtils::GetRemoteContentIds(nsIFrame* aFrame, } nsIFrame* -nsLayoutUtils::GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt, - bool aShouldIgnoreSuppression, - bool aIgnoreRootScrollFrame) +nsLayoutUtils::GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt, uint32_t aFlags) { PROFILER_LABEL("nsLayoutUtils", "GetFrameForPoint"); nsresult rv; nsAutoTArray outFrames; - rv = GetFramesForArea(aFrame, nsRect(aPt, nsSize(1, 1)), outFrames, - aShouldIgnoreSuppression, aIgnoreRootScrollFrame); + rv = GetFramesForArea(aFrame, nsRect(aPt, nsSize(1, 1)), outFrames, aFlags); NS_ENSURE_SUCCESS(rv, nullptr); return outFrames.Length() ? outFrames.ElementAt(0) : nullptr; } @@ -1818,20 +1815,19 @@ nsLayoutUtils::GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt, nsresult nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect, nsTArray &aOutFrames, - bool aShouldIgnoreSuppression, - bool aIgnoreRootScrollFrame) + uint32_t aFlags) { PROFILER_LABEL("nsLayoutUtils","GetFramesForArea"); nsDisplayListBuilder builder(aFrame, nsDisplayListBuilder::EVENT_DELIVERY, - false); + false); nsDisplayList list; nsRect target(aRect); - if (aShouldIgnoreSuppression) { + if (aFlags & IGNORE_PAINT_SUPPRESSION) { builder.IgnorePaintSuppression(); } - if (aIgnoreRootScrollFrame) { + if (aFlags & IGNORE_ROOT_SCROLL_FRAME) { nsIFrame* rootScrollFrame = aFrame->PresContext()->PresShell()->GetRootScrollFrame(); if (rootScrollFrame) { diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index a6ad3441536..263292c2e92 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -526,19 +526,28 @@ public: nsTArray &aOutIDs, bool aIgnoreRootScrollFrame); + enum FrameForPointFlags { + /** + * When set, paint suppression is ignored, so we'll return non-root page + * elements even if paint suppression is stopping them from painting. + */ + IGNORE_PAINT_SUPPRESSION = 0x01, + /** + * When set, clipping due to the root scroll frame (and any other viewport- + * related clipping) is ignored. + */ + IGNORE_ROOT_SCROLL_FRAME = 0x02 + }; + /** * 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 aShouldIgnoreSuppression a boolean to control if the display - * list builder should ignore paint suppression or not - * @param aIgnoreRootScrollFrame whether or not the display list builder - * should ignore the root scroll frame. + * @param aFlags some combination of FrameForPointFlags */ static nsIFrame* GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt, - bool aShouldIgnoreSuppression = false, - bool aIgnoreRootScrollFrame = false); + uint32_t aFlags = 0); /** * Given aFrame, the root frame of a stacking context, find all descendant @@ -546,15 +555,11 @@ public: * or nullptr if there is no such frame. * @param aRect the rect, relative to the frame origin * @param aOutFrames an array to add all the frames found - * @param aShouldIgnoreSuppression a boolean to control if the display - * list builder should ignore paint suppression or not - * @param aIgnoreRootScrollFrame whether or not the display list builder - * should ignore the root scroll frame. + * @param aFlags some combination of FrameForPointFlags */ static nsresult GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect, nsTArray &aOutFrames, - bool aShouldIgnoreSuppression = false, - bool aIgnoreRootScrollFrame = false); + uint32_t aFlags = 0); /** * Transform aRect relative to aAncestor down to the coordinate system of