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

Side by Side Diff: Source/core/dom/ContainerNode.cpp

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
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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 16 matching lines...) Expand all
27 #include "core/dom/ChildFrameDisconnector.h" 27 #include "core/dom/ChildFrameDisconnector.h"
28 #include "core/dom/ChildListMutationScope.h" 28 #include "core/dom/ChildListMutationScope.h"
29 #include "core/dom/ClassCollection.h" 29 #include "core/dom/ClassCollection.h"
30 #include "core/dom/ElementTraversal.h" 30 #include "core/dom/ElementTraversal.h"
31 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/NameNodeList.h" 32 #include "core/dom/NameNodeList.h"
33 #include "core/dom/NodeChildRemovalTracker.h" 33 #include "core/dom/NodeChildRemovalTracker.h"
34 #include "core/dom/NodeLayoutStyle.h" 34 #include "core/dom/NodeLayoutStyle.h"
35 #include "core/dom/NodeRareData.h" 35 #include "core/dom/NodeRareData.h"
36 #include "core/dom/NodeTraversal.h" 36 #include "core/dom/NodeTraversal.h"
37 #include "core/dom/NthIndexCache.h"
37 #include "core/dom/SelectorQuery.h" 38 #include "core/dom/SelectorQuery.h"
38 #include "core/dom/StaticNodeList.h" 39 #include "core/dom/StaticNodeList.h"
39 #include "core/dom/StyleEngine.h" 40 #include "core/dom/StyleEngine.h"
40 #include "core/dom/shadow/ElementShadow.h" 41 #include "core/dom/shadow/ElementShadow.h"
41 #include "core/dom/shadow/ShadowRoot.h" 42 #include "core/dom/shadow/ShadowRoot.h"
42 #include "core/events/MutationEvent.h" 43 #include "core/events/MutationEvent.h"
43 #include "core/html/HTMLCollection.h" 44 #include "core/html/HTMLCollection.h"
44 #include "core/html/HTMLFrameOwnerElement.h" 45 #include "core/html/HTMLFrameOwnerElement.h"
45 #include "core/html/HTMLTagCollection.h" 46 #include "core/html/HTMLTagCollection.h"
46 #include "core/html/RadioNodeList.h" 47 #include "core/html/RadioNodeList.h"
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 void ContainerNode::childrenChanged(const ChildrenChange& change) 849 void ContainerNode::childrenChanged(const ChildrenChange& change)
849 { 850 {
850 document().incDOMTreeVersion(); 851 document().incDOMTreeVersion();
851 if (!change.byParser && change.type != TextChanged) 852 if (!change.byParser && change.type != TextChanged)
852 document().updateRangesAfterChildrenChanged(this); 853 document().updateRangesAfterChildrenChanged(this);
853 invalidateNodeListCachesInAncestors(); 854 invalidateNodeListCachesInAncestors();
854 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { 855 if (change.isChildInsertion() && !childNeedsStyleRecalc()) {
855 setChildNeedsStyleRecalc(); 856 setChildNeedsStyleRecalc();
856 markAncestorsWithChildNeedsStyleRecalc(); 857 markAncestorsWithChildNeedsStyleRecalc();
857 } 858 }
859 ASSERT(!document().nthIndexCache());
858 } 860 }
859 861
860 void ContainerNode::cloneChildNodes(ContainerNode *clone) 862 void ContainerNode::cloneChildNodes(ContainerNode *clone)
861 { 863 {
862 TrackExceptionState exceptionState; 864 TrackExceptionState exceptionState;
863 for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nex tSibling()) 865 for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nex tSibling())
864 clone->appendChild(n->cloneNode(true), exceptionState); 866 clone->appendChild(n->cloneNode(true), exceptionState);
865 } 867 }
866 868
867 869
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 PassRefPtrWillBeRawPtr<Element> ContainerNode::querySelector(const AtomicString& selectors, ExceptionState& exceptionState) 1153 PassRefPtrWillBeRawPtr<Element> ContainerNode::querySelector(const AtomicString& selectors, ExceptionState& exceptionState)
1152 { 1154 {
1153 if (selectors.isEmpty()) { 1155 if (selectors.isEmpty()) {
1154 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty."); 1156 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
1155 return nullptr; 1157 return nullptr;
1156 } 1158 }
1157 1159
1158 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState); 1160 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1159 if (!selectorQuery) 1161 if (!selectorQuery)
1160 return nullptr; 1162 return nullptr;
1163
1164 Document::UseNthIndexCacheScope nthIndexScope(document());
1161 return selectorQuery->queryFirst(*this); 1165 return selectorQuery->queryFirst(*this);
1162 } 1166 }
1163 1167
1164 PassRefPtrWillBeRawPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState) 1168 PassRefPtrWillBeRawPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState)
1165 { 1169 {
1166 if (selectors.isEmpty()) { 1170 if (selectors.isEmpty()) {
1167 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty."); 1171 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
1168 return nullptr; 1172 return nullptr;
1169 } 1173 }
1170 1174
1171 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState); 1175 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1172 if (!selectorQuery) 1176 if (!selectorQuery)
1173 return nullptr; 1177 return nullptr;
1174 1178
1179 Document::UseNthIndexCacheScope nthIndexScope(document());
1175 return selectorQuery->queryAll(*this); 1180 return selectorQuery->queryAll(*this);
1176 } 1181 }
1177 1182
1178 static void dispatchChildInsertionEvents(Node& child) 1183 static void dispatchChildInsertionEvents(Node& child)
1179 { 1184 {
1180 if (child.isInShadowTree()) 1185 if (child.isInShadowTree())
1181 return; 1186 return;
1182 1187
1183 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 1188 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
1184 1189
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 return true; 1490 return true;
1486 1491
1487 if (node->isElementNode() && toElement(node)->shadow()) 1492 if (node->isElementNode() && toElement(node)->shadow())
1488 return true; 1493 return true;
1489 1494
1490 return false; 1495 return false;
1491 } 1496 }
1492 #endif 1497 #endif
1493 1498
1494 } // namespace blink 1499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698