Chromium Code Reviews| Index: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| index 342874f1e40051063de30fc6d7e0ecffa909c1ae..389c8da7e6d8f9664960e8b5f6fe23c5c708c9bd 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| @@ -225,16 +225,6 @@ LayoutBoxModelObject* AXLayoutObject::getLayoutBoxModelObject() const |
| return toLayoutBoxModelObject(m_layoutObject); |
| } |
| -bool AXLayoutObject::shouldNotifyActiveDescendant() const |
| -{ |
| - // We want to notify that the combo box has changed its active descendant, |
| - // but we do not want to change the focus, because focus should remain with the combo box. |
| - if (isComboBox()) |
| - return true; |
| - |
| - return shouldFocusActiveDescendant(); |
| -} |
| - |
| ScrollableArea* AXLayoutObject::getScrollableAreaIfScrollable() const |
| { |
| if (isWebArea()) |
| @@ -458,18 +448,20 @@ bool AXLayoutObject::isVisited() const |
| bool AXLayoutObject::isFocused() const |
|
dmazzoni
2016/03/31 05:48:30
We don't actually call isFocused from outside of B
|
| { |
| - if (!m_layoutObject) |
| + if (!getDocument()) |
| return false; |
| - Document& document = m_layoutObject->document(); |
| - Element* focusedElement = document.focusedElement(); |
| + Element* focusedElement = getDocument()->focusedElement(); |
| if (!focusedElement) |
| return false; |
| + AXObject* focusedObject = axObjectCache().getOrCreate(focusedElement); |
| + if (!focusedObject || !focusedObject->isAXLayoutObject()) |
| + return false; |
| // A web area is represented by the Document node in the DOM tree, which isn't focusable. |
| // Check instead if the frame's selection controller is focused |
| - if (focusedElement == m_layoutObject->node() |
| - || (roleValue() == WebAreaRole && document.frame()->selection().isFocusedAndActive())) |
| + if (focusedObject == this || focusedObject->activeDescendant() == this |
| + || (roleValue() == WebAreaRole && getDocument()->frame()->selection().isFocusedAndActive())) |
| return true; |
| return false; |
| @@ -477,17 +469,16 @@ bool AXLayoutObject::isFocused() const |
| bool AXLayoutObject::isSelected() const |
| { |
| - if (!m_layoutObject) |
| - return false; |
| - |
| - Node* node = m_layoutObject->node(); |
| - if (!node) |
| + if (!getLayoutObject() || !getNode()) |
| return false; |
| const AtomicString& ariaSelected = getAttribute(aria_selectedAttr); |
| if (equalIgnoringCase(ariaSelected, "true")) |
| return true; |
| + if (ariaRoleAttribute() == ListBoxOptionRole && isFocused()) |
| + return true; |
| + |
| if (isTabItem() && isTabItemSelected()) |
| return true; |
| @@ -1162,31 +1153,30 @@ String AXLayoutObject::textAlternative(bool recursive, bool inAriaLabelledByTrav |
| AXObject* AXLayoutObject::activeDescendant() const |
| { |
| - if (!m_layoutObject) |
| - return 0; |
| + if (!getLayoutObject() || !getNode()) |
|
dmazzoni
2016/03/31 05:48:30
Hmmm, is there a reason we need a layoutObject? Ma
|
| + return nullptr; |
| - if (m_layoutObject->node() && !m_layoutObject->node()->isElementNode()) |
| - return 0; |
| + if (!getNode()->isElementNode()) |
| + return nullptr; |
| - Element* element = toElement(m_layoutObject->node()); |
| + Element* element = toElement(getNode()); |
| if (!element) |
| - return 0; |
| + return nullptr; |
| - const AtomicString& activeDescendantAttrStr = element->getAttribute(aria_activedescendantAttr); |
| - if (activeDescendantAttrStr.isNull() || activeDescendantAttrStr.isEmpty()) |
| - return 0; |
| + const AtomicString& activeDescendantAttr = getAttribute(aria_activedescendantAttr); |
| + if (activeDescendantAttr.isNull() || activeDescendantAttr.isEmpty()) |
| + return nullptr; |
| - Element* target = element->treeScope().getElementById(activeDescendantAttrStr); |
| + Element* target = element->treeScope().getElementById(activeDescendantAttr); |
| if (!target) |
| - return 0; |
| + return nullptr; |
| AXObject* obj = axObjectCache().getOrCreate(target); |
| - |
| // An activedescendant is only useful if it has a layoutObject, because that's what's needed to post the notification. |
| if (obj && obj->isAXLayoutObject()) |
| return obj; |
| - return 0; |
| + return nullptr; |
| } |
| void AXLayoutObject::ariaFlowToElements(AXObjectVector& flowTo) const |
| @@ -1254,30 +1244,6 @@ AXObject* AXLayoutObject::ancestorForWhichThisIsAPresentationalChild() const |
| return parent; |
| } |
| -bool AXLayoutObject::shouldFocusActiveDescendant() const |
| -{ |
| - switch (ariaRoleAttribute()) { |
| - case ComboBoxRole: |
| - case GridRole: |
| - case GroupRole: |
| - case ListBoxRole: |
| - case MenuRole: |
| - case MenuBarRole: |
| - case OutlineRole: |
| - case PopUpButtonRole: |
| - case ProgressIndicatorRole: |
| - case RadioGroupRole: |
| - case RowRole: |
| - case TabListRole: |
| - case ToolbarRole: |
| - case TreeRole: |
| - case TreeGridRole: |
| - return true; |
| - default: |
| - return false; |
| - } |
| -} |
| - |
| bool AXLayoutObject::supportsARIADragging() const |
| { |
| const AtomicString& grabbed = getAttribute(aria_grabbedAttr); |
| @@ -1705,14 +1671,14 @@ double AXLayoutObject::estimatedLoadingProgress() const |
| Node* AXLayoutObject::getNode() const |
| { |
| - return m_layoutObject ? m_layoutObject->node() : 0; |
| + return getLayoutObject() ? getLayoutObject()->node() : nullptr; |
| } |
| Document* AXLayoutObject::getDocument() const |
| { |
| - if (!m_layoutObject) |
| - return 0; |
| - return &m_layoutObject->document(); |
| + if (!getLayoutObject()) |
| + return nullptr; |
| + return &getLayoutObject()->document(); |
| } |
| FrameView* AXLayoutObject::documentFrameView() const |
| @@ -2010,16 +1976,15 @@ void AXLayoutObject::setValue(const String& string) |
| void AXLayoutObject::handleActiveDescendantChanged() |
| { |
| - Element* element = toElement(getLayoutObject()->node()); |
| + Element* element = toElement(getNode()); |
| if (!element) |
| return; |
| Document& doc = getLayoutObject()->document(); |
| if (!doc.frame()->selection().isFocusedAndActive() || doc.focusedElement() != element) |
| return; |
| - AXLayoutObject* activedescendant = toAXLayoutObject(activeDescendant()); |
| - if (activedescendant && shouldNotifyActiveDescendant()) |
| - toAXObjectCacheImpl(doc.axObjectCache())->postNotification(m_layoutObject, AXObjectCacheImpl::AXActiveDescendantChanged); |
| + if (supportsActiveDescendant()) |
| + toAXObjectCacheImpl(doc.axObjectCache())->postNotification(getLayoutObject(), AXObjectCacheImpl::AXActiveDescendantChanged); |
| } |
| void AXLayoutObject::handleAriaExpandedChanged() |
| @@ -2192,10 +2157,10 @@ AXObject* AXLayoutObject::treeAncestorDisallowingChild() const |
| bool AXLayoutObject::isTabItemSelected() const |
| { |
| - if (!isTabItem() || !m_layoutObject) |
| + if (!isTabItem() || !getLayoutObject()) |
| return false; |
| - Node* node = m_layoutObject->node(); |
| + Node* node = getNode(); |
| if (!node || !node->isElementNode()) |
| return false; |