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

Side by Side Diff: Source/core/events/Event.h

Issue 26558004: Revert 158219 "Move dom/*Event* to events to match the DOM vs. E..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1651/
Patch Set: Created 7 years, 2 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/events/ErrorEvent.idl ('k') | Source/core/events/Event.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #ifndef Event_h
25 #define Event_h
26
27 #include "bindings/v8/ScriptWrappable.h"
28 #include "core/dom/DOMTimeStamp.h"
29 #include "core/events/EventContext.h"
30 #include "wtf/RefCounted.h"
31 #include "wtf/text/AtomicString.h"
32
33 namespace WebCore {
34
35 class Clipboard;
36 class EventTarget;
37 class EventDispatcher;
38 class HTMLIFrameElement;
39
40 struct EventInit {
41 EventInit();
42
43 bool bubbles;
44 bool cancelable;
45 };
46
47 class Event : public ScriptWrappable, public RefCounted<Event> {
48 public:
49 enum PhaseType {
50 NONE = 0,
51 CAPTURING_PHASE = 1,
52 AT_TARGET = 2,
53 BUBBLING_PHASE = 3
54 };
55
56 enum EventType {
57 MOUSEDOWN = 1,
58 MOUSEUP = 2,
59 MOUSEOVER = 4,
60 MOUSEOUT = 8,
61 MOUSEMOVE = 16,
62 MOUSEDRAG = 32,
63 CLICK = 64,
64 DBLCLICK = 128,
65 KEYDOWN = 256,
66 KEYUP = 512,
67 KEYPRESS = 1024,
68 DRAGDROP = 2048,
69 FOCUS = 4096,
70 BLUR = 8192,
71 SELECT = 16384,
72 CHANGE = 32768
73 };
74
75 static PassRefPtr<Event> create()
76 {
77 return adoptRef(new Event);
78 }
79
80 // A factory for a simple event. The event doesn't bubble, and isn't
81 // cancelable.
82 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.ht ml#fire-a-simple-event
83 static PassRefPtr<Event> create(const AtomicString& type)
84 {
85 return adoptRef(new Event(type, false, false));
86 }
87 static PassRefPtr<Event> createCancelable(const AtomicString& type)
88 {
89 return adoptRef(new Event(type, false, true));
90 }
91 static PassRefPtr<Event> createBubble(const AtomicString& type)
92 {
93 return adoptRef(new Event(type, true, false));
94 }
95 static PassRefPtr<Event> createCancelableBubble(const AtomicString& type)
96 {
97 return adoptRef(new Event(type, true, true));
98 }
99
100 static PassRefPtr<Event> create(const AtomicString& type, const EventInit& i nitializer)
101 {
102 return adoptRef(new Event(type, initializer));
103 }
104
105 virtual ~Event();
106
107 void initEvent(const AtomicString& type, bool canBubble, bool cancelable);
108
109 const AtomicString& type() const { return m_type; }
110 void setType(const AtomicString& type) { m_type = type; }
111
112 EventTarget* target() const { return m_target.get(); }
113 void setTarget(PassRefPtr<EventTarget>);
114
115 EventTarget* currentTarget() const { return m_currentTarget; }
116 void setCurrentTarget(EventTarget* currentTarget) { m_currentTarget = curren tTarget; }
117
118 unsigned short eventPhase() const { return m_eventPhase; }
119 void setEventPhase(unsigned short eventPhase) { m_eventPhase = eventPhase; }
120
121 bool bubbles() const { return m_canBubble; }
122 bool cancelable() const { return m_cancelable; }
123 DOMTimeStamp timeStamp() const { return m_createTime; }
124
125 void stopPropagation() { m_propagationStopped = true; }
126 void stopImmediatePropagation() { m_immediatePropagationStopped = true; }
127
128 // IE Extensions
129 EventTarget* srcElement() const { return target(); } // MSIE extension - "th e object that fired the event"
130
131 bool legacyReturnValue() const { return !defaultPrevented(); }
132 void setLegacyReturnValue(bool returnValue) { setDefaultPrevented(!returnVal ue); }
133
134 Clipboard* clipboardData() const { return isClipboardEvent() ? clipboard() : 0; }
135
136 virtual const AtomicString& interfaceName() const;
137 bool hasInterface(const AtomicString&) const;
138
139 // These events are general classes of events.
140 virtual bool isUIEvent() const;
141 virtual bool isMouseEvent() const;
142 virtual bool isFocusEvent() const;
143 virtual bool isKeyboardEvent() const;
144 virtual bool isTouchEvent() const;
145
146 // Drag events are a subset of mouse events.
147 virtual bool isDragEvent() const;
148
149 // These events lack a DOM interface.
150 virtual bool isClipboardEvent() const;
151 virtual bool isBeforeTextInsertedEvent() const;
152
153 virtual bool isBeforeUnloadEvent() const;
154
155 bool propagationStopped() const { return m_propagationStopped || m_immediate PropagationStopped; }
156 bool immediatePropagationStopped() const { return m_immediatePropagationStop ped; }
157
158 bool defaultPrevented() const { return m_defaultPrevented; }
159 void preventDefault()
160 {
161 if (m_cancelable)
162 m_defaultPrevented = true;
163 }
164 void setDefaultPrevented(bool defaultPrevented) { m_defaultPrevented = defau ltPrevented; }
165
166 bool defaultHandled() const { return m_defaultHandled; }
167 void setDefaultHandled() { m_defaultHandled = true; }
168
169 bool cancelBubble() const { return m_cancelBubble; }
170 void setCancelBubble(bool cancel) { m_cancelBubble = cancel; }
171
172 Event* underlyingEvent() const { return m_underlyingEvent.get(); }
173 void setUnderlyingEvent(PassRefPtr<Event>);
174
175 EventPath& eventPath() { return m_eventPath; }
176 PassRefPtr<NodeList> path() const;
177
178 virtual Clipboard* clipboard() const { return 0; }
179
180 bool isBeingDispatched() const { return eventPhase(); }
181
182 protected:
183 Event();
184 Event(const AtomicString& type, bool canBubble, bool cancelable);
185 Event(const AtomicString& type, const EventInit&);
186
187 virtual void receivedTarget();
188 bool dispatched() const { return m_target; }
189
190 private:
191 AtomicString m_type;
192 bool m_canBubble;
193 bool m_cancelable;
194
195 bool m_propagationStopped;
196 bool m_immediatePropagationStopped;
197 bool m_defaultPrevented;
198 bool m_defaultHandled;
199 bool m_cancelBubble;
200
201 unsigned short m_eventPhase;
202 EventTarget* m_currentTarget;
203 RefPtr<EventTarget> m_target;
204 DOMTimeStamp m_createTime;
205 RefPtr<Event> m_underlyingEvent;
206 EventPath m_eventPath;
207 };
208
209 } // namespace WebCore
210
211 #endif // Event_h
OLDNEW
« no previous file with comments | « Source/core/events/ErrorEvent.idl ('k') | Source/core/events/Event.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698