| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 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 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 using namespace XPath; | 37 using namespace XPath; |
| 38 | 38 |
| 39 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(XPathResult); |
| 40 |
| 39 XPathResult::XPathResult(Document* document, const Value& value) | 41 XPathResult::XPathResult(Document* document, const Value& value) |
| 40 : m_value(value) | 42 : m_value(value) |
| 41 , m_nodeSetPosition(0) | 43 , m_nodeSetPosition(0) |
| 42 , m_domTreeVersion(0) | 44 , m_domTreeVersion(0) |
| 43 { | 45 { |
| 44 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
| 45 switch (m_value.type()) { | 47 switch (m_value.type()) { |
| 46 case Value::BooleanValue: | 48 case Value::BooleanValue: |
| 47 m_resultType = BOOLEAN_TYPE; | 49 m_resultType = BOOLEAN_TYPE; |
| 48 return; | 50 return; |
| 49 case Value::NumberValue: | 51 case Value::NumberValue: |
| 50 m_resultType = NUMBER_TYPE; | 52 m_resultType = NUMBER_TYPE; |
| 51 return; | 53 return; |
| 52 case Value::StringValue: | 54 case Value::StringValue: |
| 53 m_resultType = STRING_TYPE; | 55 m_resultType = STRING_TYPE; |
| 54 return; | 56 return; |
| 55 case Value::NodeSetValue: | 57 case Value::NodeSetValue: |
| 56 m_resultType = UNORDERED_NODE_ITERATOR_TYPE; | 58 m_resultType = UNORDERED_NODE_ITERATOR_TYPE; |
| 57 m_nodeSetPosition = 0; | 59 m_nodeSetPosition = 0; |
| 58 m_nodeSet = NodeSet::create(m_value.toNodeSet()); | 60 m_nodeSet = NodeSet::create(m_value.toNodeSet()); |
| 59 m_document = document; | 61 m_document = document; |
| 60 m_domTreeVersion = document->domTreeVersion(); | 62 m_domTreeVersion = document->domTreeVersion(); |
| 61 return; | 63 return; |
| 62 } | 64 } |
| 63 ASSERT_NOT_REACHED(); | 65 ASSERT_NOT_REACHED(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 XPathResult::~XPathResult() | |
| 67 { | |
| 68 } | |
| 69 | |
| 70 void XPathResult::trace(Visitor* visitor) | 68 void XPathResult::trace(Visitor* visitor) |
| 71 { | 69 { |
| 72 visitor->trace(m_value); | 70 visitor->trace(m_value); |
| 73 visitor->trace(m_nodeSet); | 71 visitor->trace(m_nodeSet); |
| 74 visitor->trace(m_document); | 72 visitor->trace(m_document); |
| 75 } | 73 } |
| 76 | 74 |
| 77 void XPathResult::convertTo(unsigned short type, ExceptionState& exceptionState) | 75 void XPathResult::convertTo(unsigned short type, ExceptionState& exceptionState) |
| 78 { | 76 { |
| 79 switch (type) { | 77 switch (type) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 213 } |
| 216 | 214 |
| 217 const NodeSet& nodes = m_value.toNodeSet(); | 215 const NodeSet& nodes = m_value.toNodeSet(); |
| 218 if (index >= nodes.size()) | 216 if (index >= nodes.size()) |
| 219 return 0; | 217 return 0; |
| 220 | 218 |
| 221 return nodes[index]; | 219 return nodes[index]; |
| 222 } | 220 } |
| 223 | 221 |
| 224 } | 222 } |
| OLD | NEW |