Bug 229815 - AX: findModalNodes() and currentModalNode() should include modal <dialog>
Summary: AX: findModalNodes() and currentModalNode() should include modal <dialog>
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Tim Nguyen (:ntim)
URL:
Keywords: InRadar
Depends on:
Blocks: dialog-element
  Show dependency treegraph
 
Reported: 2021-09-02 10:10 PDT by Tim Nguyen (:ntim)
Modified: 2021-09-03 14:08 PDT (History)
10 users (show)

See Also:


Attachments
Patch (3.31 KB, patch)
2021-09-02 12:04 PDT, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff
Patch (12.71 KB, patch)
2021-09-03 09:30 PDT, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff
Patch (13.45 KB, patch)
2021-09-03 14:02 PDT, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Radar WebKit Bug Importer 2021-09-02 10:11:08 PDT
<rdar://problem/82680992>
Comment 2 Tim Nguyen (:ntim) 2021-09-02 12:04:21 PDT
Created attachment 437179 [details]
Patch
Comment 3 chris fleizach 2021-09-02 12:33:19 PDT
Comment on attachment 437179 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437179&action=review

> Source/WebCore/ChangeLog:8
> +        * accessibility/AXObjectCache.cpp:

can you add a new test for this case?
Comment 4 chris fleizach 2021-09-02 12:34:43 PDT
Comment on attachment 437179 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437179&action=review

> Source/WebCore/accessibility/AXObjectCache.cpp:259
> +        bool isAriaModal = !equalLettersIgnoringASCIICase(element->attributeWithoutSynchronization(aria_modalAttr), "true");

this should change to 

!equalLetter -> equalLetter

> Source/WebCore/accessibility/AXObjectCache.cpp:261
> +        if ((hasDialogRole && isAriaModal) || (is<HTMLDialogElement>(element) && downcast<HTMLDialogElement>(element)->isModal()))

is there any provision for aria-model=false on <dialog modal> to override the native status?
Comment 5 Andres Gonzalez 2021-09-02 12:54:31 PDT
(In reply to Tim Nguyen (:ntim) from comment #2)
> Created attachment 437179 [details]
> Patch

--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ a/Source/WebCore/accessibility/AXObjectCache.cpp

+        bool isAriaModal = !equalLettersIgnoringASCIICase(element->attributeWithoutSynchronization(aria_modalAttr), "true");

Should be :

+        bool isAriaModal = equalLettersIgnoringASCIICase(element->attributeWithoutSynchronization(aria_modalAttr), "true");

Could you add a helper function, bool isModalElement, that does:

+        bool hasDialogRole = nodeHasRole(element, "dialog") || nodeHasRole(element, "alertdialog");
+        bool isAriaModal = equalLettersIgnoringASCIICase(element->attributeWithoutSynchronization(aria_modalAttr), "true");

+        return (hasDialogRole && isAriaModal) || (is<HTMLDialogElement>(element) && downcast<HTMLDialogElement>(element)->isModal());

or equivalent?
Comment 6 Tim Nguyen (:ntim) 2021-09-02 13:03:07 PDT
(In reply to chris fleizach from comment #4)
> Comment on attachment 437179 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=437179&action=review
> 
> > Source/WebCore/accessibility/AXObjectCache.cpp:259
> > +        bool isAriaModal = !equalLettersIgnoringASCIICase(element->attributeWithoutSynchronization(aria_modalAttr), "true");
> 
> this should change to 
> 
> !equalLetter -> equalLetter

Good catch, thanks!

> > Source/WebCore/accessibility/AXObjectCache.cpp:261
> > +        if ((hasDialogRole && isAriaModal) || (is<HTMLDialogElement>(element) && downcast<HTMLDialogElement>(element)->isModal()))
> 
> is there any provision for aria-model=false on <dialog modal> to override
> the native status?

dialog.showModal() will make the content behind inert and make only the dialog interactive per the HTML spec. 

From: https://www.w3.org/TR/wai-aria-practices-1.1/examples/dialog-modal/dialog.html

> Applying the aria-modal property to the dialog element replaces the technique of using aria-hidden on the background for informing assistive technologies that content outside a dialog is inert.

So no, aria-modal=false should not have an effect on this, since the content behind will be inert either way, according to the HTML spec.
Comment 7 Tim Nguyen (:ntim) 2021-09-03 09:30:10 PDT
Created attachment 437278 [details]
Patch
Comment 8 James Craig 2021-09-03 09:45:38 PDT
> is there any provision for aria-model=false on <dialog modal> to override
> the native status?

In general, equivalent host language attributes "win", but ARIA roles always "win." There's a little ambiguity in this case, since the `is modal` flag of the dialog API is not an attribute, but in general, I would not expect `aria-modal` to have any effect on the dialog element.

There's more detail about conflict resolution in the ARIA spec, and I'll file an ARIA issue about the ambiguity.
https://w3c.github.io/aria/#host_general_conflict
Comment 9 James Craig 2021-09-03 10:04:05 PDT
Filed ARIA 1610 https://github.com/w3c/aria/issues/1610
Comment 10 Andres Gonzalez 2021-09-03 10:52:37 PDT
(In reply to Tim Nguyen (:ntim) from comment #7)
> Created attachment 437278 [details]
> Patch

--- a/LayoutTests/accessibility/dialog-showModal.html
+++ a/LayoutTests/accessibility/dialog-showModal.html

+            window.okButton = accessibilityController.accessibleElementById("ok");
+            shouldBeFalse("okButton.isIgnored");

This should be false when the dialog is modal or not because it is part of the dialog. Why are we checking this only if it is not modal? Perhaps it makes more sense to check whether an element int the background is not ignored, which you are already doing in backgroundAccessible.

Is it really a good idea that we convey that there is a modal dialog if it is aria-hidden or opacity 0?
Comment 11 Tim Nguyen (:ntim) 2021-09-03 11:41:34 PDT
(In reply to Andres Gonzalez from comment #10)
> (In reply to Tim Nguyen (:ntim) from comment #7)
> > Created attachment 437278 [details]
> > Patch
> 
> --- a/LayoutTests/accessibility/dialog-showModal.html
> +++ a/LayoutTests/accessibility/dialog-showModal.html
> 
> +            window.okButton =
> accessibilityController.accessibleElementById("ok");
> +            shouldBeFalse("okButton.isIgnored");
> 
> This should be false when the dialog is modal or not because it is part of
> the dialog. Why are we checking this only if it is not modal? Perhaps it
> makes more sense to check whether an element int the background is not
> ignored, which you are already doing in backgroundAccessible.
> 
> Is it really a good idea that we convey that there is a modal dialog if it
> is aria-hidden or opacity 0?

Yes, because the content behind is rendered inert per-HTML spec, and there's also a backdrop behind blocking any interaction.
Comment 12 Tim Nguyen (:ntim) 2021-09-03 14:02:37 PDT
Created attachment 437309 [details]
Patch
Comment 13 Tim Nguyen (:ntim) 2021-09-03 14:08:00 PDT
Committed r282022 (241327@main): <https://commits.webkit.org/241327@main>