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 ff87ae10000912a5afeaad8afb9333527002bdc0..7d19d09d7d096540643fdfeb2566d436464e6b05 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXObjectCacheImpl.cpp |
@@ -68,8 +68,6 @@ |
#include "modules/accessibility/AXMenuListPopup.h" |
#include "modules/accessibility/AXProgressIndicator.h" |
#include "modules/accessibility/AXSVGRoot.h" |
-#include "modules/accessibility/AXScrollView.h" |
-#include "modules/accessibility/AXScrollbar.h" |
#include "modules/accessibility/AXSlider.h" |
#include "modules/accessibility/AXSpinButton.h" |
#include "modules/accessibility/AXTable.h" |
@@ -153,53 +151,6 @@ AXObject* AXObjectCacheImpl::focusedImageMapUIElement(HTMLAreaElement* areaEleme |
return 0; |
} |
-AXObject* AXObjectCacheImpl::focusedUIElementForPage(const Page* page) |
-{ |
- if (!page->settings().accessibilityEnabled()) |
- return 0; |
- |
- // Cross-process accessibility is not yet implemented. |
- if (!page->focusController().focusedOrMainFrame()->isLocalFrame()) |
- return 0; |
- |
- // 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)) |
- return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); |
- |
- AXObject* obj = getOrCreate(focusedNode); |
- if (!obj) |
- return 0; |
- |
- if (obj->shouldFocusActiveDescendant()) { |
- if (AXObject* descendant = obj->activeDescendant()) |
- obj = descendant; |
- } |
- |
- // the HTML element, for example, is focusable but has an AX object that is ignored |
- if (obj->accessibilityIsIgnored()) |
- obj = obj->parentObjectUnignored(); |
- |
- return obj; |
-} |
- |
-AXObject* AXObjectCacheImpl::get(Widget* widget) |
-{ |
- if (!widget) |
- return 0; |
- |
- AXID axID = m_widgetObjectMapping.get(widget); |
- ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); |
- if (!axID) |
- return 0; |
- |
- return m_objects.get(axID); |
-} |
- |
AXObject* AXObjectCacheImpl::get(LayoutObject* layoutObject) |
{ |
if (!layoutObject) |
@@ -346,44 +297,6 @@ AXObject* AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTextBox* inli |
return AXInlineTextBox::create(inlineTextBox, *this); |
} |
-AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) |
-{ |
- if (!widget) |
- return 0; |
- |
- if (AXObject* obj = get(widget)) |
- return obj; |
- |
- AXObject* newObj = nullptr; |
- if (widget->isFrameView()) { |
- FrameView* frameView = toFrameView(widget); |
- |
- // Don't create an AXScrollView for a FrameView that isn't attached to a frame, |
- // for example if it's in the process of being disposed. |
- if (frameView->frame().view() != frameView || !frameView->layoutView()) |
- return 0; |
- |
- newObj = AXScrollView::create(toFrameView(widget), *this); |
- } else if (widget->isScrollbar()) { |
- newObj = AXScrollbar::create(toScrollbar(widget), *this); |
- } |
- |
- // Will crash later if we have two objects for the same widget. |
- ASSERT(!get(widget)); |
- |
- // Catch the case if an (unsupported) widget type is used. Only FrameView and ScrollBar are supported now. |
- ASSERT(newObj); |
- if (!newObj) |
- return 0; |
- |
- getAXID(newObj); |
- |
- m_widgetObjectMapping.set(widget, newObj->axObjectID()); |
- m_objects.set(newObj->axObjectID(), newObj); |
- newObj->init(); |
- return newObj; |
-} |
- |
AXObject* AXObjectCacheImpl::getOrCreate(Node* node) |
{ |
if (!node) |
@@ -401,6 +314,15 @@ AXObject* AXObjectCacheImpl::getOrCreate(Node* node) |
if (isHTMLHeadElement(node)) |
return 0; |
+ if (!node->document().frame()) |
+ return 0; |
+ |
+ if (node->document().frame()->pagePopupOwner() && &node->document().frame()->pagePopupOwner()->document() != m_document) |
+ return 0; |
+ |
+ if (&node->document() != m_document) |
+ return 0; |
+ |
AXObject* newObj = createFromNode(node); |
// Will crash later if we have two objects for the same node. |
@@ -424,6 +346,9 @@ AXObject* AXObjectCacheImpl::getOrCreate(LayoutObject* layoutObject) |
if (!layoutObject) |
return 0; |
+ if (&layoutObject->document() != m_document) |
+ return 0; |
+ |
if (AXObject* obj = get(layoutObject)) |
return obj; |
@@ -470,7 +395,7 @@ AXObject* AXObjectCacheImpl::rootObject() |
if (!accessibilityEnabled()) |
return 0; |
- return getOrCreate(m_document->view()); |
+ return getOrCreate(m_document); |
} |
AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role) |
@@ -560,16 +485,6 @@ void AXObjectCacheImpl::remove(Node* node) |
} |
} |
-void AXObjectCacheImpl::remove(Widget* view) |
-{ |
- if (!view) |
- return; |
- |
- AXID axID = m_widgetObjectMapping.get(view); |
- remove(axID); |
- m_widgetObjectMapping.remove(view); |
-} |
- |
void AXObjectCacheImpl::remove(AbstractInlineTextBox* inlineTextBox) |
{ |
if (!inlineTextBox) |
@@ -966,18 +881,6 @@ void AXObjectCacheImpl::listboxActiveIndexChanged(HTMLSelectElement* select) |
toAXListBox(obj)->activeIndexChanged(); |
} |
-void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) |
-{ |
- if (!view) |
- return; |
- |
- // We don't want to create a scroll view from this method, only update an existing one. |
- if (AXObject* scrollViewObject = get(view)) { |
- m_modificationCount++; |
- scrollViewObject->updateChildrenIfNecessary(); |
- } |
-} |
- |
void AXObjectCacheImpl::handleLayoutComplete(LayoutObject* layoutObject) |
{ |
if (!layoutObject) |
@@ -1165,17 +1068,6 @@ bool isNodeAriaVisible(Node* node) |
void AXObjectCacheImpl::postPlatformNotification(AXObject* obj, AXNotification notification) |
{ |
- if (obj && obj->isAXScrollbar() && notification == AXValueChanged) { |
- // Send document value changed on scrollbar value changed notification. |
- Scrollbar* scrollBar = toAXScrollbar(obj)->scrollbar(); |
- if (!scrollBar || !scrollBar->parent() || !scrollBar->parent()->isFrameView()) |
- return; |
- Document* document = toFrameView(scrollBar->parent())->frame().document(); |
- if (document != document->topDocument()) |
- return; |
- obj = get(document->layoutView()); |
- } |
- |
if (!obj || !obj->document() || !obj->documentFrameView() || !obj->documentFrameView()->frame().page()) |
return; |
@@ -1195,17 +1087,25 @@ void AXObjectCacheImpl::postPlatformNotification(AXObject* obj, AXNotification n |
void AXObjectCacheImpl::handleFocusedUIElementChanged(Node*, Node* newFocusedNode) |
{ |
if (!newFocusedNode) |
- return; |
+ newFocusedNode = m_document.get(); |
- Page* page = newFocusedNode->document().page(); |
- if (!page) |
- return; |
+ AXObject* obj = getOrCreate(newFocusedNode); |
+ |
+ if (isHTMLAreaElement(newFocusedNode)) |
+ obj = focusedImageMapUIElement(toHTMLAreaElement(newFocusedNode)); |
- AXObject* focusedObject = focusedUIElementForPage(page); |
- if (!focusedObject) |
+ if (!obj) |
return; |
- postPlatformNotification(focusedObject, AXFocusedUIElementChanged); |
+ if (obj->shouldFocusActiveDescendant()) { |
+ if (AXObject* descendant = obj->activeDescendant()) |
+ obj = descendant; |
+ } |
+ |
+ if (obj->accessibilityIsIgnored()) |
+ obj = obj->parentObjectUnignored(); |
+ |
+ postPlatformNotification(obj, AXFocusedUIElementChanged); |
} |
void AXObjectCacheImpl::handleInitialFocus() |
@@ -1277,10 +1177,8 @@ void AXObjectCacheImpl::handleScrolledToAnchor(const Node* anchorNode) |
void AXObjectCacheImpl::handleScrollPositionChanged(FrameView* frameView) |
{ |
- // Prefer to fire the scroll position changed event on the frame view's child web area, if possible. |
- AXObject* targetAXObject = getOrCreate(frameView); |
- if (targetAXObject && !targetAXObject->children().isEmpty()) |
- targetAXObject = targetAXObject->children()[0].get(); |
+ Document* doc = frameView->frame().document(); |
+ AXObject* targetAXObject = getOrCreate(doc); |
postPlatformNotification(targetAXObject, AXScrollPositionChanged); |
} |
@@ -1346,7 +1244,6 @@ DEFINE_TRACE(AXObjectCacheImpl) |
{ |
#if ENABLE(OILPAN) |
visitor->trace(m_document); |
- visitor->trace(m_widgetObjectMapping); |
visitor->trace(m_nodeObjectMapping); |
#endif |