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..1252d7fd5e2b4033688029c083a98d67ef11e28d 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() |
|
esprehn
2015/03/30 22:55:31
Instead of putting this on the Document, lets keep
|
| +{ |
| + if (!m_useNthIndexCache) |
| + return nullptr; |
| + if (!m_nthIndexCache) |
| + m_nthIndexCache = NthIndexCache::create(*this); |
| + return m_nthIndexCache.get(); |
| +} |
| + |
| +void Document::setUseNthIndexCache(bool use) |
|
esprehn
2015/03/30 22:55:31
remove this.
|
| +{ |
| + m_useNthIndexCache = use; |
| + if (!use && m_nthIndexCache) |
| + m_nthIndexCache->clear(); |
| +} |
| + |
| MediaQueryMatcher& Document::mediaQueryMatcher() |
| { |
| if (!m_mediaQueryMatcher) |
| @@ -1773,6 +1791,8 @@ void Document::updateStyle(StyleRecalcChange change) |
| HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
| m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
| + NthIndexCacheScope nthIndexScope(*this); |
| + |
| if (styleChangeType() >= SubtreeStyleChange) |
| change = Force; |
| @@ -5714,6 +5734,7 @@ DEFINE_TRACE(Document) |
| visitor->trace(m_visibilityObservers); |
| visitor->trace(m_userActionElements); |
| visitor->trace(m_svgExtensions); |
| + visitor->trace(m_nthIndexCache); |
| visitor->trace(m_timeline); |
| visitor->trace(m_compositorPendingAnimations); |
| visitor->trace(m_contextDocument); |