Changeset 253088 in webkit
- Timestamp:
- Dec 3, 2019 7:44:53 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r253086 r253088 1 2019-12-03 Andres Gonzalez <andresg_22@apple.com> 2 3 Focus tracking support in the accessibility isolatedtree. 4 https://bugs.webkit.org/show_bug.cgi?id=204535 5 6 Reviewed by Chris Fleizach. 7 8 The AXIsolatedTree focused object is now set during the tree generation. 9 It is updated on handleFocusedUIElementChanged. 10 11 * accessibility/AXObjectCache.cpp: 12 (WebCore::AXObjectCache::focusedImageMapUIElement): 13 (WebCore::AXObjectCache::focusedObject): 14 (WebCore::AXObjectCache::isolatedTreeFocusedObject): 15 (WebCore::AXObjectCache::setIsolatedTreeFocusedObject): 16 (WebCore::AXObjectCache::focusedUIElementForPage): 17 (WebCore::AXObjectCache::isolatedTreeRootObject): 18 (WebCore::AXObjectCache::handleFocusedUIElementChanged): 19 (WebCore::AXObjectCache::createIsolatedTreeHierarchy): 20 (WebCore::AXObjectCache::generateIsolatedTree): 21 * accessibility/AXObjectCache.h: 22 * accessibility/AccessibilityObject.cpp: 23 (WebCore::AccessibilityObject::focusedUIElement const): 24 1 25 2019-12-03 Ryosuke Niwa <rniwa@webkit.org> 2 26 -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r252609 r253088 349 349 return nullptr; 350 350 } 351 351 352 AXCoreObject* AXObjectCache::focusedObject(Document& document) 353 { 354 Element* focusedElement = document.focusedElement(); 355 if (is<HTMLAreaElement>(focusedElement)) 356 return focusedImageMapUIElement(downcast<HTMLAreaElement>(focusedElement)); 357 358 auto* axObjectCache = document.axObjectCache(); 359 if (!axObjectCache) 360 return nullptr; 361 362 AXCoreObject* focus = axObjectCache->getOrCreate(focusedElement ? focusedElement : static_cast<Node*>(&document)); 363 if (!focus) 364 return nullptr; 365 366 if (focus->shouldFocusActiveDescendant()) { 367 if (auto* descendant = focus->activeDescendant()) 368 focus = descendant; 369 } 370 371 // the HTML element, for example, is focusable but has an AX object that is ignored 372 if (focus->accessibilityIsIgnored()) 373 focus = focus->parentObjectUnignored(); 374 375 return focus; 376 } 377 378 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 379 AXCoreObject* AXObjectCache::isolatedTreeFocusedObject(Document& document) 380 { 381 auto pageID = document.pageID(); 382 if (!pageID) 383 return nullptr; 384 385 auto tree = AXIsolatedTree::treeForPageID(*pageID); 386 if (!tree) { 387 tree = generateIsolatedTree(*pageID, document); 388 // Now that we have created our tree, initialize the secondary thread, 389 // so future requests come in on the other thread. 390 _AXUIElementUseSecondaryAXThread(true); 391 } 392 393 if (tree) 394 return tree->focusedUIElement().get(); 395 396 // Should not get here, couldn't create the IsolatedTree. 397 ASSERT_NOT_REACHED(); 398 return nullptr; 399 } 400 401 void AXObjectCache::setIsolatedTreeFocusedObject(Node* focusedNode) 402 { 403 ASSERT(isMainThread()); 404 auto* focus = getOrCreate(focusedNode); 405 auto pageID = m_document.pageID(); 406 if (!pageID) 407 return; 408 409 if (auto tree = AXIsolatedTree::treeForPageID(*pageID)) 410 tree->setFocusedNodeID(focus ? focus->objectID() : InvalidAXID); 411 } 412 #endif 413 352 414 AXCoreObject* AXObjectCache::focusedUIElementForPage(const Page* page) 353 415 { 416 ASSERT(isMainThread()); 354 417 if (!gAccessibilityEnabled) 355 418 return nullptr; … … 357 420 // get the focused node in the page 358 421 Document* focusedDocument = page->focusController().focusedOrMainFrame().document(); 359 Element* focusedElement = focusedDocument->focusedElement(); 360 if (is<HTMLAreaElement>(focusedElement)) 361 return focusedImageMapUIElement(downcast<HTMLAreaElement>(focusedElement)); 362 363 AXCoreObject* obj = focusedDocument->axObjectCache()->getOrCreate(focusedElement ? static_cast<Node*>(focusedElement) : focusedDocument); 364 if (!obj) 365 return nullptr; 366 367 if (obj->shouldFocusActiveDescendant()) { 368 if (AXCoreObject* descendant = obj->activeDescendant()) 369 obj = descendant; 370 } 371 372 // the HTML element, for example, is focusable but has an AX object that is ignored 373 if (obj->accessibilityIsIgnored()) 374 obj = obj->parentObjectUnignored(); 375 376 return obj; 422 if (!focusedDocument) 423 return nullptr; 424 425 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 426 if (clientSupportsIsolatedTree()) 427 return isolatedTreeFocusedObject(*focusedDocument); 428 #endif 429 430 return focusedObject(*focusedDocument); 377 431 } 378 432 … … 688 742 auto tree = AXIsolatedTree::treeForPageID(*pageID); 689 743 if (!tree && isMainThread()) { 690 tree = generateIsolatedTree(*pageID );744 tree = generateIsolatedTree(*pageID, m_document); 691 745 // Now that we have created our tree, initialize the secondary thread, 692 746 // so future requests come in on the other thread. … … 701 755 702 756 // Should not get here, couldn't create or update the IsolatedTree. 703 ASSERT (false);757 ASSERT_NOT_REACHED(); 704 758 return nullptr; 705 759 } … … 1104 1158 void AXObjectCache::handleFocusedUIElementChanged(Node* oldNode, Node* newNode) 1105 1159 { 1160 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 1161 setIsolatedTreeFocusedObject(newNode); 1162 #endif 1163 1106 1164 handleMenuItemSelected(newNode); 1107 1165 platformHandleFocusedUIElementChanged(oldNode, newNode); … … 3007 3065 3008 3066 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 3009 Ref<AXIsolatedObject> AXObjectCache::createIsolatedTreeHierarchy(AXCoreObject& object, AXID parentID, AX IsolatedTree& tree, Vector<Ref<AXIsolatedObject>>& nodeChanges)3067 Ref<AXIsolatedObject> AXObjectCache::createIsolatedTreeHierarchy(AXCoreObject& object, AXID parentID, AXObjectCache* axObjectCache, AXIsolatedTree& tree, Vector<Ref<AXIsolatedObject>>& nodeChanges) 3010 3068 { 3011 3069 auto isolatedTreeNode = AXIsolatedObject::create(object); … … 3014 3072 isolatedTreeNode->setTreeIdentifier(tree.treeIdentifier()); 3015 3073 isolatedTreeNode->setParent(parentID); 3016 a ttachWrapper(&isolatedTreeNode.get());3074 axObjectCache->attachWrapper(&isolatedTreeNode.get()); 3017 3075 3018 3076 for (const auto& child : object.children()) { 3019 auto staticChild = createIsolatedTreeHierarchy(*child, isolatedTreeNode->objectID(), tree, nodeChanges);3077 auto staticChild = createIsolatedTreeHierarchy(*child, isolatedTreeNode->objectID(), axObjectCache, tree, nodeChanges); 3020 3078 isolatedTreeNode->appendChild(staticChild->objectID()); 3021 3079 } … … 3023 3081 return isolatedTreeNode; 3024 3082 } 3025 3026 Ref<AXIsolatedTree> AXObjectCache::generateIsolatedTree(PageIdentifier pageID )3083 3084 Ref<AXIsolatedTree> AXObjectCache::generateIsolatedTree(PageIdentifier pageID, Document& document) 3027 3085 { 3028 3086 RELEASE_ASSERT(isMainThread()); … … 3031 3089 if (!tree) 3032 3090 tree = AXIsolatedTree::createTreeForPageID(pageID); 3033 3034 Vector<Ref<AXIsolatedObject>> nodeChanges; 3035 AccessibilityObject* axRoot = getOrCreate(m_document.view()); 3036 auto isolatedRoot = createIsolatedTreeHierarchy(*axRoot, InvalidAXID, *tree, nodeChanges); 3037 tree->setRoot(isolatedRoot); 3038 tree->appendNodeChanges(nodeChanges); 3091 3092 // Set the root and focused objects in the isolated tree. For that, we need 3093 // the root and the focused object in the AXObject tree. 3094 auto* axObjectCache = document.axObjectCache(); 3095 if (!axObjectCache) 3096 return makeRef(*tree); 3097 3098 auto* axRoot = axObjectCache->getOrCreate(document.view()); 3099 if (axRoot) { 3100 Vector<Ref<AXIsolatedObject>> nodeChanges; 3101 auto isolatedRoot = createIsolatedTreeHierarchy(*axRoot, InvalidAXID, axObjectCache, *tree, nodeChanges); 3102 tree->setRoot(isolatedRoot); 3103 tree->appendNodeChanges(nodeChanges); 3104 } 3105 3106 auto* axFocus = axObjectCache->focusedObject(document); 3107 if (axFocus) 3108 tree->setFocusedNodeID(axFocus->objectID()); 3039 3109 3040 3110 return makeRef(*tree); -
trunk/Source/WebCore/accessibility/AXObjectCache.h
r252609 r253088 196 196 private: 197 197 AXCoreObject* isolatedTreeRootObject(); 198 Ref<AXIsolatedTree> generateIsolatedTree(PageIdentifier); 199 Ref<AXIsolatedObject> createIsolatedTreeHierarchy(AXCoreObject&, AXID, AXIsolatedTree&, Vector<Ref<AXIsolatedObject>>&); 198 static AXCoreObject* isolatedTreeFocusedObject(Document&); 199 void setIsolatedTreeFocusedObject(Node*); 200 static Ref<AXIsolatedTree> generateIsolatedTree(PageIdentifier, Document&); 201 static Ref<AXIsolatedObject> createIsolatedTreeHierarchy(AXCoreObject&, AXID, AXObjectCache*, AXIsolatedTree&, Vector<Ref<AXIsolatedObject>>&); 200 202 #endif 201 203 … … 414 416 415 417 static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*); 418 static AXCoreObject* focusedObject(Document&); 416 419 417 420 AXID getAXID(AccessibilityObject*); -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r252181 r253088 2868 2868 { 2869 2869 auto* page = this->page(); 2870 return page ? AXObjectCache::focusedUIElementForPage(page) : nullptr; 2870 auto* axObjectCache = this->axObjectCache(); 2871 return page && axObjectCache ? axObjectCache->focusedUIElementForPage(page) : nullptr; 2871 2872 } 2872 2873 -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
r252182 r253088 107 107 RefPtr<AXIsolatedObject> AXIsolatedTree::focusedUIElement() 108 108 { 109 m_focusedNodeID = m_pendingFocusedNodeID; 109 110 return nodeForID(m_focusedNodeID); 110 111 } -
trunk/Source/WebKit/ChangeLog
r253082 r253088 1 2019-12-03 Andres Gonzalez <andresg_22@apple.com> 2 3 Focus tracking support in the accessibility isolatedtree. 4 https://bugs.webkit.org/show_bug.cgi?id=204535 5 6 Reviewed by Chris Fleizach. 7 8 * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: 9 (WKAccessibilityFocusedObject): 10 1 11 2019-12-03 John Wilander <wilander@apple.com> 2 12 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
r252609 r253088 59 59 #include <WebCore/AccessibilityObjectInterface.h> 60 60 #include <WebCore/ApplicationCacheStorage.h> 61 #include <WebCore/FocusController.h> 61 62 #include <WebCore/Frame.h> 62 63 #include <WebCore/Page.h> … … 270 271 return 0; 271 272 273 auto* focusedDocument = page->focusController().focusedOrMainFrame().document(); 274 if (!focusedDocument) 275 return 0; 276 272 277 WebCore::AXObjectCache::enableAccessibility(); 273 278 274 WebCore::AXCoreObject* focusedObject = WebCore::AXObjectCache::focusedUIElementForPage(page); 279 auto* axObjectCache = focusedDocument->axObjectCache(); 280 if (!axObjectCache) 281 return 0; 282 283 auto* focusedObject = axObjectCache->focusedUIElementForPage(page); 275 284 if (!focusedObject) 276 285 return 0; -
trunk/Tools/ChangeLog
r253082 r253088 1 2019-12-03 Andres Gonzalez <andresg_22@apple.com> 2 3 Focus tracking support in the accessibility isolatedtree. 4 https://bugs.webkit.org/show_bug.cgi?id=204535 5 6 Reviewed by Chris Fleizach. 7 8 FocusElement can run on the secondary AXThread. 9 10 * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp: 11 (WTR::AccessibilityController::focusedElement): 12 1 13 2019-12-03 John Wilander <wilander@apple.com> 2 14 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp
r252832 r253088 100 100 { 101 101 WKBundlePageRef page = InjectedBundle::singleton().page()->page(); 102 void* root = WKAccessibilityFocusedObject(page); 103 104 return AccessibilityUIElement::create(static_cast<PlatformUIElement>(root)); 102 PlatformUIElement focusedElement = static_cast<PlatformUIElement>(WKAccessibilityFocusedObject(page)); 103 return AccessibilityUIElement::create(focusedElement); 105 104 } 106 105
Note: See TracChangeset
for help on using the changeset viewer.