| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 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. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 * | 21 * |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #ifndef Event_h | 24 #ifndef Event_h |
| 25 #define Event_h | 25 #define Event_h |
| 26 | 26 |
| 27 #include "bindings/core/v8/ScriptWrappable.h" | 27 #include "bindings/core/v8/ScriptWrappable.h" |
| 28 #include "core/CoreExport.h" | 28 #include "core/CoreExport.h" |
| 29 #include "core/dom/DOMTimeStamp.h" | 29 #include "core/dom/DOMTimeStamp.h" |
| 30 #include "core/events/EventInitDictionary.h" | 30 #include "core/events/EventInit.h" |
| 31 #include "core/events/EventPath.h" | 31 #include "core/events/EventPath.h" |
| 32 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
| 33 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
| 34 #include "wtf/text/AtomicString.h" | 34 #include "wtf/text/AtomicString.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 class EventTarget; | 38 class EventTarget; |
| 39 class ExecutionContext; | 39 class ExecutionContext; |
| 40 | 40 |
| 41 struct EventInit { | |
| 42 STACK_ALLOCATED(); | |
| 43 public: | |
| 44 EventInit(); | |
| 45 | |
| 46 bool bubbles; | |
| 47 bool cancelable; | |
| 48 }; | |
| 49 | |
| 50 class CORE_EXPORT Event : public RefCountedWillBeGarbageCollectedFinalized<Event
>, public ScriptWrappable { | 41 class CORE_EXPORT Event : public RefCountedWillBeGarbageCollectedFinalized<Event
>, public ScriptWrappable { |
| 51 DEFINE_WRAPPERTYPEINFO(); | 42 DEFINE_WRAPPERTYPEINFO(); |
| 52 public: | 43 public: |
| 53 enum PhaseType { | 44 enum PhaseType { |
| 54 NONE = 0, | 45 NONE = 0, |
| 55 CAPTURING_PHASE = 1, | 46 CAPTURING_PHASE = 1, |
| 56 AT_TARGET = 2, | 47 AT_TARGET = 2, |
| 57 BUBBLING_PHASE = 3 | 48 BUBBLING_PHASE = 3 |
| 58 }; | 49 }; |
| 59 | 50 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 91 } |
| 101 static PassRefPtrWillBeRawPtr<Event> createBubble(const AtomicString& type) | 92 static PassRefPtrWillBeRawPtr<Event> createBubble(const AtomicString& type) |
| 102 { | 93 { |
| 103 return adoptRefWillBeNoop(new Event(type, true, false)); | 94 return adoptRefWillBeNoop(new Event(type, true, false)); |
| 104 } | 95 } |
| 105 static PassRefPtrWillBeRawPtr<Event> createCancelableBubble(const AtomicStri
ng& type) | 96 static PassRefPtrWillBeRawPtr<Event> createCancelableBubble(const AtomicStri
ng& type) |
| 106 { | 97 { |
| 107 return adoptRefWillBeNoop(new Event(type, true, true)); | 98 return adoptRefWillBeNoop(new Event(type, true, true)); |
| 108 } | 99 } |
| 109 | 100 |
| 110 // TODO(bashi): Remove this when we remove all [EventConstructor]. | |
| 111 static PassRefPtrWillBeRawPtr<Event> create(const AtomicString& type, const
EventInit& initializer) | 101 static PassRefPtrWillBeRawPtr<Event> create(const AtomicString& type, const
EventInit& initializer) |
| 112 { | 102 { |
| 113 return adoptRefWillBeNoop(new Event(type, initializer)); | 103 return adoptRefWillBeNoop(new Event(type, initializer)); |
| 114 } | 104 } |
| 115 static PassRefPtrWillBeRawPtr<Event> create(const AtomicString& type, const
EventInitDictionary& initializer) | |
| 116 { | |
| 117 return adoptRefWillBeNoop(new Event(type, initializer)); | |
| 118 } | |
| 119 | 105 |
| 120 virtual ~Event(); | 106 virtual ~Event(); |
| 121 | 107 |
| 122 void initEvent(const AtomicString& type, bool canBubble, bool cancelable); | 108 void initEvent(const AtomicString& type, bool canBubble, bool cancelable); |
| 123 | 109 |
| 124 const AtomicString& type() const { return m_type; } | 110 const AtomicString& type() const { return m_type; } |
| 125 void setType(const AtomicString& type) { m_type = type; } | 111 void setType(const AtomicString& type) { m_type = type; } |
| 126 | 112 |
| 127 EventTarget* target() const { return m_target.get(); } | 113 EventTarget* target() const { return m_target.get(); } |
| 128 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); | 114 void setTarget(PassRefPtrWillBeRawPtr<EventTarget>); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 184 |
| 199 double uiCreateTime() const { return m_uiCreateTime; } | 185 double uiCreateTime() const { return m_uiCreateTime; } |
| 200 void setUICreateTime(double uiCreateTime) { m_uiCreateTime = uiCreateTime; } | 186 void setUICreateTime(double uiCreateTime) { m_uiCreateTime = uiCreateTime; } |
| 201 | 187 |
| 202 DECLARE_VIRTUAL_TRACE(); | 188 DECLARE_VIRTUAL_TRACE(); |
| 203 | 189 |
| 204 protected: | 190 protected: |
| 205 Event(); | 191 Event(); |
| 206 Event(const AtomicString& type, bool canBubble, bool cancelable); | 192 Event(const AtomicString& type, bool canBubble, bool cancelable); |
| 207 Event(const AtomicString& type, const EventInit&); | 193 Event(const AtomicString& type, const EventInit&); |
| 208 Event(const AtomicString& type, const EventInitDictionary&); | |
| 209 | 194 |
| 210 virtual void receivedTarget(); | 195 virtual void receivedTarget(); |
| 211 bool dispatched() const { return m_target; } | 196 bool dispatched() const { return m_target; } |
| 212 | 197 |
| 213 void setCanBubble(bool bubble) { m_canBubble = bubble; } | 198 void setCanBubble(bool bubble) { m_canBubble = bubble; } |
| 214 | 199 |
| 215 private: | 200 private: |
| 216 AtomicString m_type; | 201 AtomicString m_type; |
| 217 bool m_canBubble; | 202 bool m_canBubble; |
| 218 bool m_cancelable; | 203 bool m_cancelable; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 231 OwnPtrWillBeMember<EventPath> m_eventPath; | 216 OwnPtrWillBeMember<EventPath> m_eventPath; |
| 232 double m_uiCreateTime; // For input events, the time the event was recorded
by the UI. | 217 double m_uiCreateTime; // For input events, the time the event was recorded
by the UI. |
| 233 }; | 218 }; |
| 234 | 219 |
| 235 #define DEFINE_EVENT_TYPE_CASTS(typeName) \ | 220 #define DEFINE_EVENT_TYPE_CASTS(typeName) \ |
| 236 DEFINE_TYPE_CASTS(typeName, Event, event, event->is##typeName(), event.is##t
ypeName()) | 221 DEFINE_TYPE_CASTS(typeName, Event, event, event->is##typeName(), event.is##t
ypeName()) |
| 237 | 222 |
| 238 } // namespace blink | 223 } // namespace blink |
| 239 | 224 |
| 240 #endif // Event_h | 225 #endif // Event_h |
| OLD | NEW |