Chromium Code Reviews| Index: third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp b/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
| index d02caab647e4d0828ea334aeefb030334eee7e14..3fe2bada8a5485df541ff57a6a2ffb44b3ca7975 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
| @@ -149,24 +149,38 @@ AXObject* AXObjectCacheImpl::focusedImageMapUIElement(HTMLAreaElement* areaEleme |
| return 0; |
| } |
| -AXObject* AXObjectCacheImpl::focusedUIElementForPage(const Page* page) |
| +AXObject* AXObjectCacheImpl::focusedObject() |
| { |
| - if (!page->settings().accessibilityEnabled()) |
| + if (!accessibilityEnabled()) |
| return 0; |
| - // Cross-process accessibility is not yet implemented. |
| + // We don't have to return anything if the focused frame is not local; |
| + // the remote frame will have its own AXObjectCacheImpl and the focused |
| + // object will be sorted out by the browser process. |
| + Page* page = m_document->page(); |
| if (!page->focusController().focusedOrMainFrame()->isLocalFrame()) |
|
dcheng
2016/02/13 02:29:31
Why focusedOrMainFrame()? Is it because we have to
dmazzoni
2016/02/16 18:54:54
Ah, looks like we can just call focusedFrame() - t
|
| return 0; |
| - // get the focused node in the page |
| + // Get the focused node in the page. |
| Document* focusedDocument = toLocalFrame(page->focusController().focusedOrMainFrame())->document(); |
| Node* focusedNode = focusedDocument->focusedElement(); |
| if (!focusedNode) |
| focusedNode = focusedDocument; |
| - if (isHTMLAreaElement(*focusedNode)) |
| + // If it's an image map, get the focused link within the image map. |
| + if (isHTMLAreaElement(focusedNode)) |
| return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); |
| + // See if there's a page popup, for example a calendar picker. |
| + Element* adjustedFocusedElement = focusedDocument->adjustedFocusedElement(); |
| + if (isHTMLInputElement(adjustedFocusedElement)) { |
| + if (AXObject* axPopup = toHTMLInputElement(adjustedFocusedElement)->popupRootAXObject()) { |
| + if (Element* focusedElementInPopup = axPopup->document()->focusedElement()) |
| + focusedNode = focusedElementInPopup; |
| + } |
| + |
| + } |
| + |
| AXObject* obj = getOrCreate(focusedNode); |
| if (!obj) |
| return 0; |
| @@ -1120,7 +1134,7 @@ void AXObjectCacheImpl::handleFocusedUIElementChanged(Node* oldFocusedNode, Node |
| if (!page) |
| return; |
| - AXObject* focusedObject = focusedUIElementForPage(page); |
| + AXObject* focusedObject = this->focusedObject(); |
| if (!focusedObject) |
| return; |