Changeset 270154 in webkit
- Timestamp:
- Nov 21, 2020 3:03:28 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r270153 r270154 1 2020-11-21 Andres Gonzalez <andresg_22@apple.com> 2 3 AccessibilityObject::FocusedUIElement should not call AXObjectCache::focusedUIElementForPage that can return an isolated object. 4 https://bugs.webkit.org/show_bug.cgi?id=219238 5 6 Reviewed by Chris Fleizach. 7 8 Since AXObjectCache::focusedUIElementForPage can return an isolated 9 object, AccessibilityObject::focusedUIElement should not use it to 10 determine the focused object. This causes that isolated objects may be 11 accessed on the main thread when they shouldn't, and even infinite 12 recursion if this happens when the isolated tree is being built. 13 This patch changes AccessibilityObject::focusedUIElement to call 14 AXObjectCache::focusedObjectForPage that always returns another AccessibilityObject. 15 16 * accessibility/AXObjectCache.cpp: 17 (WebCore::AXObjectCache::focusedObjectForPage): 18 (WebCore::AXObjectCache::focusedUIElementForPage): 19 (WebCore::AXObjectCache::generateIsolatedTree): 20 (WebCore::AXObjectCache::focusedObject): Deleted. 21 * accessibility/AXObjectCache.h: 22 * accessibility/AccessibilityObject.cpp: 23 (WebCore::AccessibilityObject::focusedUIElement const): 24 1 25 2020-11-21 Zalan Bujtas <zalan@apple.com> 2 26 -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r269568 r270154 370 370 } 371 371 372 AXCoreObject* AXObjectCache::focusedObject(Document& document) 373 { 374 Element* focusedElement = document.focusedElement(); 372 AXCoreObject* AXObjectCache::focusedObjectForPage(const Page* page) 373 { 374 ASSERT(isMainThread()); 375 376 if (!gAccessibilityEnabled) 377 return nullptr; 378 379 // get the focused node in the page 380 Document* document = page->focusController().focusedOrMainFrame().document(); 381 if (!document) 382 return nullptr; 383 384 document->updateStyleIfNeeded(); 385 386 Element* focusedElement = document->focusedElement(); 375 387 if (is<HTMLAreaElement>(focusedElement)) 376 388 return focusedImageMapUIElement(downcast<HTMLAreaElement>(focusedElement)); 377 389 378 auto* axObjectCache = document .axObjectCache();390 auto* axObjectCache = document->axObjectCache(); 379 391 if (!axObjectCache) 380 392 return nullptr; 381 393 382 AXCoreObject* focus = axObjectCache->getOrCreate(focusedElement ? focusedElement : static_cast<Node*>( &document));394 AXCoreObject* focus = axObjectCache->getOrCreate(focusedElement ? focusedElement : static_cast<Node*>(document)); 383 395 if (!focus) 384 396 return nullptr; … … 422 434 AXCoreObject* AXObjectCache::focusedUIElementForPage(const Page* page) 423 435 { 424 ASSERT(isMainThread());425 if (!gAccessibilityEnabled)426 return nullptr;427 428 // get the focused node in the page429 Document* focusedDocument = page->focusController().focusedOrMainFrame().document();430 if (!focusedDocument)431 return nullptr;432 433 // Call this before isolated or non-isolated cases so the document is up to do.434 focusedDocument->updateStyleIfNeeded();435 436 436 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) 437 437 if (isIsolatedTreeEnabled()) … … 439 439 #endif 440 440 441 return focusedObject (*focusedDocument);441 return focusedObjectForPage(page); 442 442 } 443 443 … … 3180 3180 tree->generateSubtree(*axRoot, nullptr, true); 3181 3181 3182 auto* axFocus = axObjectCache->focusedObject (document);3182 auto* axFocus = axObjectCache->focusedObjectForPage(document.page()); 3183 3183 if (axFocus) 3184 3184 tree->setFocusedNodeID(axFocus->objectID()); -
trunk/Source/WebCore/accessibility/AXObjectCache.h
r268454 r270154 146 146 147 147 WEBCORE_EXPORT AXCoreObject* focusedUIElementForPage(const Page*); 148 static AXCoreObject* focusedObjectForPage(const Page*); 148 149 149 150 // Returns the root object for the entire document. … … 432 433 433 434 static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*); 434 static AXCoreObject* focusedObject(Document&);435 435 436 436 AXID getAXID(AccessibilityObject*); -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r269923 r270154 2545 2545 return document ? document->axObjectCache() : nullptr; 2546 2546 } 2547 2547 2548 2548 AXCoreObject* AccessibilityObject::focusedUIElement() const 2549 2549 { 2550 2550 auto* page = this->page(); 2551 2551 auto* axObjectCache = this->axObjectCache(); 2552 return page && axObjectCache ? axObjectCache->focused UIElementForPage(page) : nullptr;2552 return page && axObjectCache ? axObjectCache->focusedObjectForPage(page) : nullptr; 2553 2553 } 2554 2554
Note: See TracChangeset
for help on using the changeset viewer.