Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: Source/core/dom/EventContext.h

Issue 14296003: Remove TOUCH_EVENTS and TOUCH_EVENT_TRACKING compile-time flags. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.idl ('k') | Source/core/dom/EventContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #define EventContext_h 28 #define EventContext_h
29 29
30 #include "EventTarget.h" 30 #include "EventTarget.h"
31 #include "Node.h" 31 #include "Node.h"
32 #include "TreeScope.h" 32 #include "TreeScope.h"
33 #include <wtf/RefPtr.h> 33 #include <wtf/RefPtr.h>
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 class Event; 37 class Event;
38 #if ENABLE(TOUCH_EVENTS)
39 class TouchList; 38 class TouchList;
40 #endif
41 39
42 class EventContext { 40 class EventContext {
43 public: 41 public:
44 // FIXME: Use ContainerNode instead of Node. 42 // FIXME: Use ContainerNode instead of Node.
45 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRe fPtr<EventTarget> target); 43 EventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, PassRe fPtr<EventTarget> target);
46 virtual ~EventContext(); 44 virtual ~EventContext();
47 45
48 Node* node() const { return m_node.get(); } 46 Node* node() const { return m_node.get(); }
49 EventTarget* target() const { return m_target.get(); } 47 EventTarget* target() const { return m_target.get(); }
50 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t arget.get(); } 48 bool currentTargetSameAsTarget() const { return m_currentTarget.get() == m_t arget.get(); }
(...skipping 20 matching lines...) Expand all
71 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 69 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
72 void setRelatedTarget(PassRefPtr<EventTarget>); 70 void setRelatedTarget(PassRefPtr<EventTarget>);
73 virtual void handleLocalEvents(Event*) const OVERRIDE; 71 virtual void handleLocalEvents(Event*) const OVERRIDE;
74 virtual bool isMouseOrFocusEventContext() const OVERRIDE; 72 virtual bool isMouseOrFocusEventContext() const OVERRIDE;
75 73
76 private: 74 private:
77 RefPtr<EventTarget> m_relatedTarget; 75 RefPtr<EventTarget> m_relatedTarget;
78 }; 76 };
79 77
80 78
81 #if ENABLE(TOUCH_EVENTS)
82 class TouchEventContext : public EventContext { 79 class TouchEventContext : public EventContext {
83 public: 80 public:
84 TouchEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, P assRefPtr<EventTarget> target); 81 TouchEventContext(PassRefPtr<Node>, PassRefPtr<EventTarget> currentTarget, P assRefPtr<EventTarget> target);
85 virtual ~TouchEventContext(); 82 virtual ~TouchEventContext();
86 83
87 virtual void handleLocalEvents(Event*) const OVERRIDE; 84 virtual void handleLocalEvents(Event*) const OVERRIDE;
88 virtual bool isTouchEventContext() const OVERRIDE; 85 virtual bool isTouchEventContext() const OVERRIDE;
89 86
90 TouchList* touches() { return m_touches.get(); } 87 TouchList* touches() { return m_touches.get(); }
91 TouchList* targetTouches() { return m_targetTouches.get(); } 88 TouchList* targetTouches() { return m_targetTouches.get(); }
92 TouchList* changedTouches() { return m_changedTouches.get(); } 89 TouchList* changedTouches() { return m_changedTouches.get(); }
93 90
94 private: 91 private:
95 RefPtr<TouchList> m_touches; 92 RefPtr<TouchList> m_touches;
96 RefPtr<TouchList> m_targetTouches; 93 RefPtr<TouchList> m_targetTouches;
97 RefPtr<TouchList> m_changedTouches; 94 RefPtr<TouchList> m_changedTouches;
98 #ifndef NDEBUG 95 #ifndef NDEBUG
99 void checkReachability(TouchList*) const; 96 void checkReachability(TouchList*) const;
100 #endif 97 #endif
101 }; 98 };
102 99
103 inline TouchEventContext* toTouchEventContext(EventContext* eventContext) 100 inline TouchEventContext* toTouchEventContext(EventContext* eventContext)
104 { 101 {
105 ASSERT_WITH_SECURITY_IMPLICATION(!eventContext || eventContext->isTouchEvent Context()); 102 ASSERT_WITH_SECURITY_IMPLICATION(!eventContext || eventContext->isTouchEvent Context());
106 return static_cast<TouchEventContext*>(eventContext); 103 return static_cast<TouchEventContext*>(eventContext);
107 } 104 }
108 #endif // ENABLE(TOUCH_EVENTS)
109 105
110 #ifndef NDEBUG 106 #ifndef NDEBUG
111 inline bool EventContext::isUnreachableNode(EventTarget* target) 107 inline bool EventContext::isUnreachableNode(EventTarget* target)
112 { 108 {
113 // FIXME: Checks also for SVG elements. 109 // FIXME: Checks also for SVG elements.
114 return target && target->toNode() && !target->toNode()->isSVGElement() && !i sReachable(target->toNode()); 110 return target && target->toNode() && !target->toNode()->isSVGElement() && !i sReachable(target->toNode());
115 } 111 }
116 112
117 inline bool EventContext::isReachable(Node* target) const 113 inline bool EventContext::isReachable(Node* target) const
118 { 114 {
119 ASSERT(target); 115 ASSERT(target);
120 TreeScope* targetScope = target->treeScope(); 116 TreeScope* targetScope = target->treeScope();
121 for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTre eScope()) { 117 for (TreeScope* scope = m_node->treeScope(); scope; scope = scope->parentTre eScope()) {
122 if (scope == targetScope) 118 if (scope == targetScope)
123 return true; 119 return true;
124 } 120 }
125 return false; 121 return false;
126 } 122 }
127 #endif 123 #endif
128 124
129 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r elatedTarget) 125 inline void MouseOrFocusEventContext::setRelatedTarget(PassRefPtr<EventTarget> r elatedTarget)
130 { 126 {
131 ASSERT(!isUnreachableNode(relatedTarget.get())); 127 ASSERT(!isUnreachableNode(relatedTarget.get()));
132 m_relatedTarget = relatedTarget; 128 m_relatedTarget = relatedTarget;
133 } 129 }
134 130
135 } 131 }
136 132
137 #endif // EventContext_h 133 #endif // EventContext_h
OLDNEW
« no previous file with comments | « Source/core/dom/Element.idl ('k') | Source/core/dom/EventContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698