Changeset 263571 in webkit


Ignore:
Timestamp:
Jun 26, 2020 11:07:35 AM (4 years ago)
Author:
Andres Gonzalez
Message:

Fix for crash in accessibility/roles-exposed.html in isolated tree mode.
https://bugs.webkit.org/show_bug.cgi?id=213648

Reviewed by Chris Fleizach.

LayoutTest: accessibility/roles-exposed.html.

  • In layout tests, when AXObjectCache::notificationPostTimerFired is

triggered, and we try to update the isolated tree, some of the
underlying objects may already be gone. So this change ensure we don't
try to update an isolated object that corresponds to an already detached
live object.

  • accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::cacheAndInitializeWrapper): Sanity check.

  • accessibility/AccessibilityListBox.cpp:

(WebCore::AccessibilityListBox::addChildren): m_renderer can be null
when trying to update the isolated tree.

  • accessibility/AccessibilityListBoxOption.cpp:

(WebCore::AccessibilityListBoxOption::computeAccessibilityIsIgnored const):
Parent object may be gone when trying to update the isolated tree.

  • accessibility/isolatedtree/AXIsolatedTree.cpp:

(WebCore::AXIsolatedTree::updateChildrenIDs):
(WebCore::AXIsolatedTree::generateSubtree):
(WebCore::AXIsolatedTree::updateChildren):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263565 r263571  
     12020-06-26  Andres Gonzalez  <andresg_22@apple.com>
     2
     3        Fix for crash in accessibility/roles-exposed.html in isolated tree mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=213648
     5
     6        Reviewed by Chris Fleizach.
     7
     8        LayoutTest: accessibility/roles-exposed.html.
     9
     10        - In layout tests, when AXObjectCache::notificationPostTimerFired is
     11        triggered, and we try to update the isolated tree, some of the
     12        underlying objects may already be gone. So this change ensure we don't
     13        try to update an isolated object that corresponds to an already detached
     14        live object.
     15
     16        * accessibility/AXObjectCache.cpp:
     17        (WebCore::AXObjectCache::cacheAndInitializeWrapper): Sanity check.
     18        * accessibility/AccessibilityListBox.cpp:
     19        (WebCore::AccessibilityListBox::addChildren): m_renderer can be null
     20        when trying to update the isolated tree.
     21        * accessibility/AccessibilityListBoxOption.cpp:
     22        (WebCore::AccessibilityListBoxOption::computeAccessibilityIsIgnored const):
     23        Parent object may be gone when trying to update the isolated tree.
     24        * accessibility/isolatedtree/AXIsolatedTree.cpp:
     25        (WebCore::AXIsolatedTree::updateChildrenIDs):
     26        (WebCore::AXIsolatedTree::generateSubtree):
     27        (WebCore::AXIsolatedTree::updateChildren):
     28
    1292020-06-26  Youenn Fablet  <youenn@apple.com>
    230
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r263378 r263571  
    588588    ASSERT(newObject);
    589589    AXID axID = getAXID(newObject);
     590    ASSERT(axID != InvalidAXID);
     591
    590592    WTF::switchOn(domObject,
    591593        [&axID, this] (RenderObject* typedValue) { m_renderObjectMapping.set(typedValue, axID); },
     
    594596        [] (auto&) { }
    595597    );
     598
    596599    m_objects.set(axID, newObject);
    597600    newObject->init();
  • trunk/Source/WebCore/accessibility/AccessibilityListBox.cpp

    r251798 r263571  
    6565void AccessibilityListBox::addChildren()
    6666{
     67    if (!m_renderer)
     68        return;
     69
    6770    Node* selectNode = m_renderer->node();
    6871    if (!selectNode)
    6972        return;
    70    
     73
    7174    m_haveChildren = true;
    72    
     75
    7376    for (const auto& listItem : downcast<HTMLSelectElement>(*selectNode).listItems()) {
    7477        // The cast to HTMLElement below is safe because the only other possible listItem type
  • trunk/Source/WebCore/accessibility/AccessibilityListBoxOption.cpp

    r246490 r263571  
    118118    if (accessibilityIsIgnoredByDefault())
    119119        return true;
    120    
    121     return parentObject()->accessibilityIsIgnored();
     120
     121    auto* parent = parentObject();
     122    return parent ? parent->accessibilityIsIgnored() : true;
    122123}
    123124   
  • trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp

    r263378 r263571  
    167167    ASSERT(m_changeLogLock.isLocked());
    168168
    169     m_nodeMap.set(axID, childrenIDs);
    170     m_pendingChildrenUpdates.append(std::make_pair(axID, WTFMove(childrenIDs)));
     169    if (axID != InvalidAXID) {
     170        m_nodeMap.set(axID, childrenIDs);
     171        m_pendingChildrenUpdates.append(std::make_pair(axID, WTFMove(childrenIDs)));
     172    }
    171173}
    172174
     
    183185    if (!axParent)
    184186        setRootNode(object.ptr());
    185     else
     187    else if (axParent->objectID() != InvalidAXID) // Need to check for the objectID of axParent again because it may have been detached while traversing the tree.
    186188        updateChildrenIDs(axParent->objectID(), axParent->childrenIDs());
    187189}
     
    279281    });
    280282    ASSERT(axAncestor && iterator != m_nodeMap.end());
    281     if (!axAncestor || iterator == m_nodeMap.end())
     283    if (!axAncestor || axAncestor->objectID() == InvalidAXID || iterator == m_nodeMap.end())
    282284        return; // nothing to update.
    283285
     
    289291    auto axChildrenIDs = axAncestor->childrenIDs();
    290292
    291     for (size_t i = 0; i < axChildrenIDs.size(); ++i) {
     293    for (size_t i = 0; i < axChildren.size() && i < axChildrenIDs.size(); ++i) {
    292294        size_t index = removals.find(axChildrenIDs[i]);
    293295        if (index != notFound)
    294296            removals.remove(index);
    295297        else {
     298            ASSERT(axChildren[i]->objectID() == axChildrenIDs[i]);
    296299            // This is a new child, add it to the tree.
    297300            AXLOG("Adding a new child for:");
Note: See TracChangeset for help on using the changeset viewer.