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

Side by Side Diff: third_party/WebKit/Source/core/xml/XPathStep.cpp

Issue 2068053002: Rename Blink constants generated from IDL files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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) 2005 Frerich Raabe <raabe@kde.org> 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org>
3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 evaluationContext.size = nodes.size(); 145 evaluationContext.size = nodes.size();
146 evaluationContext.position = j + 1; 146 evaluationContext.position = j + 1;
147 if (predicate->evaluate(evaluationContext)) 147 if (predicate->evaluate(evaluationContext))
148 newNodes->append(node); 148 newNodes->append(node);
149 } 149 }
150 150
151 nodes.swap(*newNodes); 151 nodes.swap(*newNodes);
152 } 152 }
153 } 153 }
154 154
155 #if ENABLE(ASSERT) 155 #if DCHECK_IS_ON()
156 static inline Node::NodeType primaryNodeType(Step::Axis axis) 156 static inline Node::NodeType primaryNodeType(Step::Axis axis)
157 { 157 {
158 switch (axis) { 158 switch (axis) {
159 case Step::AttributeAxis: 159 case Step::AttributeAxis:
160 return Node::ATTRIBUTE_NODE; 160 return Node::kAttributeNode;
161 default: 161 default:
162 return Node::ELEMENT_NODE; 162 return Node::kElementNode;
163 } 163 }
164 } 164 }
165 #endif 165 #endif
166 166
167 // Evaluate NodeTest without considering merged predicates. 167 // Evaluate NodeTest without considering merged predicates.
168 static inline bool nodeMatchesBasicTest(Node* node, Step::Axis axis, const Step: :NodeTest& nodeTest) 168 static inline bool nodeMatchesBasicTest(Node* node, Step::Axis axis, const Step: :NodeTest& nodeTest)
169 { 169 {
170 switch (nodeTest.getKind()) { 170 switch (nodeTest.getKind()) {
171 case Step::NodeTest::TextNodeTest: { 171 case Step::NodeTest::TextNodeTest: {
172 Node::NodeType type = node->getNodeType(); 172 Node::NodeType type = node->getNodeType();
173 return type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE; 173 return type == Node::kTextNode || type == Node::kCdataSectionNode;
174 } 174 }
175 case Step::NodeTest::CommentNodeTest: 175 case Step::NodeTest::CommentNodeTest:
176 return node->getNodeType() == Node::COMMENT_NODE; 176 return node->getNodeType() == Node::kCommentNode;
177 case Step::NodeTest::ProcessingInstructionNodeTest: { 177 case Step::NodeTest::ProcessingInstructionNodeTest: {
178 const AtomicString& name = nodeTest.data(); 178 const AtomicString& name = nodeTest.data();
179 return node->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE && (name .isEmpty() || node->nodeName() == name); 179 return node->getNodeType() == Node::kProcessingInstructionNode && (name. isEmpty() || node->nodeName() == name);
180 } 180 }
181 case Step::NodeTest::AnyNodeTest: 181 case Step::NodeTest::AnyNodeTest:
182 return true; 182 return true;
183 case Step::NodeTest::NameTest: { 183 case Step::NodeTest::NameTest: {
184 const AtomicString& name = nodeTest.data(); 184 const AtomicString& name = nodeTest.data();
185 const AtomicString& namespaceURI = nodeTest.namespaceURI(); 185 const AtomicString& namespaceURI = nodeTest.namespaceURI();
186 186
187 if (axis == Step::AttributeAxis) { 187 if (axis == Step::AttributeAxis) {
188 Attr* attr = toAttr(node); 188 Attr* attr = toAttr(node);
189 189
190 // In XPath land, namespace nodes are not accessible on the 190 // In XPath land, namespace nodes are not accessible on the
191 // attribute axis. 191 // attribute axis.
192 if (attr->namespaceURI() == XMLNSNames::xmlnsNamespaceURI) 192 if (attr->namespaceURI() == XMLNSNames::xmlnsNamespaceURI)
193 return false; 193 return false;
194 194
195 if (name == starAtom) 195 if (name == starAtom)
196 return namespaceURI.isEmpty() || attr->namespaceURI() == namespa ceURI; 196 return namespaceURI.isEmpty() || attr->namespaceURI() == namespa ceURI;
197 197
198 return attr->localName() == name && attr->namespaceURI() == namespac eURI; 198 return attr->localName() == name && attr->namespaceURI() == namespac eURI;
199 } 199 }
200 200
201 // Node test on the namespace axis is not implemented yet, the caller 201 // Node test on the namespace axis is not implemented yet, the caller
202 // has a check for it. 202 // has a check for it.
203 ASSERT(axis != Step::NamespaceAxis); 203 DCHECK_NE(Step::NamespaceAxis, axis);
204 204
205 // For other axes, the principal node type is element. 205 // For other axes, the principal node type is element.
206 ASSERT(primaryNodeType(axis) == Node::ELEMENT_NODE); 206 #if DCHECK_IS_ON()
207 DCHECK_EQ(Node::kElementNode, primaryNodeType(axis));
208 #endif
207 if (!node->isElementNode()) 209 if (!node->isElementNode())
208 return false; 210 return false;
209 Element& element = toElement(*node); 211 Element& element = toElement(*node);
210 212
211 if (name == starAtom) 213 if (name == starAtom)
212 return namespaceURI.isEmpty() || namespaceURI == element.namespaceUR I(); 214 return namespaceURI.isEmpty() || namespaceURI == element.namespaceUR I();
213 215
214 if (element.document().isHTMLDocument()) { 216 if (element.document().isHTMLDocument()) {
215 if (element.isHTMLElement()) { 217 if (element.isHTMLElement()) {
216 // Paths without namespaces should match HTML elements in HTML 218 // Paths without namespaces should match HTML elements in HTML
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 302 }
301 for (n = n->parentNode(); n; n = n->parentNode()) { 303 for (n = n->parentNode(); n; n = n->parentNode()) {
302 if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest())) 304 if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest()))
303 nodes.append(n); 305 nodes.append(n);
304 } 306 }
305 nodes.markSorted(false); 307 nodes.markSorted(false);
306 return; 308 return;
307 } 309 }
308 310
309 case FollowingSiblingAxis: 311 case FollowingSiblingAxis:
310 if (context->getNodeType() == Node::ATTRIBUTE_NODE) 312 if (context->getNodeType() == Node::kAttributeNode)
311 return; 313 return;
312 314
313 for (Node* n = context->nextSibling(); n; n = n->nextSibling()) { 315 for (Node* n = context->nextSibling(); n; n = n->nextSibling()) {
314 if (nodeMatches(evaluationContext, n, FollowingSiblingAxis, nodeTest ())) 316 if (nodeMatches(evaluationContext, n, FollowingSiblingAxis, nodeTest ()))
315 nodes.append(n); 317 nodes.append(n);
316 } 318 }
317 return; 319 return;
318 320
319 case PrecedingSiblingAxis: 321 case PrecedingSiblingAxis:
320 if (context->getNodeType() == Node::ATTRIBUTE_NODE) 322 if (context->getNodeType() == Node::kAttributeNode)
321 return; 323 return;
322 324
323 for (Node* n = context->previousSibling(); n; n = n->previousSibling()) { 325 for (Node* n = context->previousSibling(); n; n = n->previousSibling()) {
324 if (nodeMatches(evaluationContext, n, PrecedingSiblingAxis, nodeTest ())) 326 if (nodeMatches(evaluationContext, n, PrecedingSiblingAxis, nodeTest ()))
325 nodes.append(n); 327 nodes.append(n);
326 } 328 }
327 nodes.markSorted(false); 329 nodes.markSorted(false);
328 return; 330 return;
329 331
330 case FollowingAxis: 332 case FollowingAxis:
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 nodes.markSorted(false); 430 nodes.markSorted(false);
429 return; 431 return;
430 } 432 }
431 } 433 }
432 ASSERT_NOT_REACHED(); 434 ASSERT_NOT_REACHED();
433 } 435 }
434 436
435 } // namespace XPath 437 } // namespace XPath
436 438
437 } // namespace blink 439 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/xml/XPathResult.cpp ('k') | third_party/WebKit/Source/core/xml/XPathUtil.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698