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 "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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 std::vector<std::string> ContextClick(); | 369 std::vector<std::string> ContextClick(); |
370 void TextZoomIn(); | 370 void TextZoomIn(); |
371 void TextZoomOut(); | 371 void TextZoomOut(); |
372 void ZoomPageIn(); | 372 void ZoomPageIn(); |
373 void ZoomPageOut(); | 373 void ZoomPageOut(); |
374 void SetPageZoomFactor(double factor); | 374 void SetPageZoomFactor(double factor); |
375 void SetPageScaleFactor(gin::Arguments* args); | 375 void SetPageScaleFactor(gin::Arguments* args); |
376 void SetPageScaleFactorLimits(gin::Arguments* args); | 376 void SetPageScaleFactorLimits(gin::Arguments* args); |
377 void ClearTouchPoints(); | 377 void ClearTouchPoints(); |
378 void ReleaseTouchPoint(unsigned index); | 378 void ReleaseTouchPoint(unsigned index); |
379 void UpdateTouchPoint(unsigned index, double x, double y); | 379 void UpdateTouchPoint(gin::Arguments* args); |
380 void CancelTouchPoint(unsigned index); | 380 void CancelTouchPoint(unsigned index); |
381 void SetTouchModifier(const std::string& key_name, bool set_mask); | 381 void SetTouchModifier(const std::string& key_name, bool set_mask); |
382 void SetTouchCancelable(bool cancelable); | 382 void SetTouchCancelable(bool cancelable); |
383 void DumpFilenameBeingDragged(); | 383 void DumpFilenameBeingDragged(); |
384 void GestureFlingCancel(); | 384 void GestureFlingCancel(); |
385 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); | 385 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); |
386 void GestureScrollFirstPoint(int x, int y); | 386 void GestureScrollFirstPoint(int x, int y); |
387 void TouchStart(); | 387 void TouchStart(); |
388 void TouchMove(); | 388 void TouchMove(); |
389 void TouchCancel(); | 389 void TouchCancel(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 void EventSenderBindings::ClearTouchPoints() { | 679 void EventSenderBindings::ClearTouchPoints() { |
680 if (sender_) | 680 if (sender_) |
681 sender_->ClearTouchPoints(); | 681 sender_->ClearTouchPoints(); |
682 } | 682 } |
683 | 683 |
684 void EventSenderBindings::ReleaseTouchPoint(unsigned index) { | 684 void EventSenderBindings::ReleaseTouchPoint(unsigned index) { |
685 if (sender_) | 685 if (sender_) |
686 sender_->ReleaseTouchPoint(index); | 686 sender_->ReleaseTouchPoint(index); |
687 } | 687 } |
688 | 688 |
689 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) { | 689 void EventSenderBindings::UpdateTouchPoint(gin::Arguments* args) { |
690 if (sender_) | 690 if (sender_) |
691 sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y
)); | 691 sender_->UpdateTouchPoint(args); |
692 } | 692 } |
693 | 693 |
694 void EventSenderBindings::CancelTouchPoint(unsigned index) { | 694 void EventSenderBindings::CancelTouchPoint(unsigned index) { |
695 if (sender_) | 695 if (sender_) |
696 sender_->CancelTouchPoint(index); | 696 sender_->CancelTouchPoint(index); |
697 } | 697 } |
698 | 698 |
699 void EventSenderBindings::SetTouchModifier(const std::string& key_name, | 699 void EventSenderBindings::SetTouchModifier(const std::string& key_name, |
700 bool set_mask) { | 700 bool set_mask) { |
701 if (sender_) | 701 if (sender_) |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 void EventSender::ReleaseTouchPoint(unsigned index) { | 1528 void EventSender::ReleaseTouchPoint(unsigned index) { |
1529 if (index >= touch_points_.size()) { | 1529 if (index >= touch_points_.size()) { |
1530 ThrowTouchPointError(); | 1530 ThrowTouchPointError(); |
1531 return; | 1531 return; |
1532 } | 1532 } |
1533 | 1533 |
1534 WebTouchPoint* touch_point = &touch_points_[index]; | 1534 WebTouchPoint* touch_point = &touch_points_[index]; |
1535 touch_point->state = WebTouchPoint::StateReleased; | 1535 touch_point->state = WebTouchPoint::StateReleased; |
1536 } | 1536 } |
1537 | 1537 |
1538 void EventSender::UpdateTouchPoint(unsigned index, float x, float y) { | 1538 void EventSender::UpdateTouchPoint(gin::Arguments* args) { |
| 1539 unsigned index; |
| 1540 float x; |
| 1541 float y; |
| 1542 |
| 1543 if (!args->GetNext(&index) || !args->GetNext(&x) || !args->GetNext(&y)) { |
| 1544 args->ThrowError(); |
| 1545 return; |
| 1546 } |
| 1547 |
1539 if (index >= touch_points_.size()) { | 1548 if (index >= touch_points_.size()) { |
1540 ThrowTouchPointError(); | 1549 ThrowTouchPointError(); |
1541 return; | 1550 return; |
1542 } | 1551 } |
1543 | 1552 |
1544 WebTouchPoint* touch_point = &touch_points_[index]; | 1553 WebTouchPoint* touch_point = &touch_points_[index]; |
1545 touch_point->state = WebTouchPoint::StateMoved; | 1554 touch_point->state = WebTouchPoint::StateMoved; |
1546 touch_point->position = WebFloatPoint(x, y); | 1555 touch_point->position = WebFloatPoint(x, y); |
1547 touch_point->screenPosition = touch_point->position; | 1556 touch_point->screenPosition = touch_point->position; |
| 1557 |
| 1558 if (!args->PeekNext().IsEmpty()) { |
| 1559 if (!args->GetNext(&touch_point->tilt)) { |
| 1560 args->ThrowError(); |
| 1561 return; |
| 1562 } |
| 1563 } |
| 1564 |
| 1565 if (!args->PeekNext().IsEmpty()) { |
| 1566 if (!args->GetNext(&touch_point->tiltDirection)) { |
| 1567 args->ThrowError(); |
| 1568 return; |
| 1569 } |
| 1570 } |
1548 } | 1571 } |
1549 | 1572 |
1550 void EventSender::CancelTouchPoint(unsigned index) { | 1573 void EventSender::CancelTouchPoint(unsigned index) { |
1551 if (index >= touch_points_.size()) { | 1574 if (index >= touch_points_.size()) { |
1552 ThrowTouchPointError(); | 1575 ThrowTouchPointError(); |
1553 return; | 1576 return; |
1554 } | 1577 } |
1555 | 1578 |
1556 WebTouchPoint* touch_point = &touch_points_[index]; | 1579 WebTouchPoint* touch_point = &touch_points_[index]; |
1557 touch_point->state = WebTouchPoint::StateCancelled; | 1580 touch_point->state = WebTouchPoint::StateCancelled; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 if (!args->GetNext(&radius_y)) { | 1737 if (!args->GetNext(&radius_y)) { |
1715 args->ThrowError(); | 1738 args->ThrowError(); |
1716 return; | 1739 return; |
1717 } | 1740 } |
1718 } | 1741 } |
1719 | 1742 |
1720 touch_point.radiusX = static_cast<float>(radius_x); | 1743 touch_point.radiusX = static_cast<float>(radius_x); |
1721 touch_point.radiusY = static_cast<float>(radius_y); | 1744 touch_point.radiusY = static_cast<float>(radius_y); |
1722 } | 1745 } |
1723 | 1746 |
| 1747 if (!args->PeekNext().IsEmpty()) { |
| 1748 if (!args->GetNext(&touch_point.tilt)) { |
| 1749 args->ThrowError(); |
| 1750 return; |
| 1751 } |
| 1752 } |
| 1753 |
| 1754 if (!args->PeekNext().IsEmpty()) { |
| 1755 if (!args->GetNext(&touch_point.tiltDirection)) { |
| 1756 args->ThrowError(); |
| 1757 return; |
| 1758 } |
| 1759 } |
| 1760 |
1724 int lowest_id = 0; | 1761 int lowest_id = 0; |
1725 for (size_t i = 0; i < touch_points_.size(); i++) { | 1762 for (size_t i = 0; i < touch_points_.size(); i++) { |
1726 if (touch_points_[i].id == lowest_id) | 1763 if (touch_points_[i].id == lowest_id) |
1727 lowest_id++; | 1764 lowest_id++; |
1728 } | 1765 } |
1729 touch_point.id = lowest_id; | 1766 touch_point.id = lowest_id; |
1730 touch_points_.push_back(touch_point); | 1767 touch_points_.push_back(touch_point); |
1731 } | 1768 } |
1732 | 1769 |
1733 void EventSender::MouseDragBegin() { | 1770 void EventSender::MouseDragBegin() { |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 | 2457 |
2421 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2458 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
2422 if (WebPagePopup* popup = view_->pagePopup()) { | 2459 if (WebPagePopup* popup = view_->pagePopup()) { |
2423 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2460 if (!WebInputEvent::isKeyboardEventType(event.type)) |
2424 return popup->handleInputEvent(event); | 2461 return popup->handleInputEvent(event); |
2425 } | 2462 } |
2426 return view_->handleInputEvent(event); | 2463 return view_->handleInputEvent(event); |
2427 } | 2464 } |
2428 | 2465 |
2429 } // namespace content | 2466 } // namespace content |
OLD | NEW |