OLD | NEW |
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return Node::ELEMENT_NODE; | 162 return Node::ELEMENT_NODE; |
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.kind()) { | 170 switch (nodeTest.kind()) { |
171 case Step::NodeTest::TextNodeTest: { | 171 case Step::NodeTest::TextNodeTest: { |
172 Node::NodeType type = node->nodeType(); | 172 Node::NodeType type = node->getNodeType(); |
173 return type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE; | 173 return type == Node::TEXT_NODE || type == Node::CDATA_SECTION_NODE; |
174 } | 174 } |
175 case Step::NodeTest::CommentNodeTest: | 175 case Step::NodeTest::CommentNodeTest: |
176 return node->nodeType() == Node::COMMENT_NODE; | 176 return node->getNodeType() == Node::COMMENT_NODE; |
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->nodeType() == Node::PROCESSING_INSTRUCTION_NODE && (name.is
Empty() || node->nodeName() == name); | 179 return node->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE && (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 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 for (n = n->parentNode(); n; n = n->parentNode()) { | 301 for (n = n->parentNode(); n; n = n->parentNode()) { |
302 if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest())) | 302 if (nodeMatches(evaluationContext, n, AncestorAxis, nodeTest())) |
303 nodes.append(n); | 303 nodes.append(n); |
304 } | 304 } |
305 nodes.markSorted(false); | 305 nodes.markSorted(false); |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 case FollowingSiblingAxis: | 309 case FollowingSiblingAxis: |
310 if (context->nodeType() == Node::ATTRIBUTE_NODE) | 310 if (context->getNodeType() == Node::ATTRIBUTE_NODE) |
311 return; | 311 return; |
312 | 312 |
313 for (Node* n = context->nextSibling(); n; n = n->nextSibling()) { | 313 for (Node* n = context->nextSibling(); n; n = n->nextSibling()) { |
314 if (nodeMatches(evaluationContext, n, FollowingSiblingAxis, nodeTest
())) | 314 if (nodeMatches(evaluationContext, n, FollowingSiblingAxis, nodeTest
())) |
315 nodes.append(n); | 315 nodes.append(n); |
316 } | 316 } |
317 return; | 317 return; |
318 | 318 |
319 case PrecedingSiblingAxis: | 319 case PrecedingSiblingAxis: |
320 if (context->nodeType() == Node::ATTRIBUTE_NODE) | 320 if (context->getNodeType() == Node::ATTRIBUTE_NODE) |
321 return; | 321 return; |
322 | 322 |
323 for (Node* n = context->previousSibling(); n; n = n->previousSibling())
{ | 323 for (Node* n = context->previousSibling(); n; n = n->previousSibling())
{ |
324 if (nodeMatches(evaluationContext, n, PrecedingSiblingAxis, nodeTest
())) | 324 if (nodeMatches(evaluationContext, n, PrecedingSiblingAxis, nodeTest
())) |
325 nodes.append(n); | 325 nodes.append(n); |
326 } | 326 } |
327 nodes.markSorted(false); | 327 nodes.markSorted(false); |
328 return; | 328 return; |
329 | 329 |
330 case FollowingAxis: | 330 case FollowingAxis: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 nodes.markSorted(false); | 428 nodes.markSorted(false); |
429 return; | 429 return; |
430 } | 430 } |
431 } | 431 } |
432 ASSERT_NOT_REACHED(); | 432 ASSERT_NOT_REACHED(); |
433 } | 433 } |
434 | 434 |
435 } // namespace XPath | 435 } // namespace XPath |
436 | 436 |
437 } // namespace blink | 437 } // namespace blink |
OLD | NEW |