| 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 "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 double EventSender::GetCurrentEventTimeSec() { | 2092 double EventSender::GetCurrentEventTimeSec() { |
| 2093 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + | 2093 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + |
| 2094 time_offset_ms_ / 1000.0; | 2094 time_offset_ms_ / 1000.0; |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 void EventSender::DoLeapForward(int milliseconds) { | 2097 void EventSender::DoLeapForward(int milliseconds) { |
| 2098 time_offset_ms_ += milliseconds; | 2098 time_offset_ms_ += milliseconds; |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, | 2101 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, |
| 2102 bool causesScrollingIfUncanceled) { | 2102 bool movedBeyondSlopRegion) { |
| 2103 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), | 2103 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), |
| 2104 touch_points_.size()); | 2104 touch_points_.size()); |
| 2105 if (force_layout_on_events_) | 2105 if (force_layout_on_events_) |
| 2106 view_->updateAllLifecyclePhases(); | 2106 view_->updateAllLifecyclePhases(); |
| 2107 | 2107 |
| 2108 WebTouchEvent touch_event; | 2108 WebTouchEvent touch_event; |
| 2109 touch_event.type = type; | 2109 touch_event.type = type; |
| 2110 touch_event.modifiers = touch_modifiers_; | 2110 touch_event.modifiers = touch_modifiers_; |
| 2111 touch_event.cancelable = touch_cancelable_; | 2111 touch_event.cancelable = touch_cancelable_; |
| 2112 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 2112 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
| 2113 touch_event.causesScrollingIfUncanceled = causesScrollingIfUncanceled; | 2113 touch_event.movedBeyondSlopRegion = movedBeyondSlopRegion; |
| 2114 touch_event.touchesLength = touch_points_.size(); | 2114 touch_event.touchesLength = touch_points_.size(); |
| 2115 for (size_t i = 0; i < touch_points_.size(); ++i) | 2115 for (size_t i = 0; i < touch_points_.size(); ++i) |
| 2116 touch_event.touches[i] = touch_points_[i]; | 2116 touch_event.touches[i] = touch_points_[i]; |
| 2117 HandleInputEventOnViewOrPopup(touch_event); | 2117 HandleInputEventOnViewOrPopup(touch_event); |
| 2118 | 2118 |
| 2119 for (size_t i = 0; i < touch_points_.size(); ++i) { | 2119 for (size_t i = 0; i < touch_points_.size(); ++i) { |
| 2120 WebTouchPoint* touch_point = &touch_points_[i]; | 2120 WebTouchPoint* touch_point = &touch_points_[i]; |
| 2121 if (touch_point->state == WebTouchPoint::StateReleased | 2121 if (touch_point->state == WebTouchPoint::StateReleased |
| 2122 || touch_point->state == WebTouchPoint::StateCancelled) { | 2122 || touch_point->state == WebTouchPoint::StateCancelled) { |
| 2123 touch_points_.erase(touch_points_.begin() + i); | 2123 touch_points_.erase(touch_points_.begin() + i); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 last_event_timestamp_ = event.timeStampSeconds; | 2645 last_event_timestamp_ = event.timeStampSeconds; |
| 2646 | 2646 |
| 2647 if (WebPagePopup* popup = view_->pagePopup()) { | 2647 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2648 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2648 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2649 return popup->handleInputEvent(event); | 2649 return popup->handleInputEvent(event); |
| 2650 } | 2650 } |
| 2651 return view_->handleInputEvent(event); | 2651 return view_->handleInputEvent(event); |
| 2652 } | 2652 } |
| 2653 | 2653 |
| 2654 } // namespace test_runner | 2654 } // namespace test_runner |
| OLD | NEW |