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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 m_modifiers = 0; | 98 m_modifiers = 0; |
99 if (e.modifiers & WebInputEvent::ShiftKey) | 99 if (e.modifiers & WebInputEvent::ShiftKey) |
100 m_modifiers |= PlatformEvent::ShiftKey; | 100 m_modifiers |= PlatformEvent::ShiftKey; |
101 if (e.modifiers & WebInputEvent::ControlKey) | 101 if (e.modifiers & WebInputEvent::ControlKey) |
102 m_modifiers |= PlatformEvent::CtrlKey; | 102 m_modifiers |= PlatformEvent::CtrlKey; |
103 if (e.modifiers & WebInputEvent::AltKey) | 103 if (e.modifiers & WebInputEvent::AltKey) |
104 m_modifiers |= PlatformEvent::AltKey; | 104 m_modifiers |= PlatformEvent::AltKey; |
105 if (e.modifiers & WebInputEvent::MetaKey) | 105 if (e.modifiers & WebInputEvent::MetaKey) |
106 m_modifiers |= PlatformEvent::MetaKey; | 106 m_modifiers |= PlatformEvent::MetaKey; |
| 107 if (e.modifiers & WebInputEvent::LeftButtonDown) |
| 108 m_modifiers |= PlatformEvent::LeftButtonDown; |
| 109 if (e.modifiers & WebInputEvent::MiddleButtonDown) |
| 110 m_modifiers |= PlatformEvent::MiddleButtonDown; |
| 111 if (e.modifiers & WebInputEvent::RightButtonDown) |
| 112 m_modifiers |= PlatformEvent::RightButtonDown; |
107 | 113 |
108 m_modifierFlags = e.modifiers; | 114 m_modifierFlags = e.modifiers; |
109 m_timestamp = e.timeStampSeconds; | 115 m_timestamp = e.timeStampSeconds; |
110 m_clickCount = e.clickCount; | 116 m_clickCount = e.clickCount; |
111 | 117 |
| 118 const unsigned buttonToModifier[] = { |
| 119 PlatformEvent::LeftButtonDown, |
| 120 PlatformEvent::MiddleButtonDown, |
| 121 PlatformEvent::RightButtonDown |
| 122 }; |
| 123 |
112 switch (e.type) { | 124 switch (e.type) { |
113 case WebInputEvent::MouseMove: | 125 case WebInputEvent::MouseMove: |
114 case WebInputEvent::MouseLeave: // synthesize a move event | 126 case WebInputEvent::MouseLeave: // synthesize a move event |
115 m_type = PlatformEvent::MouseMoved; | 127 m_type = PlatformEvent::MouseMoved; |
116 break; | 128 break; |
117 | 129 |
118 case WebInputEvent::MouseDown: | 130 case WebInputEvent::MouseDown: |
119 m_type = PlatformEvent::MousePressed; | 131 m_type = PlatformEvent::MousePressed; |
120 break; | 132 break; |
121 | 133 |
122 case WebInputEvent::MouseUp: | 134 case WebInputEvent::MouseUp: |
123 m_type = PlatformEvent::MouseReleased; | 135 m_type = PlatformEvent::MouseReleased; |
| 136 |
| 137 // The MouseEvent spec requires that buttons indicates the state |
| 138 // immediately after the event takes place. To ensure consistency |
| 139 // between platforms here, we explicitly clear the button that is |
| 140 // in the process of being released. |
| 141 m_modifiers &= ~buttonToModifier[e.button]; |
124 break; | 142 break; |
125 | 143 |
126 default: | 144 default: |
127 ASSERT_NOT_REACHED(); | 145 ASSERT_NOT_REACHED(); |
128 } | 146 } |
129 } | 147 } |
130 | 148 |
131 // PlatformWheelEventBuilder -------------------------------------------------- | 149 // PlatformWheelEventBuilder -------------------------------------------------- |
132 | 150 |
133 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) | 151 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) |
(...skipping 11 matching lines...) Expand all Loading... |
145 | 163 |
146 m_modifiers = 0; | 164 m_modifiers = 0; |
147 if (e.modifiers & WebInputEvent::ShiftKey) | 165 if (e.modifiers & WebInputEvent::ShiftKey) |
148 m_modifiers |= PlatformEvent::ShiftKey; | 166 m_modifiers |= PlatformEvent::ShiftKey; |
149 if (e.modifiers & WebInputEvent::ControlKey) | 167 if (e.modifiers & WebInputEvent::ControlKey) |
150 m_modifiers |= PlatformEvent::CtrlKey; | 168 m_modifiers |= PlatformEvent::CtrlKey; |
151 if (e.modifiers & WebInputEvent::AltKey) | 169 if (e.modifiers & WebInputEvent::AltKey) |
152 m_modifiers |= PlatformEvent::AltKey; | 170 m_modifiers |= PlatformEvent::AltKey; |
153 if (e.modifiers & WebInputEvent::MetaKey) | 171 if (e.modifiers & WebInputEvent::MetaKey) |
154 m_modifiers |= PlatformEvent::MetaKey; | 172 m_modifiers |= PlatformEvent::MetaKey; |
| 173 if (e.modifiers & WebInputEvent::LeftButtonDown) |
| 174 m_modifiers |= PlatformEvent::LeftButtonDown; |
| 175 if (e.modifiers & WebInputEvent::MiddleButtonDown) |
| 176 m_modifiers |= PlatformEvent::MiddleButtonDown; |
| 177 if (e.modifiers & WebInputEvent::RightButtonDown) |
| 178 m_modifiers |= PlatformEvent::RightButtonDown; |
155 | 179 |
156 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; | 180 m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas; |
157 #if OS(MACOSX) | 181 #if OS(MACOSX) |
158 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); | 182 m_phase = static_cast<PlatformWheelEventPhase>(e.phase); |
159 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); | 183 m_momentumPhase = static_cast<PlatformWheelEventPhase>(e.momentumPhase); |
160 m_timestamp = e.timeStampSeconds; | 184 m_timestamp = e.timeStampSeconds; |
161 m_canRubberbandLeft = e.canRubberbandLeft; | 185 m_canRubberbandLeft = e.canRubberbandLeft; |
162 m_canRubberbandRight = e.canRubberbandRight; | 186 m_canRubberbandRight = e.canRubberbandRight; |
163 #endif | 187 #endif |
164 } | 188 } |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 modifiers = getWebInputModifiers(event); | 840 modifiers = getWebInputModifiers(event); |
817 | 841 |
818 globalX = event.screenX(); | 842 globalX = event.screenX(); |
819 globalY = event.screenY(); | 843 globalY = event.screenY(); |
820 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 844 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
821 x = localPoint.x(); | 845 x = localPoint.x(); |
822 y = localPoint.y(); | 846 y = localPoint.y(); |
823 } | 847 } |
824 | 848 |
825 } // namespace blink | 849 } // namespace blink |
OLD | NEW |