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, 2013 Apple Inc. All rights reserved.
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.
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.
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.
26 #include "EventTarget.h"
27 #include "UserGestureIndicator.h"
28 #include <wtf/CurrentTime.h>
32 EventInit::EventInit()
38 EventInit::EventInit(bool b, bool c)
45 : m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
49 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg)
50 : m_isInitialized(true)
52 , m_canBubble(canBubbleArg)
53 , m_cancelable(cancelableArg)
54 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
58 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, double timestamp)
59 : m_isInitialized(true)
61 , m_canBubble(canBubbleArg)
62 , m_cancelable(cancelableArg)
63 , m_createTime(convertSecondsToDOMTimeStamp(timestamp))
67 Event::Event(const AtomicString& eventType, const EventInit& initializer)
68 : m_isInitialized(true)
70 , m_canBubble(initializer.bubbles)
71 , m_cancelable(initializer.cancelable)
72 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
80 void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg)
85 m_isInitialized = true;
86 m_propagationStopped = false;
87 m_immediatePropagationStopped = false;
88 m_defaultPrevented = false;
90 m_type = eventTypeArg;
91 m_canBubble = canBubbleArg;
92 m_cancelable = cancelableArg;
95 EventInterface Event::eventInterface() const
97 return EventInterfaceType;
100 bool Event::isUIEvent() const
105 bool Event::isMouseEvent() const
110 bool Event::isFocusEvent() const
115 bool Event::isKeyboardEvent() const
120 bool Event::isTouchEvent() const
125 bool Event::isDragEvent() const
130 bool Event::isClipboardEvent() const
135 bool Event::isBeforeTextInsertedEvent() const
140 bool Event::isBeforeUnloadEvent() const
145 bool Event::isErrorEvent() const
150 bool Event::isTextEvent() const
155 bool Event::isWheelEvent() const
160 PassRefPtr<Event> Event::cloneFor(HTMLIFrameElement*) const
162 return Event::create(type(), bubbles(), cancelable());
165 void Event::setTarget(PassRefPtr<EventTarget> target)
167 if (m_target == target)
175 void Event::receivedTarget()
179 void Event::setUnderlyingEvent(PassRefPtr<Event> ue)
181 // Prohibit creation of a cycle -- just do nothing in that case.
182 for (Event* e = ue.get(); e; e = e->underlyingEvent())
185 m_underlyingEvent = ue;
188 } // namespace WebCore