OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 * | 24 * |
25 */ | 25 */ |
26 | 26 |
27 #ifndef EventContext_h | 27 #ifndef EventContext_h |
28 #define EventContext_h | 28 #define EventContext_h |
29 | 29 |
30 #include "core/dom/EventTarget.h" | 30 #include "core/dom/EventTarget.h" |
31 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
| 32 #include "core/dom/StaticNodeList.h" |
32 #include "core/dom/TreeScope.h" | 33 #include "core/dom/TreeScope.h" |
33 #include <wtf/RefPtr.h> | 34 #include <wtf/RefPtr.h> |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 class Event; | 38 class Event; |
38 class TouchList; | 39 class TouchList; |
39 | 40 |
40 class EventContext { | 41 class EventContext { |
41 public: | 42 public: |
42 // FIXME: Use ContainerNode instead of Node. | 43 // FIXME: Use ContainerNode instead of Node. |
43 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRe
fPtr<EventTarget> target); | 44 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRe
fPtr<EventTarget> target); |
44 virtual ~EventContext(); | 45 virtual ~EventContext(); |
45 | 46 |
46 Node* node() const { return m_node.get(); } | 47 Node* node() const { return m_node.get(); } |
47 EventTarget* target() const { return m_target.get(); } | 48 EventTarget* target() const { return m_target.get(); } |
| 49 PassRefPtr<NodeList> eventPath() { return m_eventPath; } |
| 50 void adoptEventPath(Vector<RefPtr<Node> >&); |
| 51 void setEventPath(PassRefPtr<NodeList> nodeList) { m_eventPath = nodeList; } |
| 52 |
48 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t
arget.get(); } | 53 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t
arget.get(); } |
49 virtual void handleLocalEvents(Event*) const; | 54 virtual void handleLocalEvents(Event*) const; |
50 virtual bool isMouseOrFocusEventContext() const; | 55 virtual bool isMouseOrFocusEventContext() const; |
51 virtual bool isTouchEventContext() const; | 56 virtual bool isTouchEventContext() const; |
52 | 57 |
53 protected: | 58 protected: |
54 #ifndef NDEBUG | 59 #ifndef NDEBUG |
55 bool isUnreachableNode(EventTarget*); | 60 bool isUnreachableNode(EventTarget*); |
56 #endif | 61 #endif |
57 RefPtr<Node> m_node; | 62 RefPtr<Node> m_node; |
58 RefPtr<EventTarget> m_currentTarget; | 63 RefPtr<EventTarget> m_currentTarget; |
59 RefPtr<EventTarget> m_target; | 64 RefPtr<EventTarget> m_target; |
| 65 RefPtr<NodeList> m_eventPath; |
60 }; | 66 }; |
61 | 67 |
62 typedef Vector<OwnPtr<EventContext>, 32> EventPath; | 68 typedef Vector<OwnPtr<EventContext>, 32> EventPath; |
63 | 69 |
64 class MouseOrFocusEventContext : public EventContext { | 70 class MouseOrFocusEventContext : public EventContext { |
65 public: | 71 public: |
66 MouseOrFocusEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTa
rget, PassRefPtr<EventTarget> target); | 72 MouseOrFocusEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTa
rget, PassRefPtr<EventTarget> target); |
67 virtual ~MouseOrFocusEventContext(); | 73 virtual ~MouseOrFocusEventContext(); |
68 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 74 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
69 void setRelatedTarget(PassRefPtr<EventTarget>); | 75 void setRelatedTarget(PassRefPtr<EventTarget>); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 118 |
113 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r
elatedTarget) | 119 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r
elatedTarget) |
114 { | 120 { |
115 ASSERT(!isUnreachableNode(relatedTarget.get())); | 121 ASSERT(!isUnreachableNode(relatedTarget.get())); |
116 m_relatedTarget = relatedTarget; | 122 m_relatedTarget = relatedTarget; |
117 } | 123 } |
118 | 124 |
119 } | 125 } |
120 | 126 |
121 #endif // EventContext_h | 127 #endif // EventContext_h |
OLD | NEW |