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

Side by Side Diff: content/renderer/input/input_handler_proxy.cc

Issue 1019153002: Mac: Add rails for scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 5 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 326
327 return DID_NOT_HANDLE; 327 return DID_NOT_HANDLE;
328 } 328 }
329 329
330 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( 330 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
331 const WebMouseWheelEvent& wheel_event) { 331 const WebMouseWheelEvent& wheel_event) {
332 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; 332 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE;
333 cc::InputHandlerScrollResult scroll_result; 333 cc::InputHandlerScrollResult scroll_result;
334 334
335 // TODO(ccameron): The rail information should be pushed down into
336 // InputHandler.
337 gfx::Vector2dF scroll_delta(
jdduke (slow) 2015/03/19 22:27:44 Not sure if it would be easier to read like: gfx:
338 wheel_event.railsMode != WebInputEvent::RailsModeVertical
339 ? -wheel_event.deltaX
340 : 0,
341 wheel_event.railsMode != WebInputEvent::RailsModeHorizontal
342 ? -wheel_event.deltaY
343 : 0);
344
335 if (wheel_event.scrollByPage) { 345 if (wheel_event.scrollByPage) {
336 // TODO(jamesr): We don't properly handle scroll by page in the compositor 346 // TODO(jamesr): We don't properly handle scroll by page in the compositor
337 // thread, so punt it to the main thread. http://crbug.com/236639 347 // thread, so punt it to the main thread. http://crbug.com/236639
338 result = DID_NOT_HANDLE; 348 result = DID_NOT_HANDLE;
339 } else if (!wheel_event.canScroll) { 349 } else if (!wheel_event.canScroll) {
340 // Wheel events with |canScroll| == false will not trigger scrolling, 350 // Wheel events with |canScroll| == false will not trigger scrolling,
341 // only event handlers. Forward to the main thread. 351 // only event handlers. Forward to the main thread.
342 result = DID_NOT_HANDLE; 352 result = DID_NOT_HANDLE;
343 } else if (smooth_scroll_enabled_) { 353 } else if (smooth_scroll_enabled_) {
344 cc::InputHandler::ScrollStatus scroll_status = 354 cc::InputHandler::ScrollStatus scroll_status =
345 input_handler_->ScrollAnimated( 355 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y),
346 gfx::Point(wheel_event.x, wheel_event.y), 356 scroll_delta);
347 gfx::Vector2dF(-wheel_event.deltaX, -wheel_event.deltaY));
348 switch (scroll_status) { 357 switch (scroll_status) {
349 case cc::InputHandler::SCROLL_STARTED: 358 case cc::InputHandler::SCROLL_STARTED:
350 result = DID_HANDLE; 359 result = DID_HANDLE;
351 break; 360 break;
352 case cc::InputHandler::SCROLL_IGNORED: 361 case cc::InputHandler::SCROLL_IGNORED:
353 result = DROP_EVENT; 362 result = DROP_EVENT;
354 default: 363 default:
355 result = DID_NOT_HANDLE; 364 result = DID_NOT_HANDLE;
356 break; 365 break;
357 } 366 }
358 } else { 367 } else {
359 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( 368 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin(
360 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::WHEEL); 369 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::WHEEL);
361 switch (scroll_status) { 370 switch (scroll_status) {
362 case cc::InputHandler::SCROLL_STARTED: { 371 case cc::InputHandler::SCROLL_STARTED: {
363 TRACE_EVENT_INSTANT2( 372 TRACE_EVENT_INSTANT2("input",
364 "input", "InputHandlerProxy::handle_input wheel scroll", 373 "InputHandlerProxy::handle_input wheel scroll",
365 TRACE_EVENT_SCOPE_THREAD, "deltaX", -wheel_event.deltaX, "deltaY", 374 TRACE_EVENT_SCOPE_THREAD, "deltaX",
366 -wheel_event.deltaY); 375 scroll_delta.x(), "deltaY", scroll_delta.y());
367 gfx::Point scroll_point(wheel_event.x, wheel_event.y); 376 gfx::Point scroll_point(wheel_event.x, wheel_event.y);
368 gfx::Vector2dF scroll_delta(-wheel_event.deltaX, -wheel_event.deltaY);
369 scroll_result = input_handler_->ScrollBy(scroll_point, scroll_delta); 377 scroll_result = input_handler_->ScrollBy(scroll_point, scroll_delta);
370 HandleOverscroll(scroll_point, scroll_result); 378 HandleOverscroll(scroll_point, scroll_result);
371 input_handler_->ScrollEnd(); 379 input_handler_->ScrollEnd();
372 result = scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; 380 result = scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT;
373 break; 381 break;
374 } 382 }
375 case cc::InputHandler::SCROLL_IGNORED: 383 case cc::InputHandler::SCROLL_IGNORED:
376 // TODO(jamesr): This should be DROP_EVENT, but in cases where we fail 384 // TODO(jamesr): This should be DROP_EVENT, but in cases where we fail
377 // to properly sync scrollability it's safer to send the event to the 385 // to properly sync scrollability it's safer to send the event to the
378 // main thread. Change back to DROP_EVENT once we have synchronization 386 // main thread. Change back to DROP_EVENT once we have synchronization
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // trigger a scroll, e.g., with a trivial time delta between fling updates. 949 // trigger a scroll, e.g., with a trivial time delta between fling updates.
942 // Return true in this case to prevent early fling termination. 950 // Return true in this case to prevent early fling termination.
943 if (std::abs(clipped_increment.width) < kScrollEpsilon && 951 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
944 std::abs(clipped_increment.height) < kScrollEpsilon) 952 std::abs(clipped_increment.height) < kScrollEpsilon)
945 return true; 953 return true;
946 954
947 return did_scroll; 955 return did_scroll;
948 } 956 }
949 957
950 } // namespace content 958 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698