Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1825)

Unified Diff: Source/modules/accessibility/AXLayoutObject.cpp

Issue 1175533004: Refactor: Clear m_axObjectCache when AXObject detaches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added ASSERT Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/accessibility/AXLayoutObject.h ('k') | Source/modules/accessibility/AXList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/accessibility/AXLayoutObject.cpp
diff --git a/Source/modules/accessibility/AXLayoutObject.cpp b/Source/modules/accessibility/AXLayoutObject.cpp
index 63b98a2f16d6dff009536f948c0fd6faf42f08b4..1d0564acb34df125560efc3e34a5c7654acad84e 100644
--- a/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/Source/modules/accessibility/AXLayoutObject.cpp
@@ -171,7 +171,7 @@ static LayoutBoxModelObject* nextContinuation(LayoutObject* layoutObject)
return 0;
}
-AXLayoutObject::AXLayoutObject(LayoutObject* layoutObject, AXObjectCacheImpl* axObjectCache)
+AXLayoutObject::AXLayoutObject(LayoutObject* layoutObject, AXObjectCacheImpl& axObjectCache)
: AXNodeObject(layoutObject->node(), axObjectCache)
, m_layoutObject(layoutObject)
, m_cachedElementRectDirty(true)
@@ -181,7 +181,7 @@ AXLayoutObject::AXLayoutObject(LayoutObject* layoutObject, AXObjectCacheImpl* ax
#endif
}
-PassRefPtr<AXLayoutObject> AXLayoutObject::create(LayoutObject* layoutObject, AXObjectCacheImpl* axObjectCache)
+PassRefPtr<AXLayoutObject> AXLayoutObject::create(LayoutObject* layoutObject, AXObjectCacheImpl& axObjectCache)
{
return adoptRef(new AXLayoutObject(layoutObject, axObjectCache));
}
@@ -571,7 +571,7 @@ bool AXLayoutObject::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReason
if (ignoredReasons) {
HTMLLabelElement* label = labelElementContainer();
if (label && !label->isSameNode(node())) {
- AXObject* labelAXObject = axObjectCache()->getOrCreate(label);
+ AXObject* labelAXObject = axObjectCache().getOrCreate(label);
ignoredReasons->append(IgnoredReason(AXLabelContainer, labelAXObject));
}
@@ -1028,7 +1028,7 @@ AXObject* AXLayoutObject::nextOnLine() const
AXObject* result = 0;
for (InlineBox* next = inlineBox->nextOnLine(); next; next = next->nextOnLine()) {
LayoutObject* layoutObject = &next->layoutObject();
- result = axObjectCache()->getOrCreate(layoutObject);
+ result = axObjectCache().getOrCreate(layoutObject);
if (result)
break;
}
@@ -1057,7 +1057,7 @@ AXObject* AXLayoutObject::previousOnLine() const
AXObject* result = 0;
for (InlineBox* prev = inlineBox->prevOnLine(); prev; prev = prev->prevOnLine()) {
LayoutObject* layoutObject = &prev->layoutObject();
- result = axObjectCache()->getOrCreate(layoutObject);
+ result = axObjectCache().getOrCreate(layoutObject);
if (result)
break;
}
@@ -1187,7 +1187,7 @@ AXObject* AXLayoutObject::activeDescendant() const
if (!target)
return 0;
- AXObject* obj = axObjectCache()->getOrCreate(target);
+ 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())
@@ -1425,7 +1425,7 @@ String AXLayoutObject::deprecatedHelpText() const
// Only take help text from an ancestor element if its a group or an unknown role. If help was
// added to those kinds of elements, it is likely it was meant for a child element.
- AXObject* axObj = axObjectCache()->getOrCreate(curr);
+ AXObject* axObj = axObjectCache().getOrCreate(curr);
if (axObj) {
AccessibilityRole role = axObj->roleValue();
if (role != GroupRole && role != UnknownRole)
@@ -1548,7 +1548,7 @@ AXObject* AXLayoutObject::accessibilityHitTest(const IntPoint& point) const
if (!obj)
return 0;
- AXObject* result = axObjectCache()->getOrCreate(obj);
+ AXObject* result = axObjectCache().getOrCreate(obj);
result->updateChildrenIfNecessary();
// Allow the element to perform any hit-testing it might need to do to reach non-layout children.
@@ -1586,7 +1586,7 @@ AXObject* AXLayoutObject::computeParent() const
return 0;
if (ariaRoleAttribute() == MenuBarRole)
- return axObjectCache()->getOrCreate(m_layoutObject->parent());
+ return axObjectCache().getOrCreate(m_layoutObject->parent());
// menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child
if (ariaRoleAttribute() == MenuRole) {
@@ -1597,11 +1597,11 @@ AXObject* AXLayoutObject::computeParent() const
LayoutObject* parentObj = layoutParentObject();
if (parentObj)
- return axObjectCache()->getOrCreate(parentObj);
+ return axObjectCache().getOrCreate(parentObj);
// WebArea's parent should be the scroll view containing it.
if (isWebArea())
- return axObjectCache()->getOrCreate(m_layoutObject->frame()->view());
+ return axObjectCache().getOrCreate(m_layoutObject->frame()->view());
return 0;
}
@@ -1612,7 +1612,7 @@ AXObject* AXLayoutObject::computeParentIfExists() const
return 0;
if (ariaRoleAttribute() == MenuBarRole)
- return axObjectCache()->get(m_layoutObject->parent());
+ return axObjectCache().get(m_layoutObject->parent());
// menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child
if (ariaRoleAttribute() == MenuRole) {
@@ -1623,11 +1623,11 @@ AXObject* AXLayoutObject::computeParentIfExists() const
LayoutObject* parentObj = layoutParentObject();
if (parentObj)
- return axObjectCache()->get(parentObj);
+ return axObjectCache().get(parentObj);
// WebArea's parent should be the scroll view containing it.
if (isWebArea())
- return axObjectCache()->get(m_layoutObject->frame()->view());
+ return axObjectCache().get(m_layoutObject->frame()->view());
return 0;
}
@@ -1646,7 +1646,7 @@ AXObject* AXLayoutObject::firstChild() const
if (!firstChild)
return 0;
- return axObjectCache()->getOrCreate(firstChild);
+ return axObjectCache().getOrCreate(firstChild);
}
AXObject* AXLayoutObject::nextSibling() const
@@ -1690,7 +1690,7 @@ AXObject* AXLayoutObject::nextSibling() const
if (!nextSibling)
return 0;
- return axObjectCache()->getOrCreate(nextSibling);
+ return axObjectCache().getOrCreate(nextSibling);
}
void AXLayoutObject::addChildren()
@@ -1708,7 +1708,7 @@ void AXLayoutObject::addChildren()
computeAriaOwnsChildren(ownedChildren);
for (RefPtr<AXObject> obj = firstChild(); obj; obj = obj->nextSibling()) {
- if (!axObjectCache()->isAriaOwned(obj.get()))
+ if (!axObjectCache().isAriaOwned(obj.get()))
addChild(obj.get());
}
@@ -1799,7 +1799,7 @@ Element* AXLayoutObject::anchorElement() const
if (!m_layoutObject)
return 0;
- AXObjectCacheImpl* cache = axObjectCache();
+ AXObjectCacheImpl& cache = axObjectCache();
LayoutObject* currLayoutObject;
// Search up the layout tree for a LayoutObject with a DOM node. Defer to an earlier continuation, though.
@@ -1807,7 +1807,7 @@ Element* AXLayoutObject::anchorElement() const
if (currLayoutObject->isAnonymousBlock()) {
LayoutObject* continuation = toLayoutBlock(currLayoutObject)->continuation();
if (continuation)
- return cache->getOrCreate(continuation)->anchorElement();
+ return cache.getOrCreate(continuation)->anchorElement();
}
}
@@ -1819,7 +1819,7 @@ Element* AXLayoutObject::anchorElement() const
// NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElement
Node* node = currLayoutObject->node();
for ( ; node; node = node->parentNode()) {
- if (isHTMLAnchorElement(*node) || (node->layoutObject() && cache->getOrCreate(node->layoutObject())->isAnchor()))
+ if (isHTMLAnchorElement(*node) || (node->layoutObject() && cache.getOrCreate(node->layoutObject())->isAnchor()))
return toElement(node);
}
@@ -1934,7 +1934,7 @@ void AXLayoutObject::handleAriaExpandedChanged()
// Post that the row count changed.
if (containerParent)
- axObjectCache()->postNotification(containerParent, AXObjectCacheImpl::AXRowCountChanged);
+ axObjectCache().postNotification(containerParent, AXObjectCacheImpl::AXRowCountChanged);
// Post that the specific row either collapsed or expanded.
AccessibilityExpanded expanded = isExpanded();
@@ -1946,7 +1946,7 @@ void AXLayoutObject::handleAriaExpandedChanged()
if (expanded == ExpandedCollapsed)
notification = AXObjectCacheImpl::AXRowCollapsed;
- axObjectCache()->postNotification(this, notification);
+ axObjectCache().postNotification(this, notification);
}
}
@@ -2053,7 +2053,7 @@ void AXLayoutObject::addInlineTextBoxChildren(bool force)
LayoutText* layoutText = toLayoutText(layoutObject());
for (RefPtr<AbstractInlineTextBox> box = layoutText->firstAbstractInlineTextBox(); box.get(); box = box->nextInlineTextBox()) {
- AXObject* axObject = axObjectCache()->getOrCreate(box.get());
+ AXObject* axObject = axObjectCache().getOrCreate(box.get());
if (!axObject->accessibilityIsIgnored())
m_children.append(axObject);
}
@@ -2138,7 +2138,7 @@ bool AXLayoutObject::nodeIsTextControl(const Node* node) const
if (!node)
return false;
- const AXObject* axObjectForNode = axObjectCache()->getOrCreate(const_cast<Node*>(node));
+ const AXObject* axObjectForNode = axObjectCache().getOrCreate(const_cast<Node*>(node));
if (!axObjectForNode)
return false;
@@ -2165,7 +2165,7 @@ bool AXLayoutObject::isTabItemSelected() const
elementsFromAttribute(elements, aria_controlsAttr);
for (const auto& element : elements) {
- AXObject* tabPanel = axObjectCache()->getOrCreate(element);
+ AXObject* tabPanel = axObjectCache().getOrCreate(element);
// A tab item should only control tab panels.
if (!tabPanel || tabPanel->roleValue() != TabPanelRole)
@@ -2188,7 +2188,7 @@ AXObject* AXLayoutObject::accessibilityImageMapHitTest(HTMLAreaElement* area, co
if (!area)
return 0;
- AXObject* parent = axObjectCache()->getOrCreate(area->imageElement());
+ AXObject* parent = axObjectCache().getOrCreate(area->imageElement());
if (!parent)
return 0;
@@ -2310,7 +2310,7 @@ void AXLayoutObject::addHiddenChildren()
for (Node& child : NodeTraversal::childrenOf(*node)) {
if (child.layoutObject()) {
// Find out where the last layout sibling is located within m_children.
- if (AXObject* childObject = axObjectCache()->get(child.layoutObject())) {
+ if (AXObject* childObject = axObjectCache().get(child.layoutObject())) {
if (childObject->accessibilityIsIgnored()) {
const auto& children = childObject->children();
childObject = children.size() ? children.last().get() : 0;
@@ -2328,7 +2328,7 @@ void AXLayoutObject::addHiddenChildren()
if (insertionIndex > previousSize)
insertionIndex = previousSize;
- insertChild(axObjectCache()->getOrCreate(&child), insertionIndex);
+ insertChild(axObjectCache().getOrCreate(&child), insertionIndex);
insertionIndex += (m_children.size() - previousSize);
}
}
@@ -2344,7 +2344,7 @@ void AXLayoutObject::addTextFieldChildren()
if (!spinButtonElement || !spinButtonElement->isSpinButtonElement())
return;
- AXSpinButton* axSpinButton = toAXSpinButton(axObjectCache()->getOrCreate(SpinButtonRole));
+ AXSpinButton* axSpinButton = toAXSpinButton(axObjectCache().getOrCreate(SpinButtonRole));
axSpinButton->setSpinButtonElement(toSpinButtonElement(spinButtonElement));
axSpinButton->setParent(this);
m_children.append(axSpinButton);
@@ -2363,14 +2363,14 @@ void AXLayoutObject::addImageMapChildren()
for (HTMLAreaElement& area : Traversal<HTMLAreaElement>::descendantsOf(*map)) {
// add an <area> element for this child if it has a link
if (area.isLink()) {
- AXImageMapLink* areaObject = toAXImageMapLink(axObjectCache()->getOrCreate(ImageMapLinkRole));
+ AXImageMapLink* areaObject = toAXImageMapLink(axObjectCache().getOrCreate(ImageMapLinkRole));
areaObject->setHTMLAreaElement(&area);
areaObject->setHTMLMapElement(map);
areaObject->setParent(this);
if (!areaObject->accessibilityIsIgnored())
m_children.append(areaObject);
else
- axObjectCache()->remove(areaObject->axObjectID());
+ axObjectCache().remove(areaObject->axObjectID());
}
}
}
@@ -2397,7 +2397,7 @@ void AXLayoutObject::addAttachmentChildren()
if (!widget || !widget->isFrameView())
return;
- AXObject* axWidget = axObjectCache()->getOrCreate(widget);
+ AXObject* axWidget = axObjectCache().getOrCreate(widget);
if (!axWidget->accessibilityIsIgnored())
m_children.append(axWidget);
}
@@ -2493,7 +2493,7 @@ LayoutRect AXLayoutObject::computeElementRect() const
offsetBoundingBoxForRemoteSVGElement(result);
if (document && document->frame() && document->frame()->pagePopupOwner()) {
IntPoint popupOrigin = document->view()->contentsToScreen(IntRect()).location();
- IntPoint mainOrigin = axObjectCache()->rootObject()->documentFrameView()->contentsToScreen(IntRect()).location();
+ IntPoint mainOrigin = axObjectCache().rootObject()->documentFrameView()->contentsToScreen(IntRect()).location();
result.moveBy(IntPoint(popupOrigin - mainOrigin));
}
@@ -2505,7 +2505,7 @@ LayoutRect AXLayoutObject::computeElementRect() const
if (isCheckboxOrRadio()) {
HTMLLabelElement* label = labelForElement(toElement(m_layoutObject->node()));
if (label && label->layoutObject()) {
- LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementRect();
+ LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRect();
result.unite(labelRect);
}
}
« no previous file with comments | « Source/modules/accessibility/AXLayoutObject.h ('k') | Source/modules/accessibility/AXList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698