| 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. All rights reserved. | 3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/xml/XPathEvaluator.h" | 33 #include "core/xml/XPathEvaluator.h" |
| 34 #include "core/xml/XPathExpressionNode.h" | 34 #include "core/xml/XPathExpressionNode.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 using namespace XPath; | 38 using namespace XPath; |
| 39 | 39 |
| 40 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(XPathResult); | |
| 41 | |
| 42 XPathResult::XPathResult(EvaluationContext& context, const Value& value) | 40 XPathResult::XPathResult(EvaluationContext& context, const Value& value) |
| 43 : m_value(value) | 41 : m_value(value) |
| 44 , m_nodeSetPosition(0) | 42 , m_nodeSetPosition(0) |
| 45 , m_domTreeVersion(0) | 43 , m_domTreeVersion(0) |
| 46 { | 44 { |
| 47 switch (m_value.type()) { | 45 switch (m_value.type()) { |
| 48 case Value::BooleanValue: | 46 case Value::BooleanValue: |
| 49 m_resultType = BOOLEAN_TYPE; | 47 m_resultType = BOOLEAN_TYPE; |
| 50 return; | 48 return; |
| 51 case Value::NumberValue: | 49 case Value::NumberValue: |
| 52 m_resultType = NUMBER_TYPE; | 50 m_resultType = NUMBER_TYPE; |
| 53 return; | 51 return; |
| 54 case Value::StringValue: | 52 case Value::StringValue: |
| 55 m_resultType = STRING_TYPE; | 53 m_resultType = STRING_TYPE; |
| 56 return; | 54 return; |
| 57 case Value::NodeSetValue: | 55 case Value::NodeSetValue: |
| 58 m_resultType = UNORDERED_NODE_ITERATOR_TYPE; | 56 m_resultType = UNORDERED_NODE_ITERATOR_TYPE; |
| 59 m_nodeSetPosition = 0; | 57 m_nodeSetPosition = 0; |
| 60 m_nodeSet = NodeSet::create(m_value.toNodeSet(&context)); | 58 m_nodeSet = NodeSet::create(m_value.toNodeSet(&context)); |
| 61 m_document = &context.node->document(); | 59 m_document = &context.node->document(); |
| 62 m_domTreeVersion = m_document->domTreeVersion(); | 60 m_domTreeVersion = m_document->domTreeVersion(); |
| 63 return; | 61 return; |
| 64 } | 62 } |
| 65 ASSERT_NOT_REACHED(); | 63 ASSERT_NOT_REACHED(); |
| 66 } | 64 } |
| 67 | 65 |
| 66 XPathResult::~XPathResult() |
| 67 { |
| 68 } |
| 69 |
| 68 void XPathResult::trace(Visitor* visitor) | 70 void XPathResult::trace(Visitor* visitor) |
| 69 { | 71 { |
| 70 visitor->trace(m_value); | 72 visitor->trace(m_value); |
| 71 visitor->trace(m_nodeSet); | 73 visitor->trace(m_nodeSet); |
| 72 visitor->trace(m_document); | 74 visitor->trace(m_document); |
| 73 } | 75 } |
| 74 | 76 |
| 75 void XPathResult::convertTo(unsigned short type, ExceptionState& exceptionState) | 77 void XPathResult::convertTo(unsigned short type, ExceptionState& exceptionState) |
| 76 { | 78 { |
| 77 switch (type) { | 79 switch (type) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 215 } |
| 214 | 216 |
| 215 const NodeSet& nodes = m_value.toNodeSet(0); | 217 const NodeSet& nodes = m_value.toNodeSet(0); |
| 216 if (index >= nodes.size()) | 218 if (index >= nodes.size()) |
| 217 return 0; | 219 return 0; |
| 218 | 220 |
| 219 return nodes[index]; | 221 return nodes[index]; |
| 220 } | 222 } |
| 221 | 223 |
| 222 } | 224 } |
| OLD | NEW |