Chromium Code Reviews| Index: Source/core/dom/AXObjectCache.cpp |
| diff --git a/Source/core/dom/AXObjectCache.cpp b/Source/core/dom/AXObjectCache.cpp |
| index 340616585a1efceb73bd691051ee2524ed4b56dc..3670a5ad71b109d0fea6b8b390563fab274be923 100644 |
| --- a/Source/core/dom/AXObjectCache.cpp |
| +++ b/Source/core/dom/AXObjectCache.cpp |
| @@ -40,7 +40,7 @@ void AXObjectCache::init(AXObjectCacheCreateFunction function) |
| m_createFunction = function; |
| } |
| -AXObjectCache* AXObjectCache::create(Document& document) |
| +PassOwnPtrWillBeRawPtr<AXObjectCache> AXObjectCache::create(Document& document) |
| { |
| ASSERT(m_createFunction); |
| return (m_createFunction)(document); |
| @@ -54,34 +54,31 @@ AXObjectCache::~AXObjectCache() |
| { |
| } |
| -ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
| - : m_document(document) |
| - , m_cache(0) |
| +PassOwnPtr<ScopedAXObjectCache> ScopedAXObjectCache::create(Document& document) |
| { |
| - if (AXObjectCache* existingCache = document.axObjectCache()) { |
| - m_cache = existingCache; |
| - m_isScoped = false; |
| - } else { |
| - m_isScoped = true; |
| - m_cache = AXObjectCache::create(m_document); |
| - } |
| + return adoptPtr(new ScopedAXObjectCache(document)); |
| } |
| -ScopedAXObjectCache::~ScopedAXObjectCache() |
| +ScopedAXObjectCache::ScopedAXObjectCache(Document& document) |
| + : m_document(&document) |
| { |
| - if (m_isScoped) |
| - delete m_cache; |
| + if (!m_document->axObjectCache()) |
| + m_cache = AXObjectCache::create(*m_document); |
|
haraken
2015/06/08 11:03:13
A slightly better way would be to create the cache
|
| } |
| -AXObjectCache* ScopedAXObjectCache::get() |
| +ScopedAXObjectCache::~ScopedAXObjectCache() |
| { |
| - ASSERT(m_cache); |
| - return m_cache; |
| + if (m_cache) |
| + m_cache->dispose(); |
| } |
| -AXObjectCache* ScopedAXObjectCache::operator->() |
| +AXObjectCache* ScopedAXObjectCache::get() |
| { |
| - return get(); |
| + if (m_cache) |
|
haraken
2015/06/08 11:03:13
You can do something like:
if (m_document->axObje
dmazzoni
2015/06/08 15:04:06
Doing this assumes that the accessibility flag doe
haraken
2015/06/08 23:38:15
Makes sense -- let's go with the current CL.
|
| + return m_cache.get(); |
| + AXObjectCache* cache = m_document->axObjectCache(); |
| + ASSERT(cache); |
| + return cache; |
| } |
| } // namespace blink |