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. | 3 * Copyright (C) 2006, 2009 Apple Inc. |
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 11 matching lines...) Expand all Loading... |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/xml/XPathPath.h" | 29 #include "core/xml/XPathPath.h" |
30 | 30 |
31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/NodeTraversal.h" |
32 #include "core/xml/XPathPredicate.h" | 33 #include "core/xml/XPathPredicate.h" |
33 #include "core/xml/XPathStep.h" | 34 #include "core/xml/XPathStep.h" |
34 #include "core/xml/XPathValue.h" | 35 #include "core/xml/XPathValue.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 namespace XPath { | 38 namespace XPath { |
38 | 39 |
39 Filter::Filter(PassOwnPtrWillBeRawPtr<Expression> expr, WillBeHeapVector<OwnPtrW
illBeMember<Predicate> >& predicates) | 40 Filter::Filter(PassOwnPtrWillBeRawPtr<Expression> expr, WillBeHeapVector<OwnPtrW
illBeMember<Predicate> >& predicates) |
40 : m_expr(expr) | 41 : m_expr(expr) |
41 { | 42 { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // "A / by itself selects the root node of the document containing the conte
xt node." | 114 // "A / by itself selects the root node of the document containing the conte
xt node." |
114 // In the case of a tree that is detached from the document, we violate | 115 // In the case of a tree that is detached from the document, we violate |
115 // the spec and treat / as the root node of the detached tree. | 116 // the spec and treat / as the root node of the detached tree. |
116 // This is for compatibility with Firefox, and also seems like a more | 117 // This is for compatibility with Firefox, and also seems like a more |
117 // logical treatment of where you would expect the "root" to be. | 118 // logical treatment of where you would expect the "root" to be. |
118 Node* context = evaluationContext.node.get(); | 119 Node* context = evaluationContext.node.get(); |
119 if (m_absolute && context->nodeType() != Node::DOCUMENT_NODE) { | 120 if (m_absolute && context->nodeType() != Node::DOCUMENT_NODE) { |
120 if (context->inDocument()) | 121 if (context->inDocument()) |
121 context = context->ownerDocument(); | 122 context = context->ownerDocument(); |
122 else | 123 else |
123 context = &context->highestAncestorOrSelf(); | 124 context = &NodeTraversal::highestAncestorOrSelf(*context); |
124 } | 125 } |
125 | 126 |
126 OwnPtrWillBeRawPtr<NodeSet> nodes(NodeSet::create()); | 127 OwnPtrWillBeRawPtr<NodeSet> nodes(NodeSet::create()); |
127 nodes->append(context); | 128 nodes->append(context); |
128 evaluate(clonedContext, *nodes); | 129 evaluate(clonedContext, *nodes); |
129 | 130 |
130 return Value(nodes.release(), Value::adopt); | 131 return Value(nodes.release(), Value::adopt); |
131 } | 132 } |
132 | 133 |
133 void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const | 134 void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 Value v = m_filter->evaluate(context); | 229 Value v = m_filter->evaluate(context); |
229 | 230 |
230 NodeSet& nodes = v.modifiableNodeSet(context); | 231 NodeSet& nodes = v.modifiableNodeSet(context); |
231 m_path->evaluate(context, nodes); | 232 m_path->evaluate(context, nodes); |
232 | 233 |
233 return v; | 234 return v; |
234 } | 235 } |
235 | 236 |
236 } | 237 } |
237 } | 238 } |
OLD | NEW |