Index: Source/core/dom/AXObjectCache.cpp |
diff --git a/Source/core/dom/AXObjectCache.cpp b/Source/core/dom/AXObjectCache.cpp |
index d9e64928a742bd192e0877b4ca151e9e930461d7..0411f271c29eea21aac8d5fae938b277b34a0930 100644 |
--- a/Source/core/dom/AXObjectCache.cpp |
+++ b/Source/core/dom/AXObjectCache.cpp |
@@ -40,4 +40,34 @@ AXObjectCache::~AXObjectCache() |
{ |
} |
+ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
+ : m_document(document) |
+ , m_cache(0) |
+{ |
+ if (AXObjectCache* existingCache = document.axObjectCache()) { |
+ m_cache = existingCache; |
+ m_isScoped = false; |
+ } else { |
+ m_isScoped = true; |
+ m_cache = AXObjectCache::create(m_document); |
+ } |
+} |
+ |
+ScopedAXObjectCache::~ScopedAXObjectCache() |
+{ |
+ if (m_isScoped) |
+ delete m_cache; |
+} |
+ |
+AXObjectCache* ScopedAXObjectCache::get() |
+{ |
+ ASSERT(m_cache); |
+ return m_cache; |
+} |
+ |
+AXObjectCache* ScopedAXObjectCache::operator->() |
+{ |
+ return get(); |
+} |
+ |
} // namespace blink |