AX: Override aria-hidden on a modal when the page would otherwise be completely empty due to inertness#64337
Merged
Conversation
Collaborator
|
EWS run on current version of this PR (hash b4467d4) Details
|
minorninth
approved these changes
May 6, 2026
Contributor
minorninth
left a comment
There was a problem hiding this comment.
Some suggestions for readability and maintainability, but no blockers - the fix looks good
…completely empty due to inertness https://bugs.webkit.org/show_bug.cgi?id=314165 rdar://176326010 Reviewed by Dominic Mazzoni. On a very popular webpage, the web developer added an aria-modal to the page, and used JavaScript to make all other content outside the modal inert. This is reasonable, but unfortunately they forget to remove aria-hidden="true" from the modal's container element, meaning the page remains empty forever. To fix this, we start detecting this scenario during modalNode() queries. When the page has zero unignored content objects and a modal element exists that is blocked by an ancestor aria-hidden, we override aria-hidden on that ancestor using the existing shouldIgnoreARIAHidden mechanism. To make the "is the page empty" check O(1), we maintain an unignored content object counter that is incremented/decremented during ignored-state transitions in isIgnoredWithoutCache and decremented in the AccessibilityObject destructor. Structural roles (web areas, mock objects, scroll bars, etc.) are excluded from the count since they don't represent meaningful content, and the lifetime model for mock objects is broken (we leak all of them), so including them in the count would make it difficult to maintain. The override check is armed lazily: only when aria-hidden is set to true, when an element becomes inert/invisible, or when modal elements are found. There is no cost on pages that don't hit this pattern. * LayoutTests/accessibility/aria-hidden-modal-override-when-page-empty-expected.txt: Added. * LayoutTests/accessibility/aria-hidden-modal-override-when-page-empty.html: Added. * Source/WebCore/accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::findModalNodes): (WebCore::AXObjectCache::modalNode): (WebCore::AXObjectCache::onInertOrVisibilityChange): (WebCore::AXObjectCache::handleAttributeChange): * Source/WebCore/accessibility/AXObjectCache.h: * Source/WebCore/accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::~AccessibilityObject): (WebCore::AccessibilityObject::isIgnoredWithoutCache const): Canonical link: https://commits.webkit.org/312744@main
b4467d4 to
4170dc9
Compare
Collaborator
|
Committed 312744@main (4170dc9): https://commits.webkit.org/312744@main Reviewed commits have been landed. Closing PR #64337 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
4170dc9
b4467d4