OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 newModifiers |= PlatformEvent::ShiftKey; | 105 newModifiers |= PlatformEvent::ShiftKey; |
106 if (webModifiers & WebInputEvent::ControlKey) | 106 if (webModifiers & WebInputEvent::ControlKey) |
107 newModifiers |= PlatformEvent::CtrlKey; | 107 newModifiers |= PlatformEvent::CtrlKey; |
108 if (webModifiers & WebInputEvent::AltKey) | 108 if (webModifiers & WebInputEvent::AltKey) |
109 newModifiers |= PlatformEvent::AltKey; | 109 newModifiers |= PlatformEvent::AltKey; |
110 if (webModifiers & WebInputEvent::MetaKey) | 110 if (webModifiers & WebInputEvent::MetaKey) |
111 newModifiers |= PlatformEvent::MetaKey; | 111 newModifiers |= PlatformEvent::MetaKey; |
112 return newModifiers; | 112 return newModifiers; |
113 } | 113 } |
114 | 114 |
| 115 static unsigned toPlatformMouseEventModifiers(int webModifiers) |
| 116 { |
| 117 unsigned newModifiers = toPlatformEventModifiers(webModifiers); |
| 118 if (webModifiers & WebInputEvent::LeftButtonDown) |
| 119 newModifiers |= PlatformEvent::LeftButtonDown; |
| 120 if (webModifiers & WebInputEvent::MiddleButtonDown) |
| 121 newModifiers |= PlatformEvent::MiddleButtonDown; |
| 122 if (webModifiers & WebInputEvent::RightButtonDown) |
| 123 newModifiers |= PlatformEvent::RightButtonDown; |
| 124 return newModifiers; |
| 125 } |
| 126 |
| 127 static unsigned toPlatformModifierFrom(WebMouseEvent::Button button) |
| 128 { |
| 129 if (button == WebMouseEvent::ButtonNone) |
| 130 return 0; |
| 131 |
| 132 unsigned webMouseButtonToPlatformModifier[] = { |
| 133 PlatformEvent::LeftButtonDown, |
| 134 PlatformEvent::MiddleButtonDown, |
| 135 PlatformEvent::RightButtonDown |
| 136 }; |
| 137 |
| 138 return webMouseButtonToPlatformModifier[button]; |
| 139 } |
| 140 |
115 // MakePlatformMouseEvent ----------------------------------------------------- | 141 // MakePlatformMouseEvent ----------------------------------------------------- |
116 | 142 |
117 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) | 143 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) |
118 { | 144 { |
119 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 145 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
120 // to get rid of this once we abstract popups into a WebKit API. | 146 // to get rid of this once we abstract popups into a WebKit API. |
121 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, IntPoint(e.x, e.y)))); | 147 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, IntPoint(e.x, e.y)))); |
122 m_globalPosition = IntPoint(e.globalX, e.globalY); | 148 m_globalPosition = IntPoint(e.globalX, e.globalY); |
123 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel
taToWindow(widget, e.movementY)); | 149 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel
taToWindow(widget, e.movementY)); |
124 m_button = static_cast<MouseButton>(e.button); | 150 m_button = static_cast<MouseButton>(e.button); |
125 m_modifiers = toPlatformEventModifiers(e.modifiers); | 151 m_modifiers = toPlatformMouseEventModifiers(e.modifiers); |
126 | 152 |
127 m_timestamp = e.timeStampSeconds; | 153 m_timestamp = e.timeStampSeconds; |
128 m_clickCount = e.clickCount; | 154 m_clickCount = e.clickCount; |
129 | 155 |
130 switch (e.type) { | 156 switch (e.type) { |
131 case WebInputEvent::MouseMove: | 157 case WebInputEvent::MouseMove: |
132 case WebInputEvent::MouseLeave: // synthesize a move event | 158 case WebInputEvent::MouseLeave: // synthesize a move event |
133 m_type = PlatformEvent::MouseMoved; | 159 m_type = PlatformEvent::MouseMoved; |
134 break; | 160 break; |
135 | 161 |
136 case WebInputEvent::MouseDown: | 162 case WebInputEvent::MouseDown: |
137 m_type = PlatformEvent::MousePressed; | 163 m_type = PlatformEvent::MousePressed; |
138 break; | 164 break; |
139 | 165 |
140 case WebInputEvent::MouseUp: | 166 case WebInputEvent::MouseUp: |
141 m_type = PlatformEvent::MouseReleased; | 167 m_type = PlatformEvent::MouseReleased; |
| 168 |
| 169 // The MouseEvent spec requires that buttons indicates the state |
| 170 // immediately after the event takes place. To ensure consistency |
| 171 // between platforms here, we explicitly clear the button that is |
| 172 // in the process of being released. |
| 173 m_modifiers &= ~toPlatformModifierFrom(e.button); |
142 break; | 174 break; |
143 | 175 |
144 default: | 176 default: |
145 ASSERT_NOT_REACHED(); | 177 ASSERT_NOT_REACHED(); |
146 } | 178 } |
147 } | 179 } |
148 | 180 |
149 // PlatformWheelEventBuilder -------------------------------------------------- | 181 // PlatformWheelEventBuilder -------------------------------------------------- |
150 | 182 |
151 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) | 183 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) |
152 { | 184 { |
153 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, FloatPoint(e.x, e.y)))); | 185 m_position = widget->convertFromContainingWindow(flooredIntPoint(convertHitP
ointToWindow(widget, FloatPoint(e.x, e.y)))); |
154 m_globalPosition = IntPoint(e.globalX, e.globalY); | 186 m_globalPosition = IntPoint(e.globalX, e.globalY); |
155 m_deltaX = e.deltaX; | 187 m_deltaX = e.deltaX; |
156 m_deltaY = e.deltaY; | 188 m_deltaY = e.deltaY; |
157 m_wheelTicksX = e.wheelTicksX; | 189 m_wheelTicksX = e.wheelTicksX; |
158 m_wheelTicksY = e.wheelTicksY; | 190 m_wheelTicksY = e.wheelTicksY; |
159 m_granularity = e.scrollByPage ? | 191 m_granularity = e.scrollByPage ? |
160 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; | 192 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; |
161 | 193 |
162 m_type = PlatformEvent::Wheel; | 194 m_type = PlatformEvent::Wheel; |
163 | 195 |
164 m_modifiers = toPlatformEventModifiers(e.modifiers); | 196 m_modifiers = toPlatformMouseEventModifiers(e.modifiers); |
165 | 197 |
166 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; | 198 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; |
167 #if OS(MACOSX) | 199 #if OS(MACOSX) |
168 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); | 200 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); |
169 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); | 201 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); |
170 m_timestamp = e.timeStampSeconds; | 202 m_timestamp = e.timeStampSeconds; |
171 m_canRubberbandLeft = e.canRubberbandLeft; | 203 m_canRubberbandLeft = e.canRubberbandLeft; |
172 m_canRubberbandRight = e.canRubberbandRight; | 204 m_canRubberbandRight = e.canRubberbandRight; |
173 #endif | 205 #endif |
174 } | 206 } |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 modifiers = getWebInputModifiers(event); | 800 modifiers = getWebInputModifiers(event); |
769 | 801 |
770 globalX = event.screenX(); | 802 globalX = event.screenX(); |
771 globalY = event.screenY(); | 803 globalY = event.screenY(); |
772 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 804 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
773 x = localPoint.x(); | 805 x = localPoint.x(); |
774 y = localPoint.y(); | 806 y = localPoint.y(); |
775 } | 807 } |
776 | 808 |
777 } // namespace blink | 809 } // namespace blink |
OLD | NEW |