Changeset 256442 in webkit
- Timestamp:
- Feb 12, 2020 9:31:03 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256437 r256442 1 2020-02-12 Andres Gonzalez <andresg_22@apple.com> 2 3 Support event notifications in IsolatedTree mode. 4 https://bugs.webkit.org/show_bug.cgi?id=207581 5 6 Reviewed by Chris Fleizach. 7 8 - DOM/Render trees notifications are listened to by AXObjectCache and 9 the corresponding IsolatedTree is updated. 10 - The update is now happening for state, value and children change 11 notifications. 12 - AXObjectCache::updateIsolatedTree re-generates the subtree rooted at 13 the node receiving the notification. 14 - Consolidated creation of AXIsolatedObjects by passing treeID and 15 parentID to the create method and constructor. 16 - Changes to the IsolatedTree are set on the main thread using the 17 NodeChange structure, and applied to the tree on the AX thread. 18 - The updated IsolatedObjects are attached to their corresponding 19 platform wrappers on the AX thread, so that after creation they are only 20 accessed on the secondary thread. 21 22 * accessibility/AXObjectCache.cpp: 23 (WebCore::AXObjectCache::postNotification): Invokes updateIsolatedTree. 24 (WebCore::createIsolatedTreeHierarchy): 25 (WebCore::AXObjectCache::generateIsolatedTree): 26 (WebCore::AXObjectCache::updateIsolatedTree): 27 (WebCore::AXObjectCache::createIsolatedTreeHierarchy): Became a static helper function. 28 * accessibility/AXObjectCache.h: 29 * accessibility/AccessibilityObjectInterface.h: 30 * accessibility/isolatedtree/AXIsolatedObject.cpp: 31 (WebCore::AXIsolatedObject::AXIsolatedObject): 32 (WebCore::AXIsolatedObject::create): 33 (WebCore::AXIsolatedObject::setProperty): 34 (WebCore::AXIsolatedObject::setParent): 35 (WebCore::AXIsolatedObject::detachFromParent): 36 (WebCore::AXIsolatedObject::setTreeIdentifier): Deleted, the tree identifier is set in the constructor. 37 * accessibility/isolatedtree/AXIsolatedObject.h: 38 * accessibility/isolatedtree/AXIsolatedTree.cpp: 39 (WebCore::AXIsolatedTree::NodeChange::NodeChange): 40 (WebCore::AXIsolatedTree::appendNodeChanges): 41 (WebCore::AXIsolatedTree::applyPendingChanges): 42 * accessibility/isolatedtree/AXIsolatedTree.h: 43 * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm: 44 (WebCore::AXIsolatedObject::attachPlatformWrapper): 45 * accessibility/mac/AXObjectCacheMac.mm: 46 1 47 2020-02-12 Zalan Bujtas <zalan@apple.com> 2 48 -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r255548 r256442 1118 1118 if (!object) 1119 1119 return; 1120 1121 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 1122 updateIsolatedTree(object, notification); 1123 #endif 1120 1124 1121 1125 if (postType == PostAsynchronously) { … … 3069 3073 3070 3074 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 3071 Ref<AXIsolatedObject> AXObjectCache::createIsolatedTreeHierarchy(AXCoreObject& object, AXID parentID, AXObjectCache* axObjectCache, AXIsolatedTree& tree, Vector<Ref<AXIsolatedObject>>& nodeChanges, bool isRoot) 3072 { 3073 auto isolatedTreeNode = AXIsolatedObject::create(object, isRoot); 3074 nodeChanges.append(isolatedTreeNode.copyRef()); 3075 3076 isolatedTreeNode->setTreeIdentifier(tree.treeIdentifier()); 3077 isolatedTreeNode->setParent(parentID); 3078 axObjectCache->attachWrapper(&isolatedTreeNode.get(), object.wrapper()); 3075 static Ref<AXIsolatedObject> createIsolatedTreeHierarchy(AXCoreObject& object, AXIsolatedTreeID treeID, AXID parentID, bool attachWrapper, Vector<AXIsolatedTree::NodeChange>& nodeChanges) 3076 { 3077 auto isolatedObject = AXIsolatedObject::create(object, treeID, parentID); 3078 nodeChanges.append(AXIsolatedTree::NodeChange(isolatedObject, object.wrapper())); 3079 if (attachWrapper) 3080 isolatedObject->attachPlatformWrapper(object.wrapper()); 3079 3081 3080 3082 for (const auto& child : object.children()) { 3081 auto staticChild = createIsolatedTreeHierarchy(*child, isolatedTreeNode->objectID(), axObjectCache, tree, nodeChanges, false);3082 isolated TreeNode->appendChild(staticChild->objectID());3083 } 3084 3085 return isolated TreeNode;3083 auto staticChild = createIsolatedTreeHierarchy(*child, treeID, isolatedObject->objectID(), attachWrapper, nodeChanges); 3084 isolatedObject->appendChild(staticChild->objectID()); 3085 } 3086 3087 return isolatedObject; 3086 3088 } 3087 3089 … … 3101 3103 auto* axRoot = axObjectCache->getOrCreate(document.view()); 3102 3104 if (axRoot) { 3103 Vector< Ref<AXIsolatedObject>> nodeChanges;3104 auto isolatedRoot = createIsolatedTreeHierarchy(*axRoot, InvalidAXID, axObjectCache, *tree, nodeChanges, true);3105 Vector<AXIsolatedTree::NodeChange> nodeChanges; 3106 auto isolatedRoot = createIsolatedTreeHierarchy(*axRoot, tree->treeIdentifier(), InvalidAXID, true, nodeChanges); 3105 3107 tree->setRootNode(isolatedRoot); 3106 3108 tree->appendNodeChanges(nodeChanges); … … 3112 3114 3113 3115 return makeRef(*tree); 3116 } 3117 3118 void AXObjectCache::updateIsolatedTree(AXCoreObject* object, AXNotification notification) 3119 { 3120 if (!m_pageID) 3121 return; 3122 3123 auto tree = AXIsolatedTree::treeForPageID(*m_pageID); 3124 if (!tree) 3125 return; 3126 3127 switch (notification) { 3128 case AXCheckedStateChanged: 3129 case AXChildrenChanged: 3130 case AXValueChanged: { 3131 tree->removeNode(object->objectID()); 3132 auto* parent = object->parentObject(); 3133 AXID parentID = parent ? parent->objectID() : InvalidAXID; 3134 Vector<AXIsolatedTree::NodeChange> nodeChanges; 3135 auto isolatedObject = createIsolatedTreeHierarchy(*object, tree->treeIdentifier(), parentID, false, nodeChanges); 3136 tree->appendNodeChanges(nodeChanges); 3137 break; 3138 } 3139 default: 3140 break; 3141 } 3114 3142 } 3115 3143 #endif -
trunk/Source/WebCore/accessibility/AXObjectCache.h
r255167 r256442 26 26 #pragma once 27 27 28 #include "AXIsolatedTree.h" 28 29 #include "AXTextStateChangeIntent.h" 29 30 #include "AccessibilityObject.h" … … 44 45 namespace WebCore { 45 46 46 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)47 class AXIsolatedObject;48 class AXIsolatedTree;49 #endif50 47 class Document; 51 48 class HTMLAreaElement; … … 179 176 void cacheAndInitializeWrapper(AccessibilityObject*, DOMObjectVariant = nullptr); 180 177 void attachWrapper(AXCoreObject*); 181 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)182 void attachWrapper(AXIsolatedObject*, WebAccessibilityObjectWrapper*);183 #endif184 178 185 179 public: … … 200 194 void recomputeIsIgnored(RenderObject* renderer); 201 195 202 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)203 WEBCORE_EXPORT static bool clientSupportsIsolatedTree();204 private:205 AXCoreObject* isolatedTreeRootObject();206 static AXCoreObject* isolatedTreeFocusedObject(Document&);207 void setIsolatedTreeFocusedObject(Node*);208 static Ref<AXIsolatedTree> generateIsolatedTree(PageIdentifier, Document&);209 static Ref<AXIsolatedObject> createIsolatedTreeHierarchy(AXCoreObject&, AXID, AXObjectCache*, AXIsolatedTree&, Vector<Ref<AXIsolatedObject>>&, bool isRoot);210 #endif211 212 public:213 196 WEBCORE_EXPORT bool canUseSecondaryAXThread(); 214 197 … … 368 351 369 352 RefPtr<Range> rangeMatchesTextNearRange(RefPtr<Range>, const String&); 370 353 354 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 355 WEBCORE_EXPORT static bool clientSupportsIsolatedTree(); 356 private: 357 AXCoreObject* isolatedTreeRootObject(); 358 static AXCoreObject* isolatedTreeFocusedObject(Document&); 359 void setIsolatedTreeFocusedObject(Node*); 360 static Ref<AXIsolatedTree> generateIsolatedTree(PageIdentifier, Document&); 361 void updateIsolatedTree(AXCoreObject*, AXNotification); 362 #endif 371 363 372 364 protected: -
trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h
r256347 r256442 71 71 typedef unsigned AXID; 72 72 extern const AXID InvalidAXID; 73 typedef unsigned AXIsolatedTreeID;74 73 75 74 enum class AccessibilityRole { -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
r255884 r256442 33 33 namespace WebCore { 34 34 35 AXIsolatedObject::AXIsolatedObject(AXCoreObject& object, bool isRoot) 36 : m_id(object.objectID()) 35 AXIsolatedObject::AXIsolatedObject(AXCoreObject& object, AXIsolatedTreeID treeID, AXID parentID) 36 : m_treeID(treeID) 37 , m_parentID(parentID) 38 , m_id(object.objectID()) 37 39 { 38 40 ASSERT(isMainThread()); 39 initializeAttributeData(object, isRoot); 40 m_initialized = true; 41 } 42 43 Ref<AXIsolatedObject> AXIsolatedObject::create(AXCoreObject& object, bool isRoot) 44 { 45 return adoptRef(*new AXIsolatedObject(object, isRoot)); 41 if (auto tree = AXIsolatedTree::treeForID(m_treeID)) 42 m_cachedTree = tree; 43 initializeAttributeData(object, parentID == InvalidAXID); 44 } 45 46 Ref<AXIsolatedObject> AXIsolatedObject::create(AXCoreObject& object, AXIsolatedTreeID treeID, AXID parentID) 47 { 48 return adoptRef(*new AXIsolatedObject(object, treeID, parentID)); 46 49 } 47 50 … … 387 390 void AXIsolatedObject::setProperty(AXPropertyName propertyName, AttributeValueVariant&& value, bool shouldRemove) 388 391 { 389 ASSERT(!m_initialized);390 392 ASSERT(isMainThread()); 391 393 … … 405 407 { 406 408 ASSERT(isMainThread()); 407 m_parent = parent;409 m_parentID = parent; 408 410 } 409 411 … … 426 428 void AXIsolatedObject::detachFromParent() 427 429 { 428 m_parent = InvalidAXID; 429 } 430 431 void AXIsolatedObject::setTreeIdentifier(AXIsolatedTreeID treeIdentifier) 432 { 433 m_treeIdentifier = treeIdentifier; 434 if (auto tree = AXIsolatedTree::treeForID(m_treeIdentifier)) 435 m_cachedTree = tree; 430 m_parentID = InvalidAXID; 436 431 } 437 432 -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
r255884 r256442 48 48 class AXIsolatedObject final : public AXCoreObject { 49 49 public: 50 static Ref<AXIsolatedObject> create(AXCoreObject&, bool isRoot);50 static Ref<AXIsolatedObject> create(AXCoreObject&, AXIsolatedTreeID, AXID parentID); 51 51 ~AXIsolatedObject(); 52 52 … … 55 55 void init() override { } 56 56 57 void attachPlatformWrapper(AccessibilityObjectWrapper*); 57 58 bool isDetached() const override; 58 59 59 void setTreeIdentifier(AXIsolatedTreeID);60 60 void setParent(AXID); 61 61 void appendChild(AXID); … … 65 65 void detachPlatformWrapper(AccessibilityDetachmentType) override; 66 66 67 AXID parent() const { return m_parent ; }68 69 AXIsolatedTreeID treeIdentifier() const { return m_treeI dentifier; }67 AXID parent() const { return m_parentID; } 68 69 AXIsolatedTreeID treeIdentifier() const { return m_treeID; } 70 70 AXIsolatedTree* tree() const { return m_cachedTree.get(); } 71 71 72 72 AXIsolatedObject() = default; 73 AXIsolatedObject(AXCoreObject&, bool isRoot);73 AXIsolatedObject(AXCoreObject&, AXIsolatedTreeID, AXID parentID); 74 74 void initializeAttributeData(AXCoreObject&, bool isRoot); 75 75 AXCoreObject* associatedAXObject() const … … 822 822 void updateBackingStore() override; 823 823 824 AXID m_parent { InvalidAXID }; 824 AXIsolatedTreeID m_treeID; 825 RefPtr<AXIsolatedTree> m_cachedTree; 826 AXID m_parentID { InvalidAXID }; 825 827 AXID m_id { InvalidAXID }; 826 bool m_initialized { false };827 AXIsolatedTreeID m_treeIdentifier;828 RefPtr<AXIsolatedTree> m_cachedTree;829 828 Vector<AXID> m_childrenIDs; 830 829 Vector<RefPtr<AXCoreObject>> m_children; -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
r255311 r256442 43 43 } 44 44 45 AXIsolatedTree::NodeChange::NodeChange(const Ref<AXIsolatedObject>& isolatedObject, AccessibilityObjectWrapper* wrapper) 46 : m_isolatedObject(isolatedObject.copyRef()) 47 , m_wrapper(wrapper) 48 { 49 } 50 51 AXIsolatedTree::NodeChange::NodeChange(const NodeChange& other) 52 : m_isolatedObject(other.m_isolatedObject.copyRef()) 53 , m_wrapper(other.m_wrapper) 54 { 55 } 56 45 57 HashMap<PageIdentifier, Ref<AXIsolatedTree>>& AXIsolatedTree::treePageCache() 46 58 { … … 156 168 } 157 169 158 void AXIsolatedTree::appendNodeChanges( Vector<Ref<AXIsolatedObject>>& log)159 { 160 LockHolder locker { m_changeLogLock }; 161 for ( auto& node : log)162 m_pendingAppends.append(node .copyRef());170 void AXIsolatedTree::appendNodeChanges(const Vector<NodeChange>& log) 171 { 172 LockHolder locker { m_changeLogLock }; 173 for (const auto& node : log) 174 m_pendingAppends.append(node); 163 175 } 164 176 … … 168 180 LockHolder locker { m_changeLogLock }; 169 181 170 // We don't clear the pending IDs beacause if the next round of updates does not modify them, then they stay the same171 // value without extra bookkeeping.172 182 m_focusedNodeID = m_pendingFocusedNodeID; 173 183 174 for (auto& item : m_pendingAppends) 175 m_readerThreadNodeMap.add(item->objectID(), WTFMove(item)); 176 m_pendingAppends.clear(); 177 178 for (auto& item : m_pendingRemovals) { 184 for (const auto& item : m_pendingRemovals) { 179 185 if (auto object = nodeForID(item)) 180 186 object->detach(AccessibilityDetachmentType::ElementDestroyed); … … 182 188 } 183 189 m_pendingRemovals.clear(); 184 } 185 190 191 for (auto& item : m_pendingAppends) { 192 ASSERT(item.m_wrapper); 193 item.m_isolatedObject->attachPlatformWrapper(item.m_wrapper); 194 m_readerThreadNodeMap.add(item.m_isolatedObject->objectID(), item.m_isolatedObject.copyRef()); 195 } 196 m_pendingAppends.clear(); 197 } 198 186 199 } // namespace WebCore 187 200 -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
r255311 r256442 28 28 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 29 29 30 #include "AccessibilityObjectInterface.h" 30 31 #include "PageIdentifier.h" 31 32 #include <wtf/HashMap.h> … … 35 36 namespace WebCore { 36 37 38 class AXIsolatedObject; 39 class AXObjectCache; 37 40 class Page; 41 42 typedef unsigned AXIsolatedTreeID; 38 43 39 44 class AXIsolatedTree : public ThreadSafeRefCounted<AXIsolatedTree> { … … 57 62 static RefPtr<AXIsolatedObject> nodeInTreeForID(AXIsolatedTreeID, AXID); 58 63 64 struct NodeChange { 65 Ref<AXIsolatedObject> m_isolatedObject; 66 AccessibilityObjectWrapper* m_wrapper; 67 NodeChange(const Ref<AXIsolatedObject>&, AccessibilityObjectWrapper*); 68 NodeChange(const NodeChange&); 69 }; 70 59 71 // Call on main thread 60 void appendNodeChanges( Vector<Ref<AXIsolatedObject>>&);72 void appendNodeChanges(const Vector<NodeChange>&); 61 73 void removeNode(AXID); 62 74 … … 81 93 82 94 // Written to by main thread under lock, accessed and applied by AX thread. 83 Vector< Ref<AXIsolatedObject>> m_pendingAppends;95 Vector<NodeChange> m_pendingAppends; 84 96 Vector<AXID> m_pendingRemovals; 85 97 AXID m_pendingFocusedNodeID; -
trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm
r255167 r256442 33 33 namespace WebCore { 34 34 35 void AXIsolatedObject::attachPlatformWrapper(AccessibilityObjectWrapper* wrapper) 36 { 37 [wrapper attachIsolatedObject:this]; 38 setWrapper(wrapper); 39 } 40 35 41 void AXIsolatedObject::detachPlatformWrapper(AccessibilityDetachmentType) 36 42 { -
trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
r255167 r256442 239 239 } 240 240 241 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)242 void AXObjectCache::attachWrapper(AXIsolatedObject* isolatedObject, WebAccessibilityObjectWrapper* wrapper)243 {244 [wrapper attachIsolatedObject:(AXCoreObject*)isolatedObject];245 isolatedObject->setWrapper(wrapper);246 }247 #endif248 249 241 static BOOL axShouldRepostNotificationsForTests = false; 250 242
Note: See TracChangeset
for help on using the changeset viewer.