Skip to content

Commit

Permalink
Bug 1825611: Trim bounds when hittesting overflow:hidden containers r…
Browse files Browse the repository at this point in the history
…=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D175194
  • Loading branch information
MReschenberg committed May 3, 2023
1 parent 5dc1fa0 commit e2c0640
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 17 additions & 5 deletions accessible/ipc/RemoteAccessibleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,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 {
Expand Down Expand Up @@ -735,11 +746,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()) {
Expand Down
1 change: 1 addition & 0 deletions accessible/ipc/RemoteAccessibleBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,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);
Expand Down

0 comments on commit e2c0640

Please sign in to comment.