Lines Matching full:node
59 // Evaluate predicates as part of node test if possible to avoid building unnecessary NodeSets.
61 // This optimization can be applied to predicates that are not context node list sensitive, or to first predicate that is only context position sensitive, e.g. foo[position() mod 2 = 0].
85 // Optimize the common case of "//" AKA /descendant-or-self::node()/child::NodeTest to /descendant::NodeTest.
114 void Step::evaluate(Node* context, NodeSet& nodes) const
121 // Check predicates that couldn't be merged into node test.
130 Node* node = nodes[j];
132 evaluationContext.node = node;
136 newNodes.append(node);
143 static inline Node::NodeType primaryNodeType(Step::Axis axis)
147 return Node::ATTRIBUTE_NODE;
149 return Node::XPATH_NAMESPACE_NODE;
151 return Node::ELEMENT_NODE;
156 static inline bool nodeMatchesBasicTest(Node* node, Step::Axis axis, const Step::NodeTest& nodeTest)
160 return node->nodeType() == Node::TEXT_NODE || node->nodeType() == Node::CDATA_SECTION_NODE;
162 return node->nodeType() == Node::COMMENT_NODE;
165 return node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE && (name.isEmpty() || node->nodeName() == name);
174 ASSERT(node->isAttributeNode());
177 if (node->namespaceURI() == XMLNSNames::xmlnsNamespaceURI)
181 return namespaceURI.isEmpty() || node->namespaceURI() == namespaceURI;
183 return node->localName() == name && node->namespaceURI() == namespaceURI;
186 // Node test on the namespace axis is not implemented yet, the caller has a check for it.
189 // For other axes, the principal node type is element.
190 ASSERT(primaryNodeType(axis) == Node::ELEMENT_NODE);
191 if (node->nodeType() != Node::ELEMENT_NODE)
195 return namespaceURI.isEmpty() || namespaceURI == node->namespaceURI();
197 if (node->document()->isHTMLDocument()) {
198 if (node->isHTMLElement()) {
200 return equalIgnoringCase(static_cast<Element*>(node)->localName(), name) && (namespaceURI.isNull() || namespaceURI == node->namespaceURI());
203 return static_cast<Element*>(node)->hasLocalName(name) && namespaceURI == node->namespaceURI() && !namespaceURI.isNull();
205 return static_cast<Element*>(node)->hasLocalName(name) && namespaceURI == node->namespaceURI();
212 static inline bool nodeMatches(Node* node, Step::Axis axis, const Step::NodeTest& nodeTest)
214 if (!nodeMatchesBasicTest(node, axis, nodeTest))
226 evaluationContext.node = node;
235 // Result nodes are ordered in axis order. Node test (including merged predicates) is applied.
236 void Step::nodesInAxis(Node* context, NodeSet& nodes) const
244 for (Node* n = context->firstChild(); n; n = n->nextSibling())
252 for (Node* n = context->firstChild(); n; n = n->traverseNextNode(context))
258 Node* n = static_cast<Attr*>(context)->ownerElement();
262 Node* n = context->parentNode();
268 Node* n = context;
281 if (context->nodeType() == Node::ATTRIBUTE_NODE ||
282 context->nodeType() == Node::XPATH_NAMESPACE_NODE)
285 for (Node* n = context->nextSibling(); n; n = n->nextSibling())
290 if (context->nodeType() == Node::ATTRIBUTE_NODE ||
291 context->nodeType() == Node::XPATH_NAMESPACE_NODE)
294 for (Node* n = context->previousSibling(); n; n = n->previousSibling())
302 Node* p = static_cast<Attr*>(context)->ownerElement();
307 for (Node* p = context; !isRootDomNode(p); p = p->parentNode()) {
308 for (Node* n = p->nextSibling(); n; n = n->nextSibling()) {
311 for (Node* c = n->firstChild(); c; c = c->traverseNextNode(n))
322 Node* n = context;
323 while (Node* parent = n->parent()) {
333 if (context->nodeType() != Node::ELEMENT_NODE)
338 RefPtr<Node> n = static_cast<Element*>(context)->getAttributeNodeNS(m_nodeTest.namespaceURI(), m_nodeTest.data());
370 for (Node* n = context->firstChild(); n; n = n->traverseNextNode(context))
377 Node* n = context;