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

Side by Side Diff: content/browser/renderer_host/input/input_router_impl.cc

Issue 739013008: Explicitly suppress scrolling for wheel events that will trigger zooming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests Created 6 years 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/browser/renderer_host/input/input_router_impl.h" 5 #include "content/browser/renderer_host/input/input_router_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 SendWheelEvent(QueuedWheelEvent(wheel_event, false)); 129 SendWheelEvent(QueuedWheelEvent(wheel_event, false));
130 } 130 }
131 131
132 void InputRouterImpl::SendWheelEvent(const QueuedWheelEvent& wheel_event) { 132 void InputRouterImpl::SendWheelEvent(const QueuedWheelEvent& wheel_event) {
133 if (mouse_wheel_pending_) { 133 if (mouse_wheel_pending_) {
134 // If there's already a mouse wheel event waiting to be sent to the 134 // If there's already a mouse wheel event waiting to be sent to the
135 // renderer, add the new deltas to that event. Not doing so (e.g., by 135 // renderer, add the new deltas to that event. Not doing so (e.g., by
136 // dropping the old event, as for mouse moves) results in very slow 136 // dropping the old event, as for mouse moves) results in very slow
137 // scrolling on the Mac (on which many, very small wheel events are sent). 137 // scrolling on the Mac (on which many, very small wheel events are sent).
138 // Note that we can't coalesce wheel events for pinches because the GEQ 138 // Note that we can't coalesce wheel events for pinches because the GEQ
139 // expects one ACK for each (but it's fine to coalesce non-pinch wheels 139 // expects one ACK for each. But such events always have canScroll==false
140 // into a pinch one). Note that the GestureEventQueue ensures we only 140 // and hasPreciseDeltas=true, which should never happen for a real wheel
141 // ever have a single pinch event queued here. 141 // event and so coalescing shouldn't occur. Note that the
142 // GestureEventQueue ensures we only ever have a single pinch event queued
143 // here.
142 if (coalesced_mouse_wheel_events_.empty() || 144 if (coalesced_mouse_wheel_events_.empty() ||
143 wheel_event.synthesized_from_pinch || 145 wheel_event.synthesized_from_pinch !=
146 coalesced_mouse_wheel_events_.back().synthesized_from_pinch ||
144 !coalesced_mouse_wheel_events_.back().event.CanCoalesceWith( 147 !coalesced_mouse_wheel_events_.back().event.CanCoalesceWith(
145 wheel_event.event)) { 148 wheel_event.event)) {
146 coalesced_mouse_wheel_events_.push_back(wheel_event); 149 coalesced_mouse_wheel_events_.push_back(wheel_event);
147 } else { 150 } else {
148 coalesced_mouse_wheel_events_.back().event.CoalesceWith( 151 coalesced_mouse_wheel_events_.back().event.CoalesceWith(
149 wheel_event.event); 152 wheel_event.event);
150 } 153 }
151 return; 154 return;
152 } 155 }
153 156
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 454 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
452 // - a formula that's relatively easy to use from JavaScript 455 // - a formula that's relatively easy to use from JavaScript
453 // Note that 'wheel' event deltaY values have their sign inverted. So to 456 // Note that 'wheel' event deltaY values have their sign inverted. So to
454 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100). 457 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100).
455 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0); 458 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0);
456 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale); 459 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale);
457 wheelEvent.hasPreciseScrollingDeltas = true; 460 wheelEvent.hasPreciseScrollingDeltas = true;
458 wheelEvent.wheelTicksX = 0; 461 wheelEvent.wheelTicksX = 0;
459 wheelEvent.wheelTicksY = 462 wheelEvent.wheelTicksY =
460 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1; 463 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1;
461 464 // Prevent trackpad pinch from scrolling on Mac OS.
Rick Byers 2014/12/12 22:20:29 nit: This comment seems redundant with the code (a
lanwei 2014/12/17 23:16:40 Done.
465 wheelEvent.canScroll = false;
462 SendWheelEvent(QueuedWheelEvent( 466 SendWheelEvent(QueuedWheelEvent(
463 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true)); 467 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true));
464 } 468 }
465 469
466 void InputRouterImpl::OnInputEventAck( 470 void InputRouterImpl::OnInputEventAck(
467 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { 471 const InputHostMsg_HandleInputEvent_ACK_Params& ack) {
468 client_->DecrementInFlightEventCount(); 472 client_->DecrementInFlightEventCount();
469 473
470 // Log the time delta for processing an input event. 474 // Log the time delta for processing an input event.
471 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 475 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( 716 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent(
713 const MouseWheelEventWithLatencyInfo& event, 717 const MouseWheelEventWithLatencyInfo& event,
714 bool synthesized_from_pinch) 718 bool synthesized_from_pinch)
715 : event(event), synthesized_from_pinch(synthesized_from_pinch) { 719 : event(event), synthesized_from_pinch(synthesized_from_pinch) {
716 } 720 }
717 721
718 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { 722 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() {
719 } 723 }
720 724
721 } // namespace content 725 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698