Chromium Code Reviews| Index: components/test_runner/event_sender.cc |
| diff --git a/components/test_runner/event_sender.cc b/components/test_runner/event_sender.cc |
| index be730ccc00809fa273ecd47071c9eb71d6e49259..83d4b4070d1b294df224bfffe72fe9983833469d 100644 |
| --- a/components/test_runner/event_sender.cc |
| +++ b/components/test_runner/event_sender.cc |
| @@ -329,6 +329,35 @@ int GetKeyModifiersFromV8(v8::Isolate* isolate, v8::Local<v8::Value> value) { |
| return GetKeyModifiers(modifier_names); |
| } |
| +WebMouseWheelEvent::Phase GetMouseWheelEventPhase( |
| + const std::string& phase_name) { |
| + const char* characters = phase_name.c_str(); |
| + 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
|
| + return WebMouseWheelEvent::PhaseNone; |
| + } else if (!strcmp(characters, "phaseBegan")) { |
| + return WebMouseWheelEvent::PhaseBegan; |
| + } else if (!strcmp(characters, "phaseStationary")) { |
| + return WebMouseWheelEvent::PhaseStationary; |
| + } else if (!strcmp(characters, "phaseChanged")) { |
| + return WebMouseWheelEvent::PhaseChanged; |
| + } else if (!strcmp(characters, "phaseEnded")) { |
| + return WebMouseWheelEvent::PhaseEnded; |
| + } else if (!strcmp(characters, "phaseCancelled")) { |
| + return WebMouseWheelEvent::PhaseCancelled; |
| + } else if (!strcmp(characters, "phaseMayBegin")) { |
| + return WebMouseWheelEvent::PhaseMayBegin; |
| + } |
| + |
| + return WebMouseWheelEvent::PhaseNone; |
| +} |
| + |
| +WebMouseWheelEvent::Phase GetMouseWheelEventPhaseFromV8( |
| + v8::Local<v8::Value> value) { |
| + if (value->IsString()) |
| + return GetMouseWheelEventPhase(gin::V8ToString(value)); |
| + return WebMouseWheelEvent::PhaseNone; |
| +} |
| + |
| // Maximum distance (in space and time) for a mouse click to register as a |
| // double or triple click. |
| const double kMultipleClickTimeSec = 1; |
| @@ -2540,6 +2569,7 @@ void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| bool paged = false; |
| bool has_precise_scrolling_deltas = false; |
| int modifiers = 0; |
| + WebMouseWheelEvent::Phase phase = WebMouseWheelEvent::PhaseNone; |
| if (!args->PeekNext().IsEmpty()) { |
| args->GetNext(&paged); |
| if (!args->PeekNext().IsEmpty()) { |
| @@ -2550,6 +2580,11 @@ void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| modifiers = GetKeyModifiersFromV8(args->isolate(), value); |
| if (!args->PeekNext().IsEmpty()) { |
| args->GetNext(send_gestures); |
| + if (!args->PeekNext().IsEmpty()) { |
| + v8::Local<v8::Value> phase_value; |
| + args->GetNext(&phase_value); |
| + phase = GetMouseWheelEventPhaseFromV8(phase_value); |
| + } |
| } |
| } |
| } |
| @@ -2566,6 +2601,7 @@ void EventSender::InitMouseWheelEvent(gin::Arguments* args, |
| event->deltaY = event->wheelTicksY; |
| event->scrollByPage = paged; |
| event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; |
| + event->phase = phase; |
| if (scroll_type == MouseScrollType::PIXEL) { |
| event->wheelTicksX /= kScrollbarPixelsPerTick; |
| event->wheelTicksY /= kScrollbarPixelsPerTick; |