Bug 244972

Summary: Integrate ARIA element reflection in the Accessibility Tree
Product: WebKit Reporter: Manuel Rego Casasnovas <rego>
Component: AccessibilityAssignee: Manuel Rego Casasnovas <rego>
Status: RESOLVED FIXED    
Severity: Normal CC: andresg_22, commit-queue, rackler, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 245762    
Bug Blocks: 196843, 245301    
Attachments:
Description Flags
Patch none

Description Manuel Rego Casasnovas 2022-09-09 06:34:13 PDT
IDREF element reflection hasn't been hooked up with AccessibilityObject.

Right now if you do something like the following example, the a11y tree doesn't know anything about the label you're assigning to the custom input:
        <label id="anotherLabel">Another label</label>
        <x-input-idref id="myxinput"></x-input-idref>

        <script>
          class XInputIDREF extends HTMLElement {
            constructor() {
              super();
              this.attachShadow({ mode: "open" });
              let input = document.createElement("input");
              input.id = "innerbutton";
              this.shadowRoot.appendChild(input);
              input.ariaLabelledByElements = [anotherLabel];
            }
          }
          customElements.define("x-input-idref", XInputIDREF);

If you use the accessibility info in the inspector, you'll see the inner <input> doesn't have the label associated to it.
This is because as the attribute is not reflected, as the label is not in the shadow tree, and we need to update AccessibilityObject::elementsFromAttribute() to return the explicitly set elements in that scenario.
Comment 1 Radar WebKit Bug Importer 2022-09-09 06:34:40 PDT
<rdar://problem/99742765>
Comment 2 Ryosuke Niwa 2022-09-12 09:07:23 PDT
I think this is also broken when the referenced element doesn't have an ID
Comment 3 Manuel Rego Casasnovas 2022-09-12 22:40:04 PDT
Pull request: https://github.com/WebKit/WebKit/pull/4299
Comment 4 Manuel Rego Casasnovas 2022-09-20 22:08:46 PDT
Created attachment 462484 [details]
Patch
Comment 5 Manuel Rego Casasnovas 2022-09-20 22:09:14 PDT
Comment on attachment 462484 [details]
Patch

Sorry wrong command to upload patch.
Comment 6 EWS 2022-09-27 04:19:40 PDT
Committed 254905@main (5a61ea9a8257): <https://commits.webkit.org/254905@main>

Reviewed commits have been landed. Closing PR #4299 and removing active labels.
Comment 7 WebKit Commit Bot 2022-09-27 17:29:03 PDT
Re-opened since this is blocked by bug 245762
Comment 8 Manuel Rego Casasnovas 2022-09-27 22:24:47 PDT
*** Bug 245761 has been marked as a duplicate of this bug. ***
Comment 9 Manuel Rego Casasnovas 2022-09-27 23:47:25 PDT
New pull request: https://github.com/WebKit/WebKit/pull/4784
Comment 10 EWS 2022-09-28 22:05:00 PDT
Committed 254985@main (fa51d4c1048c): <https://commits.webkit.org/254985@main>

Reviewed commits have been landed. Closing PR #4784 and removing active labels.