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

Unified Diff: Source/modules/accessibility/AXObject.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/AXObject.h ('k') | Source/modules/accessibility/AXObjectCacheImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/accessibility/AXObject.cpp
diff --git a/Source/modules/accessibility/AXObject.cpp b/Source/modules/accessibility/AXObject.cpp
index c040275ff613fc27cc5f6ddc738e157a39ce2be0..d32949862ce207240aef7bef12bfb99dedfe2c43 100644
--- a/Source/modules/accessibility/AXObject.cpp
+++ b/Source/modules/accessibility/AXObject.cpp
@@ -370,12 +370,11 @@ HTMLDialogElement* getActiveDialogElement(Node* node)
} // namespace
-AXObject::AXObject(AXObjectCacheImpl* axObjectCache)
+AXObject::AXObject(AXObjectCacheImpl& axObjectCache)
: m_id(0)
, m_haveChildren(false)
, m_role(UnknownRole)
, m_lastKnownIsIgnoredValue(DefaultBehavior)
- , m_detached(false)
, m_parent(0)
, m_lastModificationCount(-1)
, m_cachedIsIgnored(false)
@@ -385,7 +384,7 @@ AXObject::AXObject(AXObjectCacheImpl* axObjectCache)
, m_cachedHasInheritedPresentationalRole(false)
, m_cachedIsPresentationalChild(false)
, m_cachedLiveRegionRoot(0)
- , m_axObjectCache(axObjectCache)
+ , m_axObjectCache(&axObjectCache)
{
}
@@ -400,12 +399,12 @@ void AXObject::detach()
// no children are left with dangling pointers to their parent.
clearChildren();
- m_detached = true;
+ m_axObjectCache = nullptr;
}
bool AXObject::isDetached() const
{
- return m_detached;
+ return !m_axObjectCache;
}
bool AXObject::isARIATextControl() const
@@ -495,14 +494,15 @@ bool AXObject::accessibilityIsIgnored() const
void AXObject::updateCachedAttributeValuesIfNeeded() const
{
- AXObjectCacheImpl* cache = axObjectCache();
- if (!cache)
+ if (isDetached())
return;
- if (cache->modificationCount() == m_lastModificationCount)
+ AXObjectCacheImpl& cache = axObjectCache();
+
+ if (cache.modificationCount() == m_lastModificationCount)
return;
- m_lastModificationCount = cache->modificationCount();
+ m_lastModificationCount = cache.modificationCount();
m_cachedIsInertOrAriaHidden = computeIsInertOrAriaHidden();
m_cachedIsDescendantOfLeafNode = (leafNodeAncestor() != 0);
m_cachedIsDescendantOfDisabledNode = (disabledAncestor() != 0);
@@ -559,7 +559,7 @@ bool AXObject::computeIsInertOrAriaHidden(IgnoredReasons* ignoredReasons) const
if (ignoredReasons) {
HTMLDialogElement* dialog = getActiveDialogElement(node());
if (dialog) {
- AXObject* dialogObject = axObjectCache()->getOrCreate(dialog);
+ AXObject* dialogObject = axObjectCache().getOrCreate(dialog);
if (dialogObject)
ignoredReasons->append(IgnoredReason(AXActiveModalDialog, dialogObject));
else
@@ -898,7 +898,7 @@ AXObject* AXObject::elementAccessibilityHitTest(const IntPoint& point) const
Widget* widget = widgetForAttachmentView();
// Normalize the point for the widget's bounds.
if (widget && widget->isFrameView())
- return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(IntPoint(point - widget->frameRect().location()));
+ return axObjectCache().getOrCreate(widget)->accessibilityHitTest(IntPoint(point - widget->frameRect().location()));
}
// Check if there are any mock elements that need to be handled.
@@ -919,21 +919,21 @@ const AXObject::AccessibilityChildrenVector& AXObject::children()
AXObject* AXObject::parentObject() const
{
- if (m_detached)
+ if (isDetached())
return 0;
if (m_parent)
return m_parent;
- if (axObjectCache()->isAriaOwned(this))
- return axObjectCache()->getAriaOwnedParent(this);
+ if (axObjectCache().isAriaOwned(this))
+ return axObjectCache().getAriaOwnedParent(this);
return computeParent();
}
AXObject* AXObject::parentObjectIfExists() const
{
- if (m_detached)
+ if (isDetached())
return 0;
if (m_parent)
@@ -977,7 +977,7 @@ AXObject* AXObject::focusedUIElement() const
if (!page)
return 0;
- return axObjectCache()->focusedUIElementForPage(page);
+ return axObjectCache().focusedUIElementForPage(page);
}
Document* AXObject::document() const
@@ -1316,7 +1316,7 @@ void AXObject::notifyIfIgnoredValueChanged()
{
bool isIgnored = accessibilityIsIgnored();
if (lastKnownIsIgnoredValue() != isIgnored) {
- axObjectCache()->childrenChanged(parentObject());
+ axObjectCache().childrenChanged(parentObject());
setLastKnownIsIgnoredValue(isIgnored);
}
}
« no previous file with comments | « Source/modules/accessibility/AXObject.h ('k') | Source/modules/accessibility/AXObjectCacheImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698