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

Side by Side Diff: third_party/WebKit/Source/core/events/MouseEvent.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
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 12 matching lines...) Expand all
23 #include "core/events/MouseEvent.h" 23 #include "core/events/MouseEvent.h"
24 24
25 #include "bindings/core/v8/DOMWrapperWorld.h" 25 #include "bindings/core/v8/DOMWrapperWorld.h"
26 #include "bindings/core/v8/ScriptState.h" 26 #include "bindings/core/v8/ScriptState.h"
27 #include "core/dom/Element.h" 27 #include "core/dom/Element.h"
28 #include "core/events/EventDispatcher.h" 28 #include "core/events/EventDispatcher.h"
29 #include "platform/PlatformMouseEvent.h" 29 #include "platform/PlatformMouseEvent.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(ScriptState* scriptState, const AtomicString& type, const MouseEventInit& initializer) 33 RawPtr<MouseEvent> MouseEvent::create(ScriptState* scriptState, const AtomicStri ng& type, const MouseEventInit& initializer)
34 { 34 {
35 if (scriptState && scriptState->world().isIsolatedWorld()) 35 if (scriptState && scriptState->world().isIsolatedWorld())
36 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey() , initializer.altKey(), initializer.shiftKey(), initializer.metaKey()); 36 UIEventWithKeyState::didCreateEventInIsolatedWorld(initializer.ctrlKey() , initializer.altKey(), initializer.shiftKey(), initializer.metaKey());
37 return adoptRefWillBeNoop(new MouseEvent(type, initializer)); 37 return (new MouseEvent(type, initializer));
38 } 38 }
39 39
40 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT ype, PassRefPtrWillBeRawPtr<AbstractView> view, const PlatformMouseEvent& event, int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget) 40 RawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, RawPtr<Abst ractView> view, const PlatformMouseEvent& event, int detail, RawPtr<Node> relate dTarget)
41 { 41 {
42 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt on); 42 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt on);
43 43
44 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT ype == EventTypeNames::mouseleave; 44 bool isMouseEnterOrLeave = eventType == EventTypeNames::mouseenter || eventT ype == EventTypeNames::mouseleave;
45 bool isCancelable = !isMouseEnterOrLeave; 45 bool isCancelable = !isMouseEnterOrLeave;
46 bool isBubbling = !isMouseEnterOrLeave; 46 bool isBubbling = !isMouseEnterOrLeave;
47 47
48 return MouseEvent::create( 48 return MouseEvent::create(
49 eventType, isBubbling, isCancelable, view, 49 eventType, isBubbling, isCancelable, view,
50 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(), 50 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(),
51 event.movementDelta().x(), event.movementDelta().y(), 51 event.movementDelta().x(), event.movementDelta().y(),
52 event.modifiers(), event.button(), 52 event.modifiers(), event.button(),
53 platformModifiersToButtons(event.modifiers()), 53 platformModifiersToButtons(event.modifiers()),
54 relatedTarget, event.timestamp(), event.syntheticEventType()); 54 relatedTarget, event.timestamp(), event.syntheticEventType());
55 } 55 }
56 56
57 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 57 RawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, RawPtr<AbstractView> view,
58 int detail, int screenX, int screenY, int windowX, int windowY, 58 int detail, int screenX, int screenY, int windowX, int windowY,
59 int movementX, int movementY, 59 int movementX, int movementY,
60 PlatformEvent::Modifiers modifiers, 60 PlatformEvent::Modifiers modifiers,
61 short button, unsigned short buttons, 61 short button, unsigned short buttons,
62 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, 62 RawPtr<EventTarget> relatedTarget,
63 double platformTimeStamp, 63 double platformTimeStamp,
64 PlatformMouseEvent::SyntheticEventType syntheticEventType) 64 PlatformMouseEvent::SyntheticEventType syntheticEventType)
65 { 65 {
66 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, 66 return (new MouseEvent(type, canBubble, cancelable, view,
67 detail, screenX, screenY, windowX, windowY, 67 detail, screenX, screenY, windowX, windowY,
68 movementX, movementY, 68 movementX, movementY,
69 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType)); 69 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType));
70 } 70 }
71 71
72 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT ype, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> un derlyingEvent, SimulatedClickCreationScope creationScope) 72 RawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, RawPtr<Abst ractView> view, RawPtr<Event> underlyingEvent, SimulatedClickCreationScope creat ionScope)
73 { 73 {
74 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers; 74 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers;
75 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) { 75 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) {
76 modifiers = keyStateEvent->modifiers(); 76 modifiers = keyStateEvent->modifiers();
77 } 77 }
78 78
79 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless; 79 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless;
80 int screenX = 0; 80 int screenX = 0;
81 int screenY = 0; 81 int screenY = 0;
82 if (underlyingEvent && underlyingEvent->isMouseEvent()) { 82 if (underlyingEvent && underlyingEvent->isMouseEvent()) {
83 syntheticType = PlatformMouseEvent::RealOrIndistinguishable; 83 syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
84 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get()); 84 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
85 screenX = mouseEvent->screenLocation().x(); 85 screenX = mouseEvent->screenLocation().x();
86 screenY = mouseEvent->screenLocation().y(); 86 screenY = mouseEvent->screenLocation().y();
87 } 87 }
88 88
89 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime(); 89 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime();
90 RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view, 90 RawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view,
91 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr, 91 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr,
92 timestamp, syntheticType); 92 timestamp, syntheticType);
93 93
94 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent); 94 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent);
95 createdEvent->setUnderlyingEvent(underlyingEvent); 95 createdEvent->setUnderlyingEvent(underlyingEvent);
96 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) { 96 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
97 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent()); 97 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent());
98 createdEvent->initCoordinates(mouseEvent->clientLocation()); 98 createdEvent->initCoordinates(mouseEvent->clientLocation());
99 } 99 }
100 100
101 return createdEvent.release(); 101 return createdEvent.release();
102 } 102 }
103 103
104 MouseEvent::MouseEvent() 104 MouseEvent::MouseEvent()
105 : m_button(0) 105 : m_button(0)
106 , m_buttons(0) 106 , m_buttons(0)
107 , m_relatedTarget(nullptr) 107 , m_relatedTarget(nullptr)
108 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) 108 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
109 { 109 {
110 } 110 }
111 111
112 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, 112 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, RawPtr<AbstractView> view,
113 int detail, int screenX, int screenY, int windowX, int windowY, 113 int detail, int screenX, int screenY, int windowX, int windowY,
114 int movementX, int movementY, 114 int movementX, int movementY,
115 PlatformEvent::Modifiers modifiers, 115 PlatformEvent::Modifiers modifiers,
116 short button, unsigned short buttons, 116 short button, unsigned short buttons,
117 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, 117 RawPtr<EventTarget> relatedTarget,
118 double platformTimeStamp, 118 double platformTimeStamp,
119 PlatformMouseEvent::SyntheticEventType syntheticEventType) 119 PlatformMouseEvent::SyntheticEventType syntheticEventType)
120 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), 120 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY),
121 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers, 121 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers,
122 platformTimeStamp, 122 platformTimeStamp,
123 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position, 123 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position,
124 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities()) 124 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities())
125 , m_button(button) 125 , m_button(button)
126 , m_buttons(buttons) 126 , m_buttons(buttons)
127 , m_relatedTarget(relatedTarget) 127 , m_relatedTarget(relatedTarget)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return static_cast<unsigned short>(Buttons::Left); 165 return static_cast<unsigned short>(Buttons::Left);
166 case RightButton: 166 case RightButton:
167 return static_cast<unsigned short>(Buttons::Right); 167 return static_cast<unsigned short>(Buttons::Right);
168 case MiddleButton: 168 case MiddleButton:
169 return static_cast<unsigned short>(Buttons::Middle); 169 return static_cast<unsigned short>(Buttons::Middle);
170 } 170 }
171 ASSERT_NOT_REACHED(); 171 ASSERT_NOT_REACHED();
172 return 0; 172 return 0;
173 } 173 }
174 174
175 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 175 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, RawPtr<AbstractView> view,
176 int detail, int screenX, int screenY, int client X, int clientY, 176 int detail, int screenX, int screenY, int client X, int clientY,
177 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, 177 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey,
178 short button, PassRefPtrWillBeRawPtr<EventTarget > relatedTarget, unsigned short buttons) 178 short button, RawPtr<EventTarget> relatedTarget, unsigned short buttons)
179 { 179 {
180 if (dispatched()) 180 if (dispatched())
181 return; 181 return;
182 182
183 if (scriptState && scriptState->world().isIsolatedWorld()) 183 if (scriptState && scriptState->world().isIsolatedWorld())
184 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); 184 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey);
185 185
186 initModifiers(ctrlKey, altKey, shiftKey, metaKey); 186 initModifiers(ctrlKey, altKey, shiftKey, metaKey);
187 initMouseEventInternal(type, canBubble, cancelable, view, detail, screenX, s creenY, clientX, clientY, modifiers(), button, relatedTarget, nullptr, buttons); 187 initMouseEventInternal(type, canBubble, cancelable, view, detail, screenX, s creenY, clientX, clientY, modifiers(), button, relatedTarget, nullptr, buttons);
188 } 188 }
189 189
190 void MouseEvent::initMouseEventInternal(const AtomicString& type, bool canBubble , bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 190 void MouseEvent::initMouseEventInternal(const AtomicString& type, bool canBubble , bool cancelable, RawPtr<AbstractView> view,
191 int detail, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers, 191 int detail, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers,
192 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDevice Capabilities* sourceCapabilities, unsigned short buttons) 192 short button, RawPtr<EventTarget> relatedTarget, InputDeviceCapabilities* so urceCapabilities, unsigned short buttons)
193 { 193 {
194 initUIEventInternal(type, canBubble, cancelable, view, detail, sourceCapabil ities); 194 initUIEventInternal(type, canBubble, cancelable, view, detail, sourceCapabil ities);
195 195
196 m_screenLocation = IntPoint(screenX, screenY); 196 m_screenLocation = IntPoint(screenX, screenY);
197 m_button = button; 197 m_button = button;
198 m_buttons = buttons; 198 m_buttons = buttons;
199 m_relatedTarget = relatedTarget; 199 m_relatedTarget = relatedTarget;
200 m_modifiers = modifiers; 200 m_modifiers = modifiers;
201 201
202 initCoordinates(IntPoint(clientX, clientY)); 202 initCoordinates(IntPoint(clientX, clientY));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 return target() ? target()->toNode() : nullptr; 240 return target() ? target()->toNode() : nullptr;
241 } 241 }
242 242
243 DEFINE_TRACE(MouseEvent) 243 DEFINE_TRACE(MouseEvent)
244 { 244 {
245 visitor->trace(m_relatedTarget); 245 visitor->trace(m_relatedTarget);
246 MouseRelatedEvent::trace(visitor); 246 MouseRelatedEvent::trace(visitor);
247 } 247 }
248 248
249 PassRefPtrWillBeRawPtr<EventDispatchMediator> MouseEvent::createMediator() 249 RawPtr<EventDispatchMediator> MouseEvent::createMediator()
250 { 250 {
251 return MouseEventDispatchMediator::create(this); 251 return MouseEventDispatchMediator::create(this);
252 } 252 }
253 253
254 PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::c reate(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent) 254 RawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(RawPtr<Mou seEvent> mouseEvent)
255 { 255 {
256 return adoptRefWillBeNoop(new MouseEventDispatchMediator(mouseEvent)); 256 return (new MouseEventDispatchMediator(mouseEvent));
257 } 257 }
258 258
259 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo useEvent> mouseEvent) 259 MouseEventDispatchMediator::MouseEventDispatchMediator(RawPtr<MouseEvent> mouseE vent)
260 : EventDispatchMediator(mouseEvent) 260 : EventDispatchMediator(mouseEvent)
261 { 261 {
262 } 262 }
263 263
264 MouseEvent& MouseEventDispatchMediator::event() const 264 MouseEvent& MouseEventDispatchMediator::event() const
265 { 265 {
266 return toMouseEvent(EventDispatchMediator::event()); 266 return toMouseEvent(EventDispatchMediator::event());
267 } 267 }
268 268
269 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons t 269 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) cons t
(...skipping 17 matching lines...) Expand all
287 287
288 dispatcher.dispatch(); 288 dispatcher.dispatch();
289 bool swallowEvent = mouseEvent.defaultHandled() || mouseEvent.defaultPrevent ed(); 289 bool swallowEvent = mouseEvent.defaultHandled() || mouseEvent.defaultPrevent ed();
290 290
291 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) 291 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2)
292 return !swallowEvent; 292 return !swallowEvent;
293 293
294 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part 294 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part
295 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated 295 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated
296 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same. 296 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
297 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); 297 RawPtr<MouseEvent> doubleClickEvent = MouseEvent::create();
298 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(), 298 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(),
299 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(), 299 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(),
300 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons()); 300 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons());
301 301
302 // Inherit the trusted status from the original event. 302 // Inherit the trusted status from the original event.
303 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); 303 doubleClickEvent->setTrusted(mouseEvent.isTrusted());
304 if (mouseEvent.defaultHandled()) 304 if (mouseEvent.defaultHandled())
305 doubleClickEvent->setDefaultHandled(); 305 doubleClickEvent->setDefaultHandled();
306 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); 306 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent));
307 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) 307 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ())
308 return false; 308 return false;
309 return !swallowEvent; 309 return !swallowEvent;
310 } 310 }
311 311
312 } // namespace blink 312 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698