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

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

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/Event.h ('k') | Source/core/events/Event.idl » ('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, 2005, 2006, 2008 Apple Inc. All rights reserved.
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 #include "config.h"
24 #include "core/events/Event.h"
25
26 #include "core/events/EventNames.h"
27 #include "core/events/EventTarget.h"
28 #include "core/dom/StaticNodeList.h"
29 #include "wtf/CurrentTime.h"
30 #include "wtf/text/AtomicString.h"
31
32 namespace WebCore {
33
34 EventInit::EventInit()
35 : bubbles(false)
36 , cancelable(false)
37 {
38 }
39
40
41 Event::Event()
42 : m_canBubble(false)
43 , m_cancelable(false)
44 , m_propagationStopped(false)
45 , m_immediatePropagationStopped(false)
46 , m_defaultPrevented(false)
47 , m_defaultHandled(false)
48 , m_cancelBubble(false)
49 , m_eventPhase(0)
50 , m_currentTarget(0)
51 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
52 {
53 ScriptWrappable::init(this);
54 }
55
56 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g)
57 : m_type(eventType)
58 , m_canBubble(canBubbleArg)
59 , m_cancelable(cancelableArg)
60 , m_propagationStopped(false)
61 , m_immediatePropagationStopped(false)
62 , m_defaultPrevented(false)
63 , m_defaultHandled(false)
64 , m_cancelBubble(false)
65 , m_eventPhase(0)
66 , m_currentTarget(0)
67 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
68 {
69 ScriptWrappable::init(this);
70 }
71
72 Event::Event(const AtomicString& eventType, const EventInit& initializer)
73 : m_type(eventType)
74 , m_canBubble(initializer.bubbles)
75 , m_cancelable(initializer.cancelable)
76 , m_propagationStopped(false)
77 , m_immediatePropagationStopped(false)
78 , m_defaultPrevented(false)
79 , m_defaultHandled(false)
80 , m_cancelBubble(false)
81 , m_eventPhase(0)
82 , m_currentTarget(0)
83 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
84 {
85 ScriptWrappable::init(this);
86 }
87
88 Event::~Event()
89 {
90 }
91
92 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg)
93 {
94 if (dispatched())
95 return;
96
97 m_propagationStopped = false;
98 m_immediatePropagationStopped = false;
99 m_defaultPrevented = false;
100
101 m_type = eventTypeArg;
102 m_canBubble = canBubbleArg;
103 m_cancelable = cancelableArg;
104 }
105
106 const AtomicString& Event::interfaceName() const
107 {
108 return eventNames().interfaceForEvent;
109 }
110
111 bool Event::hasInterface(const AtomicString& name) const
112 {
113 return interfaceName() == name;
114 }
115
116 bool Event::isUIEvent() const
117 {
118 return false;
119 }
120
121 bool Event::isMouseEvent() const
122 {
123 return false;
124 }
125
126 bool Event::isFocusEvent() const
127 {
128 return false;
129 }
130
131 bool Event::isKeyboardEvent() const
132 {
133 return false;
134 }
135
136 bool Event::isTouchEvent() const
137 {
138 return false;
139 }
140
141 bool Event::isDragEvent() const
142 {
143 return false;
144 }
145
146 bool Event::isClipboardEvent() const
147 {
148 return false;
149 }
150
151 bool Event::isBeforeTextInsertedEvent() const
152 {
153 return false;
154 }
155
156 bool Event::isBeforeUnloadEvent() const
157 {
158 return false;
159 }
160
161 void Event::setTarget(PassRefPtr<EventTarget> target)
162 {
163 if (m_target == target)
164 return;
165
166 m_target = target;
167 if (m_target)
168 receivedTarget();
169 }
170
171 void Event::receivedTarget()
172 {
173 }
174
175 void Event::setUnderlyingEvent(PassRefPtr<Event> ue)
176 {
177 // Prohibit creation of a cycle -- just do nothing in that case.
178 for (Event* e = ue.get(); e; e = e->underlyingEvent())
179 if (e == this)
180 return;
181 m_underlyingEvent = ue;
182 }
183
184 PassRefPtr<NodeList> Event::path() const
185 {
186 if (!m_currentTarget || !m_currentTarget->toNode())
187 return StaticNodeList::createEmpty();
188 Node* node = m_currentTarget->toNode();
189 size_t eventPathSize = m_eventPath.size();
190 for (size_t i = 0; i < eventPathSize; ++i) {
191 if (node == m_eventPath[i]->node()) {
192 ASSERT(m_eventPath[i]->eventPath());
193 return m_eventPath[i]->eventPath();
194 }
195 }
196 return StaticNodeList::createEmpty();
197 }
198
199 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/events/Event.h ('k') | Source/core/events/Event.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698