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, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. |
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. |
(...skipping 22 matching lines...) Expand all Loading... |
33 MouseEventInit::MouseEventInit() | 33 MouseEventInit::MouseEventInit() |
34 : screenX(0) | 34 : screenX(0) |
35 , screenY(0) | 35 , screenY(0) |
36 , clientX(0) | 36 , clientX(0) |
37 , clientY(0) | 37 , clientY(0) |
38 , ctrlKey(false) | 38 , ctrlKey(false) |
39 , altKey(false) | 39 , altKey(false) |
40 , shiftKey(false) | 40 , shiftKey(false) |
41 , metaKey(false) | 41 , metaKey(false) |
42 , button(0) | 42 , button(0) |
| 43 , buttons(0) |
43 , relatedTarget(nullptr) | 44 , relatedTarget(nullptr) |
44 { | 45 { |
45 } | 46 } |
46 | 47 |
47 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
const MouseEventInit& initializer) | 48 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
const MouseEventInit& initializer) |
48 { | 49 { |
49 return adoptRefWillBeNoop(new MouseEvent(type, initializer)); | 50 return adoptRefWillBeNoop(new MouseEvent(type, initializer)); |
50 } | 51 } |
51 | 52 |
52 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT
ype, PassRefPtrWillBeRawPtr<AbstractView> view, const PlatformMouseEvent& event,
int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget) | 53 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT
ype, PassRefPtrWillBeRawPtr<AbstractView> view, const PlatformMouseEvent& event,
int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget) |
53 { | 54 { |
54 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt
on); | 55 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt
on); |
55 | 56 |
56 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT
ype == EventTypeNames::mouseleave; | 57 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT
ype == EventTypeNames::mouseleave; |
57 bool isCancelable = !isMouseEnterOrLeave; | 58 bool isCancelable = !isMouseEnterOrLeave; |
58 bool isBubbling = !isMouseEnterOrLeave; | 59 bool isBubbling = !isMouseEnterOrLeave; |
59 | 60 |
60 return MouseEvent::create( | 61 return MouseEvent::create( |
61 eventType, isBubbling, isCancelable, view, | 62 eventType, isBubbling, isCancelable, view, |
62 detail, event.globalPosition().x(), event.globalPosition().y(), event.po
sition().x(), event.position().y(), | 63 detail, event.globalPosition().x(), event.globalPosition().y(), event.po
sition().x(), event.position().y(), |
63 event.movementDelta().x(), event.movementDelta().y(), | 64 event.movementDelta().x(), event.movementDelta().y(), |
64 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even
t.button(), | 65 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even
t.button(), event.buttons(), |
65 relatedTarget, nullptr, false, event.syntheticEventType()); | 66 relatedTarget, nullptr, false, event.syntheticEventType()); |
66 } | 67 } |
67 | 68 |
68 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, | 69 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type,
bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, |
69 int detail, int screenX, int screenY, int pageX, int pageY, | 70 int detail, int screenX, int screenY, int pageX, int pageY, |
70 int movementX, int movementY, | 71 int movementX, int movementY, |
71 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short butto
n, | 72 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 73 unsigned short button, unsigned short buttons, |
72 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<Da
taTransfer> dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventTy
pe syntheticEventType) | 74 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPtr<Da
taTransfer> dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticEventTy
pe syntheticEventType) |
73 { | 75 { |
74 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, | 76 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, |
75 detail, screenX, screenY, pageX, pageY, | 77 detail, screenX, screenY, pageX, pageY, |
76 movementX, movementY, | 78 movementX, movementY, |
77 ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, dataTransfer,
isSimulated, syntheticEventType)); | 79 ctrlKey, altKey, shiftKey, metaKey, button, buttons, |
| 80 relatedTarget, dataTransfer, isSimulated, syntheticEventType)); |
78 } | 81 } |
79 | 82 |
80 MouseEvent::MouseEvent() | 83 MouseEvent::MouseEvent() |
81 : m_button(0) | 84 : m_button(0) |
| 85 , m_buttons(0) |
82 , m_buttonDown(false) | 86 , m_buttonDown(false) |
83 { | 87 { |
84 } | 88 } |
85 | 89 |
86 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
lable, PassRefPtrWillBeRawPtr<AbstractView> view, | 90 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
lable, PassRefPtrWillBeRawPtr<AbstractView> view, |
87 int detail, int screenX, int screenY, int pageX, int pageY, | 91 int detail, int screenX, int screenY, int pageX, int pageY, |
88 int movementX, int movementY, | 92 int movementX, int movementY, |
89 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 93 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
90 unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, | 94 unsigned short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventT
arget> relatedTarget, |
91 PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, bool isSimulated, Platfor
mMouseEvent::SyntheticEventType syntheticEventType) | 95 PassRefPtrWillBeRawPtr<DataTransfer> dataTransfer, bool isSimulated, Platfor
mMouseEvent::SyntheticEventType syntheticEventType) |
92 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint
(screenX, screenY), | 96 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint
(screenX, screenY), |
93 IntPoint(pageX, pageY), | 97 IntPoint(pageX, pageY), |
94 IntPoint(movementX, movementY), | 98 IntPoint(movementX, movementY), |
95 ctrlKey, altKey, shiftKey, metaKey, isSimulated) | 99 ctrlKey, altKey, shiftKey, metaKey, isSimulated) |
96 , m_button(button == (unsigned short)-1 ? 0 : button) | 100 , m_button(button == (unsigned short)-1 ? 0 : button) |
| 101 , m_buttons(buttons) |
97 , m_buttonDown(button != (unsigned short)-1) | 102 , m_buttonDown(button != (unsigned short)-1) |
98 , m_relatedTarget(relatedTarget) | 103 , m_relatedTarget(relatedTarget) |
99 , m_dataTransfer(dataTransfer) | 104 , m_dataTransfer(dataTransfer) |
100 , m_syntheticEventType(syntheticEventType) | 105 , m_syntheticEventType(syntheticEventType) |
101 { | 106 { |
102 } | 107 } |
103 | 108 |
104 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
ializer) | 109 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init
ializer) |
105 : MouseRelatedEvent(eventType, initializer.bubbles, initializer.cancelable,
initializer.view, initializer.detail, IntPoint(initializer.screenX, initializer.
screenY), | 110 : MouseRelatedEvent(eventType, initializer.bubbles, initializer.cancelable,
initializer.view, initializer.detail, IntPoint(initializer.screenX, initializer.
screenY), |
106 IntPoint(0 /* pageX */, 0 /* pageY */), | 111 IntPoint(0 /* pageX */, 0 /* pageY */), |
107 IntPoint(0 /* movementX */, 0 /* movementY */), | 112 IntPoint(0 /* movementX */, 0 /* movementY */), |
108 initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializ
er.metaKey, false /* isSimulated */) | 113 initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializ
er.metaKey, false /* isSimulated */) |
109 , m_button(initializer.button == (unsigned short)-1 ? 0 : initializer.button
) | 114 , m_button(initializer.button == (unsigned short)-1 ? 0 : initializer.button
) |
| 115 , m_buttons(initializer.buttons) |
110 , m_buttonDown(initializer.button != (unsigned short)-1) | 116 , m_buttonDown(initializer.button != (unsigned short)-1) |
111 , m_relatedTarget(initializer.relatedTarget) | 117 , m_relatedTarget(initializer.relatedTarget) |
112 , m_dataTransfer(nullptr) | 118 , m_dataTransfer(nullptr) |
113 { | 119 { |
114 initCoordinates(IntPoint(initializer.clientX, initializer.clientY)); | 120 initCoordinates(IntPoint(initializer.clientX, initializer.clientY)); |
115 } | 121 } |
116 | 122 |
117 MouseEvent::~MouseEvent() | 123 MouseEvent::~MouseEvent() |
118 { | 124 { |
119 } | 125 } |
120 | 126 |
121 void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c
ancelable, PassRefPtrWillBeRawPtr<AbstractView> view, | 127 void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c
ancelable, PassRefPtrWillBeRawPtr<AbstractView> view, |
122 int detail, int screenX, int screenY, int client
X, int clientY, | 128 int detail, int screenX, int screenY, int client
X, int clientY, |
123 bool ctrlKey, bool altKey, bool shiftKey, bool m
etaKey, | 129 bool ctrlKey, bool altKey, bool shiftKey, bool m
etaKey, |
124 unsigned short button, PassRefPtrWillBeRawPtr<Ev
entTarget> relatedTarget) | 130 unsigned short button, PassRefPtrWillBeRawPtr<Ev
entTarget> relatedTarget, unsigned short buttons) |
125 { | 131 { |
126 if (dispatched()) | 132 if (dispatched()) |
127 return; | 133 return; |
128 | 134 |
129 initUIEvent(type, canBubble, cancelable, view, detail); | 135 initUIEvent(type, canBubble, cancelable, view, detail); |
130 | 136 |
131 m_screenLocation = IntPoint(screenX, screenY); | 137 m_screenLocation = IntPoint(screenX, screenY); |
132 m_ctrlKey = ctrlKey; | 138 m_ctrlKey = ctrlKey; |
133 m_altKey = altKey; | 139 m_altKey = altKey; |
134 m_shiftKey = shiftKey; | 140 m_shiftKey = shiftKey; |
135 m_metaKey = metaKey; | 141 m_metaKey = metaKey; |
136 m_button = button == (unsigned short)-1 ? 0 : button; | 142 m_button = button == (unsigned short)-1 ? 0 : button; |
137 m_buttonDown = button != (unsigned short)-1; | 143 m_buttonDown = button != (unsigned short)-1; |
138 m_relatedTarget = relatedTarget; | 144 m_relatedTarget = relatedTarget; |
| 145 m_buttons = buttons; |
139 | 146 |
140 initCoordinates(IntPoint(clientX, clientY)); | 147 initCoordinates(IntPoint(clientX, clientY)); |
141 | 148 |
142 // FIXME: m_isSimulated is not set to false here. | 149 // FIXME: m_isSimulated is not set to false here. |
143 // FIXME: m_dataTransfer is not set to nullptr here. | 150 // FIXME: m_dataTransfer is not set to nullptr here. |
144 } | 151 } |
145 | 152 |
146 const AtomicString& MouseEvent::interfaceName() const | 153 const AtomicString& MouseEvent::interfaceName() const |
147 { | 154 { |
148 return EventNames::MouseEvent; | 155 return EventNames::MouseEvent; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 PassRefPtrWillBeRawPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const At
omicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWill
BeRawPtr<Event> underlyingEvent) | 205 PassRefPtrWillBeRawPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const At
omicString& eventType, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWill
BeRawPtr<Event> underlyingEvent) |
199 { | 206 { |
200 return adoptRefWillBeNoop(new SimulatedMouseEvent(eventType, view, underlyin
gEvent)); | 207 return adoptRefWillBeNoop(new SimulatedMouseEvent(eventType, view, underlyin
gEvent)); |
201 } | 208 } |
202 | 209 |
203 SimulatedMouseEvent::~SimulatedMouseEvent() | 210 SimulatedMouseEvent::~SimulatedMouseEvent() |
204 { | 211 { |
205 } | 212 } |
206 | 213 |
207 SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
trWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent
) | 214 SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
trWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> underlyingEvent
) |
208 : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false,
false, false, 0, | 215 : MouseEvent(eventType, true, true, view, 0, 0, 0, 0, 0, 0, 0, false, false,
false, false, 0, 0, |
209 nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable) | 216 nullptr, nullptr, true, PlatformMouseEvent::RealOrIndistinguishable) |
210 { | 217 { |
211 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve
nt.get())) { | 218 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve
nt.get())) { |
212 m_ctrlKey = keyStateEvent->ctrlKey(); | 219 m_ctrlKey = keyStateEvent->ctrlKey(); |
213 m_altKey = keyStateEvent->altKey(); | 220 m_altKey = keyStateEvent->altKey(); |
214 m_shiftKey = keyStateEvent->shiftKey(); | 221 m_shiftKey = keyStateEvent->shiftKey(); |
215 m_metaKey = keyStateEvent->metaKey(); | 222 m_metaKey = keyStateEvent->metaKey(); |
216 } | 223 } |
217 setUnderlyingEvent(underlyingEvent); | 224 setUnderlyingEvent(underlyingEvent); |
218 | 225 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented()
; | 272 bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented()
; |
266 | 273 |
267 if (event()->type() != EventTypeNames::click || event()->detail() != 2) | 274 if (event()->type() != EventTypeNames::click || event()->detail() != 2) |
268 return !swallowEvent; | 275 return !swallowEvent; |
269 | 276 |
270 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part | 277 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part |
271 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated | 278 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated |
272 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. | 279 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. |
273 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); | 280 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); |
274 doubleClickEvent->initMouseEvent(EventTypeNames::dblclick, event()->bubbles(
), event()->cancelable(), event()->view(), | 281 doubleClickEvent->initMouseEvent(EventTypeNames::dblclick, event()->bubbles(
), event()->cancelable(), event()->view(), |
275 event()->detail(), event()->screenX(), even
t()->screenY(), event()->clientX(), event()->clientY(), | 282 event()->detail(), event()->screenX(), event()->screenY(), event()->clie
ntX(), event()->clientY(), |
276 event()->ctrlKey(), event()->altKey(), even
t()->shiftKey(), event()->metaKey(), | 283 event()->ctrlKey(), event()->altKey(), event()->shiftKey(), event()->met
aKey(), |
277 event()->button(), relatedTarget); | 284 event()->button(), relatedTarget, event()->buttons()); |
278 if (event()->defaultHandled()) | 285 if (event()->defaultHandled()) |
279 doubleClickEvent->setDefaultHandled(); | 286 doubleClickEvent->setDefaultHandled(); |
280 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato
r::create(doubleClickEvent)); | 287 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato
r::create(doubleClickEvent)); |
281 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented
()) | 288 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented
()) |
282 return false; | 289 return false; |
283 return !swallowEvent; | 290 return !swallowEvent; |
284 } | 291 } |
285 | 292 |
286 } // namespace blink | 293 } // namespace blink |
OLD | NEW |