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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 event.movementDelta().x(), event.movementDelta().y(), | 53 event.movementDelta().x(), event.movementDelta().y(), |
| 54 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even t.button(), | 54 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even t.button(), |
| 55 platformModifiersToButtons(event.modifiers()), | 55 platformModifiersToButtons(event.modifiers()), |
| 56 relatedTarget, nullptr, false, event.syntheticEventType(), event.timesta mp()); | 56 relatedTarget, nullptr, false, event.syntheticEventType(), event.timesta mp()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, | 59 PassRefPtrWillBeRawPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, |
| 60 int detail, int screenX, int screenY, int windowX, int windowY, | 60 int detail, int screenX, int screenY, int windowX, int windowY, |
| 61 int movementX, int movementY, | 61 int movementX, int movementY, |
| 62 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 62 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 63 unsigned short button, unsigned short buttons, | 63 short button, unsigned short buttons, |
| 64 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, DataTransfer* dataTransfe r, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType, | 64 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, DataTransfer* dataTransfe r, bool isSimulated, PlatformMouseEvent::SyntheticEventType syntheticEventType, |
| 65 double uiCreateTime) | 65 double uiCreateTime) |
| 66 { | 66 { |
| 67 return adoptRefWillBeNoop(new MouseEvent(type, canBubble, cancelable, view, | 67 return adoptRefWillBeNoop(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 ctrlKey, altKey, shiftKey, metaKey, button, buttons, relatedTarget, data Transfer, isSimulated, syntheticEventType, uiCreateTime)); | 70 ctrlKey, altKey, shiftKey, metaKey, button, buttons, relatedTarget, data Transfer, isSimulated, syntheticEventType, uiCreateTime)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 MouseEvent::MouseEvent() | 73 MouseEvent::MouseEvent() |
| 74 : m_button(0) | 74 : m_button(0) |
| 75 , m_buttons(0) | 75 , m_buttons(0) |
| 76 , m_buttonDown(false) | 76 , m_buttonDown(false) |
| 77 , m_relatedTarget(nullptr) | 77 , m_relatedTarget(nullptr) |
| 78 , m_dataTransfer(nullptr) | 78 , m_dataTransfer(nullptr) |
| 79 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) | 79 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) |
| 80 { | 80 { |
| 81 } | 81 } |
| 82 | 82 |
| 83 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, | 83 MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance lable, PassRefPtrWillBeRawPtr<AbstractView> view, |
| 84 int detail, int screenX, int screenY, int windowX, int windowY, | 84 int detail, int screenX, int screenY, int windowX, int windowY, |
| 85 int movementX, int movementY, | 85 int movementX, int movementY, |
| 86 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | 86 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, |
| 87 unsigned short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventT arget> relatedTarget, | 87 short button, unsigned short buttons, PassRefPtrWillBeRawPtr<EventTarget> re latedTarget, |
| 88 DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticE ventType syntheticEventType, | 88 DataTransfer* dataTransfer, bool isSimulated, PlatformMouseEvent::SyntheticE ventType syntheticEventType, |
| 89 double uiCreateTime) | 89 double uiCreateTime) |
| 90 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), | 90 : MouseRelatedEvent(eventType, canBubble, cancelable, view, detail, IntPoint (screenX, screenY), |
| 91 IntPoint(windowX, windowY), | 91 IntPoint(windowX, windowY), |
| 92 IntPoint(movementX, movementY), | 92 IntPoint(movementX, movementY), |
| 93 ctrlKey, altKey, shiftKey, metaKey, isSimulated) | 93 ctrlKey, altKey, shiftKey, metaKey, isSimulated) |
| 94 , m_button(button == (unsigned short)-1 ? 0 : button) | 94 , m_button(button == -1 ? 0 : button) |
|
philipj_slow
2015/06/09 09:35:38
Getting rid of these casts will be nice. However,
ramya.v
2015/06/09 11:14:31
I've checked for any internal paths which could pa
philipj_slow
2015/06/09 12:04:06
OK, it looks like the MouseButton enum member NoBu
| |
| 95 , m_buttons(buttons) | 95 , m_buttons(buttons) |
| 96 , m_buttonDown(button != (unsigned short)-1) | 96 , m_buttonDown(button != -1) |
| 97 , m_relatedTarget(relatedTarget) | 97 , m_relatedTarget(relatedTarget) |
| 98 , m_dataTransfer(dataTransfer) | 98 , m_dataTransfer(dataTransfer) |
| 99 , m_syntheticEventType(syntheticEventType) | 99 , m_syntheticEventType(syntheticEventType) |
| 100 { | 100 { |
| 101 setUICreateTime(uiCreateTime); | 101 setUICreateTime(uiCreateTime); |
| 102 } | 102 } |
| 103 | 103 |
| 104 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer) | 104 MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init ializer) |
| 105 : MouseRelatedEvent(eventType, initializer.bubbles(), initializer.cancelable (), initializer.view(), initializer.detail(), IntPoint(initializer.screenX(), in itializer.screenY()), | 105 : MouseRelatedEvent(eventType, initializer.bubbles(), initializer.cancelable (), initializer.view(), initializer.detail(), IntPoint(initializer.screenX(), in itializer.screenY()), |
| 106 IntPoint(0 /* pageX */, 0 /* pageY */), | 106 IntPoint(0 /* pageX */, 0 /* pageY */), |
| 107 IntPoint(initializer.movementX(), initializer.movementY()), | 107 IntPoint(initializer.movementX(), initializer.movementY()), |
| 108 initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), ini tializer.metaKey(), false /* isSimulated */) | 108 initializer.ctrlKey(), initializer.altKey(), initializer.shiftKey(), ini tializer.metaKey(), false /* isSimulated */) |
| 109 , m_button(initializer.button() == (unsigned short)-1 ? 0 : initializer.butt on()) | 109 , m_button(initializer.button() == -1 ? 0 : initializer.button()) |
| 110 , m_buttons(initializer.buttons()) | 110 , m_buttons(initializer.buttons()) |
| 111 , m_buttonDown(initializer.button() != (unsigned short)-1) | 111 , m_buttonDown(initializer.button() != -1) |
| 112 , m_relatedTarget(initializer.relatedTarget()) | 112 , m_relatedTarget(initializer.relatedTarget()) |
| 113 , m_dataTransfer(nullptr) | 113 , m_dataTransfer(nullptr) |
| 114 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) | 114 , m_syntheticEventType(PlatformMouseEvent::RealOrIndistinguishable) |
| 115 { | 115 { |
| 116 initCoordinates(IntPoint(initializer.clientX(), initializer.clientY())); | 116 initCoordinates(IntPoint(initializer.clientX(), initializer.clientY())); |
| 117 } | 117 } |
| 118 | 118 |
| 119 MouseEvent::~MouseEvent() | 119 MouseEvent::~MouseEvent() |
| 120 { | 120 { |
| 121 } | 121 } |
| 122 | 122 |
| 123 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers) | 123 unsigned short MouseEvent::platformModifiersToButtons(unsigned modifiers) |
| 124 { | 124 { |
| 125 unsigned short buttons = 0; | 125 unsigned short buttons = 0; |
| 126 | 126 |
| 127 if (modifiers & PlatformEvent::LeftButtonDown) | 127 if (modifiers & PlatformEvent::LeftButtonDown) |
| 128 buttons |= 1; | 128 buttons |= 1; |
| 129 if (modifiers & PlatformEvent::RightButtonDown) | 129 if (modifiers & PlatformEvent::RightButtonDown) |
| 130 buttons |= 2; | 130 buttons |= 2; |
| 131 if (modifiers & PlatformEvent::MiddleButtonDown) | 131 if (modifiers & PlatformEvent::MiddleButtonDown) |
| 132 buttons |= 4; | 132 buttons |= 4; |
| 133 | 133 |
| 134 return buttons; | 134 return buttons; |
| 135 } | 135 } |
| 136 | 136 |
| 137 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, | 137 void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty pe, bool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView> view, |
| 138 int detail, int screenX, int screenY, int client X, int clientY, | 138 int detail, int screenX, int screenY, int client X, int clientY, |
| 139 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, | 139 bool ctrlKey, bool altKey, bool shiftKey, bool m etaKey, |
| 140 unsigned short button, PassRefPtrWillBeRawPtr<Ev entTarget> relatedTarget, unsigned short buttons) | 140 short button, PassRefPtrWillBeRawPtr<EventTarget > relatedTarget, unsigned short buttons) |
| 141 { | 141 { |
| 142 if (dispatched()) | 142 if (dispatched()) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 if (scriptState && scriptState->world().isIsolatedWorld()) | 145 if (scriptState && scriptState->world().isIsolatedWorld()) |
| 146 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); | 146 UIEventWithKeyState::didCreateEventInIsolatedWorld(ctrlKey, altKey, shif tKey, metaKey); |
| 147 | 147 |
| 148 initUIEvent(type, canBubble, cancelable, view, detail); | 148 initUIEvent(type, canBubble, cancelable, view, detail); |
| 149 | 149 |
| 150 m_screenLocation = IntPoint(screenX, screenY); | 150 m_screenLocation = IntPoint(screenX, screenY); |
| 151 m_ctrlKey = ctrlKey; | 151 m_ctrlKey = ctrlKey; |
| 152 m_altKey = altKey; | 152 m_altKey = altKey; |
| 153 m_shiftKey = shiftKey; | 153 m_shiftKey = shiftKey; |
| 154 m_metaKey = metaKey; | 154 m_metaKey = metaKey; |
| 155 m_button = button == (unsigned short)-1 ? 0 : button; | 155 m_button = button == -1 ? 0 : button; |
| 156 m_buttons = buttons; | 156 m_buttons = buttons; |
| 157 m_buttonDown = button != (unsigned short)-1; | 157 m_buttonDown = button != -1; |
| 158 m_relatedTarget = relatedTarget; | 158 m_relatedTarget = relatedTarget; |
| 159 | 159 |
| 160 initCoordinates(IntPoint(clientX, clientY)); | 160 initCoordinates(IntPoint(clientX, clientY)); |
| 161 | 161 |
| 162 // FIXME: m_isSimulated is not set to false here. | 162 // FIXME: m_isSimulated is not set to false here. |
| 163 // FIXME: m_dataTransfer is not set to nullptr here. | 163 // FIXME: m_dataTransfer is not set to nullptr here. |
| 164 } | 164 } |
| 165 | 165 |
| 166 const AtomicString& MouseEvent::interfaceName() const | 166 const AtomicString& MouseEvent::interfaceName() const |
| 167 { | 167 { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 event().button(), relatedTarget, event().buttons()); | 297 event().button(), relatedTarget, event().buttons()); |
| 298 if (event().defaultHandled()) | 298 if (event().defaultHandled()) |
| 299 doubleClickEvent->setDefaultHandled(); | 299 doubleClickEvent->setDefaultHandled(); |
| 300 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); | 300 EventDispatcher::dispatchEvent(dispatcher.node(), MouseEventDispatchMediator ::create(doubleClickEvent)); |
| 301 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) | 301 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) |
| 302 return false; | 302 return false; |
| 303 return !swallowEvent; | 303 return !swallowEvent; |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |