Bug 238680

Summary: AccessibilityNodeObject::elementRect should use children rects for display:contents AX objects
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Tyler Wilcock
Reported 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.
Attachments
Patch (6.78 KB, patch)
2022-04-01 13:05 PDT, Tyler Wilcock
no flags
Patch (6.64 KB, patch)
2022-04-01 13:31 PDT, Tyler Wilcock
no flags
Patch (8.70 KB, patch)
2022-04-03 12:23 PDT, Tyler Wilcock
no flags
Patch (9.57 KB, patch)
2022-04-03 18:37 PDT, Tyler Wilcock
no flags
Patch (9.62 KB, patch)
2022-04-04 07:11 PDT, Tyler Wilcock
no flags
Radar WebKit Bug Importer
Comment 1 2022-04-01 13:02:15 PDT
Tyler Wilcock
Comment 2 2022-04-01 13:05:38 PDT
chris fleizach
Comment 3 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
Tyler Wilcock
Comment 4 2022-04-01 13:31:49 PDT
Tyler Wilcock
Comment 5 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!
chris fleizach
Comment 6 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?
Andres Gonzalez
Comment 7 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.
Andres Gonzalez
Comment 8 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))
Tyler Wilcock
Comment 9 2022-04-03 12:23:17 PDT
Tyler Wilcock
Comment 10 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).
Tyler Wilcock
Comment 11 2022-04-03 18:37:29 PDT
Andres Gonzalez
Comment 12 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.
Tyler Wilcock
Comment 13 2022-04-04 07:11:31 PDT
EWS
Comment 14 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].
Note You need to log in before you can comment on or make changes to this bug.