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

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: 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 unified diff | Download patch
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 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 ...
1068 UseNthIndexCacheScope(Document& document)
1069 : m_document(document)
1070 {
1071 ASSERT(!m_document.useNthIndexCache());
1072 m_document.setUseNthIndexCache(true);
1073 }
1074 ~UseNthIndexCacheScope()
1075 {
1076 ASSERT(m_document.useNthIndexCache());
1077 m_document.setUseNthIndexCache(false);
1078 }
1079 private:
1080 Document& m_document;
1081 };
1082
1064 protected: 1083 protected:
1065 Document(const DocumentInit&, DocumentClassFlags = DefaultDocumentClass); 1084 Document(const DocumentInit&, DocumentClassFlags = DefaultDocumentClass);
1066 1085
1067 virtual void didUpdateSecurityOrigin() override final; 1086 virtual void didUpdateSecurityOrigin() override final;
1068 1087
1069 void clearXMLVersion() { m_xmlVersion = String(); } 1088 void clearXMLVersion() { m_xmlVersion = String(); }
1070 1089
1071 #if !ENABLE(OILPAN) 1090 #if !ENABLE(OILPAN)
1072 virtual void dispose() override; 1091 virtual void dispose() override;
1073 #endif 1092 #endif
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 1329
1311 OwnPtrWillBeMember<SVGDocumentExtensions> m_svgExtensions; 1330 OwnPtrWillBeMember<SVGDocumentExtensions> m_svgExtensions;
1312 1331
1313 Vector<AnnotatedRegionValue> m_annotatedRegions; 1332 Vector<AnnotatedRegionValue> m_annotatedRegions;
1314 bool m_hasAnnotatedRegions; 1333 bool m_hasAnnotatedRegions;
1315 bool m_annotatedRegionsDirty; 1334 bool m_annotatedRegionsDirty;
1316 1335
1317 WillBeHeapHashMap<String, RefPtrWillBeMember<HTMLCanvasElement>> m_cssCanvas Elements; 1336 WillBeHeapHashMap<String, RefPtrWillBeMember<HTMLCanvasElement>> m_cssCanvas Elements;
1318 1337
1319 OwnPtr<SelectorQueryCache> m_selectorQueryCache; 1338 OwnPtr<SelectorQueryCache> m_selectorQueryCache;
1339 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.
1320 1340
1321 bool m_useSecureKeyboardEntryWhenActive; 1341 bool m_useSecureKeyboardEntryWhenActive;
1322 1342
1323 DocumentClassFlags m_documentClasses; 1343 DocumentClassFlags m_documentClasses;
1324 1344
1325 bool m_isViewSource; 1345 bool m_isViewSource;
1326 bool m_sawElementsInKnownNamespaces; 1346 bool m_sawElementsInKnownNamespaces;
1327 bool m_isSrcdocDocument; 1347 bool m_isSrcdocDocument;
1328 bool m_isMobileDocument; 1348 bool m_isMobileDocument;
1329 bool m_isTransitionDocument; 1349 bool m_isTransitionDocument;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 bool m_hasViewportUnits; 1410 bool m_hasViewportUnits;
1391 1411
1392 using DocumentVisibilityObserverSet = WillBeHeapHashSet<RawPtrWillBeWeakMemb er<DocumentVisibilityObserver>>; 1412 using DocumentVisibilityObserverSet = WillBeHeapHashSet<RawPtrWillBeWeakMemb er<DocumentVisibilityObserver>>;
1393 DocumentVisibilityObserverSet m_visibilityObservers; 1413 DocumentVisibilityObserverSet m_visibilityObservers;
1394 1414
1395 int m_styleRecalcElementCounter; 1415 int m_styleRecalcElementCounter;
1396 1416
1397 ParserSynchronizationPolicy m_parserSyncPolicy; 1417 ParserSynchronizationPolicy m_parserSyncPolicy;
1398 1418
1399 OriginsUsingFeatures::Value m_originsUsingFeaturesValue; 1419 OriginsUsingFeatures::Value m_originsUsingFeaturesValue;
1420
1421 bool useNthIndexCache() const { return m_useNthIndexCache; }
1422 void setUseNthIndexCache(bool);
1423
1424 bool m_useNthIndexCache;
1400 }; 1425 };
1401 1426
1402 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin) 1427 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin)
1403 { 1428 {
1404 // The different (legacy) meta tags have different priorities based on the t ype 1429 // 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 1430 // regardless of which order they appear in the DOM. The priority is given b y the
1406 // ViewportDescription::Type enum. 1431 // ViewportDescription::Type enum.
1407 return origin >= m_legacyViewportDescription.type; 1432 return origin >= m_legacyViewportDescription.type;
1408 } 1433 }
1409 1434
(...skipping 27 matching lines...) Expand all
1437 DEFINE_TYPE_CASTS(TreeScope, Document, document, true, true); 1462 DEFINE_TYPE_CASTS(TreeScope, Document, document, true, true);
1438 1463
1439 } // namespace blink 1464 } // namespace blink
1440 1465
1441 #ifndef NDEBUG 1466 #ifndef NDEBUG
1442 // Outside the WebCore namespace for ease of invocation from gdb. 1467 // Outside the WebCore namespace for ease of invocation from gdb.
1443 void showLiveDocumentInstances(); 1468 void showLiveDocumentInstances();
1444 #endif 1469 #endif
1445 1470
1446 #endif // Document_h 1471 #endif // Document_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698