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

Side by Side Diff: components/test_runner/event_sender.cc

Issue 2669663002: Move touch slop suppression to TouchEventManager (Closed)
Patch Set: slop regesion Created 3 years, 10 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
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 "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 <memory> 9 #include <memory>
10 10
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 2229
2230 double EventSender::GetCurrentEventTimeSec() { 2230 double EventSender::GetCurrentEventTimeSec() {
2231 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + 2231 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() +
2232 time_offset_ms_ / 1000.0; 2232 time_offset_ms_ / 1000.0;
2233 } 2233 }
2234 2234
2235 void EventSender::DoLeapForward(int milliseconds) { 2235 void EventSender::DoLeapForward(int milliseconds) {
2236 time_offset_ms_ += milliseconds; 2236 time_offset_ms_ += milliseconds;
2237 } 2237 }
2238 2238
2239 void EventSender::GetOptionalTouchArgs(gin::Arguments* args,
2240 bool& moved_beyond_slop_region,
2241 uint32_t& unique_touch_event_id) {
2242 moved_beyond_slop_region = false;
2243 if(!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) {
2244 std::string arg;
2245 if (args->GetNext(&arg) && arg == "movedBeyondSlopRegion")
2246 moved_beyond_slop_region = true;
2247 else
2248 args->ThrowError();
2249 }
2250
2251 unique_touch_event_id = GetUniqueTouchEventId(args);
2252 return;
2253 }
2254
2255 uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) { 2239 uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) {
2256 uint32_t unique_touch_event_id; 2240 uint32_t unique_touch_event_id;
2257 if(!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id)) 2241 if(!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id))
2258 return unique_touch_event_id; 2242 return unique_touch_event_id;
2259 2243
2260 return 0; 2244 return 0;
2261 } 2245 }
2262 2246
2263 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, 2247 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
2264 gin::Arguments* args) { 2248 gin::Arguments* args) {
2265 bool moved_beyond_slop_region; 2249 uint32_t unique_touch_event_id = GetUniqueTouchEventId(args);
2266 uint32_t unique_touch_event_id;
2267 GetOptionalTouchArgs(args, moved_beyond_slop_region, unique_touch_event_id);
2268 2250
2269 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), 2251 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap),
2270 touch_points_.size()); 2252 touch_points_.size());
2271 if (force_layout_on_events_) 2253 if (force_layout_on_events_)
2272 widget()->updateAllLifecyclePhases(); 2254 widget()->updateAllLifecyclePhases();
2273 2255
2274 WebTouchEvent touch_event(type, touch_modifiers_, GetCurrentEventTimeSec()); 2256 WebTouchEvent touch_event(type, touch_modifiers_, GetCurrentEventTimeSec());
2275 touch_event.dispatchType = touch_cancelable_ 2257 touch_event.dispatchType = touch_cancelable_
2276 ? WebInputEvent::Blocking 2258 ? WebInputEvent::Blocking
2277 : WebInputEvent::EventNonBlocking; 2259 : WebInputEvent::EventNonBlocking;
2278 touch_event.movedBeyondSlopRegion = moved_beyond_slop_region; 2260 touch_event.movedBeyondSlopRegion = true;
2279 touch_event.uniqueTouchEventId = unique_touch_event_id; 2261 touch_event.uniqueTouchEventId = unique_touch_event_id;
2280 touch_event.touchesLength = touch_points_.size(); 2262 touch_event.touchesLength = touch_points_.size();
2281 for (size_t i = 0; i < touch_points_.size(); ++i) 2263 for (size_t i = 0; i < touch_points_.size(); ++i)
2282 touch_event.touches[i] = touch_points_[i]; 2264 touch_event.touches[i] = touch_points_[i];
2283 HandleInputEventOnViewOrPopup(touch_event); 2265 HandleInputEventOnViewOrPopup(touch_event);
2284 2266
2285 for (size_t i = 0; i < touch_points_.size(); ++i) { 2267 for (size_t i = 0; i < touch_points_.size(); ++i) {
2286 WebTouchPoint* touch_point = &touch_points_[i]; 2268 WebTouchPoint* touch_point = &touch_points_[i];
2287 if (touch_point->state == WebTouchPoint::StateReleased 2269 if (touch_point->state == WebTouchPoint::StateReleased
2288 || touch_point->state == WebTouchPoint::StateCancelled) { 2270 || touch_point->state == WebTouchPoint::StateCancelled) {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); 2883 return view()->mainFrame()->toWebLocalFrame()->frameWidget();
2902 } 2884 }
2903 2885
2904 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( 2886 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates(
2905 const WebInputEvent& event) { 2887 const WebInputEvent& event) {
2906 return delegate()->TransformScreenToWidgetCoordinates( 2888 return delegate()->TransformScreenToWidgetCoordinates(
2907 web_widget_test_proxy_base_, event); 2889 web_widget_test_proxy_base_, event);
2908 } 2890 }
2909 2891
2910 } // namespace test_runner 2892 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/event_sender.h ('k') | content/browser/renderer_host/input/legacy_touch_event_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698