| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 bool IsSystemKeyEvent(const WebKeyboardEvent& event) { | 401 bool IsSystemKeyEvent(const WebKeyboardEvent& event) { |
| 402 #if defined(OS_MACOSX) | 402 #if defined(OS_MACOSX) |
| 403 return event.modifiers & WebInputEvent::MetaKey && | 403 return event.modifiers & WebInputEvent::MetaKey && |
| 404 event.windowsKeyCode != ui::VKEY_B && | 404 event.windowsKeyCode != ui::VKEY_B && |
| 405 event.windowsKeyCode != ui::VKEY_I; | 405 event.windowsKeyCode != ui::VKEY_I; |
| 406 #else | 406 #else |
| 407 return !!(event.modifiers & WebInputEvent::AltKey); | 407 return !!(event.modifiers & WebInputEvent::AltKey); |
| 408 #endif | 408 #endif |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool GetScrollUnits(gin::Arguments* args, WebGestureEvent::ScrollUnits* units) { |
| 412 std::string units_string; |
| 413 if (!args->PeekNext().IsEmpty()) { |
| 414 if (args->PeekNext()->IsString()) |
| 415 args->GetNext(&units_string); |
| 416 if (units_string == "Page") { |
| 417 *units = WebGestureEvent::Page; |
| 418 return true; |
| 419 } else if (units_string == "Pixels") { |
| 420 *units = WebGestureEvent::Pixels; |
| 421 return true; |
| 422 } else if (units_string == "PrecisePixels") { |
| 423 *units = WebGestureEvent::PrecisePixels; |
| 424 return true; |
| 425 } else { |
| 426 args->ThrowError(); |
| 427 return false; |
| 428 } |
| 429 } else { |
| 430 *units = WebGestureEvent::PrecisePixels; |
| 431 return true; |
| 432 } |
| 433 } |
| 434 |
| 411 const char* kSourceDeviceStringTouchpad = "touchpad"; | 435 const char* kSourceDeviceStringTouchpad = "touchpad"; |
| 412 const char* kSourceDeviceStringTouchscreen = "touchscreen"; | 436 const char* kSourceDeviceStringTouchscreen = "touchscreen"; |
| 413 | 437 |
| 414 const char* kPointerTypeStringUnknown = ""; | 438 const char* kPointerTypeStringUnknown = ""; |
| 415 const char* kPointerTypeStringMouse = "mouse"; | 439 const char* kPointerTypeStringMouse = "mouse"; |
| 416 const char* kPointerTypeStringPen = "pen"; | 440 const char* kPointerTypeStringPen = "pen"; |
| 417 const char* kPointerTypeStringTouch = "touch"; | 441 const char* kPointerTypeStringTouch = "touch"; |
| 418 | 442 |
| 419 } // namespace | 443 } // namespace |
| 420 | 444 |
| (...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 switch (type) { | 2159 switch (type) { |
| 2136 case WebInputEvent::GestureScrollUpdate: | 2160 case WebInputEvent::GestureScrollUpdate: |
| 2137 { | 2161 { |
| 2138 bool preventPropagation = false; | 2162 bool preventPropagation = false; |
| 2139 if (!args->PeekNext().IsEmpty()) { | 2163 if (!args->PeekNext().IsEmpty()) { |
| 2140 if (!args->GetNext(&preventPropagation)) { | 2164 if (!args->GetNext(&preventPropagation)) { |
| 2141 args->ThrowError(); | 2165 args->ThrowError(); |
| 2142 return; | 2166 return; |
| 2143 } | 2167 } |
| 2144 } | 2168 } |
| 2169 if (!GetScrollUnits(args, &event.data.scrollUpdate.deltaUnits)) |
| 2170 return; |
| 2145 | 2171 |
| 2146 event.data.scrollUpdate.deltaX = static_cast<float>(x); | 2172 event.data.scrollUpdate.deltaX = static_cast<float>(x); |
| 2147 event.data.scrollUpdate.deltaY = static_cast<float>(y); | 2173 event.data.scrollUpdate.deltaY = static_cast<float>(y); |
| 2148 event.data.scrollUpdate.preventPropagation = preventPropagation; | 2174 event.data.scrollUpdate.preventPropagation = preventPropagation; |
| 2149 event.x = current_gesture_location_.x; | 2175 event.x = current_gesture_location_.x; |
| 2150 event.y = current_gesture_location_.y; | 2176 event.y = current_gesture_location_.y; |
| 2151 current_gesture_location_.x = | 2177 current_gesture_location_.x = |
| 2152 current_gesture_location_.x + event.data.scrollUpdate.deltaX; | 2178 current_gesture_location_.x + event.data.scrollUpdate.deltaX; |
| 2153 current_gesture_location_.y = | 2179 current_gesture_location_.y = |
| 2154 current_gesture_location_.y + event.data.scrollUpdate.deltaY; | 2180 current_gesture_location_.y + event.data.scrollUpdate.deltaY; |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2615 last_event_timestamp_ = event.timeStampSeconds; | 2641 last_event_timestamp_ = event.timeStampSeconds; |
| 2616 | 2642 |
| 2617 if (WebPagePopup* popup = view_->pagePopup()) { | 2643 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2618 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2644 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2619 return popup->handleInputEvent(event); | 2645 return popup->handleInputEvent(event); |
| 2620 } | 2646 } |
| 2621 return view_->handleInputEvent(event); | 2647 return view_->handleInputEvent(event); |
| 2622 } | 2648 } |
| 2623 | 2649 |
| 2624 } // namespace test_runner | 2650 } // namespace test_runner |
| OLD | NEW |