Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 902173003: EventSender::GestureFlingStart takes a source_device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/shell/renderer/test_runner/event_sender.h" 5 #include "content/shell/renderer/test_runner/event_sender.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/public/common/page_zoom.h" 10 #include "content/public/common/page_zoom.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 bool IsSystemKeyEvent(const WebKeyboardEvent& event) { 338 bool IsSystemKeyEvent(const WebKeyboardEvent& event) {
339 #if defined(OS_MACOSX) 339 #if defined(OS_MACOSX)
340 return event.modifiers & WebInputEvent::MetaKey && 340 return event.modifiers & WebInputEvent::MetaKey &&
341 event.windowsKeyCode != ui::VKEY_B && 341 event.windowsKeyCode != ui::VKEY_B &&
342 event.windowsKeyCode != ui::VKEY_I; 342 event.windowsKeyCode != ui::VKEY_I;
343 #else 343 #else
344 return !!(event.modifiers & WebInputEvent::AltKey); 344 return !!(event.modifiers & WebInputEvent::AltKey);
345 #endif 345 #endif
346 } 346 }
347 347
348 const char* kSourceDeviceStringTouchpad = "touchpad";
349 const char* kSourceDeviceStringTouchscreen = "touchscreen";
350
348 } // namespace 351 } // namespace
349 352
350 class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { 353 class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
351 public: 354 public:
352 static gin::WrapperInfo kWrapperInfo; 355 static gin::WrapperInfo kWrapperInfo;
353 356
354 static void Install(base::WeakPtr<EventSender> sender, 357 static void Install(base::WeakPtr<EventSender> sender,
355 blink::WebFrame* frame); 358 blink::WebFrame* frame);
356 359
357 private: 360 private:
(...skipping 17 matching lines...) Expand all
375 void SetPageScaleFactor(gin::Arguments* args); 378 void SetPageScaleFactor(gin::Arguments* args);
376 void SetPageScaleFactorLimits(gin::Arguments* args); 379 void SetPageScaleFactorLimits(gin::Arguments* args);
377 void ClearTouchPoints(); 380 void ClearTouchPoints();
378 void ReleaseTouchPoint(unsigned index); 381 void ReleaseTouchPoint(unsigned index);
379 void UpdateTouchPoint(unsigned index, double x, double y); 382 void UpdateTouchPoint(unsigned index, double x, double y);
380 void CancelTouchPoint(unsigned index); 383 void CancelTouchPoint(unsigned index);
381 void SetTouchModifier(const std::string& key_name, bool set_mask); 384 void SetTouchModifier(const std::string& key_name, bool set_mask);
382 void SetTouchCancelable(bool cancelable); 385 void SetTouchCancelable(bool cancelable);
383 void DumpFilenameBeingDragged(); 386 void DumpFilenameBeingDragged();
384 void GestureFlingCancel(); 387 void GestureFlingCancel();
385 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); 388 void GestureFlingStart(float x,
389 float y,
390 float velocity_x,
391 float velocity_y,
392 gin::Arguments* args);
386 void GestureScrollFirstPoint(int x, int y); 393 void GestureScrollFirstPoint(int x, int y);
387 void TouchStart(); 394 void TouchStart();
388 void TouchMove(); 395 void TouchMove();
389 void TouchCancel(); 396 void TouchCancel();
390 void TouchEnd(); 397 void TouchEnd();
391 void LeapForward(int milliseconds); 398 void LeapForward(int milliseconds);
392 void BeginDragWithFiles(const std::vector<std::string>& files); 399 void BeginDragWithFiles(const std::vector<std::string>& files);
393 void AddTouchPoint(gin::Arguments* args); 400 void AddTouchPoint(gin::Arguments* args);
394 void MouseDragBegin(); 401 void MouseDragBegin();
395 void MouseDragEnd(); 402 void MouseDragEnd();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 void EventSenderBindings::DumpFilenameBeingDragged() { 717 void EventSenderBindings::DumpFilenameBeingDragged() {
711 if (sender_) 718 if (sender_)
712 sender_->DumpFilenameBeingDragged(); 719 sender_->DumpFilenameBeingDragged();
713 } 720 }
714 721
715 void EventSenderBindings::GestureFlingCancel() { 722 void EventSenderBindings::GestureFlingCancel() {
716 if (sender_) 723 if (sender_)
717 sender_->GestureFlingCancel(); 724 sender_->GestureFlingCancel();
718 } 725 }
719 726
727 // TODO(tdresser): Once we've migrated all calls to GestureFlingStart
728 // to pass the device_string, change |args| to |std::string
729 // device_string|. See crbug.com/456136 for details.
720 void EventSenderBindings::GestureFlingStart(float x, 730 void EventSenderBindings::GestureFlingStart(float x,
721 float y, 731 float y,
722 float velocity_x, 732 float velocity_x,
723 float velocity_y) { 733 float velocity_y,
734 gin::Arguments* args) {
735 std::string device_string = kSourceDeviceStringTouchpad;
736 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) {
737 if (!args->GetNext(&device_string)) {
738 args->ThrowError();
739 return;
740 }
741 }
724 if (sender_) 742 if (sender_)
725 sender_->GestureFlingStart(x, y, velocity_x, velocity_y); 743 sender_->GestureFlingStart(x, y, velocity_x, velocity_y, device_string);
726 } 744 }
727 745
728 void EventSenderBindings::GestureScrollFirstPoint(int x, int y) { 746 void EventSenderBindings::GestureScrollFirstPoint(int x, int y) {
729 if (sender_) 747 if (sender_)
730 sender_->GestureScrollFirstPoint(x, y); 748 sender_->GestureScrollFirstPoint(x, y);
731 } 749 }
732 750
733 void EventSenderBindings::TouchStart() { 751 void EventSenderBindings::TouchStart() {
734 if (sender_) 752 if (sender_)
735 sender_->TouchStart(); 753 sender_->TouchStart();
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 event.type = WebInputEvent::GestureFlingCancel; 1618 event.type = WebInputEvent::GestureFlingCancel;
1601 event.timeStampSeconds = GetCurrentEventTimeSec(); 1619 event.timeStampSeconds = GetCurrentEventTimeSec();
1602 1620
1603 if (force_layout_on_events_) 1621 if (force_layout_on_events_)
1604 view_->layout(); 1622 view_->layout();
1605 1623
1606 HandleInputEventOnViewOrPopup(event); 1624 HandleInputEventOnViewOrPopup(event);
1607 } 1625 }
1608 1626
1609 void EventSender::GestureFlingStart(float x, 1627 void EventSender::GestureFlingStart(float x,
1610 float y, 1628 float y,
1611 float velocity_x, 1629 float velocity_x,
1612 float velocity_y) { 1630 float velocity_y,
1631 std::string device_string) {
1613 WebGestureEvent event; 1632 WebGestureEvent event;
1614 event.type = WebInputEvent::GestureFlingStart; 1633 event.type = WebInputEvent::GestureFlingStart;
1615 1634
1635 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
Rick Byers 2015/02/07 11:20:23 This should probably have logic similar to Gesture
tdresser 2015/02/09 14:48:08 My plan was to switch to use |std::string| instead
1636 if (device_string == kSourceDeviceStringTouchpad)
1637 event.sourceDevice = blink::WebGestureDeviceTouchpad;
1638
1616 event.x = x; 1639 event.x = x;
1617 event.y = y; 1640 event.y = y;
1618 event.globalX = event.x; 1641 event.globalX = event.x;
1619 event.globalY = event.y; 1642 event.globalY = event.y;
1620 1643
1621 event.data.flingStart.velocityX = velocity_x; 1644 event.data.flingStart.velocityX = velocity_x;
1622 event.data.flingStart.velocityY = velocity_y; 1645 event.data.flingStart.velocityY = velocity_y;
1623 event.timeStampSeconds = GetCurrentEventTimeSec(); 1646 event.timeStampSeconds = GetCurrentEventTimeSec();
1624 1647
1625 if (force_layout_on_events_) 1648 if (force_layout_on_events_)
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 // If the first argument is a string, it is to specify the device, otherwise 2014 // If the first argument is a string, it is to specify the device, otherwise
1992 // the device is assumed to be a touchscreen (since most tests were written 2015 // the device is assumed to be a touchscreen (since most tests were written
1993 // assuming this). 2016 // assuming this).
1994 event.sourceDevice = blink::WebGestureDeviceTouchscreen; 2017 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
1995 if (args->PeekNext()->IsString()) { 2018 if (args->PeekNext()->IsString()) {
1996 std::string device_string; 2019 std::string device_string;
1997 if (!args->GetNext(&device_string)) { 2020 if (!args->GetNext(&device_string)) {
1998 args->ThrowError(); 2021 args->ThrowError();
1999 return; 2022 return;
2000 } 2023 }
2001 if (device_string == "touchpad") { 2024 if (device_string == kSourceDeviceStringTouchpad) {
2002 event.sourceDevice = blink::WebGestureDeviceTouchpad; 2025 event.sourceDevice = blink::WebGestureDeviceTouchpad;
2003 } else if (device_string == "touchscreen") { 2026 } else if (device_string == kSourceDeviceStringTouchscreen) {
2004 event.sourceDevice = blink::WebGestureDeviceTouchscreen; 2027 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
2005 } else { 2028 } else {
2006 args->ThrowError(); 2029 args->ThrowError();
2007 return; 2030 return;
2008 } 2031 }
2009 } 2032 }
2010 2033
2011 double x; 2034 double x;
2012 double y; 2035 double y;
2013 if (!args->GetNext(&x) || !args->GetNext(&y)) { 2036 if (!args->GetNext(&x) || !args->GetNext(&y)) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2420 2443
2421 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { 2444 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) {
2422 if (WebPagePopup* popup = view_->pagePopup()) { 2445 if (WebPagePopup* popup = view_->pagePopup()) {
2423 if (!WebInputEvent::isKeyboardEventType(event.type)) 2446 if (!WebInputEvent::isKeyboardEventType(event.type))
2424 return popup->handleInputEvent(event); 2447 return popup->handleInputEvent(event);
2425 } 2448 }
2426 return view_->handleInputEvent(event); 2449 return view_->handleInputEvent(event);
2427 } 2450 }
2428 2451
2429 } // namespace content 2452 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698