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

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, 8 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.getModifiers(), event.button(), 52 event.getModifiers(), event.button(),
53 platformModifiersToButtons(event.getModifiers()), 53 platformModifiersToButtons(event.getModifiers()),
54 relatedTarget, event.timestamp(), event.getSyntheticEventType(), event.r egion()); 54 relatedTarget, event.timestamp(), event.getSyntheticEventType(), event.r egion());
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 const String& region) 65 const String& region)
66 { 66 {
67 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, 67 return new MouseEvent(type, canBubble, cancelable, view,
68 detail, screenX, screenY, windowX, windowY, 68 detail, screenX, screenY, windowX, windowY,
69 movementX, movementY, 69 movementX, movementY,
70 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType, region)); 70 modifiers, button, buttons, relatedTarget, platformTimeStamp, syntheticE ventType, region);
71 } 71 }
72 72
73 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventT ype, PassRefPtrWillBeRawPtr<AbstractView> view, PassRefPtrWillBeRawPtr<Event> un derlyingEvent, SimulatedClickCreationScope creationScope) 73 RawPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, RawPtr<Abst ractView> view, RawPtr<Event> underlyingEvent, SimulatedClickCreationScope creat ionScope)
74 { 74 {
75 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers; 75 PlatformEvent::Modifiers modifiers = PlatformEvent::NoModifiers;
76 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) { 76 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve nt.get())) {
77 modifiers = keyStateEvent->modifiers(); 77 modifiers = keyStateEvent->modifiers();
78 } 78 }
79 79
80 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless; 80 PlatformMouseEvent::SyntheticEventType syntheticType = PlatformMouseEvent::P ositionless;
81 int screenX = 0; 81 int screenX = 0;
82 int screenY = 0; 82 int screenY = 0;
83 if (underlyingEvent && underlyingEvent->isMouseEvent()) { 83 if (underlyingEvent && underlyingEvent->isMouseEvent()) {
84 syntheticType = PlatformMouseEvent::RealOrIndistinguishable; 84 syntheticType = PlatformMouseEvent::RealOrIndistinguishable;
85 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get()); 85 MouseEvent* mouseEvent = toMouseEvent(underlyingEvent.get());
86 screenX = mouseEvent->screenLocation().x(); 86 screenX = mouseEvent->screenLocation().x();
87 screenY = mouseEvent->screenLocation().y(); 87 screenY = mouseEvent->screenLocation().y();
88 } 88 }
89 89
90 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime(); 90 double timestamp = underlyingEvent ? underlyingEvent->platformTimeStamp() : monotonicallyIncreasingTime();
91 RefPtrWillBeRawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view, 91 RawPtr<MouseEvent> createdEvent = MouseEvent::create(eventType, true, true, view,
92 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr, 92 0, screenX, screenY, 0, 0, 0, 0, modifiers, 0, 0, nullptr,
93 timestamp, syntheticType, String()); 93 timestamp, syntheticType, String());
94 94
95 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent); 95 createdEvent->setTrusted(creationScope == SimulatedClickCreationScope::FromU serAgent);
96 createdEvent->setUnderlyingEvent(underlyingEvent); 96 createdEvent->setUnderlyingEvent(underlyingEvent);
97 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) { 97 if (syntheticType == PlatformMouseEvent::RealOrIndistinguishable) {
98 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent()); 98 MouseEvent* mouseEvent = toMouseEvent(createdEvent->underlyingEvent());
99 createdEvent->initCoordinates(mouseEvent->clientLocation()); 99 createdEvent->initCoordinates(mouseEvent->clientLocation());
100 } 100 }
101 101
102 return createdEvent.release(); 102 return createdEvent.release();
103 } 103 }
104 104
105 MouseEvent::MouseEvent() 105 MouseEvent::MouseEvent()
106 : m_button(0) 106 : m_button(0)
107 , m_buttons(0) 107 , m_buttons(0)
108 , m_relatedTarget(nullptr) 108 , m_relatedTarget(nullptr)
109 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) 109 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable)
110 { 110 {
111 } 111 }
112 112
113 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, 113 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, RawPtr<AbstractView> view,
114 int detail, int screenX, int screenY, int windowX, int windowY, 114 int detail, int screenX, int screenY, int windowX, int windowY,
115 int movementX, int movementY, 115 int movementX, int movementY,
116 PlatformEvent::Modifiers modifiers, 116 PlatformEvent::Modifiers modifiers,
117 short button, unsigned short buttons, 117 short button, unsigned short buttons,
118 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, 118 RawPtr<EventTarget> relatedTarget,
119 double platformTimeStamp, 119 double platformTimeStamp,
120 PlatformMouseEvent::SyntheticEventType syntheticEventType, 120 PlatformMouseEvent::SyntheticEventType syntheticEventType,
121 const String& region) 121 const String& region)
122 : MouseRelatedEvent(eventType, canBubble, cancelable, relatedTarget.get(), v iew, detail, IntPoint(screenX, screenY), 122 : MouseRelatedEvent(eventType, canBubble, cancelable, relatedTarget.get(), v iew, detail, IntPoint(screenX, screenY),
123 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers, 123 IntPoint(windowX, windowY), IntPoint(movementX, movementY), modifiers,
124 platformTimeStamp, 124 platformTimeStamp,
125 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position, 125 syntheticEventType == PlatformMouseEvent::Positionless ? PositionType::P ositionless : PositionType::Position,
126 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities()) 126 syntheticEventType == PlatformMouseEvent::FromTouch ? InputDeviceCapabil ities::firesTouchEventsSourceCapabilities() : InputDeviceCapabilities::doesntFir eTouchEventsSourceCapabilities())
127 , m_button(button) 127 , m_button(button)
128 , m_buttons(buttons) 128 , m_buttons(buttons)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return static_cast<unsigned short>(Buttons::Left); 169 return static_cast<unsigned short>(Buttons::Left);
170 case RightButton: 170 case RightButton:
171 return static_cast<unsigned short>(Buttons::Right); 171 return static_cast<unsigned short>(Buttons::Right);
172 case MiddleButton: 172 case MiddleButton:
173 return static_cast<unsigned short>(Buttons::Middle); 173 return static_cast<unsigned short>(Buttons::Middle);
174 } 174 }
175 ASSERT_NOT_REACHED(); 175 ASSERT_NOT_REACHED();
176 return 0; 176 return 0;
177 } 177 }
178 178
179 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 179 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, RawPtr<AbstractView> view,
180 int detail, int screenX, int screenY, int client X, int clientY, 180 int detail, int screenX, int screenY, int client X, int clientY,
181 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, 181 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey,
182 short button, PassRefPtrWillBeRawPtr<EventTarget > relatedTarget, unsigned short buttons) 182 short button, RawPtr<EventTarget> relatedTarget, unsigned short buttons)
183 { 183 {
184 if (dispatched()) 184 if (dispatched())
185 return; 185 return;
186 186
187 if (scriptState && scriptState->world().isIsolatedWorld()) 187 if (scriptState && scriptState->world().isIsolatedWorld())
188 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); 188 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey);
189 189
190 initModifiers(ctrlKey, altKey, shiftKey, metaKey); 190 initModifiers(ctrlKey, altKey, shiftKey, metaKey);
191 initMouseEventInternal(type, canBubble, cancelable, view, detail, screenX, s creenY, clientX, clientY, modifiers(), button, relatedTarget, nullptr, buttons); 191 initMouseEventInternal(type, canBubble, cancelable, view, detail, screenX, s creenY, clientX, clientY, modifiers(), button, relatedTarget, nullptr, buttons);
192 } 192 }
193 193
194 void MouseEvent::initMouseEventInternal(const AtomicString& type, bool canBubble , bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, 194 void MouseEvent::initMouseEventInternal(const AtomicString& type, bool canBubble , bool cancelable, RawPtr<AbstractView> view,
195 int detail, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers, 195 int detail, int screenX, int screenY, int clientX, int clientY, PlatformEven t::Modifiers modifiers,
196 short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, InputDevice Capabilities* sourceCapabilities, unsigned short buttons) 196 short button, RawPtr<EventTarget> relatedTarget, InputDeviceCapabilities* so urceCapabilities, unsigned short buttons)
197 { 197 {
198 initUIEventInternal(type, canBubble, cancelable, relatedTarget.get(), view, detail, sourceCapabilities); 198 initUIEventInternal(type, canBubble, cancelable, relatedTarget.get(), view, detail, sourceCapabilities);
199 199
200 m_screenLocation = IntPoint(screenX, screenY); 200 m_screenLocation = IntPoint(screenX, screenY);
201 m_button = button; 201 m_button = button;
202 m_buttons = buttons; 202 m_buttons = buttons;
203 m_relatedTarget = relatedTarget; 203 m_relatedTarget = relatedTarget;
204 m_modifiers = modifiers; 204 m_modifiers = modifiers;
205 205
206 initCoordinates(IntPoint(clientX, clientY)); 206 initCoordinates(IntPoint(clientX, clientY));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 return target() ? target()->toNode() : nullptr; 244 return target() ? target()->toNode() : nullptr;
245 } 245 }
246 246
247 DEFINE_TRACE(MouseEvent) 247 DEFINE_TRACE(MouseEvent)
248 { 248 {
249 visitor->trace(m_relatedTarget); 249 visitor->trace(m_relatedTarget);
250 MouseRelatedEvent::trace(visitor); 250 MouseRelatedEvent::trace(visitor);
251 } 251 }
252 252
253 PassRefPtrWillBeRawPtr<EventDispatchMediator> MouseEvent::createMediator() 253 RawPtr<EventDispatchMediator> MouseEvent::createMediator()
254 { 254 {
255 return MouseEventDispatchMediator::create(this); 255 return MouseEventDispatchMediator::create(this);
256 } 256 }
257 257
258 PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::c reate(PassRefPtrWillBeRawPtr<MouseEvent> mouseEvent) 258 RawPtr<MouseEventDispatchMediator> MouseEventDispatchMediator::create(RawPtr<Mou seEvent> mouseEvent)
259 { 259 {
260 return adoptRefWillBeNoop(new MouseEventDispatchMediator(mouseEvent)); 260 return new MouseEventDispatchMediator(mouseEvent);
261 } 261 }
262 262
263 MouseEventDispatchMediator::MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<Mo useEvent> mouseEvent) 263 MouseEventDispatchMediator::MouseEventDispatchMediator(RawPtr<MouseEvent> mouseE vent)
264 : EventDispatchMediator(mouseEvent) 264 : EventDispatchMediator(mouseEvent)
265 { 265 {
266 } 266 }
267 267
268 MouseEvent& MouseEventDispatchMediator::event() const 268 MouseEvent& MouseEventDispatchMediator::event() const
269 { 269 {
270 return toMouseEvent(EventDispatchMediator::event()); 270 return toMouseEvent(EventDispatchMediator::event());
271 } 271 }
272 272
273 DispatchEventResult MouseEventDispatchMediator::dispatchEvent(EventDispatcher& d ispatcher) const 273 DispatchEventResult MouseEventDispatchMediator::dispatchEvent(EventDispatcher& d ispatcher) const
(...skipping 16 matching lines...) Expand all
290 EventTarget* relatedTarget = mouseEvent.relatedTarget(); 290 EventTarget* relatedTarget = mouseEvent.relatedTarget();
291 291
292 DispatchEventResult dispatchResult = dispatcher.dispatch(); 292 DispatchEventResult dispatchResult = dispatcher.dispatch();
293 293
294 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2) 294 if (mouseEvent.type() != EventTypeNames::click || mouseEvent.detail() != 2)
295 return dispatchResult; 295 return dispatchResult;
296 296
297 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part 297 // Special case: If it's a double click event, we also send the dblclick eve nt. This is not part
298 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated 298 // of the DOM specs, but is used for compatibility with the ondblclick="" at tribute. This is treated
299 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same. 299 // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
300 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); 300 RawPtr<MouseEvent> doubleClickEvent = MouseEvent::create();
301 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(), 301 doubleClickEvent->initMouseEventInternal(EventTypeNames::dblclick, mouseEven t.bubbles(), mouseEvent.cancelable(), mouseEvent.view(),
302 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(), 302 mouseEvent.detail(), mouseEvent.screenX(), mouseEvent.screenY(), mouseEv ent.clientX(), mouseEvent.clientY(),
303 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons()); 303 mouseEvent.modifiers(), mouseEvent.button(), relatedTarget, mouseEvent.s ourceCapabilities(), mouseEvent.buttons());
304 304
305 // Inherit the trusted status from the original event. 305 // Inherit the trusted status from the original event.
306 doubleClickEvent->setTrusted(mouseEvent.isTrusted()); 306 doubleClickEvent->setTrusted(mouseEvent.isTrusted());
307 if (mouseEvent.defaultHandled()) 307 if (mouseEvent.defaultHandled())
308 doubleClickEvent->setDefaultHandled(); 308 doubleClickEvent->setDefaultHandled();
309 DispatchEventResult doubleClickDispatchResult = EventDispatcher::dispatchEve nt(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent)); 309 DispatchEventResult doubleClickDispatchResult = EventDispatcher::dispatchEve nt(dispatcher.node(), MouseEventDispatchMediator::create(doubleClickEvent));
310 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled) 310 if (doubleClickDispatchResult != DispatchEventResult::NotCanceled)
311 return doubleClickDispatchResult; 311 return doubleClickDispatchResult;
312 return dispatchResult; 312 return dispatchResult;
313 } 313 }
314 314
315 } // namespace blink 315 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/MouseEvent.h ('k') | third_party/WebKit/Source/core/events/MouseRelatedEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698