Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index 0e83a6fc8b4c3f1f9d4761ba9695a15ff178e575..e68b659f7f54389d762d639322686cd454f601ed 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -86,6 +86,7 @@ |
| #include "core/dom/NodeRenderingTraversal.h" |
| #include "core/dom/NodeTraversal.h" |
| #include "core/dom/NodeWithIndex.h" |
| +#include "core/dom/NthIndexCache.h" |
| #include "core/dom/ProcessingInstruction.h" |
| #include "core/dom/RequestAnimationFrameCallback.h" |
| #include "core/dom/ScriptRunner.h" |
| @@ -474,6 +475,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
| , m_hasViewportUnits(false) |
| , m_styleRecalcElementCounter(0) |
| , m_parserSyncPolicy(AllowAsynchronousParsing) |
| + , m_useNthIndexCache(false) |
| { |
| if (m_frame) { |
| ASSERT(m_frame->page()); |
| @@ -656,6 +658,22 @@ SelectorQueryCache& Document::selectorQueryCache() |
| return *m_selectorQueryCache; |
| } |
| +NthIndexCache* Document::nthIndexCache() |
| +{ |
| + if (!m_useNthIndexCache) |
| + return nullptr; |
| + if (!m_nthIndexCache) |
| + m_nthIndexCache = adoptPtr(new NthIndexCache(*this)); |
|
sof
2015/03/28 08:33:59
adoptPtrWillBeNoop() -- would be tidier to provide
rune
2015/03/30 09:00:03
Done.
sof
2015/03/30 20:55:16
Oh, not quite, you're still using adoptPtr() -- ou
|
| + return m_nthIndexCache.get(); |
| +} |
| + |
| +void Document::setUseNthIndexCache(bool use) |
| +{ |
| + m_useNthIndexCache = use; |
| + if (!use && m_nthIndexCache) |
| + m_nthIndexCache->clear(); |
| +} |
| + |
| MediaQueryMatcher& Document::mediaQueryMatcher() |
| { |
| if (!m_mediaQueryMatcher) |
| @@ -1713,6 +1731,8 @@ void Document::updateRenderTree(StyleRecalcChange change) |
| if (inStyleRecalc()) |
| return; |
| + UseNthIndexCacheScope nthIndexScope(*this); |
| + |
| // Entering here from inside layout or paint would be catastrophic since recalcStyle can |
| // tear down the render tree or (unfortunately) run script. Kill the whole renderer if |
| // someone managed to get into here from inside layout or paint. |