Bug 238680 - AccessibilityNodeObject::elementRect should use children rects for display:contents AX objects
Summary: AccessibilityNodeObject::elementRect should use children rects for display:co...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-01 13:02 PDT by Tyler Wilcock
Modified: 2022-04-04 13:42 PDT (History)
10 users (show)

See Also:


Attachments
Patch (6.78 KB, patch)
2022-04-01 13:05 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (6.64 KB, patch)
2022-04-01 13:31 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (8.70 KB, patch)
2022-04-03 12:23 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (9.57 KB, patch)
2022-04-03 18:37 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (9.62 KB, patch)
2022-04-04 07:11 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2022-04-01 13:02:04 PDT
Because display:contents AccessibilityNodeObjects can have rendered content (unlike `hidden`, `aria-hidden="false"` node objects), we can compute AccessibilityNodeObject::elementRect by adding up the rectangles of the object's children.
Comment 1 Radar WebKit Bug Importer 2022-04-01 13:02:15 PDT
<rdar://problem/91177670>
Comment 2 Tyler Wilcock 2022-04-01 13:05:38 PDT
Created attachment 456393 [details]
Patch
Comment 3 chris fleizach 2022-04-01 13:17:20 PDT
Comment on attachment 456393 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:227
> +        if (is<AccessibilityNodeObject>(ancestor))

since AXRenderObject inherits from AXNodeObject isn't this true for render objects?
is this better as

if (!is<AccessibilityRenderObject>) { continue
Comment 4 Tyler Wilcock 2022-04-01 13:31:49 PDT
Created attachment 456397 [details]
Patch
Comment 5 Tyler Wilcock 2022-04-01 13:32:24 PDT
(In reply to chris fleizach from comment #3)
> Comment on attachment 456393 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=456393&action=review
> 
> > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:227
> > +        if (is<AccessibilityNodeObject>(ancestor))
> 
> since AXRenderObject inherits from AXNodeObject isn't this true for render
> objects?
> is this better as
> 
> if (!is<AccessibilityRenderObject>) { continue
Yes, thanks!
Comment 6 chris fleizach 2022-04-01 13:41:31 PDT
Comment on attachment 456397 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityNodeObject.cpp:212
> +        auto childrenCopy = m_children;

are we actually doing any copying here? or can we just iteration m_children?
Comment 7 Andres Gonzalez 2022-04-01 13:55:29 PDT
(In reply to chris fleizach from comment #6)
> Comment on attachment 456397 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=456397&action=review
> 
> > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:212
> > +        auto childrenCopy = m_children;
> 
> are we actually doing any copying here? or can we just iteration m_children?

Yes, I think the copy is not necessary since m_children is a Vector<RefPtr<AXCoreObject>> so the objects are not going away since they are held by the RefPtr.
Comment 8 Andres Gonzalez 2022-04-01 13:59:11 PDT
(In reply to Andres Gonzalez from comment #7)
> (In reply to chris fleizach from comment #6)
> > Comment on attachment 456397 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=456397&action=review
> > 
> > > Source/WebCore/accessibility/AccessibilityNodeObject.cpp:212
> > > +        auto childrenCopy = m_children;
> > 
> > are we actually doing any copying here? or can we just iteration m_children?
> 
> Yes, I think the copy is not necessary since m_children is a
> Vector<RefPtr<AXCoreObject>> so the objects are not going away since they
> are held by the RefPtr.

So I think you can do just:

+        for (const auto& child : children(false))
Comment 9 Tyler Wilcock 2022-04-03 12:23:17 PDT
Created attachment 456508 [details]
Patch
Comment 10 Tyler Wilcock 2022-04-03 12:26:24 PDT
> So I think you can do just:
> 
> +        for (const auto& child : children(false))
We can't use children() (even children(false)) because AXCoreObject::children is not const, while boundingBoxRect is. So we can loop through m_children, which is essentially the same as children(false).
Comment 11 Tyler Wilcock 2022-04-03 18:37:29 PDT
Created attachment 456525 [details]
Patch
Comment 12 Andres Gonzalez 2022-04-04 07:03:15 PDT
(In reply to Tyler Wilcock from comment #10)
> > So I think you can do just:
> > 
> > +        for (const auto& child : children(false))
> We can't use children() (even children(false)) because
> AXCoreObject::children is not const, while boundingBoxRect is. So we can
> loop through m_children, which is essentially the same as children(false).

The problem with that is that a subclass of AXNodeObject now or in the future may override children() and do something that is not equivalent to just m_children. A workaround for the const issue is to use const_cast as ugly as it is.
Comment 13 Tyler Wilcock 2022-04-04 07:11:31 PDT
Created attachment 456566 [details]
Patch
Comment 14 EWS 2022-04-04 13:42:44 PDT
Committed r292314 (249207@main): <https://commits.webkit.org/249207@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 456566 [details].