Chromium Code Reviews| 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 SetTouchPointTilt(unsigned index, float tils, float tiltDirection); | |
| 381 void SetTouchModifier(const std::string& key_name, bool set_mask); | 382 void SetTouchModifier(const std::string& key_name, bool set_mask); |
| 382 void SetTouchCancelable(bool cancelable); | 383 void SetTouchCancelable(bool cancelable); |
| 383 void DumpFilenameBeingDragged(); | 384 void DumpFilenameBeingDragged(); |
| 384 void GestureFlingCancel(); | 385 void GestureFlingCancel(); |
| 385 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); | 386 void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); |
| 386 void GestureScrollFirstPoint(int x, int y); | 387 void GestureScrollFirstPoint(int x, int y); |
| 387 void TouchStart(); | 388 void TouchStart(); |
| 388 void TouchMove(); | 389 void TouchMove(); |
| 389 void TouchCancel(); | 390 void TouchCancel(); |
| 390 void TouchEnd(); | 391 void TouchEnd(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) | 502 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) |
| 502 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) | 503 .SetMethod("zoomPageOut", &EventSenderBindings::ZoomPageOut) |
| 503 .SetMethod("setPageZoomFactor", &EventSenderBindings::SetPageZoomFactor) | 504 .SetMethod("setPageZoomFactor", &EventSenderBindings::SetPageZoomFactor) |
| 504 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) | 505 .SetMethod("setPageScaleFactor", &EventSenderBindings::SetPageScaleFactor) |
| 505 .SetMethod("setPageScaleFactorLimits", | 506 .SetMethod("setPageScaleFactorLimits", |
| 506 &EventSenderBindings::SetPageScaleFactorLimits) | 507 &EventSenderBindings::SetPageScaleFactorLimits) |
| 507 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) | 508 .SetMethod("clearTouchPoints", &EventSenderBindings::ClearTouchPoints) |
| 508 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) | 509 .SetMethod("releaseTouchPoint", &EventSenderBindings::ReleaseTouchPoint) |
| 509 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) | 510 .SetMethod("updateTouchPoint", &EventSenderBindings::UpdateTouchPoint) |
| 510 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) | 511 .SetMethod("cancelTouchPoint", &EventSenderBindings::CancelTouchPoint) |
| 512 .SetMethod("setTouchPointTilt", &EventSenderBindings::SetTouchPointTilt) | |
| 511 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) | 513 .SetMethod("setTouchModifier", &EventSenderBindings::SetTouchModifier) |
| 512 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) | 514 .SetMethod("setTouchCancelable", &EventSenderBindings::SetTouchCancelable) |
| 513 .SetMethod("dumpFilenameBeingDragged", | 515 .SetMethod("dumpFilenameBeingDragged", |
| 514 &EventSenderBindings::DumpFilenameBeingDragged) | 516 &EventSenderBindings::DumpFilenameBeingDragged) |
| 515 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) | 517 .SetMethod("gestureFlingCancel", &EventSenderBindings::GestureFlingCancel) |
| 516 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) | 518 .SetMethod("gestureFlingStart", &EventSenderBindings::GestureFlingStart) |
| 517 .SetMethod("gestureScrollFirstPoint", | 519 .SetMethod("gestureScrollFirstPoint", |
| 518 &EventSenderBindings::GestureScrollFirstPoint) | 520 &EventSenderBindings::GestureScrollFirstPoint) |
| 519 .SetMethod("touchStart", &EventSenderBindings::TouchStart) | 521 .SetMethod("touchStart", &EventSenderBindings::TouchStart) |
| 520 .SetMethod("touchMove", &EventSenderBindings::TouchMove) | 522 .SetMethod("touchMove", &EventSenderBindings::TouchMove) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 void EventSenderBindings::ClearTouchPoints() { | 681 void EventSenderBindings::ClearTouchPoints() { |
| 680 if (sender_) | 682 if (sender_) |
| 681 sender_->ClearTouchPoints(); | 683 sender_->ClearTouchPoints(); |
| 682 } | 684 } |
| 683 | 685 |
| 684 void EventSenderBindings::ReleaseTouchPoint(unsigned index) { | 686 void EventSenderBindings::ReleaseTouchPoint(unsigned index) { |
| 685 if (sender_) | 687 if (sender_) |
| 686 sender_->ReleaseTouchPoint(index); | 688 sender_->ReleaseTouchPoint(index); |
| 687 } | 689 } |
| 688 | 690 |
| 689 void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) { | 691 void EventSenderBindings::UpdateTouchPoint(gin::Arguments* args) { |
| 690 if (sender_) | 692 if (sender_) |
| 691 sender_->UpdateTouchPoint(index, static_cast<float>(x), static_cast<float>(y )); | 693 sender_->UpdateTouchPoint(args); |
| 692 } | 694 } |
| 693 | 695 |
| 694 void EventSenderBindings::CancelTouchPoint(unsigned index) { | 696 void EventSenderBindings::CancelTouchPoint(unsigned index) { |
| 695 if (sender_) | 697 if (sender_) |
| 696 sender_->CancelTouchPoint(index); | 698 sender_->CancelTouchPoint(index); |
| 697 } | 699 } |
| 698 | 700 |
| 701 void EventSenderBindings::SetTouchPointTilt(unsigned index, | |
| 702 float tilt, | |
| 703 float tiltDirection) { | |
| 704 if (sender_) | |
| 705 sender_->SetTouchPointTilt(index, tilt, tiltDirection); | |
| 706 } | |
| 707 | |
| 699 void EventSenderBindings::SetTouchModifier(const std::string& key_name, | 708 void EventSenderBindings::SetTouchModifier(const std::string& key_name, |
| 700 bool set_mask) { | 709 bool set_mask) { |
| 701 if (sender_) | 710 if (sender_) |
| 702 sender_->SetTouchModifier(key_name, set_mask); | 711 sender_->SetTouchModifier(key_name, set_mask); |
| 703 } | 712 } |
| 704 | 713 |
| 705 void EventSenderBindings::SetTouchCancelable(bool cancelable) { | 714 void EventSenderBindings::SetTouchCancelable(bool cancelable) { |
| 706 if (sender_) | 715 if (sender_) |
| 707 sender_->SetTouchCancelable(cancelable); | 716 sender_->SetTouchCancelable(cancelable); |
| 708 } | 717 } |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 void EventSender::ReleaseTouchPoint(unsigned index) { | 1537 void EventSender::ReleaseTouchPoint(unsigned index) { |
| 1529 if (index >= touch_points_.size()) { | 1538 if (index >= touch_points_.size()) { |
| 1530 ThrowTouchPointError(); | 1539 ThrowTouchPointError(); |
| 1531 return; | 1540 return; |
| 1532 } | 1541 } |
| 1533 | 1542 |
| 1534 WebTouchPoint* touch_point = &touch_points_[index]; | 1543 WebTouchPoint* touch_point = &touch_points_[index]; |
| 1535 touch_point->state = WebTouchPoint::StateReleased; | 1544 touch_point->state = WebTouchPoint::StateReleased; |
| 1536 } | 1545 } |
| 1537 | 1546 |
| 1538 void EventSender::UpdateTouchPoint(unsigned index, float x, float y) { | 1547 void EventSender::UpdateTouchPoint(gin::Arguments* args) { |
| 1548 unsigned index; | |
| 1549 float x; | |
| 1550 float y; | |
| 1551 | |
| 1552 if (!args->GetNext(&index) || !args->GetNext(&x) || !args->GetNext(&y)) { | |
| 1553 args->ThrowError(); | |
| 1554 return; | |
| 1555 } | |
| 1556 | |
| 1539 if (index >= touch_points_.size()) { | 1557 if (index >= touch_points_.size()) { |
| 1540 ThrowTouchPointError(); | 1558 ThrowTouchPointError(); |
| 1541 return; | 1559 return; |
| 1542 } | 1560 } |
| 1543 | 1561 |
| 1544 WebTouchPoint* touch_point = &touch_points_[index]; | 1562 WebTouchPoint* touch_point = &touch_points_[index]; |
| 1545 touch_point->state = WebTouchPoint::StateMoved; | 1563 touch_point->state = WebTouchPoint::StateMoved; |
| 1546 touch_point->position = WebFloatPoint(x, y); | 1564 touch_point->position = WebFloatPoint(x, y); |
| 1547 touch_point->screenPosition = touch_point->position; | 1565 touch_point->screenPosition = touch_point->position; |
| 1566 | |
| 1567 if (!args->PeekNext().IsEmpty()) { | |
|
Rick Byers
2015/03/05 15:01:02
Is there a good reason to allow tilt to be set two
d.pikalov
2015/03/09 13:39:50
Done.
| |
| 1568 if (!args->GetNext(&touch_point->tilt)) { | |
| 1569 args->ThrowError(); | |
| 1570 return; | |
| 1571 } | |
| 1572 } | |
| 1573 | |
| 1574 if (!args->PeekNext().IsEmpty()) { | |
| 1575 if (!args->GetNext(&touch_point->tiltDirection)) { | |
| 1576 args->ThrowError(); | |
| 1577 return; | |
| 1578 } | |
| 1579 } | |
| 1548 } | 1580 } |
| 1549 | 1581 |
| 1550 void EventSender::CancelTouchPoint(unsigned index) { | 1582 void EventSender::CancelTouchPoint(unsigned index) { |
| 1551 if (index >= touch_points_.size()) { | 1583 if (index >= touch_points_.size()) { |
| 1552 ThrowTouchPointError(); | 1584 ThrowTouchPointError(); |
| 1553 return; | 1585 return; |
| 1554 } | 1586 } |
| 1555 | 1587 |
| 1556 WebTouchPoint* touch_point = &touch_points_[index]; | 1588 WebTouchPoint* touch_point = &touch_points_[index]; |
| 1557 touch_point->state = WebTouchPoint::StateCancelled; | 1589 touch_point->state = WebTouchPoint::StateCancelled; |
| 1558 } | 1590 } |
| 1559 | 1591 |
| 1592 void EventSender::SetTouchPointTilt(unsigned index, | |
| 1593 float tilt, | |
| 1594 float tiltDirection) { | |
| 1595 if (index >= touch_points_.size()) { | |
| 1596 ThrowTouchPointError(); | |
| 1597 return; | |
| 1598 } | |
| 1599 | |
| 1600 WebTouchPoint* touch_point = &touch_points_[index]; | |
| 1601 touch_point->tilt = tilt; | |
| 1602 touch_point->tiltDirection = tiltDirection; | |
| 1603 touch_point->state = WebTouchPoint::StateMoved; | |
| 1604 } | |
| 1605 | |
| 1560 void EventSender::SetTouchModifier(const std::string& key_name, | 1606 void EventSender::SetTouchModifier(const std::string& key_name, |
| 1561 bool set_mask) { | 1607 bool set_mask) { |
| 1562 int mask = 0; | 1608 int mask = 0; |
| 1563 if (key_name == "shift") | 1609 if (key_name == "shift") |
| 1564 mask = WebInputEvent::ShiftKey; | 1610 mask = WebInputEvent::ShiftKey; |
| 1565 else if (key_name == "alt") | 1611 else if (key_name == "alt") |
| 1566 mask = WebInputEvent::AltKey; | 1612 mask = WebInputEvent::AltKey; |
| 1567 else if (key_name == "ctrl") | 1613 else if (key_name == "ctrl") |
| 1568 mask = WebInputEvent::ControlKey; | 1614 mask = WebInputEvent::ControlKey; |
| 1569 else if (key_name == "meta") | 1615 else if (key_name == "meta") |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1714 if (!args->GetNext(&radius_y)) { | 1760 if (!args->GetNext(&radius_y)) { |
| 1715 args->ThrowError(); | 1761 args->ThrowError(); |
| 1716 return; | 1762 return; |
| 1717 } | 1763 } |
| 1718 } | 1764 } |
| 1719 | 1765 |
| 1720 touch_point.radiusX = static_cast<float>(radius_x); | 1766 touch_point.radiusX = static_cast<float>(radius_x); |
| 1721 touch_point.radiusY = static_cast<float>(radius_y); | 1767 touch_point.radiusY = static_cast<float>(radius_y); |
| 1722 } | 1768 } |
| 1723 | 1769 |
| 1770 if (!args->PeekNext().IsEmpty()) { | |
| 1771 if (!args->GetNext(&touch_point.tilt)) { | |
| 1772 args->ThrowError(); | |
| 1773 return; | |
| 1774 } | |
| 1775 } | |
| 1776 | |
| 1777 if (!args->PeekNext().IsEmpty()) { | |
| 1778 if (!args->GetNext(&touch_point.tiltDirection)) { | |
| 1779 args->ThrowError(); | |
| 1780 return; | |
| 1781 } | |
| 1782 } | |
| 1783 | |
| 1724 int lowest_id = 0; | 1784 int lowest_id = 0; |
| 1725 for (size_t i = 0; i < touch_points_.size(); i++) { | 1785 for (size_t i = 0; i < touch_points_.size(); i++) { |
| 1726 if (touch_points_[i].id == lowest_id) | 1786 if (touch_points_[i].id == lowest_id) |
| 1727 lowest_id++; | 1787 lowest_id++; |
| 1728 } | 1788 } |
| 1729 touch_point.id = lowest_id; | 1789 touch_point.id = lowest_id; |
| 1730 touch_points_.push_back(touch_point); | 1790 touch_points_.push_back(touch_point); |
| 1731 } | 1791 } |
| 1732 | 1792 |
| 1733 void EventSender::MouseDragBegin() { | 1793 void EventSender::MouseDragBegin() { |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2420 | 2480 |
| 2421 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2481 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
| 2422 if (WebPagePopup* popup = view_->pagePopup()) { | 2482 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2423 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2483 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2424 return popup->handleInputEvent(event); | 2484 return popup->handleInputEvent(event); |
| 2425 } | 2485 } |
| 2426 return view_->handleInputEvent(event); | 2486 return view_->handleInputEvent(event); |
| 2427 } | 2487 } |
| 2428 | 2488 |
| 2429 } // namespace content | 2489 } // namespace content |
| OLD | NEW |