| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const AtomicString& name = nodeTest.data(); | 179 const AtomicString& name = nodeTest.data(); |
| 180 return node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE && (name.is
Empty() || node->nodeName() == name); | 180 return node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE && (name.is
Empty() || node->nodeName() == name); |
| 181 } | 181 } |
| 182 case Step::NodeTest::AnyNodeTest: | 182 case Step::NodeTest::AnyNodeTest: |
| 183 return true; | 183 return true; |
| 184 case Step::NodeTest::NameTest: { | 184 case Step::NodeTest::NameTest: { |
| 185 const AtomicString& name = nodeTest.data(); | 185 const AtomicString& name = nodeTest.data(); |
| 186 const AtomicString& namespaceURI = nodeTest.namespaceURI(); | 186 const AtomicString& namespaceURI = nodeTest.namespaceURI(); |
| 187 | 187 |
| 188 if (axis == Step::AttributeAxis) { | 188 if (axis == Step::AttributeAxis) { |
| 189 ASSERT(node->isAttributeNode()); | 189 Attr* attr = toAttr(node); |
| 190 | 190 |
| 191 // In XPath land, namespace nodes are not accessible on the | 191 // In XPath land, namespace nodes are not accessible on the |
| 192 // attribute axis. | 192 // attribute axis. |
| 193 if (node->namespaceURI() == XMLNSNames::xmlnsNamespaceURI) | 193 if (attr->namespaceURI() == XMLNSNames::xmlnsNamespaceURI) |
| 194 return false; | 194 return false; |
| 195 | 195 |
| 196 if (name == starAtom) | 196 if (name == starAtom) |
| 197 return namespaceURI.isEmpty() || node->namespaceURI() == namespa
ceURI; | 197 return namespaceURI.isEmpty() || attr->namespaceURI() == namespa
ceURI; |
| 198 | 198 |
| 199 return node->localName() == name && node->namespaceURI() == namespac
eURI; | 199 return attr->localName() == name && attr->namespaceURI() == namespac
eURI; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Node test on the namespace axis is not implemented yet, the caller | 202 // Node test on the namespace axis is not implemented yet, the caller |
| 203 // has a check for it. | 203 // has a check for it. |
| 204 ASSERT(axis != Step::NamespaceAxis); | 204 ASSERT(axis != Step::NamespaceAxis); |
| 205 | 205 |
| 206 // For other axes, the principal node type is element. | 206 // For other axes, the principal node type is element. |
| 207 ASSERT(primaryNodeType(axis) == Node::ELEMENT_NODE); | 207 ASSERT(primaryNodeType(axis) == Node::ELEMENT_NODE); |
| 208 if (!node->isElementNode()) | 208 if (!node->isElementNode()) |
| 209 return false; | 209 return false; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 365 } |
| 366 | 366 |
| 367 case AttributeAxis: { | 367 case AttributeAxis: { |
| 368 if (!context->isElementNode()) | 368 if (!context->isElementNode()) |
| 369 return; | 369 return; |
| 370 | 370 |
| 371 Element* contextElement = toElement(context); | 371 Element* contextElement = toElement(context); |
| 372 // Avoid lazily creating attribute nodes for attributes that we do not | 372 // Avoid lazily creating attribute nodes for attributes that we do not |
| 373 // need anyway. | 373 // need anyway. |
| 374 if (nodeTest().kind() == NodeTest::NameTest && nodeTest().data() != star
Atom) { | 374 if (nodeTest().kind() == NodeTest::NameTest && nodeTest().data() != star
Atom) { |
| 375 RefPtrWillBeRawPtr<Node> n = contextElement->getAttributeNodeNS(node
Test().namespaceURI(), nodeTest().data()); | 375 RefPtrWillBeRawPtr<Attr> attr = contextElement->getAttributeNodeNS(n
odeTest().namespaceURI(), nodeTest().data()); |
| 376 // In XPath land, namespace nodes are not accessible on the attribut
e axis. | 376 // In XPath land, namespace nodes are not accessible on the attribut
e axis. |
| 377 if (n && n->namespaceURI() != XMLNSNames::xmlnsNamespaceURI) { | 377 if (attr && attr->namespaceURI() != XMLNSNames::xmlnsNamespaceURI) { |
| 378 // Still need to check merged predicates. | 378 // Still need to check merged predicates. |
| 379 if (nodeMatches(evaluationContext, n.get(), AttributeAxis, nodeT
est())) | 379 if (nodeMatches(evaluationContext, attr.get(), AttributeAxis, no
deTest())) |
| 380 nodes.append(n.release()); | 380 nodes.append(attr.release()); |
| 381 } | 381 } |
| 382 return; | 382 return; |
| 383 } | 383 } |
| 384 | 384 |
| 385 AttributeCollection attributes = contextElement->attributes(); | 385 AttributeCollection attributes = contextElement->attributes(); |
| 386 for (auto& attribute : attributes) { | 386 for (auto& attribute : attributes) { |
| 387 RefPtrWillBeRawPtr<Attr> attr = contextElement->ensureAttr(attribute
.name()); | 387 RefPtrWillBeRawPtr<Attr> attr = contextElement->ensureAttr(attribute
.name()); |
| 388 if (nodeMatches(evaluationContext, attr.get(), AttributeAxis, nodeTe
st())) | 388 if (nodeMatches(evaluationContext, attr.get(), AttributeAxis, nodeTe
st())) |
| 389 nodes.append(attr.release()); | 389 nodes.append(attr.release()); |
| 390 } | 390 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 nodes.markSorted(false); | 429 nodes.markSorted(false); |
| 430 return; | 430 return; |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 ASSERT_NOT_REACHED(); | 433 ASSERT_NOT_REACHED(); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } | 436 } |
| 437 | 437 |
| 438 } | 438 } |
| OLD | NEW |