Chromium Code Reviews| 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); |
|
adamk
2014/12/16 01:54:48
This looks like a pretty heavy operation; is this
aboxhall
2014/12/16 04:15:26
It's not as heavy as it might appear - this is ess
adamk
2014/12/16 18:25:14
It's "just" a constructor, but that constructor it
dmazzoni
2014/12/16 19:18:19
No, the problem is that computing the role or name
adamk
2014/12/16 19:25:24
Okay, looking at this from the other direction, wh
|
| + ASSERT(m_cache); |
| + return m_cache; |
| +} |
| + |
| +AXObjectCache* ScopedAXObjectCache::operator->() |
| +{ |
| + return get(); |
| +} |
| + |
| } // namespace blink |