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

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

Issue 316303002: Enable floating point touch co-ordinates in EventSender (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 sender_->ClearTouchPoints(); 626 sender_->ClearTouchPoints();
627 } 627 }
628 628
629 void EventSenderBindings::ReleaseTouchPoint(unsigned index) { 629 void EventSenderBindings::ReleaseTouchPoint(unsigned index) {
630 if (sender_) 630 if (sender_)
631 sender_->ReleaseTouchPoint(index); 631 sender_->ReleaseTouchPoint(index);
632 } 632 }
633 633
634 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) { 634 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) {
635 if (sender_) 635 if (sender_)
636 sender_->UpdateTouchPoint(index, static_cast<int>(x), static_cast<int>(y)); 636 sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y ));
637 } 637 }
638 638
639 void EventSenderBindings::CancelTouchPoint(unsigned index) { 639 void EventSenderBindings::CancelTouchPoint(unsigned index) {
640 if (sender_) 640 if (sender_)
641 sender_->CancelTouchPoint(index); 641 sender_->CancelTouchPoint(index);
642 } 642 }
643 643
644 void EventSenderBindings::SetTouchModifier(const std::string& key_name, 644 void EventSenderBindings::SetTouchModifier(const std::string& key_name,
645 bool set_mask) { 645 bool set_mask) {
646 if (sender_) 646 if (sender_)
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 void EventSender::ReleaseTouchPoint(unsigned index) { 1450 void EventSender::ReleaseTouchPoint(unsigned index) {
1451 if (index >= touch_points_.size()) { 1451 if (index >= touch_points_.size()) {
1452 ThrowTouchPointError(); 1452 ThrowTouchPointError();
1453 return; 1453 return;
1454 } 1454 }
1455 1455
1456 WebTouchPoint* touch_point = &touch_points_[index]; 1456 WebTouchPoint* touch_point = &touch_points_[index];
1457 touch_point->state = WebTouchPoint::StateReleased; 1457 touch_point->state = WebTouchPoint::StateReleased;
1458 } 1458 }
1459 1459
1460 void EventSender::UpdateTouchPoint(unsigned index, int x, int y) { 1460 void EventSender::UpdateTouchPoint(unsigned index, float x, float y) {
1461 if (index >= touch_points_.size()) { 1461 if (index >= touch_points_.size()) {
1462 ThrowTouchPointError(); 1462 ThrowTouchPointError();
1463 return; 1463 return;
1464 } 1464 }
1465 1465
1466 WebTouchPoint* touch_point = &touch_points_[index]; 1466 WebTouchPoint* touch_point = &touch_points_[index];
1467 touch_point->state = WebTouchPoint::StateMoved; 1467 touch_point->state = WebTouchPoint::StateMoved;
1468 touch_point->position = WebFloatPoint(x, y); 1468 touch_point->position = WebFloatPoint(x, y);
1469 touch_point->screenPosition = touch_point->position; 1469 touch_point->screenPosition = touch_point->position;
1470 } 1470 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 } 1608 }
1609 1609
1610 void EventSender::AddTouchPoint(gin::Arguments* args) { 1610 void EventSender::AddTouchPoint(gin::Arguments* args) {
1611 double x; 1611 double x;
1612 double y; 1612 double y;
1613 args->GetNext(&x); 1613 args->GetNext(&x);
1614 args->GetNext(&y); 1614 args->GetNext(&y);
1615 1615
1616 WebTouchPoint touch_point; 1616 WebTouchPoint touch_point;
1617 touch_point.state = WebTouchPoint::StatePressed; 1617 touch_point.state = WebTouchPoint::StatePressed;
1618 touch_point.position = WebFloatPoint(static_cast<int>(x), 1618 touch_point.position = WebFloatPoint(static_cast<float>(x),
1619 static_cast<int>(y)); 1619 static_cast<float>(y));
1620 touch_point.screenPosition = touch_point.position; 1620 touch_point.screenPosition = touch_point.position;
1621 1621
1622 if (!args->PeekNext().IsEmpty()) { 1622 if (!args->PeekNext().IsEmpty()) {
1623 double radius_x; 1623 double radius_x;
1624 if (!args->GetNext(&radius_x)) { 1624 if (!args->GetNext(&radius_x)) {
1625 args->ThrowError(); 1625 args->ThrowError();
1626 return; 1626 return;
1627 } 1627 }
1628 1628
1629 double radius_y = radius_x; 1629 double radius_y = radius_x;
1630 if (!args->PeekNext().IsEmpty()) { 1630 if (!args->PeekNext().IsEmpty()) {
1631 if (!args->GetNext(&radius_y)) { 1631 if (!args->GetNext(&radius_y)) {
1632 args->ThrowError(); 1632 args->ThrowError();
1633 return; 1633 return;
1634 } 1634 }
1635 } 1635 }
1636 1636
1637 touch_point.radiusX = static_cast<int>(radius_x); 1637 touch_point.radiusX = static_cast<float>(radius_x);
1638 touch_point.radiusY = static_cast<int>(radius_y); 1638 touch_point.radiusY = static_cast<float>(radius_y);
1639 } 1639 }
1640 1640
1641 int lowest_id = 0; 1641 int lowest_id = 0;
1642 for (size_t i = 0; i < touch_points_.size(); i++) { 1642 for (size_t i = 0; i < touch_points_.size(); i++) {
1643 if (touch_points_[i].id == lowest_id) 1643 if (touch_points_[i].id == lowest_id)
1644 lowest_id++; 1644 lowest_id++;
1645 } 1645 }
1646 touch_point.id = lowest_id; 1646 touch_point.id = lowest_id;
1647 touch_points_.push_back(touch_point); 1647 touch_points_.push_back(touch_point);
1648 } 1648 }
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 } 2242 }
2243 default: 2243 default:
2244 NOTREACHED(); 2244 NOTREACHED();
2245 } 2245 }
2246 } 2246 }
2247 2247
2248 replaying_saved_events_ = false; 2248 replaying_saved_events_ = false;
2249 } 2249 }
2250 2250
2251 } // namespace content 2251 } // 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