Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: Source/core/dom/Document.h

Issue 1023393002: Cache element indices for :nth-child and :nth-last-child selectors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clear cache after each operation Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.h
diff --git a/Source/core/dom/Document.h b/Source/core/dom/Document.h
index 51a3c60befaffd8c8722eedee272a4a7ce04c092..967a7400af57c4e5a3f0e59a2975990fc3e3be19 100644
--- a/Source/core/dom/Document.h
+++ b/Source/core/dom/Document.h
@@ -128,6 +128,7 @@ class MediaQueryListListener;
class MediaQueryMatcher;
class NodeFilter;
class NodeIterator;
+class NthIndexCache;
class Page;
class PlatformMouseEvent;
class ProcessingInstruction;
@@ -247,6 +248,7 @@ public:
virtual bool canContainRangeEndPoint() const override { return true; }
SelectorQueryCache& selectorQueryCache();
+ NthIndexCache* nthIndexCache();
// Focus Management.
Element* activeElement() const;
@@ -1061,6 +1063,23 @@ public:
OriginsUsingFeatures::Value& originsUsingFeaturesValue() { return m_originsUsingFeaturesValue; }
+ class UseNthIndexCacheScope {
+ public:
sof 2015/03/28 08:33:59 If you add STACK_ALLOCATED(); here and turn the Do
rune 2015/03/30 09:00:03 Done.
sof 2015/03/30 13:27:53 ...
+ UseNthIndexCacheScope(Document& document)
+ : m_document(document)
+ {
+ ASSERT(!m_document.useNthIndexCache());
+ m_document.setUseNthIndexCache(true);
+ }
+ ~UseNthIndexCacheScope()
+ {
+ ASSERT(m_document.useNthIndexCache());
+ m_document.setUseNthIndexCache(false);
+ }
+ private:
+ Document& m_document;
+ };
+
protected:
Document(const DocumentInit&, DocumentClassFlags = DefaultDocumentClass);
@@ -1317,6 +1336,7 @@ private:
WillBeHeapHashMap<String, RefPtrWillBeMember<HTMLCanvasElement>> m_cssCanvasElements;
OwnPtr<SelectorQueryCache> m_selectorQueryCache;
+ OwnPtrWillBeMember<NthIndexCache> m_nthIndexCache;
sof 2015/03/28 08:33:59 Add a trace() call for this to Document's trace()
rune 2015/03/30 09:00:03 Done.
bool m_useSecureKeyboardEntryWhenActive;
@@ -1397,6 +1417,11 @@ private:
ParserSynchronizationPolicy m_parserSyncPolicy;
OriginsUsingFeatures::Value m_originsUsingFeaturesValue;
+
+ bool useNthIndexCache() const { return m_useNthIndexCache; }
+ void setUseNthIndexCache(bool);
+
+ bool m_useNthIndexCache;
};
inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin)

Powered by Google App Engine
This is Rietveld 408576698