Changeset 295779 in webkit
- Timestamp:
- Jun 23, 2022, 9:44:06 AM (2 years ago)
- Location:
- trunk/Source/WebCore/accessibility
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/accessibility/AccessibilityObject.h
r295139 r295779 498 498 499 499 virtual void updateRole() { } 500 bool childrenInitialized() const { return m_childrenInitialized; } 500 501 const AccessibilityChildrenVector& children(bool updateChildrenIfNeeded = true) override; 501 502 virtual void addChildren() { } … … 828 829 829 830 protected: // FIXME: Make the data members private. 830 bool childrenInitialized() const { return m_childrenInitialized; }831 831 AccessibilityChildrenVector m_children; 832 832 mutable bool m_childrenInitialized { false }; -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
r295727 r295779 210 210 } 211 211 212 static bool shouldCreateNodeChange(AXCoreObject& axObject) 213 { 214 // We should never create an isolated object from an ignored object or one with an invalid ID. 215 return !axObject.accessibilityIsIgnored() && axObject.objectID().isValid(); 216 } 217 212 218 std::optional<AXIsolatedTree::NodeChange> AXIsolatedTree::nodeChangeForObject(Ref<AXCoreObject> axObject, AttachWrapper attachWrapper) 213 219 { 214 220 ASSERT(isMainThread()); 215 216 // We should never create an isolated object from an ignored object. 217 if ( axObject->accessibilityIsIgnored())221 ASSERT(axObject->objectID().isValid()); 222 223 if (!shouldCreateNodeChange(axObject.get())) 218 224 return std::nullopt; 219 220 if (!axObject->objectID().isValid()) {221 // Either the axObject has an invalid ID or something else went terribly wrong. Don't bother doing anything else.222 ASSERT_NOT_REACHED();223 return std::nullopt;224 }225 225 226 226 auto object = AXIsolatedObject::create(axObject, this); … … 459 459 } 460 460 461 void AXIsolatedTree::updateChildren(AXCoreObject& axObject )461 void AXIsolatedTree::updateChildren(AXCoreObject& axObject, ResolveNodeChanges resolveNodeChanges) 462 462 { 463 463 AXTRACE("AXIsolatedTree::updateChildren"_s); … … 490 490 } 491 491 492 #ifndef NDEBUG493 492 if (axAncestor != &axObject) { 494 493 AXLOG(makeString("Original object with ID ", axObject.objectID().loggingString(), " wasn't in the isolated tree, so instead updating the closest in-isolated-tree ancestor:")); 495 494 AXLOG(axAncestor); 496 } 497 #endif 495 for (auto& child : axObject.children()) { 496 auto* liveChild = dynamicDowncast<AccessibilityObject>(child.get()); 497 if (!liveChild || liveChild->childrenInitialized()) 498 continue; 499 500 if (!m_nodeMap.contains(liveChild->objectID())) { 501 if (!shouldCreateNodeChange(*liveChild)) 502 continue; 503 504 // This child should be added to the isolated tree but hasn't been yet. 505 // Add it to the nodemap so the recursive call to updateChildren below properly builds the subtree for this object. 506 auto* parent = liveChild->parentObjectUnignored(); 507 m_nodeMap.set(liveChild->objectID(), ParentChildrenIDs { parent ? parent->objectID() : AXID(), liveChild->childrenIDs() }); 508 m_unresolvedPendingAppends.set(liveChild->objectID(), AttachWrapper::OnMainThread); 509 } 510 511 AXLOG(makeString( 512 "Child ID ", liveChild->objectID().loggingString(), " of original object ID ", axObject.objectID().loggingString(), " was found in the isolated tree with uninitialized live children. Updating its isolated children." 513 )); 514 // Don't immediately resolve node changes in these recursive calls to updateChildren. This avoids duplicate node change creation in this scenario: 515 // 1. Some subtree is updated in the below call to updateChildren. 516 // 2. Later in this function, when updating axAncestor, we update some higher subtree that includes the updated subtree from step 1. 517 updateChildren(*liveChild, ResolveNodeChanges::No); 518 } 519 } 498 520 499 521 auto oldIDs = m_nodeMap.get(axAncestor->objectID()); … … 529 551 removeSubtreeFromNodeMap(axID, axAncestor); 530 552 } 531 queueRemovalsAndUnresolvedChanges(oldChildrenIDs); 553 554 if (resolveNodeChanges == ResolveNodeChanges::Yes) 555 queueRemovalsAndUnresolvedChanges(oldChildrenIDs); 556 else 557 queueRemovals(oldChildrenIDs); 532 558 533 559 // Also queue updates to the target node itself and any properties that depend on children(). -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
r295727 r295779 347 347 void generateSubtree(AXCoreObject&); 348 348 void updateNode(AXCoreObject&); 349 void updateChildren(AXCoreObject&); 349 enum class ResolveNodeChanges : bool { No, Yes }; 350 void updateChildren(AXCoreObject&, ResolveNodeChanges = ResolveNodeChanges::Yes); 350 351 void updateNodeProperty(AXCoreObject&, AXPropertyName); 351 352 void updateNodeAndDependentProperties(AXCoreObject&);
Note:
See TracChangeset
for help on using the changeset viewer.