| 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 DEFINE_TRACE(LocationPath) { | 87 DEFINE_TRACE(LocationPath) { |
| 88 visitor->trace(m_steps); | 88 visitor->trace(m_steps); |
| 89 Expression::trace(visitor); | 89 Expression::trace(visitor); |
| 90 } | 90 } |
| 91 | 91 |
| 92 Value LocationPath::evaluate(EvaluationContext& evaluationContext) const { | 92 Value LocationPath::evaluate(EvaluationContext& evaluationContext) const { |
| 93 EvaluationContext clonedContext = evaluationContext; | 93 EvaluationContext clonedContext = evaluationContext; |
| 94 // http://www.w3.org/TR/xpath/ | 94 // http://www.w3.org/TR/xpath/ |
| 95 // Section 2, Location Paths: | 95 // Section 2, Location Paths: |
| 96 // "/ selects the document root (which is always the parent of the document el
ement)" | 96 // "/ selects the document root (which is always the parent of the document |
| 97 // "A / by itself selects the root node of the document containing the context
node." | 97 // element)" |
| 98 // "A / by itself selects the root node of the document containing the context |
| 99 // node." |
| 98 // In the case of a tree that is detached from the document, we violate | 100 // In the case of a tree that is detached from the document, we violate |
| 99 // the spec and treat / as the root node of the detached tree. | 101 // the spec and treat / as the root node of the detached tree. |
| 100 // This is for compatibility with Firefox, and also seems like a more | 102 // This is for compatibility with Firefox, and also seems like a more |
| 101 // logical treatment of where you would expect the "root" to be. | 103 // logical treatment of where you would expect the "root" to be. |
| 102 Node* context = evaluationContext.node.get(); | 104 Node* context = evaluationContext.node.get(); |
| 103 if (m_absolute && context->getNodeType() != Node::kDocumentNode) { | 105 if (m_absolute && context->getNodeType() != Node::kDocumentNode) { |
| 104 if (context->isConnected()) | 106 if (context->isConnected()) |
| 105 context = context->ownerDocument(); | 107 context = context->ownerDocument(); |
| 106 else | 108 else |
| 107 context = &NodeTraversal::highestAncestorOrSelf(*context); | 109 context = &NodeTraversal::highestAncestorOrSelf(*context); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 197 |
| 196 NodeSet& nodes = v.modifiableNodeSet(context); | 198 NodeSet& nodes = v.modifiableNodeSet(context); |
| 197 m_path->evaluate(context, nodes); | 199 m_path->evaluate(context, nodes); |
| 198 | 200 |
| 199 return v; | 201 return v; |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace XPath | 204 } // namespace XPath |
| 203 | 205 |
| 204 } // namespace blink | 206 } // namespace blink |
| OLD | NEW |