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

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: Missing initializer and incorrect assert. 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/css/SiblingTraversalStrategies.h ('k') | Source/core/dom/Document.h » ('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 * 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/NodeComputedStyle.h" 34 #include "core/dom/NodeComputedStyle.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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 PassRefPtrWillBeRawPtr<Element> ContainerNode::querySelector(const AtomicString& selectors, ExceptionState& exceptionState) 1152 PassRefPtrWillBeRawPtr<Element> ContainerNode::querySelector(const AtomicString& selectors, ExceptionState& exceptionState)
1152 { 1153 {
1153 if (selectors.isEmpty()) { 1154 if (selectors.isEmpty()) {
1154 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty."); 1155 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
1155 return nullptr; 1156 return nullptr;
1156 } 1157 }
1157 1158
1158 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState); 1159 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1159 if (!selectorQuery) 1160 if (!selectorQuery)
1160 return nullptr; 1161 return nullptr;
1162
1163 NthIndexCache nthIndexCache(document());
1161 return selectorQuery->queryFirst(*this); 1164 return selectorQuery->queryFirst(*this);
1162 } 1165 }
1163 1166
1164 PassRefPtrWillBeRawPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState) 1167 PassRefPtrWillBeRawPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString& selectors, ExceptionState& exceptionState)
1165 { 1168 {
1166 if (selectors.isEmpty()) { 1169 if (selectors.isEmpty()) {
1167 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty."); 1170 exceptionState.throwDOMException(SyntaxError, "The provided selector is empty.");
1168 return nullptr; 1171 return nullptr;
1169 } 1172 }
1170 1173
1171 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState); 1174 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1172 if (!selectorQuery) 1175 if (!selectorQuery)
1173 return nullptr; 1176 return nullptr;
1174 1177
1178 NthIndexCache nthIndexCache(document());
1175 return selectorQuery->queryAll(*this); 1179 return selectorQuery->queryAll(*this);
1176 } 1180 }
1177 1181
1178 static void dispatchChildInsertionEvents(Node& child) 1182 static void dispatchChildInsertionEvents(Node& child)
1179 { 1183 {
1180 if (child.isInShadowTree()) 1184 if (child.isInShadowTree())
1181 return; 1185 return;
1182 1186
1183 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 1187 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
1184 1188
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 return true; 1489 return true;
1486 1490
1487 if (node->isElementNode() && toElement(node)->shadow()) 1491 if (node->isElementNode() && toElement(node)->shadow())
1488 return true; 1492 return true;
1489 1493
1490 return false; 1494 return false;
1491 } 1495 }
1492 #endif 1496 #endif
1493 1497
1494 } // namespace blink 1498 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/SiblingTraversalStrategies.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698