Index: Source/core/dom/AXObjectCache.cpp |
diff --git a/Source/core/dom/AXObjectCache.cpp b/Source/core/dom/AXObjectCache.cpp |
index d9e64928a742bd192e0877b4ca151e9e930461d7..d299dde9259e6751598ef12625b2671a86f84897 100644 |
--- a/Source/core/dom/AXObjectCache.cpp |
+++ b/Source/core/dom/AXObjectCache.cpp |
@@ -40,4 +40,43 @@ AXObjectCache::~AXObjectCache() |
{ |
} |
+ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
+ : m_document(document) |
+ , m_cache(0) |
+{ |
+ fprintf(stderr, "Constructing ScopedAXObjectCache\n"); |
+ if (AXObjectCache* existingCache = document.axObjectCache()) { |
+ m_cache = existingCache; |
+ m_isScoped = false; |
+ } else { |
+ m_isScoped = true; |
+ } |
+} |
+ |
+ScopedAXObjectCache::~ScopedAXObjectCache() |
+{ |
+ fprintf(stderr, "Destroying ScopedAXObjectCache\n"); |
+ if (m_isScoped) { |
+ fprintf(stderr, "Deleting m_cache\n"); |
+ delete m_cache; |
+ } |
+} |
+ |
+AXObjectCache* ScopedAXObjectCache::get() |
+{ |
+ fprintf(stderr, "ScopedAXObjectCache::get()\n"); |
+ if (!m_cache && m_isScoped) |
+ m_cache = AXObjectCache::create(m_document); |
+ fprintf(stderr, "about to ASSERT(%p)\n", m_cache); |
+ ASSERT(m_cache); |
+ fprintf(stderr, "ASSERT succeeded\n"); |
+ return m_cache; |
+} |
+ |
+AXObjectCache* ScopedAXObjectCache::operator->() |
+{ |
+ fprintf(stderr, "ScopedAXObjectCache::operator->()\n"); |
+ return get(); |
+} |
+ |
} // namespace blink |