Changeset 261934 in webkit


Ignore:
Timestamp:
May 20, 2020 11:21:10 AM (4 years ago)
Author:
Andres Gonzalez
Message:

Fix for accessibility-node-memory-management.html in isolated tree mode.
https://bugs.webkit.org/show_bug.cgi?id=212142

Reviewed by Chris Fleizach.

LayoutTests/accessibility/accessibility-node-memory-management.html.

  • Fix in applyPendingChanges that was not removing removed nodes from

the nodes map. This was causing that some detached AXIsolatedObjects
were being returned.

  • Also handle the case where pending changes can come from a detached

AXObject with invalid ID and no platform wrapper.

  • updateChildren better handles the case when the notification target

is not in the isolated tree by walking up the object hierarchy until it
finds an associated object that does have a corresponding isolated object.

  • accessibility/isolatedtree/AXIsolatedTree.cpp:

(WebCore::AXIsolatedTree::treeForPageID):
(WebCore::AXIsolatedTree::updateChildren):
(WebCore::AXIsolatedTree::applyPendingChanges):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r261927 r261934  
     12020-05-20  Andres Gonzalez  <andresg_22@apple.com>
     2
     3        Fix for accessibility-node-memory-management.html in isolated tree mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=212142
     5
     6        Reviewed by Chris Fleizach.
     7
     8        LayoutTests/accessibility/accessibility-node-memory-management.html.
     9
     10        - Fix in applyPendingChanges that was not removing removed nodes from
     11        the nodes map. This was causing that some detached AXIsolatedObjects
     12        were being returned.
     13        - Also handle the case where pending changes can come from a detached
     14        AXObject with invalid ID and no platform wrapper.
     15        - updateChildren better handles the case when the notification target
     16        is not in the isolated tree by walking up the object hierarchy until it
     17        finds an associated object that does have a corresponding isolated object.
     18
     19        * accessibility/isolatedtree/AXIsolatedTree.cpp:
     20        (WebCore::AXIsolatedTree::treeForPageID):
     21        (WebCore::AXIsolatedTree::updateChildren):
     22        (WebCore::AXIsolatedTree::applyPendingChanges):
     23
    1242020-05-20  Antoine Quint  <graouts@apple.com>
    225
  • trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp

    r261694 r261934  
    130130RefPtr<AXIsolatedTree> AXIsolatedTree::treeForPageID(PageIdentifier pageID)
    131131{
    132     AXTRACE("AXIsolatedTree::treeForPageID");
    133132    LockHolder locker(s_cacheLock);
    134133
     
    238237        return;
    239238
    240     AXID axObjectID = axObject.objectID();
    241 
    242239    applyPendingChanges();
    243240    LockHolder locker { m_changeLogLock };
    244     auto object = nodeForID(axObjectID);
    245     if (!object) {
    246         AXLOG("No associated isolated object!");
     241
     242    // updateChildren may be called as the result of a children changed
     243    // notification for an axObject that has no associated isolated object.
     244    // An example of this is when an empty element such as a <canvas> or <div>
     245    // is added a new child. So find the closest ancestor of axObject that has
     246    // an associated isolated object and update its children.
     247    RefPtr<AXIsolatedObject> object;
     248    auto* axAncestor = Accessibility::findAncestor(axObject, true, [&object, this] (const AXCoreObject& ancestor) {
     249        return object = nodeForID(ancestor.objectID());
     250    });
     251    ASSERT(object && object->objectID() != InvalidAXID);
     252    if (!axAncestor || !object)
    247253        return; // nothing to update.
    248     }
    249254
    250255    auto removals = object->m_childrenIDs;
    251256    locker.unlockEarly();
    252257
    253     const auto& axChildren = axObject.children();
    254     auto axChildrenIDs = axObject.childrenIDs();
     258    const auto& axChildren = axAncestor->children();
     259    auto axChildrenIDs = axAncestor->childrenIDs();
    255260
    256261    for (size_t i = 0; i < axChildrenIDs.size(); ++i) {
     
    262267            AXLOG("Adding a new child for:");
    263268            AXLOG(axChildren[i]);
    264             generateSubtree(*axChildren[i], axObjectID, true);
     269            generateSubtree(*axChildren[i], object->objectID(), true);
    265270        }
    266271    }
     
    351356        auto axID = m_pendingNodeRemovals.takeLast();
    352357        AXLOG(makeString("removing axID ", axID));
    353         if (axID == InvalidAXID)
    354             continue;
    355 
    356         if (auto object = nodeForID(axID))
     358        if (auto object = nodeForID(axID)) {
    357359            object->detach(AccessibilityDetachmentType::ElementDestroyed);
     360            m_readerThreadNodeMap.remove(axID);
     361        }
    358362    }
    359363
     
    361365        auto axID = m_pendingSubtreeRemovals.takeLast();
    362366        AXLOG(makeString("removing subtree axID ", axID));
    363         if (axID == InvalidAXID)
    364             continue;
    365 
    366367        if (auto object = nodeForID(axID)) {
    367368            object->detach(AccessibilityDetachmentType::ElementDestroyed);
    368369            m_pendingSubtreeRemovals.appendVector(object->m_childrenIDs);
     370            m_readerThreadNodeMap.remove(axID);
    369371        }
    370372    }
    371373
    372374    for (const auto& item : m_pendingAppends) {
    373         // Either the new object has a wrapper already attached, or one is passed to be attached, not both.
    374         ASSERT((item.m_isolatedObject->wrapper() || item.m_wrapper)
    375             && !(item.m_isolatedObject->wrapper() && item.m_wrapper));
    376375        AXID axID = item.m_isolatedObject->objectID();
    377376        AXLOG(makeString("appending axID ", axID));
     
    380379
    381380        auto& wrapper = item.m_wrapper ? item.m_wrapper : item.m_isolatedObject->wrapper();
     381        if (!wrapper)
     382            continue;
    382383
    383384        if (auto object = m_readerThreadNodeMap.get(axID)) {
Note: See TracChangeset for help on using the changeset viewer.