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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 LocationPath::~LocationPath() | 87 LocationPath::~LocationPath() |
88 { | 88 { |
89 deleteAllValues(m_steps); | 89 deleteAllValues(m_steps); |
90 } | 90 } |
91 | 91 |
92 Value LocationPath::evaluate() const | 92 Value LocationPath::evaluate() const |
93 { | 93 { |
94 EvaluationContext& evaluationContext = Expression::evaluationContext(); | 94 EvaluationContext& evaluationContext = Expression::evaluationContext(); |
95 EvaluationContext backupContext = evaluationContext; | 95 EvaluationContext backupContext = evaluationContext; |
96 // For absolute location paths, the context node is ignored - the | 96 // For absolute location paths, the context node is ignored. The |
97 // document's root node is used instead. | 97 // document's root node is used for attached nodes, otherwise the root |
| 98 // node of the detached subtree is used. |
98 Node* context = evaluationContext.node.get(); | 99 Node* context = evaluationContext.node.get(); |
99 if (m_absolute && context->nodeType() != Node::DOCUMENT_NODE) | 100 if (m_absolute && context->nodeType() != Node::DOCUMENT_NODE) { |
100 context = context->ownerDocument(); | 101 if (context->inDocument()) |
| 102 context = context->ownerDocument(); |
| 103 else |
| 104 context = context->highestAncestor(); |
| 105 } |
101 | 106 |
102 NodeSet nodes; | 107 NodeSet nodes; |
103 nodes.append(context); | 108 nodes.append(context); |
104 evaluate(nodes); | 109 evaluate(nodes); |
105 | 110 |
106 evaluationContext = backupContext; | 111 evaluationContext = backupContext; |
107 return Value(nodes, Value::adopt); | 112 return Value(nodes, Value::adopt); |
108 } | 113 } |
109 | 114 |
110 void LocationPath::evaluate(NodeSet& nodes) const | 115 void LocationPath::evaluate(NodeSet& nodes) const |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 Value v = m_filter->evaluate(); | 201 Value v = m_filter->evaluate(); |
197 | 202 |
198 NodeSet& nodes = v.modifiableNodeSet(); | 203 NodeSet& nodes = v.modifiableNodeSet(); |
199 m_path->evaluate(nodes); | 204 m_path->evaluate(nodes); |
200 | 205 |
201 return v; | 206 return v; |
202 } | 207 } |
203 | 208 |
204 } | 209 } |
205 } | 210 } |
OLD | NEW |