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

Unified Diff: Source/core/dom/AXObjectCache.cpp

Issue 742353004: Implement computedRole and computedName (behind a flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: dmazzoni review comments Created 6 years 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
Index: Source/core/dom/AXObjectCache.cpp
diff --git a/Source/core/dom/AXObjectCache.cpp b/Source/core/dom/AXObjectCache.cpp
index d9e64928a742bd192e0877b4ca151e9e930461d7..484efe7dc3a3296665dbef88d5ff91d28178e10e 100644
--- a/Source/core/dom/AXObjectCache.cpp
+++ b/Source/core/dom/AXObjectCache.cpp
@@ -40,4 +40,35 @@ 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;
+ }
+}
+
+ScopedAXObjectCache::~ScopedAXObjectCache()
+{
+ if (m_isScoped)
+ delete m_cache;
+}
+
+AXObjectCache* ScopedAXObjectCache::get()
+{
+ if (!m_cache && m_isScoped)
+ m_cache = AXObjectCache::create(m_document);
+ ASSERT(m_cache);
+ return m_cache;
+}
+
+AXObjectCache* ScopedAXObjectCache::operator->()
+{
+ return get();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698