Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, | 82 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, |
| 83 int detail, int screenX, int screenY, int windowX, int windowY, | 83 int detail, int screenX, int screenY, int windowX, int windowY, |
| 84 int movementX, int movementY, | 84 int movementX, int movementY, |
| 85 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 85 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 86 short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> re latedTarget, | 86 short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> re latedTarget, |
| 87 DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticE ventType syntheticEventType, | 87 DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticE ventType syntheticEventType, |
| 88 double uiCreateTime) | 88 double uiCreateTime) |
| 89 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), | 89 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), |
| 90 IntPoint(windowX, windowY), | 90 IntPoint(windowX, windowY), |
| 91 IntPoint(movementX, movementY), | 91 IntPoint(movementX, movementY), |
| 92 ctrlKey, altKey, shiftKey, metaKey, isSimulated) | 92 ctrlKey, altKey, shiftKey, metaKey, isSimulated) |
|
Rick Byers
2015/06/23 00:55:57
rather than rely on a setSourceDevice method on UI
lanwei
2015/06/23 22:19:20
Done.
| |
| 93 , m_button(button) | 93 , m_button(button) |
| 94 , m_buttons(buttons) | 94 , m_buttons(buttons) |
| 95 , m_relatedTarget(relatedTarget) | 95 , m_relatedTarget(relatedTarget) |
| 96 , m_dataTransfer(dataTransfer) | 96 , m_dataTransfer(dataTransfer) |
| 97 , m_syntheticEventType(syntheticEventType) | 97 , m_syntheticEventType(syntheticEventType) |
| 98 { | 98 { |
| 99 setUICreateTime(uiCreateTime); | 99 setUICreateTime(uiCreateTime); |
| 100 if (syntheticEventType == PlatformMouseEvent::FromTouch) | |
| 101 setSourceDevice(InputDevice::firesTouchEventsInputDevice()); | |
| 102 else | |
| 103 setSourceDevice(InputDevice::doesntFireTouchEventsInputDevice()); | |
| 100 } | 104 } |
| 101 | 105 |
| 102 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer) | 106 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer) |
| 103 : MouseRelatedEvent(eventType, initializer.bubbles(), initializer.cancelable (), initializer.view(), initializer.detail(), IntPoint(initializer.screenX(), in itializer.screenY()), | 107 : MouseRelatedEvent(eventType, initializer.bubbles(), initializer.cancelable (), initializer.view(), initializer.detail(), IntPoint(initializer.screenX(), in itializer.screenY()), |
| 104 IntPoint(0 /* pageX */, 0 /* pageY */), | 108 IntPoint(0 /* pageX */, 0 /* pageY */), |
| 105 IntPoint(initializer.movementX(), initializer.movementY()), | 109 IntPoint(initializer.movementX(), initializer.movementY()), |
| 106 initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), ini tializer.metaKey(), false /* isSimulated */) | 110 initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), ini tializer.metaKey(), false /* isSimulated */, initializer.sourceDevice()) |
| 107 , m_button(initializer.button()) | 111 , m_button(initializer.button()) |
| 108 , m_buttons(initializer.buttons()) | 112 , m_buttons(initializer.buttons()) |
| 109 , m_relatedTarget(initializer.relatedTarget()) | 113 , m_relatedTarget(initializer.relatedTarget()) |
| 110 , m_dataTransfer(nullptr) | 114 , m_dataTransfer(nullptr) |
| 111 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) | 115 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) |
| 112 { | 116 { |
| 113 initCoordinates(IntPoint(initializer.clientX(), initializer.clientY())); | 117 initCoordinates(IntPoint(initializer.clientX(), initializer.clientY())); |
| 114 } | 118 } |
| 115 | 119 |
| 116 MouseEvent::~MouseEvent() | 120 MouseEvent::~MouseEvent() |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 127 buttons |= 2; | 131 buttons |= 2; |
| 128 if (modifiers & PlatformEvent::MiddleButtonDown) | 132 if (modifiers & PlatformEvent::MiddleButtonDown) |
| 129 buttons |= 4; | 133 buttons |= 4; |
| 130 | 134 |
| 131 return buttons; | 135 return buttons; |
| 132 } | 136 } |
| 133 | 137 |
| 134 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, | 138 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, |
| 135 int detail, int screenX, int screenY, int client X, int clientY, | 139 int detail, int screenX, int screenY, int client X, int clientY, |
| 136 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, | 140 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, |
| 137 short button, PassRefPtrWillBeRawPtr<EventTarget > relatedTarget, unsigned short buttons) | 141 short button, PassRefPtrWillBeRawPtr<EventTarget > relatedTarget, InputDevice* sourceDevice, unsigned short buttons) |
| 138 { | 142 { |
| 139 if (dispatched()) | 143 if (dispatched()) |
| 140 return; | 144 return; |
| 141 | 145 |
| 142 if (scriptState && scriptState->world().isIsolatedWorld()) | 146 if (scriptState && scriptState->world().isIsolatedWorld()) |
| 143 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); | 147 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); |
| 144 | 148 |
| 145 initUIEvent(type, canBubble, cancelable, view, detail); | 149 initUIEvent(type, canBubble, cancelable, view, detail, sourceDevice); |
| 146 | 150 |
| 147 m_screenLocation = IntPoint(screenX, screenY); | 151 m_screenLocation = IntPoint(screenX, screenY); |
| 148 m_ctrlKey = ctrlKey; | 152 m_ctrlKey = ctrlKey; |
| 149 m_altKey = altKey; | 153 m_altKey = altKey; |
| 150 m_shiftKey = shiftKey; | 154 m_shiftKey = shiftKey; |
| 151 m_metaKey = metaKey; | 155 m_metaKey = metaKey; |
| 152 m_button = button; | 156 m_button = button; |
| 153 m_buttons = buttons; | 157 m_buttons = buttons; |
| 154 m_relatedTarget = relatedTarget; | 158 m_relatedTarget = relatedTarget; |
| 155 | 159 |
| 156 initCoordinates(IntPoint(clientX, clientY)); | 160 initCoordinates(IntPoint(clientX, clientY)); |
| 157 | 161 |
| 158 // FIXME: m_isSimulated is not set to false here. | 162 // FIXME: m_isSimulated is not set to false here. |
| 159 // FIXME: m_dataTransfer is not set to nullptr here. | 163 // FIXME: m_dataTransfer is not set to nullptr here. |
| 160 } | 164 } |
| 161 | 165 |
| 166 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, int detail, int screenX, int screenY, | |
| 167 int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool met aKey, short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, unsigned short buttons) | |
| 168 { | |
| 169 initMouseEvent(scriptState, type, canBubble, cancelable, view, detail, scree nX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relat edTarget, nullptr, buttons); | |
| 170 } | |
| 171 | |
| 162 const AtomicString& MouseEvent::interfaceName() const | 172 const AtomicString& MouseEvent::interfaceName() const |
| 163 { | 173 { |
| 164 return EventNames::MouseEvent; | 174 return EventNames::MouseEvent; |
| 165 } | 175 } |
| 166 | 176 |
| 167 bool MouseEvent::isMouseEvent() const | 177 bool MouseEvent::isMouseEvent() const |
| 168 { | 178 { |
| 169 return true; | 179 return true; |
| 170 } | 180 } |
| 171 | 181 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (event().type() != EventTypeNames::click || event().detail() != 2) | 291 if (event().type() != EventTypeNames::click || event().detail() != 2) |
| 282 return !swallowEvent; | 292 return !swallowEvent; |
| 283 | 293 |
| 284 // 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 |
| 285 // 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 |
| 286 // 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. |
| 287 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); | 297 RefPtrWillBeRawPtr<MouseEvent> doubleClickEvent = MouseEvent::create(); |
| 288 doubleClickEvent->initMouseEvent(nullptr, EventTypeNames::dblclick, event(). bubbles(), event().cancelable(), event().view(), | 298 doubleClickEvent->initMouseEvent(nullptr, EventTypeNames::dblclick, event(). bubbles(), event().cancelable(), event().view(), |
| 289 event().detail(), event().screenX(), event().screenY(), event().clientX( ), event().clientY(), | 299 event().detail(), event().screenX(), event().screenY(), event().clientX( ), event().clientY(), |
| 290 event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey (), | 300 event().ctrlKey(), event().altKey(), event().shiftKey(), event().metaKey (), |
| 291 event().button(), relatedTarget, event().buttons()); | 301 event().button(), relatedTarget, event().sourceDevice(), event().buttons ()); |
| 292 if (event().defaultHandled()) | 302 if (event().defaultHandled()) |
| 293 doubleClickEvent->setDefaultHandled(); | 303 doubleClickEvent->setDefaultHandled(); |
| 294 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); | 304 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); |
| 295 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) | 305 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) |
| 296 return false; | 306 return false; |
| 297 return !swallowEvent; | 307 return !swallowEvent; |
| 298 } | 308 } |
| 299 | 309 |
| 300 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |