OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> |
3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
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 13 matching lines...) Expand all Loading... |
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "XPathResult.h" | 28 #include "XPathResult.h" |
29 | 29 |
30 #if ENABLE(XPATH) | 30 #if ENABLE(XPATH) |
31 | 31 |
32 #include "EventListener.h" | 32 #include "EventListener.h" |
33 #include "EventNames.h" | 33 #include "EventNames.h" |
34 #include "Node.h" | 34 #include "EventTargetNode.h" |
35 #include "ExceptionCode.h" | 35 #include "ExceptionCode.h" |
36 #include "XPathEvaluator.h" | 36 #include "XPathEvaluator.h" |
37 #include "XPathException.h" | 37 #include "XPathException.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 using namespace XPath; | 41 using namespace XPath; |
42 | 42 |
43 class InvalidatingEventListener : public EventListener { | 43 class InvalidatingEventListener : public EventListener { |
44 public: | 44 public: |
45 static PassRefPtr<InvalidatingEventListener> create(XPathResult* result) { r
eturn adoptRef(new InvalidatingEventListener(result)); } | 45 static PassRefPtr<InvalidatingEventListener> create(XPathResult* result) { r
eturn adoptRef(new InvalidatingEventListener(result)); } |
46 virtual void handleEvent(Event*, bool) { m_result->invalidateIteratorState()
; } | 46 virtual void handleEvent(Event*, bool) { m_result->invalidateIteratorState()
; } |
47 | 47 |
48 private: | 48 private: |
49 InvalidatingEventListener(XPathResult* result) : m_result(result) { } | 49 InvalidatingEventListener(XPathResult* result) : m_result(result) { } |
50 XPathResult* m_result; | 50 XPathResult* m_result; |
51 }; | 51 }; |
52 | 52 |
53 XPathResult::XPathResult(Node* eventTarget, const Value& value) | 53 XPathResult::XPathResult(EventTargetNode* eventTarget, const Value& value) |
54 : m_value(value) | 54 : m_value(value) |
55 , m_eventTarget(eventTarget) | 55 , m_eventTarget(eventTarget) |
56 { | 56 { |
57 m_eventListener = InvalidatingEventListener::create(this); | 57 m_eventListener = InvalidatingEventListener::create(this); |
58 m_eventTarget->addEventListener(eventNames().DOMSubtreeModifiedEvent, m_even
tListener, false); | 58 m_eventTarget->addEventListener(eventNames().DOMSubtreeModifiedEvent, m_even
tListener, false); |
59 switch (m_value.type()) { | 59 switch (m_value.type()) { |
60 case Value::BooleanValue: | 60 case Value::BooleanValue: |
61 m_resultType = BOOLEAN_TYPE; | 61 m_resultType = BOOLEAN_TYPE; |
62 return; | 62 return; |
63 case Value::NumberValue: | 63 case Value::NumberValue: |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 const NodeSet& nodes = m_value.toNodeSet(); | 236 const NodeSet& nodes = m_value.toNodeSet(); |
237 if (index >= nodes.size()) | 237 if (index >= nodes.size()) |
238 return 0; | 238 return 0; |
239 | 239 |
240 return nodes[index]; | 240 return nodes[index]; |
241 } | 241 } |
242 | 242 |
243 } | 243 } |
244 | 244 |
245 #endif // ENABLE(XPATH) | 245 #endif // ENABLE(XPATH) |
OLD | NEW |