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

Unified Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 755403006: Added experimental Touch.tilt, Touch.tiltDirection support for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added logic to detect whether Tilt, TiltDirection are supported (use NaN value, if not) 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/renderer/test_runner/event_sender.cc
diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc
index e02fe0cef1c2ca25679949bc5cd748cdb726e9ee..17b9f36ad2e71b1bf0d43de78a828f00493c0efd 100644
--- a/content/shell/renderer/test_runner/event_sender.cc
+++ b/content/shell/renderer/test_runner/event_sender.cc
@@ -376,7 +376,7 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
void SetPageScaleFactorLimits(gin::Arguments* args);
void ClearTouchPoints();
void ReleaseTouchPoint(unsigned index);
- void UpdateTouchPoint(unsigned index, double x, double y);
+ void UpdateTouchPoint(gin::Arguments* args);
void CancelTouchPoint(unsigned index);
void SetTouchModifier(const std::string& key_name, bool set_mask);
void SetTouchCancelable(bool cancelable);
@@ -686,9 +686,9 @@ void EventSenderBindings::ReleaseTouchPoint(unsigned index) {
sender_->ReleaseTouchPoint(index);
}
-void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) {
+void EventSenderBindings::UpdateTouchPoint(gin::Arguments* args) {
if (sender_)
- sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y));
+ sender_->UpdateTouchPoint(args);
}
void EventSenderBindings::CancelTouchPoint(unsigned index) {
@@ -1535,7 +1535,16 @@ void EventSender::ReleaseTouchPoint(unsigned index) {
touch_point->state = WebTouchPoint::StateReleased;
}
-void EventSender::UpdateTouchPoint(unsigned index, float x, float y) {
+void EventSender::UpdateTouchPoint(gin::Arguments* args) {
+ unsigned index;
+ float x;
+ float y;
+
+ if (!args->GetNext(&index) || !args->GetNext(&x) || !args->GetNext(&y)) {
+ args->ThrowError();
+ return;
+ }
+
if (index >= touch_points_.size()) {
ThrowTouchPointError();
return;
@@ -1545,6 +1554,20 @@ void EventSender::UpdateTouchPoint(unsigned index, float x, float y) {
touch_point->state = WebTouchPoint::StateMoved;
touch_point->position = WebFloatPoint(x, y);
touch_point->screenPosition = touch_point->position;
+
+ if (!args->PeekNext().IsEmpty()) {
+ if (!args->GetNext(&touch_point->tilt)) {
+ args->ThrowError();
+ return;
+ }
+ }
+
+ if (!args->PeekNext().IsEmpty()) {
+ if (!args->GetNext(&touch_point->tiltDirection)) {
+ args->ThrowError();
+ return;
+ }
+ }
}
void EventSender::CancelTouchPoint(unsigned index) {
@@ -1721,6 +1744,20 @@ void EventSender::AddTouchPoint(gin::Arguments* args) {
touch_point.radiusY = static_cast<float>(radius_y);
}
+ if (!args->PeekNext().IsEmpty()) {
+ if (!args->GetNext(&touch_point.tilt)) {
+ args->ThrowError();
+ return;
+ }
+ }
+
+ if (!args->PeekNext().IsEmpty()) {
+ if (!args->GetNext(&touch_point.tiltDirection)) {
+ args->ThrowError();
+ return;
+ }
+ }
+
int lowest_id = 0;
for (size_t i = 0; i < touch_points_.size(); i++) {
if (touch_points_[i].id == lowest_id)

Powered by Google App Engine
This is Rietveld 408576698