Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index 0e83a6fc8b4c3f1f9d4761ba9695a15ff178e575..3ec67f73373a14d35c7d83f201945f89c0fb0cad 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 = NthIndexCache::create(*this); |
+ 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) |
@@ -1773,6 +1791,8 @@ void Document::updateStyle(StyleRecalcChange change) |
HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
+ UseNthIndexCacheScope 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); |