This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch geckoview-102.3.0esr-12.0-1 in repository tor-browser.
commit 3be2527950f266f76f9f3c31cbe34df813e6270e Author: Timothy Nikkel tnikkel@gmail.com AuthorDate: Mon Aug 29 09:58:11 2022 +0000
Bug 1787684. Only return views with widgets from FindFloatingViewContaining. r=emilio, a=RyanVM
The code that bug 1754436 deleted checked to make sure there was a widget for the returned view, but it looks like it's possible in some edge cases to have an open popup that doesn't have a widget (most likely just for a split second). We need a widget to dispatch the event, and if it doesn't have a widget it's not visible so no point in touching it at all anyways.
Differential Revision: https://phabricator.services.mozilla.com/D155819 --- layout/base/PresShell.cpp | 5 +++-- layout/base/nsLayoutUtils.cpp | 17 +++++++++++++---- layout/base/nsLayoutUtils.h | 7 ++++++- 3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 51da6729aacfc..8cecd2497fc33 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5635,8 +5635,9 @@ void PresShell::SynthesizeMouseMove(bool aFromScroll) { static nsView* FindFloatingViewContaining(nsPresContext* aRootPresContext, nsIWidget* aRootWidget, const LayoutDeviceIntPoint& aPt) { - nsIFrame* popupFrame = - nsLayoutUtils::GetPopupFrameForPoint(aRootPresContext, aRootWidget, aPt); + nsIFrame* popupFrame = nsLayoutUtils::GetPopupFrameForPoint( + aRootPresContext, aRootWidget, aPt, + nsLayoutUtils::GetPopupFrameForPointFlags::OnlyReturnFramesWithWidgets); return popupFrame ? popupFrame->GetView() : nullptr; }
diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d9d8036382d5d..4cae8e948de7b 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1756,7 +1756,8 @@ nsIFrame* nsLayoutUtils::GetPopupFrameForEventCoordinates(
nsIFrame* nsLayoutUtils::GetPopupFrameForPoint( nsPresContext* aRootPresContext, nsIWidget* aWidget, - const mozilla::LayoutDeviceIntPoint& aPoint) { + const mozilla::LayoutDeviceIntPoint& aPoint, + GetPopupFrameForPointFlags aFlags /* = GetPopupFrameForPointFlags(0) */) { nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); if (!pm) { return nullptr; @@ -1765,11 +1766,19 @@ nsIFrame* nsLayoutUtils::GetPopupFrameForPoint( pm->GetVisiblePopups(popups); // Search from top to bottom for (nsIFrame* popup : popups) { - if (popup->PresContext()->GetRootPresContext() == aRootPresContext && - popup->ScrollableOverflowRect().Contains(GetEventCoordinatesRelativeTo( + if (popup->PresContext()->GetRootPresContext() != aRootPresContext) { + continue; + } + if (!popup->ScrollableOverflowRect().Contains(GetEventCoordinatesRelativeTo( aWidget, aPoint, RelativeTo{popup}))) { - return popup; + continue; + } + if (aFlags & GetPopupFrameForPointFlags::OnlyReturnFramesWithWidgets) { + if (!popup->HasView() || !popup->GetView()->HasWidget()) { + continue; + } } + return popup; } return nullptr; } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index e4ed53fea274a..fef3dd5329a71 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -750,9 +750,13 @@ class nsLayoutUtils { * @return Null, if there is no popup frame at the point, otherwise, * returns top-most popup frame at the point. */ + enum class GetPopupFrameForPointFlags : uint8_t { + OnlyReturnFramesWithWidgets = 0x1, + }; static nsIFrame* GetPopupFrameForPoint( nsPresContext* aRootPresContext, nsIWidget* aWidget, - const mozilla::LayoutDeviceIntPoint& aPoint); + const mozilla::LayoutDeviceIntPoint& aPoint, + GetPopupFrameForPointFlags aFlags = GetPopupFrameForPointFlags(0));
/** * Get container and offset if aEvent collapses Selection. @@ -3018,6 +3022,7 @@ class nsLayoutUtils { };
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsLayoutUtils::PaintFrameFlags) +MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsLayoutUtils::GetPopupFrameForPointFlags)
template <typename PointType, typename RectType, typename CoordType> /* static */ bool nsLayoutUtils::PointIsCloserToRect(