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

Side by Side 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: Moved nth-index-cache scope to updateStyle Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2011 Google Inc. All rights reserved. 9 * Copyright (C) 2011 Google Inc. All rights reserved.
10 * 10 *
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 class LayoutPoint; 121 class LayoutPoint;
122 class LiveNodeListBase; 122 class LiveNodeListBase;
123 class Locale; 123 class Locale;
124 class LocalFrame; 124 class LocalFrame;
125 class Location; 125 class Location;
126 class MainThreadTaskRunner; 126 class MainThreadTaskRunner;
127 class MediaQueryListListener; 127 class MediaQueryListListener;
128 class MediaQueryMatcher; 128 class MediaQueryMatcher;
129 class NodeFilter; 129 class NodeFilter;
130 class NodeIterator; 130 class NodeIterator;
131 class NthIndexCache;
131 class Page; 132 class Page;
132 class PlatformMouseEvent; 133 class PlatformMouseEvent;
133 class ProcessingInstruction; 134 class ProcessingInstruction;
134 class QualifiedName; 135 class QualifiedName;
135 class Range; 136 class Range;
136 class LayoutView; 137 class LayoutView;
137 class RequestAnimationFrameCallback; 138 class RequestAnimationFrameCallback;
138 class ResourceFetcher; 139 class ResourceFetcher;
139 class SVGDocumentExtensions; 140 class SVGDocumentExtensions;
140 class SVGUseElement; 141 class SVGUseElement;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 using ContainerNode::ref; 241 using ContainerNode::ref;
241 using ContainerNode::deref; 242 using ContainerNode::deref;
242 #endif 243 #endif
243 using SecurityContext::securityOrigin; 244 using SecurityContext::securityOrigin;
244 using SecurityContext::contentSecurityPolicy; 245 using SecurityContext::contentSecurityPolicy;
245 using TreeScope::getElementById; 246 using TreeScope::getElementById;
246 247
247 virtual bool canContainRangeEndPoint() const override { return true; } 248 virtual bool canContainRangeEndPoint() const override { return true; }
248 249
249 SelectorQueryCache& selectorQueryCache(); 250 SelectorQueryCache& selectorQueryCache();
251 NthIndexCache* nthIndexCache();
250 252
251 // Focus Management. 253 // Focus Management.
252 Element* activeElement() const; 254 Element* activeElement() const;
253 bool hasFocus() const; 255 bool hasFocus() const;
254 256
255 // DOM methods & attributes for Document 257 // DOM methods & attributes for Document
256 258
257 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy); 259 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
258 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut); 260 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
259 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste); 261 DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1056
1055 void platformColorsChanged(); 1057 void platformColorsChanged();
1056 1058
1057 virtual DOMTimerCoordinator* timers() override final; 1059 virtual DOMTimerCoordinator* timers() override final;
1058 1060
1059 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext, v8::Isolate*) override; 1061 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext, v8::Isolate*) override;
1060 virtual v8::Handle<v8::Object> associateWithWrapper(v8::Isolate*, const Wrap perTypeInfo*, v8::Handle<v8::Object> wrapper) override; 1062 virtual v8::Handle<v8::Object> associateWithWrapper(v8::Isolate*, const Wrap perTypeInfo*, v8::Handle<v8::Object> wrapper) override;
1061 1063
1062 OriginsUsingFeatures::Value& originsUsingFeaturesValue() { return m_originsU singFeaturesValue; } 1064 OriginsUsingFeatures::Value& originsUsingFeaturesValue() { return m_originsU singFeaturesValue; }
1063 1065
1066 class UseNthIndexCacheScope {
1067 STACK_ALLOCATED();
1068 WTF_MAKE_NONCOPYABLE(UseNthIndexCacheScope);
1069 public:
1070 UseNthIndexCacheScope(Document& document)
1071 : m_document(&document)
1072 {
1073 ASSERT(!document.useNthIndexCache());
sof 2015/03/30 13:27:53 Just to verify: there's no possibility that you ma
rune 2015/03/30 20:14:40 Shouldn't with the current uses of this scope. que
1074 document.setUseNthIndexCache(true);
1075 }
1076 ~UseNthIndexCacheScope()
1077 {
1078 ASSERT(m_document->useNthIndexCache());
1079 m_document->setUseNthIndexCache(false);
1080 }
1081 private:
1082 RawPtrWillBeMember<Document> m_document;
1083 };
1084
1064 protected: 1085 protected:
1065 Document(const DocumentInit&, DocumentClassFlags = DefaultDocumentClass); 1086 Document(const DocumentInit&, DocumentClassFlags = DefaultDocumentClass);
1066 1087
1067 virtual void didUpdateSecurityOrigin() override final; 1088 virtual void didUpdateSecurityOrigin() override final;
1068 1089
1069 void clearXMLVersion() { m_xmlVersion = String(); } 1090 void clearXMLVersion() { m_xmlVersion = String(); }
1070 1091
1071 #if !ENABLE(OILPAN) 1092 #if !ENABLE(OILPAN)
1072 virtual void dispose() override; 1093 virtual void dispose() override;
1073 #endif 1094 #endif
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 1331
1311 OwnPtrWillBeMember<SVGDocumentExtensions> m_svgExtensions; 1332 OwnPtrWillBeMember<SVGDocumentExtensions> m_svgExtensions;
1312 1333
1313 Vector<AnnotatedRegionValue> m_annotatedRegions; 1334 Vector<AnnotatedRegionValue> m_annotatedRegions;
1314 bool m_hasAnnotatedRegions; 1335 bool m_hasAnnotatedRegions;
1315 bool m_annotatedRegionsDirty; 1336 bool m_annotatedRegionsDirty;
1316 1337
1317 WillBeHeapHashMap<String, RefPtrWillBeMember<HTMLCanvasElement>> m_cssCanvas Elements; 1338 WillBeHeapHashMap<String, RefPtrWillBeMember<HTMLCanvasElement>> m_cssCanvas Elements;
1318 1339
1319 OwnPtr<SelectorQueryCache> m_selectorQueryCache; 1340 OwnPtr<SelectorQueryCache> m_selectorQueryCache;
1341 OwnPtrWillBeMember<NthIndexCache> m_nthIndexCache;
1320 1342
1321 bool m_useSecureKeyboardEntryWhenActive; 1343 bool m_useSecureKeyboardEntryWhenActive;
1322 1344
1323 DocumentClassFlags m_documentClasses; 1345 DocumentClassFlags m_documentClasses;
1324 1346
1325 bool m_isViewSource; 1347 bool m_isViewSource;
1326 bool m_sawElementsInKnownNamespaces; 1348 bool m_sawElementsInKnownNamespaces;
1327 bool m_isSrcdocDocument; 1349 bool m_isSrcdocDocument;
1328 bool m_isMobileDocument; 1350 bool m_isMobileDocument;
1329 bool m_isTransitionDocument; 1351 bool m_isTransitionDocument;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 bool m_hasViewportUnits; 1412 bool m_hasViewportUnits;
1391 1413
1392 using DocumentVisibilityObserverSet = WillBeHeapHashSet<RawPtrWillBeWeakMemb er<DocumentVisibilityObserver>>; 1414 using DocumentVisibilityObserverSet = WillBeHeapHashSet<RawPtrWillBeWeakMemb er<DocumentVisibilityObserver>>;
1393 DocumentVisibilityObserverSet m_visibilityObservers; 1415 DocumentVisibilityObserverSet m_visibilityObservers;
1394 1416
1395 int m_styleRecalcElementCounter; 1417 int m_styleRecalcElementCounter;
1396 1418
1397 ParserSynchronizationPolicy m_parserSyncPolicy; 1419 ParserSynchronizationPolicy m_parserSyncPolicy;
1398 1420
1399 OriginsUsingFeatures::Value m_originsUsingFeaturesValue; 1421 OriginsUsingFeatures::Value m_originsUsingFeaturesValue;
1422
1423 bool useNthIndexCache() const { return m_useNthIndexCache; }
1424 void setUseNthIndexCache(bool);
1425
1426 bool m_useNthIndexCache;
1400 }; 1427 };
1401 1428
1402 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin) 1429 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin)
1403 { 1430 {
1404 // The different (legacy) meta tags have different priorities based on the t ype 1431 // The different (legacy) meta tags have different priorities based on the t ype
1405 // regardless of which order they appear in the DOM. The priority is given b y the 1432 // regardless of which order they appear in the DOM. The priority is given b y the
1406 // ViewportDescription::Type enum. 1433 // ViewportDescription::Type enum.
1407 return origin >= m_legacyViewportDescription.type; 1434 return origin >= m_legacyViewportDescription.type;
1408 } 1435 }
1409 1436
(...skipping 27 matching lines...) Expand all
1437 DEFINE_TYPE_CASTS(TreeScope, Document, document, true, true); 1464 DEFINE_TYPE_CASTS(TreeScope, Document, document, true, true);
1438 1465
1439 } // namespace blink 1466 } // namespace blink
1440 1467
1441 #ifndef NDEBUG 1468 #ifndef NDEBUG
1442 // Outside the WebCore namespace for ease of invocation from gdb. 1469 // Outside the WebCore namespace for ease of invocation from gdb.
1443 void showLiveDocumentInstances(); 1470 void showLiveDocumentInstances();
1444 #endif 1471 #endif
1445 1472
1446 #endif // Document_h 1473 #endif // Document_h
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698