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