| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
| 33 #include "core/xml/XPathPredicate.h" | 33 #include "core/xml/XPathPredicate.h" |
| 34 #include "core/xml/XPathStep.h" | 34 #include "core/xml/XPathStep.h" |
| 35 #include "core/xml/XPathValue.h" | 35 #include "core/xml/XPathValue.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 namespace XPath { | 38 namespace XPath { |
| 39 | 39 |
| 40 Filter::Filter(PassOwnPtrWillBeRawPtr<Expression> expr, WillBeHeapVector<OwnPtrW
illBeMember<Predicate> >& predicates) | 40 Filter::Filter(PassOwnPtrWillBeRawPtr<Expression> expr, WillBeHeapVector<OwnPtrW
illBeMember<Predicate>>& predicates) |
| 41 : m_expr(expr) | 41 : m_expr(expr) |
| 42 { | 42 { |
| 43 m_predicates.swap(predicates); | 43 m_predicates.swap(predicates); |
| 44 setIsContextNodeSensitive(m_expr->isContextNodeSensitive()); | 44 setIsContextNodeSensitive(m_expr->isContextNodeSensitive()); |
| 45 setIsContextPositionSensitive(m_expr->isContextPositionSensitive()); | 45 setIsContextPositionSensitive(m_expr->isContextPositionSensitive()); |
| 46 setIsContextSizeSensitive(m_expr->isContextSizeSensitive()); | 46 setIsContextSizeSensitive(m_expr->isContextSizeSensitive()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 Filter::~Filter() | 49 Filter::~Filter() |
| 50 { | 50 { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return Value(nodes.release(), Value::adopt); | 131 return Value(nodes.release(), Value::adopt); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const | 134 void LocationPath::evaluate(EvaluationContext& context, NodeSet& nodes) const |
| 135 { | 135 { |
| 136 bool resultIsSorted = nodes.isSorted(); | 136 bool resultIsSorted = nodes.isSorted(); |
| 137 | 137 |
| 138 for (unsigned i = 0; i < m_steps.size(); i++) { | 138 for (unsigned i = 0; i < m_steps.size(); i++) { |
| 139 Step* step = m_steps[i]; | 139 Step* step = m_steps[i]; |
| 140 OwnPtrWillBeRawPtr<NodeSet> newNodes(NodeSet::create()); | 140 OwnPtrWillBeRawPtr<NodeSet> newNodes(NodeSet::create()); |
| 141 WillBeHeapHashSet<RawPtrWillBeMember<Node> > newNodesSet; | 141 WillBeHeapHashSet<RawPtrWillBeMember<Node>> newNodesSet; |
| 142 | 142 |
| 143 bool needToCheckForDuplicateNodes = !nodes.subtreesAreDisjoint() || (ste
p->axis() != Step::ChildAxis && step->axis() != Step::SelfAxis | 143 bool needToCheckForDuplicateNodes = !nodes.subtreesAreDisjoint() || (ste
p->axis() != Step::ChildAxis && step->axis() != Step::SelfAxis |
| 144 && step->axis() != Step::DescendantAxis && step->axis() != Step::Des
cendantOrSelfAxis && step->axis() != Step::AttributeAxis); | 144 && step->axis() != Step::DescendantAxis && step->axis() != Step::Des
cendantOrSelfAxis && step->axis() != Step::AttributeAxis); |
| 145 | 145 |
| 146 if (needToCheckForDuplicateNodes) | 146 if (needToCheckForDuplicateNodes) |
| 147 resultIsSorted = false; | 147 resultIsSorted = false; |
| 148 | 148 |
| 149 // This is a simplified check that can be improved to handle more cases. | 149 // This is a simplified check that can be improved to handle more cases. |
| 150 if (nodes.subtreesAreDisjoint() && (step->axis() == Step::ChildAxis || s
tep->axis() == Step::SelfAxis)) | 150 if (nodes.subtreesAreDisjoint() && (step->axis() == Step::ChildAxis || s
tep->axis() == Step::SelfAxis)) |
| 151 newNodes->markSubtreesDisjoint(true); | 151 newNodes->markSubtreesDisjoint(true); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 Value v = m_filter->evaluate(context); | 229 Value v = m_filter->evaluate(context); |
| 230 | 230 |
| 231 NodeSet& nodes = v.modifiableNodeSet(context); | 231 NodeSet& nodes = v.modifiableNodeSet(context); |
| 232 m_path->evaluate(context, nodes); | 232 m_path->evaluate(context, nodes); |
| 233 | 233 |
| 234 return v; | 234 return v; |
| 235 } | 235 } |
| 236 | 236 |
| 237 } | 237 } |
| 238 } | 238 } |
| OLD | NEW |