| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 std::vector<std::string> modifier_names; | 322 std::vector<std::string> modifier_names; |
| 323 if (value->IsString()) { | 323 if (value->IsString()) { |
| 324 modifier_names.push_back(gin::V8ToString(value)); | 324 modifier_names.push_back(gin::V8ToString(value)); |
| 325 } else if (value->IsArray()) { | 325 } else if (value->IsArray()) { |
| 326 gin::Converter<std::vector<std::string> >::FromV8( | 326 gin::Converter<std::vector<std::string> >::FromV8( |
| 327 isolate, value, &modifier_names); | 327 isolate, value, &modifier_names); |
| 328 } | 328 } |
| 329 return GetKeyModifiers(modifier_names); | 329 return GetKeyModifiers(modifier_names); |
| 330 } | 330 } |
| 331 | 331 |
| 332 WebMouseWheelEvent::Phase GetMouseWheelEventPhase( |
| 333 const std::string& phase_name) { |
| 334 if (phase_name == "phaseNone") { |
| 335 return WebMouseWheelEvent::PhaseNone; |
| 336 } else if (phase_name == "phaseBegan") { |
| 337 return WebMouseWheelEvent::PhaseBegan; |
| 338 } else if (phase_name == "phaseStationary") { |
| 339 return WebMouseWheelEvent::PhaseStationary; |
| 340 } else if (phase_name == "phaseChanged") { |
| 341 return WebMouseWheelEvent::PhaseChanged; |
| 342 } else if (phase_name == "phaseEnded") { |
| 343 return WebMouseWheelEvent::PhaseEnded; |
| 344 } else if (phase_name == "phaseCancelled") { |
| 345 return WebMouseWheelEvent::PhaseCancelled; |
| 346 } else if (phase_name == "phaseMayBegin") { |
| 347 return WebMouseWheelEvent::PhaseMayBegin; |
| 348 } |
| 349 |
| 350 return WebMouseWheelEvent::PhaseNone; |
| 351 } |
| 352 |
| 353 WebMouseWheelEvent::Phase GetMouseWheelEventPhaseFromV8( |
| 354 v8::Local<v8::Value> value) { |
| 355 if (value->IsString()) |
| 356 return GetMouseWheelEventPhase(gin::V8ToString(value)); |
| 357 return WebMouseWheelEvent::PhaseNone; |
| 358 } |
| 359 |
| 332 // Maximum distance (in space and time) for a mouse click to register as a | 360 // Maximum distance (in space and time) for a mouse click to register as a |
| 333 // double or triple click. | 361 // double or triple click. |
| 334 const double kMultipleClickTimeSec = 1; | 362 const double kMultipleClickTimeSec = 1; |
| 335 const int kMultipleClickRadiusPixels = 5; | 363 const int kMultipleClickRadiusPixels = 5; |
| 336 const char kSubMenuDepthIdentifier[] = "_"; | 364 const char kSubMenuDepthIdentifier[] = "_"; |
| 337 const char kSubMenuIdentifier[] = " >"; | 365 const char kSubMenuIdentifier[] = " >"; |
| 338 const char kSeparatorIdentifier[] = "---------"; | 366 const char kSeparatorIdentifier[] = "---------"; |
| 339 const char kDisabledIdentifier[] = "#"; | 367 const char kDisabledIdentifier[] = "#"; |
| 340 const char kCheckedIdentifier[] = "*"; | 368 const char kCheckedIdentifier[] = "*"; |
| 341 | 369 |
| (...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2533 } | 2561 } |
| 2534 double vertical; | 2562 double vertical; |
| 2535 if (!args->GetNext(&vertical)) { | 2563 if (!args->GetNext(&vertical)) { |
| 2536 args->ThrowError(); | 2564 args->ThrowError(); |
| 2537 return; | 2565 return; |
| 2538 } | 2566 } |
| 2539 | 2567 |
| 2540 bool paged = false; | 2568 bool paged = false; |
| 2541 bool has_precise_scrolling_deltas = false; | 2569 bool has_precise_scrolling_deltas = false; |
| 2542 int modifiers = 0; | 2570 int modifiers = 0; |
| 2571 WebMouseWheelEvent::Phase phase = WebMouseWheelEvent::PhaseNone; |
| 2543 if (!args->PeekNext().IsEmpty()) { | 2572 if (!args->PeekNext().IsEmpty()) { |
| 2544 args->GetNext(&paged); | 2573 args->GetNext(&paged); |
| 2545 if (!args->PeekNext().IsEmpty()) { | 2574 if (!args->PeekNext().IsEmpty()) { |
| 2546 args->GetNext(&has_precise_scrolling_deltas); | 2575 args->GetNext(&has_precise_scrolling_deltas); |
| 2547 if (!args->PeekNext().IsEmpty()) { | 2576 if (!args->PeekNext().IsEmpty()) { |
| 2548 v8::Local<v8::Value> value; | 2577 v8::Local<v8::Value> value; |
| 2549 args->GetNext(&value); | 2578 args->GetNext(&value); |
| 2550 modifiers = GetKeyModifiersFromV8(args->isolate(), value); | 2579 modifiers = GetKeyModifiersFromV8(args->isolate(), value); |
| 2551 if (!args->PeekNext().IsEmpty()) { | 2580 if (!args->PeekNext().IsEmpty()) { |
| 2552 args->GetNext(send_gestures); | 2581 args->GetNext(send_gestures); |
| 2582 if (!args->PeekNext().IsEmpty()) { |
| 2583 v8::Local<v8::Value> phase_value; |
| 2584 args->GetNext(&phase_value); |
| 2585 phase = GetMouseWheelEventPhaseFromV8(phase_value); |
| 2586 } |
| 2553 } | 2587 } |
| 2554 } | 2588 } |
| 2555 } | 2589 } |
| 2556 } | 2590 } |
| 2557 | 2591 |
| 2558 InitMouseEvent(WebInputEvent::MouseWheel, | 2592 InitMouseEvent(WebInputEvent::MouseWheel, |
| 2559 current_pointer_state_[kRawMousePointerId].pressed_button_, | 2593 current_pointer_state_[kRawMousePointerId].pressed_button_, |
| 2560 current_pointer_state_[kRawMousePointerId].current_buttons_, | 2594 current_pointer_state_[kRawMousePointerId].current_buttons_, |
| 2561 current_pointer_state_[kRawMousePointerId].last_pos_, | 2595 current_pointer_state_[kRawMousePointerId].last_pos_, |
| 2562 GetCurrentEventTimeSec(), click_count_, modifiers, event); | 2596 GetCurrentEventTimeSec(), click_count_, modifiers, event); |
| 2563 event->wheelTicksX = static_cast<float>(horizontal); | 2597 event->wheelTicksX = static_cast<float>(horizontal); |
| 2564 event->wheelTicksY = static_cast<float>(vertical); | 2598 event->wheelTicksY = static_cast<float>(vertical); |
| 2565 event->deltaX = event->wheelTicksX; | 2599 event->deltaX = event->wheelTicksX; |
| 2566 event->deltaY = event->wheelTicksY; | 2600 event->deltaY = event->wheelTicksY; |
| 2567 event->scrollByPage = paged; | 2601 event->scrollByPage = paged; |
| 2568 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; | 2602 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; |
| 2603 event->phase = phase; |
| 2569 if (scroll_type == MouseScrollType::PIXEL) { | 2604 if (scroll_type == MouseScrollType::PIXEL) { |
| 2570 event->wheelTicksX /= kScrollbarPixelsPerTick; | 2605 event->wheelTicksX /= kScrollbarPixelsPerTick; |
| 2571 event->wheelTicksY /= kScrollbarPixelsPerTick; | 2606 event->wheelTicksY /= kScrollbarPixelsPerTick; |
| 2572 } else { | 2607 } else { |
| 2573 event->deltaX *= kScrollbarPixelsPerTick; | 2608 event->deltaX *= kScrollbarPixelsPerTick; |
| 2574 event->deltaY *= kScrollbarPixelsPerTick; | 2609 event->deltaY *= kScrollbarPixelsPerTick; |
| 2575 } | 2610 } |
| 2576 } | 2611 } |
| 2577 | 2612 |
| 2578 // Radius fields radius_x and radius_y should eventually be moved to | 2613 // Radius fields radius_x and radius_y should eventually be moved to |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2829 } | 2864 } |
| 2830 | 2865 |
| 2831 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( | 2866 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( |
| 2832 const WebInputEvent& event) { | 2867 const WebInputEvent& event) { |
| 2833 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event | 2868 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event |
| 2834 // does not have to be converted. | 2869 // does not have to be converted. |
| 2835 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | 2870 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); |
| 2836 } | 2871 } |
| 2837 | 2872 |
| 2838 } // namespace test_runner | 2873 } // namespace test_runner |
| OLD | NEW |