| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "config.h" | 5 #include "config.h" | 
| 6 | 6 | 
| 7 #include "webkit/glue/webinputevent.h" | 7 #include "webkit/glue/webinputevent.h" | 
| 8 | 8 | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 156         break; | 156         break; | 
| 157       case SB_PAGEDOWN: | 157       case SB_PAGEDOWN: | 
| 158         wheel_delta = -1; | 158         wheel_delta = -1; | 
| 159         scroll_by_page = true; | 159         scroll_by_page = true; | 
| 160         break; | 160         break; | 
| 161       default:  // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here. | 161       default:  // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here. | 
| 162         wheel_delta = 0; | 162         wheel_delta = 0; | 
| 163         break; | 163         break; | 
| 164     } | 164     } | 
| 165 | 165 | 
| 166     if (message == WM_HSCROLL) { | 166     if (message == WM_HSCROLL) | 
| 167       horizontal_scroll = true; | 167       horizontal_scroll = true; | 
| 168       wheel_delta = -wheel_delta; |  | 
| 169     } |  | 
| 170   } else { | 168   } else { | 
| 171     // Non-synthesized event; we can just read data off the event. | 169     // Non-synthesized event; we can just read data off the event. | 
| 172     get_key_state = GetKeyState; | 170     get_key_state = GetKeyState; | 
| 173     key_state = GET_KEYSTATE_WPARAM(wparam); | 171     key_state = GET_KEYSTATE_WPARAM(wparam); | 
| 174 | 172 | 
| 175     global_x = static_cast<short>(LOWORD(lparam)); | 173     global_x = static_cast<short>(LOWORD(lparam)); | 
| 176     global_y = static_cast<short>(HIWORD(lparam)); | 174     global_y = static_cast<short>(HIWORD(lparam)); | 
| 177 | 175 | 
| 178     wheel_delta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam)); | 176     wheel_delta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam)); | 
| 179     if (((message == WM_MOUSEHWHEEL) || (key_state & MK_SHIFT)) && | 177     if (message == WM_MOUSEHWHEEL) { | 
| 180         (wheel_delta != 0)) |  | 
| 181       horizontal_scroll = true; | 178       horizontal_scroll = true; | 
|  | 179       wheel_delta = -wheel_delta;  // Windows is <- -/+ ->, WebKit <- +/- ->. | 
|  | 180     } | 
| 182   } | 181   } | 
|  | 182   if (key_state & MK_SHIFT) | 
|  | 183     horizontal_scroll = true; | 
| 183 | 184 | 
| 184   // Set modifiers based on key state. | 185   // Set modifiers based on key state. | 
| 185   if (key_state & MK_SHIFT) | 186   if (key_state & MK_SHIFT) | 
| 186     modifiers |= SHIFT_KEY; | 187     modifiers |= SHIFT_KEY; | 
| 187   if (key_state & MK_CONTROL) | 188   if (key_state & MK_CONTROL) | 
| 188     modifiers |= CTRL_KEY; | 189     modifiers |= CTRL_KEY; | 
| 189   if (get_key_state(VK_MENU) & 0x8000) | 190   if (get_key_state(VK_MENU) & 0x8000) | 
| 190     modifiers |= (ALT_KEY | META_KEY); | 191     modifiers |= (ALT_KEY | META_KEY); | 
| 191 | 192 | 
| 192   // Set coordinates by translating event coordinates from screen to client. | 193   // Set coordinates by translating event coordinates from screen to client. | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 216     unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; | 217     unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; | 
| 217     SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); | 218     SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); | 
| 218     if (scroll_lines == WHEEL_PAGESCROLL) | 219     if (scroll_lines == WHEEL_PAGESCROLL) | 
| 219       scroll_by_page = true; | 220       scroll_by_page = true; | 
| 220     if (!scroll_by_page) { | 221     if (!scroll_by_page) { | 
| 221       scroll_delta *= | 222       scroll_delta *= | 
| 222           static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine; | 223           static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine; | 
| 223     } | 224     } | 
| 224   } | 225   } | 
| 225 | 226 | 
| 226   // Set scroll amount based on above calculations. | 227   // Set scroll amount based on above calculations.  WebKit expects positive | 
|  | 228   // delta_y to mean "scroll up" and positive delta_x to mean "scroll left". | 
| 227   if (horizontal_scroll) { | 229   if (horizontal_scroll) { | 
| 228     delta_x = scroll_delta; | 230     delta_x = scroll_delta; | 
| 229     delta_y = 0; | 231     delta_y = 0; | 
| 230   } else { | 232   } else { | 
| 231     delta_x = 0; | 233     delta_x = 0; | 
| 232     delta_y = scroll_delta; | 234     delta_y = scroll_delta; | 
| 233   } | 235   } | 
| 234 } | 236 } | 
| 235 | 237 | 
| 236 // WebKeyboardEvent ----------------------------------------------------------- | 238 // WebKeyboardEvent ----------------------------------------------------------- | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 330     modifiers |= CTRL_KEY; | 332     modifiers |= CTRL_KEY; | 
| 331   if (GetKeyState(VK_MENU) & 0x8000) | 333   if (GetKeyState(VK_MENU) & 0x8000) | 
| 332     modifiers |= (ALT_KEY | META_KEY); | 334     modifiers |= (ALT_KEY | META_KEY); | 
| 333 | 335 | 
| 334   if (LOWORD(lparam) > 1) | 336   if (LOWORD(lparam) > 1) | 
| 335     modifiers |= IS_AUTO_REPEAT; | 337     modifiers |= IS_AUTO_REPEAT; | 
| 336   if (IsKeyPad(wparam, lparam)) | 338   if (IsKeyPad(wparam, lparam)) | 
| 337     modifiers |= IS_KEYPAD; | 339     modifiers |= IS_KEYPAD; | 
| 338 } | 340 } | 
| 339 | 341 | 
| OLD | NEW | 
|---|