⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 291747 in webkit


Ignore:
Timestamp:
Mar 23, 2022, 10:00:33 AM (5 years ago)
Author:
Tyler Wilcock
Message:

AccessibilityRenderObject::nextSibling should allow parent differences in the presence of display: contents
​https://bugs.webkit.org/show_bug.cgi?id=238184

Reviewed by Andres Gonzalez.

Source/WebCore:

AccessibilityRenderObject::nextSibling currently has this logic to
return nullptr if the computed sibling has a parent different from this:

auto* nextObject = objectCache->getOrCreate(nextSibling);
if (nextObject && nextObject->parentObject() != this->parentObject())

return nullptr;

This is problematic in the presence of display: contents since we expect
parent object differences due to the way this property affects the render tree.

Concretely, this breaks the firstChild(), nextSibling() iteration we do throughout
WebKit (e.g. in AccessibilityRenderObject::addChildren), as when we get to an element
with display: contents we get a parent mismatch and iteration stops unnecessarily.

This patch fixes the issue by allowing a parent mismatch when either
object has display: contents, as we account for this difference in the
appropriate places (e.g. AccessibilityObject::insertChild).

Test: accessibility/display-contents-search-traversal.html

  • accessibility/AXLogger.cpp:

(WebCore::operator<<):
Log when an object has display: contents. This property affects the
render tree and AX tree, so it's useful to log.

  • accessibility/AccessibilityObject.h:

(WebCore::AccessibilityObject::hasDisplayContents const): Added.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::nextSibling const):

LayoutTests:

  • accessibility/display-contents-search-traversal-expected.txt: Added.
  • accessibility/display-contents-search-traversal.html: Added.
  • platform/glib/TestExpectations: Skip new test.
  • platform/ios/TestExpectations: Enable new test.
  • platform/ios/accessibility/display-contents-search-traversal-expected.txt: Added.
  • platform/win/TestExpectations: Skip new test.
Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r291746 r291747  
     12022-03-23  Tyler Wilcock  <tyler_w@apple.com>
     2
     3        AccessibilityRenderObject::nextSibling should allow parent differences in the presence of display: contents
     4        https://bugs.webkit.org/show_bug.cgi?id=238184
     5
     6        Reviewed by Andres Gonzalez.
     7
     8        * accessibility/display-contents-search-traversal-expected.txt: Added.
     9        * accessibility/display-contents-search-traversal.html: Added.
     10        * platform/glib/TestExpectations: Skip new test.
     11        * platform/ios/TestExpectations: Enable new test.
     12        * platform/ios/accessibility/display-contents-search-traversal-expected.txt: Added.
     13        * platform/win/TestExpectations: Skip new test.
     14
    1152022-03-23  Patrick Angle  <pangle@apple.com>
    216
  • trunk/LayoutTests/platform/glib/TestExpectations

    r291600 r291747  
    343343
    344344# Missing AccessibilityUIElement::uiElementForSearchPredicate implementation.
     345accessibility/display-contents-search-traversal.html [ Skip ]
    345346accessibility/table-search-traversal.html [ Skip ]
    346347accessibility/dynamically-changing-iframe-remains-accessible.html [ Skip ]
  • trunk/LayoutTests/platform/ios/TestExpectations

    r291721 r291747  
    21152115webkit.org/b/150366 accessibility/aria-table-attributes.html [ Pass ]
    21162116
     2117accessibility/display-contents-search-traversal.html [ Pass ]
    21172118accessibility/table-search-traversal.html [ Pass ]
    21182119accessibility/dynamically-changing-iframe-remains-accessible.html [ Pass ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r291737 r291747  
    479479
    480480# Missing AccessibilityUIElement::uiElementForSearchPredicate implementation.
     481accessibility/display-contents-search-traversal.html [ Skip ]
    481482accessibility/table-search-traversal.html [ Skip ]
    482483accessibility/dynamically-changing-iframe-remains-accessible.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r291744 r291747  
     12022-03-23  Tyler Wilcock  <tyler_w@apple.com>
     2
     3        AccessibilityRenderObject::nextSibling should allow parent differences in the presence of display: contents
     4        https://bugs.webkit.org/show_bug.cgi?id=238184
     5
     6        Reviewed by Andres Gonzalez.
     7
     8        AccessibilityRenderObject::nextSibling currently has this logic to
     9        return nullptr if the computed sibling has a parent different from `this`:
     10
     11            auto* nextObject = objectCache->getOrCreate(nextSibling);
     12            if (nextObject && nextObject->parentObject() != this->parentObject())
     13                return nullptr;
     14
     15        This is problematic in the presence of display: contents since we expect
     16        parent object differences due to the way this property affects the render tree.
     17
     18        Concretely, this breaks the firstChild(), nextSibling() iteration we do throughout
     19        WebKit (e.g. in AccessibilityRenderObject::addChildren), as when we get to an element
     20        with display: contents we get a parent mismatch and iteration stops unnecessarily.
     21
     22        This patch fixes the issue by allowing a parent mismatch when either
     23        object has display: contents, as we account for this difference in the
     24        appropriate places (e.g. AccessibilityObject::insertChild).
     25
     26        Test: accessibility/display-contents-search-traversal.html
     27
     28        * accessibility/AXLogger.cpp:
     29        (WebCore::operator<<):
     30        Log when an object has display: contents. This property affects the
     31        render tree and AX tree, so it's useful to log.
     32        * accessibility/AccessibilityObject.h:
     33        (WebCore::AccessibilityObject::hasDisplayContents const): Added.
     34        * accessibility/AccessibilityRenderObject.cpp:
     35        (WebCore::AccessibilityRenderObject::nextSibling const):
     36
    1372022-03-23  Youenn Fablet  <youenn@apple.com>
    238
  • trunk/Source/WebCore/accessibility/AXLogger.cpp

    r288963 r291747  
    533533        stream.dumpProperty("outerHTML", objectWithInterestingHTML->outerHTML());
    534534
     535    if (auto* axObject = dynamicDowncast<AccessibilityObject>(&object); axObject && axObject->hasDisplayContents())
     536        stream.dumpProperty("hasDisplayContents", true);
    535537    stream.dumpProperty("address", &object);
    536538    stream.dumpProperty("wrapper", object.wrapper());
  • trunk/Source/WebCore/accessibility/AccessibilityObject.h

    r291613 r291747  
    545545    bool hasTagName(const QualifiedName&) const override;
    546546    String tagName() const override;
     547    bool hasDisplayContents() const;
    547548
    548549    VisiblePositionRange visiblePositionRange() const override { return VisiblePositionRange(); }
    … …  
    860861
    861862#if ENABLE(ACCESSIBILITY)
     863inline bool AccessibilityObject::hasDisplayContents() const
     864{
     865    return is<Element>(node()) && downcast<Element>(node())->hasDisplayContents();
     866}
     867
    862868inline std::optional<BoundaryPoint> AccessibilityObject::lastBoundaryPointContainedInRect(const Vector<BoundaryPoint>& boundaryPoints, const BoundaryPoint& startBoundaryPoint, const FloatRect& targetRect) const
    863869{
    … …  
    870876}
    871877#else
     878inline bool AccessibilityObject::hasDisplayContents() const { return false; }
    872879inline std::optional<BoundaryPoint> AccessibilityObject::lastBoundaryPointContainedInRect(const Vector<BoundaryPoint>&, const BoundaryPoint&, const FloatRect&) const { return std::nullopt; }
    873880inline VisiblePosition AccessibilityObject::previousLineStartPosition(const VisiblePosition& position) const { return { }; }
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r291613 r291747  
    422422        return nullptr;
    423423
     424    auto* nextObject = objectCache->getOrCreate(nextSibling);
     425    auto* nextObjectParent = nextObject ? nextObject->parentObject() : nullptr;
     426    auto* thisParent = parentObject();
    424427    // Make sure next sibling has the same parent.
    425     auto* nextObject = objectCache->getOrCreate(nextSibling);
    426     if (nextObject && nextObject->parentObject() != this->parentObject())
    427         return nullptr;
    428 
     428    if (nextObjectParent && nextObjectParent != thisParent) {
     429        // Unless either object has a parent with display: contents, as display: contents can cause parent differences
     430        // that we properly account for elsewhere.
     431        if (nextObjectParent->hasDisplayContents() || (thisParent && thisParent->hasDisplayContents()))
     432            return nextObject;
     433        return nullptr;
     434    }
    429435    return nextObject;
    430436}
Note: See TracChangeset for help on using the changeset viewer.