Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 class Event; | 38 class Event; |
| 39 class TouchList; | 39 class TouchList; |
| 40 | 40 |
| 41 class TouchEventContext : public RefCounted<TouchEventContext> { | 41 class TouchEventContext : public RefCounted<TouchEventContext> { |
| 42 public: | 42 public: |
| 43 static PassRefPtr<TouchEventContext> create(); | 43 static PassRefPtr<TouchEventContext> create(); |
| 44 ~TouchEventContext(); | 44 ~TouchEventContext(); |
| 45 void handleLocalEvents(Event*) const; | 45 void handleLocalEvents(Event*) const; |
| 46 TouchList* touches() { return m_touches.get(); } | 46 TouchList& touches() { return *m_touches; } |
| 47 TouchList* targetTouches() { return m_targetTouches.get(); } | 47 TouchList& targetTouches() { return *m_targetTouches; } |
| 48 TouchList* changedTouches() { return m_changedTouches.get(); } | 48 TouchList& changedTouches() { return *m_changedTouches; } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 TouchEventContext(); | 51 TouchEventContext(); |
| 52 | 52 |
| 53 RefPtr<TouchList> m_touches; | 53 RefPtr<TouchList> m_touches; |
| 54 RefPtr<TouchList> m_targetTouches; | 54 RefPtr<TouchList> m_targetTouches; |
| 55 RefPtr<TouchList> m_changedTouches; | 55 RefPtr<TouchList> m_changedTouches; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class EventContext { | 58 class SharedEventContext : public RefCounted<SharedEventContext> { |
|
dglazkov
2013/12/26 17:30:13
"Shared" is a bit too vague here. To be fair, "Eve
| |
| 59 public: | 59 public: |
| 60 // FIXME: Use ContainerNode instead of Node. | 60 static PassRefPtr<SharedEventContext> create(TreeScope&); |
| 61 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget); | 61 ~SharedEventContext(); |
| 62 ~EventContext(); | |
| 63 | 62 |
| 64 Node* node() const { return m_node.get(); } | 63 TreeScope& treeScope() const { return m_treeScope; } |
| 65 EventTarget* currentTarget() const { return m_currentTarget.get(); } | |
| 66 | 64 |
| 67 EventTarget* target() const { return m_target.get(); } | 65 EventTarget* target() const { return m_target.get(); } |
| 68 void setTarget(PassRefPtr<EventTarget>); | 66 void setTarget(PassRefPtr<EventTarget>); |
| 69 | 67 |
| 70 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } | 68 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } |
| 71 void setRelatedTarget(PassRefPtr<EventTarget>); | 69 void setRelatedTarget(PassRefPtr<EventTarget>); |
| 72 | 70 |
| 73 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } | 71 TouchEventContext* touchEventContext() const { return m_touchEventContext.ge t(); } |
| 74 TouchEventContext* ensureTouchEventContext(); | 72 TouchEventContext* ensureTouchEventContext(); |
| 75 | 73 |
| 76 PassRefPtr<NodeList> eventPath() const { return m_eventPath; } | 74 PassRefPtr<NodeList> eventPath() const { return m_eventPath; } |
| 77 void adoptEventPath(Vector<RefPtr<Node> >&); | 75 void adoptEventPath(Vector<RefPtr<Node> >&); |
| 78 void setEventPath(PassRefPtr<NodeList> nodeList) { m_eventPath = nodeList; } | |
| 79 | 76 |
| 80 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t arget.get(); } | 77 private: |
| 81 void handleLocalEvents(Event*) const; | 78 SharedEventContext(TreeScope&); |
| 82 | 79 |
| 83 protected: | |
| 84 #ifndef NDEBUG | 80 #ifndef NDEBUG |
| 85 bool isUnreachableNode(EventTarget*); | 81 bool isUnreachableNode(EventTarget*); |
| 86 #endif | 82 #endif |
| 87 RefPtr<Node> m_node; | 83 |
| 88 RefPtr<EventTarget> m_currentTarget; | 84 TreeScope& m_treeScope; |
| 89 RefPtr<EventTarget> m_target; | 85 RefPtr<EventTarget> m_target; |
| 90 RefPtr<EventTarget> m_relatedTarget; | 86 RefPtr<EventTarget> m_relatedTarget; |
| 91 RefPtr<NodeList> m_eventPath; | 87 RefPtr<NodeList> m_eventPath; |
| 92 RefPtr<TouchEventContext> m_touchEventContext; | 88 RefPtr<TouchEventContext> m_touchEventContext; |
| 93 }; | 89 }; |
| 94 | 90 |
| 91 class EventContext { | |
| 92 public: | |
| 93 // FIXME: Use ContainerNode instead of Node. | |
| 94 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget); | |
| 95 ~EventContext(); | |
| 96 | |
| 97 Node* node() const { return m_node.get(); } | |
| 98 EventTarget* currentTarget() const { return m_currentTarget.get(); } | |
| 99 | |
| 100 SharedEventContext* sharedEventContext() const { return m_sharedEventContext .get(); } | |
| 101 void setSharedEventContext(PassRefPtr<SharedEventContext> sharedEventContext ) { m_sharedEventContext = sharedEventContext; } | |
| 102 | |
| 103 EventTarget* target() const { return m_sharedEventContext->target(); } | |
| 104 EventTarget* relatedTarget() const { return m_sharedEventContext->relatedTar get(); } | |
| 105 TouchEventContext* touchEventContext() const { return m_sharedEventContext-> touchEventContext(); } | |
| 106 PassRefPtr<NodeList> eventPath() const { return m_sharedEventContext->eventP ath(); } | |
| 107 | |
| 108 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == tar get(); } | |
| 109 void handleLocalEvents(Event*) const; | |
| 110 | |
| 111 private: | |
| 112 RefPtr<Node> m_node; | |
| 113 RefPtr<EventTarget> m_currentTarget; | |
| 114 RefPtr<SharedEventContext> m_sharedEventContext; | |
| 115 }; | |
| 116 | |
| 95 #ifndef NDEBUG | 117 #ifndef NDEBUG |
| 96 inline bool EventContext::isUnreachableNode(EventTarget* target) | 118 inline bool SharedEventContext::isUnreachableNode(EventTarget* target) |
| 97 { | 119 { |
| 98 // FIXME: Checks also for SVG elements. | 120 // FIXME: Checks also for SVG elements. |
| 99 return target && target->toNode() && !target->toNode()->isSVGElement() && !t arget->toNode()->treeScope().isInclusiveAncestorOf(m_node->treeScope()); | 121 return target && target->toNode() && !target->toNode()->isSVGElement() && !t arget->toNode()->treeScope().isInclusiveAncestorOf(m_treeScope); |
| 100 } | 122 } |
| 101 #endif | 123 #endif |
| 102 | 124 |
| 103 inline void EventContext::setTarget(PassRefPtr<EventTarget> target) | 125 inline void SharedEventContext::setTarget(PassRefPtr<EventTarget> target) |
| 104 { | 126 { |
| 105 ASSERT(!isUnreachableNode(target.get())); | 127 ASSERT(!isUnreachableNode(target.get())); |
| 106 m_target = target; | 128 m_target = target; |
| 107 } | 129 } |
| 108 | 130 |
| 109 inline void EventContext::setRelatedTarget(PassRefPtr<EventTarget> relatedTarget ) | 131 inline void SharedEventContext::setRelatedTarget(PassRefPtr<EventTarget> related Target) |
| 110 { | 132 { |
| 111 ASSERT(!isUnreachableNode(relatedTarget.get())); | 133 ASSERT(!isUnreachableNode(relatedTarget.get())); |
| 112 m_relatedTarget = relatedTarget; | 134 m_relatedTarget = relatedTarget; |
| 113 } | 135 } |
| 114 | 136 |
| 115 } | 137 } |
| 116 | 138 |
| 117 #endif // EventContext_h | 139 #endif // EventContext_h |
| OLD | NEW |