| 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/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 void TextZoomOut(); | 376 void TextZoomOut(); |
| 377 void ZoomPageIn(); | 377 void ZoomPageIn(); |
| 378 void ZoomPageOut(); | 378 void ZoomPageOut(); |
| 379 void SetPageZoomFactor(double factor); | 379 void SetPageZoomFactor(double factor); |
| 380 void SetPageScaleFactor(gin::Arguments* args); | 380 void SetPageScaleFactor(gin::Arguments* args); |
| 381 void SetPageScaleFactorLimits(gin::Arguments* args); | 381 void SetPageScaleFactorLimits(gin::Arguments* args); |
| 382 void ClearTouchPoints(); | 382 void ClearTouchPoints(); |
| 383 void ReleaseTouchPoint(unsigned index); | 383 void ReleaseTouchPoint(unsigned index); |
| 384 void UpdateTouchPoint(unsigned index, double x, double y); | 384 void UpdateTouchPoint(unsigned index, double x, double y); |
| 385 void CancelTouchPoint(unsigned index); | 385 void CancelTouchPoint(unsigned index); |
| 386 void SetTouchPointRadius(unsigned index, |
| 387 float rx, |
| 388 float ry, |
| 389 bool set_state_moved); |
| 386 void SetTouchModifier(const std::string& key_name, bool set_mask); | 390 void SetTouchModifier(const std::string& key_name, bool set_mask); |
| 387 void SetTouchCancelable(bool cancelable); | 391 void SetTouchCancelable(bool cancelable); |
| 388 void DumpFilenameBeingDragged(); | 392 void DumpFilenameBeingDragged(); |
| 389 void GestureFlingCancel(); | 393 void GestureFlingCancel(); |
| 390 void GestureFlingStart(float x, | 394 void GestureFlingStart(float x, |
| 391 float y, | 395 float y, |
| 392 float velocity_x, | 396 float velocity_x, |
| 393 float velocity_y, | 397 float velocity_y, |
| 394 gin::Arguments* args); | 398 gin::Arguments* args); |
| 395 void GestureScrollFirstPoint(int x, int y); | 399 void GestureScrollFirstPoint(int x, int y); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) | 515 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) |
| 512 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) | 516 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) |
| 513 .SetMethod("setPageZoomFactor", &EventSenderBindings::SetPageZoomFactor) | 517 .SetMethod("setPageZoomFactor", &EventSenderBindings::SetPageZoomFactor) |
| 514 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) | 518 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) |
| 515 .SetMethod("setPageScaleFactorLimits", | 519 .SetMethod("setPageScaleFactorLimits", |
| 516 &EventSenderBindings::SetPageScaleFactorLimits) | 520 &EventSenderBindings::SetPageScaleFactorLimits) |
| 517 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) | 521 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) |
| 518 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) | 522 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) |
| 519 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) | 523 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) |
| 520 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) | 524 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) |
| 525 .SetMethod("setTouchPointRadius", |
| 526 &EventSenderBindings::SetTouchPointRadius) |
| 521 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) | 527 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) |
| 522 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) | 528 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) |
| 523 .SetMethod("dumpFilenameBeingDragged", | 529 .SetMethod("dumpFilenameBeingDragged", |
| 524 &EventSenderBindings::DumpFilenameBeingDragged) | 530 &EventSenderBindings::DumpFilenameBeingDragged) |
| 525 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) | 531 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) |
| 526 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) | 532 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) |
| 527 .SetMethod("gestureScrollFirstPoint", | 533 .SetMethod("gestureScrollFirstPoint", |
| 528 &EventSenderBindings::GestureScrollFirstPoint) | 534 &EventSenderBindings::GestureScrollFirstPoint) |
| 529 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 535 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 530 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 536 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) { | 706 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) { |
| 701 if (sender_) | 707 if (sender_) |
| 702 sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y
)); | 708 sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y
)); |
| 703 } | 709 } |
| 704 | 710 |
| 705 void EventSenderBindings::CancelTouchPoint(unsigned index) { | 711 void EventSenderBindings::CancelTouchPoint(unsigned index) { |
| 706 if (sender_) | 712 if (sender_) |
| 707 sender_->CancelTouchPoint(index); | 713 sender_->CancelTouchPoint(index); |
| 708 } | 714 } |
| 709 | 715 |
| 716 void EventSenderBindings::SetTouchPointRadius(unsigned index, |
| 717 float rx, |
| 718 float ry, |
| 719 bool set_state_moved) { |
| 720 if (sender_) |
| 721 sender_->SetTouchPointRadius(index, rx, ry, set_state_moved); |
| 722 } |
| 723 |
| 710 void EventSenderBindings::SetTouchModifier(const std::string& key_name, | 724 void EventSenderBindings::SetTouchModifier(const std::string& key_name, |
| 711 bool set_mask) { | 725 bool set_mask) { |
| 712 if (sender_) | 726 if (sender_) |
| 713 sender_->SetTouchModifier(key_name, set_mask); | 727 sender_->SetTouchModifier(key_name, set_mask); |
| 714 } | 728 } |
| 715 | 729 |
| 716 void EventSenderBindings::SetTouchCancelable(bool cancelable) { | 730 void EventSenderBindings::SetTouchCancelable(bool cancelable) { |
| 717 if (sender_) | 731 if (sender_) |
| 718 sender_->SetTouchCancelable(cancelable); | 732 sender_->SetTouchCancelable(cancelable); |
| 719 } | 733 } |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 void EventSender::CancelTouchPoint(unsigned index) { | 1618 void EventSender::CancelTouchPoint(unsigned index) { |
| 1605 if (index >= touch_points_.size()) { | 1619 if (index >= touch_points_.size()) { |
| 1606 ThrowTouchPointError(); | 1620 ThrowTouchPointError(); |
| 1607 return; | 1621 return; |
| 1608 } | 1622 } |
| 1609 | 1623 |
| 1610 WebTouchPoint* touch_point = &touch_points_[index]; | 1624 WebTouchPoint* touch_point = &touch_points_[index]; |
| 1611 touch_point->state = WebTouchPoint::StateCancelled; | 1625 touch_point->state = WebTouchPoint::StateCancelled; |
| 1612 } | 1626 } |
| 1613 | 1627 |
| 1628 void EventSender::SetTouchPointRadius(unsigned index, |
| 1629 float rx, |
| 1630 float ry, |
| 1631 bool set_state_moved) { |
| 1632 if (index >= touch_points_.size()) { |
| 1633 ThrowTouchPointError(); |
| 1634 return; |
| 1635 } |
| 1636 |
| 1637 WebTouchPoint* touch_point = &touch_points_[index]; |
| 1638 if (set_state_moved) |
| 1639 touch_point->state = WebTouchPoint::StateMoved; |
| 1640 touch_point->radiusX = rx; |
| 1641 touch_point->radiusY = ry; |
| 1642 } |
| 1643 |
| 1614 void EventSender::SetTouchModifier(const std::string& key_name, | 1644 void EventSender::SetTouchModifier(const std::string& key_name, |
| 1615 bool set_mask) { | 1645 bool set_mask) { |
| 1616 int mask = 0; | 1646 int mask = 0; |
| 1617 if (key_name == "shift") | 1647 if (key_name == "shift") |
| 1618 mask = WebInputEvent::ShiftKey; | 1648 mask = WebInputEvent::ShiftKey; |
| 1619 else if (key_name == "alt") | 1649 else if (key_name == "alt") |
| 1620 mask = WebInputEvent::AltKey; | 1650 mask = WebInputEvent::AltKey; |
| 1621 else if (key_name == "ctrl") | 1651 else if (key_name == "ctrl") |
| 1622 mask = WebInputEvent::ControlKey; | 1652 mask = WebInputEvent::ControlKey; |
| 1623 else if (key_name == "meta") | 1653 else if (key_name == "meta") |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 args->ThrowError(); | 1793 args->ThrowError(); |
| 1764 return; | 1794 return; |
| 1765 } | 1795 } |
| 1766 | 1796 |
| 1767 WebTouchPoint touch_point; | 1797 WebTouchPoint touch_point; |
| 1768 touch_point.state = WebTouchPoint::StatePressed; | 1798 touch_point.state = WebTouchPoint::StatePressed; |
| 1769 touch_point.position = WebFloatPoint(static_cast<float>(x), | 1799 touch_point.position = WebFloatPoint(static_cast<float>(x), |
| 1770 static_cast<float>(y)); | 1800 static_cast<float>(y)); |
| 1771 touch_point.screenPosition = touch_point.position; | 1801 touch_point.screenPosition = touch_point.position; |
| 1772 | 1802 |
| 1803 // TODO: remove this after blink patch #990193002 be landed |
| 1773 if (!args->PeekNext().IsEmpty()) { | 1804 if (!args->PeekNext().IsEmpty()) { |
| 1774 double radius_x; | 1805 double radius_x; |
| 1775 if (!args->GetNext(&radius_x)) { | 1806 if (!args->GetNext(&radius_x)) { |
| 1776 args->ThrowError(); | 1807 args->ThrowError(); |
| 1777 return; | 1808 return; |
| 1778 } | 1809 } |
| 1779 | 1810 |
| 1780 double radius_y = radius_x; | 1811 double radius_y = radius_x; |
| 1781 if (!args->PeekNext().IsEmpty()) { | 1812 if (!args->PeekNext().IsEmpty()) { |
| 1782 if (!args->GetNext(&radius_y)) { | 1813 if (!args->GetNext(&radius_y)) { |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 | 2535 |
| 2505 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2536 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
| 2506 if (WebPagePopup* popup = view_->pagePopup()) { | 2537 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2507 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2538 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2508 return popup->handleInputEvent(event); | 2539 return popup->handleInputEvent(event); |
| 2509 } | 2540 } |
| 2510 return view_->handleInputEvent(event); | 2541 return view_->handleInputEvent(event); |
| 2511 } | 2542 } |
| 2512 | 2543 |
| 2513 } // namespace content | 2544 } // namespace content |
| OLD | NEW |