Bug 1825611: Trim bounds when hittesting overflow:hidden containers r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D175194
This commit is contained in:
Morgan Rae Reschenberg 2023-04-19 22:55:39 +00:00
Родитель 513cf054fc
Коммит f6166a5774
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -629,6 +629,17 @@ bool RemoteAccessibleBase<Derived>::IsFixedPos() const {
return false;
}
template <class Derived>
bool RemoteAccessibleBase<Derived>::IsOverflowHidden() const {
MOZ_ASSERT(mCachedFields);
if (auto maybeOverflow =
mCachedFields->GetAttribute<RefPtr<nsAtom>>(nsGkAtoms::overflow)) {
return *maybeOverflow == nsGkAtoms::hidden;
}
return false;
}
template <class Derived>
LayoutDeviceIntRect RemoteAccessibleBase<Derived>::BoundsWithOffset(
Maybe<nsRect> aOffset, bool aBoundsAreForHittesting) const {
@ -705,11 +716,12 @@ LayoutDeviceIntRect RemoteAccessibleBase<Derived>::BoundsWithOffset(
// that the bounds we've calculated so far are constrained to the
// bounds of the scroll area. Without this, we'll "hit" the off-screen
// portions of accs that are are partially (but not fully) within the
// scroll area.
if (aBoundsAreForHittesting && hasScrollArea) {
nsRect selfRelativeScrollBounds(0, 0, remoteBounds.width,
remoteBounds.height);
bounds = bounds.SafeIntersect(selfRelativeScrollBounds);
// scroll area. This is also a problem for accs with overflow:hidden;
if (aBoundsAreForHittesting &&
(hasScrollArea || remoteAcc->IsOverflowHidden())) {
nsRect selfRelativeVisibleBounds(0, 0, remoteBounds.width,
remoteBounds.height);
bounds = bounds.SafeIntersect(selfRelativeVisibleBounds);
}
}
if (remoteAcc->IsDoc()) {

Просмотреть файл

@ -443,6 +443,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
LayoutDeviceIntRect BoundsWithOffset(
Maybe<nsRect> aOffset, bool aBoundsAreForHittesting = false) const;
bool IsFixedPos() const;
bool IsOverflowHidden() const;
// This function is used exclusively for hit testing.
bool ContainsPoint(int32_t aX, int32_t aY);