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

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

Issue 835523006: Explicitly suppress scrolling for wheel events that will trigger zooming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DCHECK Created 5 years, 11 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/input_router_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
144 DCHECK((wheel_event.event.event.hasPreciseScrollingDeltas &&
145 !wheel_event.event.event.canScroll) ==
146 wheel_event.synthesized_from_pinch);
142 if (coalesced_mouse_wheel_events_.empty() || 147 if (coalesced_mouse_wheel_events_.empty() ||
143 wheel_event.synthesized_from_pinch || 148 wheel_event.synthesized_from_pinch !=
149 coalesced_mouse_wheel_events_.back().synthesized_from_pinch ||
144 !coalesced_mouse_wheel_events_.back().event.CanCoalesceWith( 150 !coalesced_mouse_wheel_events_.back().event.CanCoalesceWith(
145 wheel_event.event)) { 151 wheel_event.event)) {
146 coalesced_mouse_wheel_events_.push_back(wheel_event); 152 coalesced_mouse_wheel_events_.push_back(wheel_event);
147 } else { 153 } else {
148 coalesced_mouse_wheel_events_.back().event.CoalesceWith( 154 coalesced_mouse_wheel_events_.back().event.CoalesceWith(
149 wheel_event.event); 155 wheel_event.event);
150 } 156 }
151 return; 157 return;
152 } 158 }
153 159
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 454 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
449 // - a formula that's relatively easy to use from JavaScript 455 // - a formula that's relatively easy to use from JavaScript
450 // 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
451 // 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).
452 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0); 458 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0);
453 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale); 459 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale);
454 wheelEvent.hasPreciseScrollingDeltas = true; 460 wheelEvent.hasPreciseScrollingDeltas = true;
455 wheelEvent.wheelTicksX = 0; 461 wheelEvent.wheelTicksX = 0;
456 wheelEvent.wheelTicksY = 462 wheelEvent.wheelTicksY =
457 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1; 463 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1;
458 464 wheelEvent.canScroll = false;
459 SendWheelEvent(QueuedWheelEvent( 465 SendWheelEvent(QueuedWheelEvent(
460 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true)); 466 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true));
461 } 467 }
462 468
463 void InputRouterImpl::OnInputEventAck( 469 void InputRouterImpl::OnInputEventAck(
464 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { 470 const InputHostMsg_HandleInputEvent_ACK_Params& ack) {
465 client_->DecrementInFlightEventCount(); 471 client_->DecrementInFlightEventCount();
466 472
467 // Log the time delta for processing an input event. 473 // Log the time delta for processing an input event.
468 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 474 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( 712 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent(
707 const MouseWheelEventWithLatencyInfo& event, 713 const MouseWheelEventWithLatencyInfo& event,
708 bool synthesized_from_pinch) 714 bool synthesized_from_pinch)
709 : event(event), synthesized_from_pinch(synthesized_from_pinch) { 715 : event(event), synthesized_from_pinch(synthesized_from_pinch) {
710 } 716 }
711 717
712 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { 718 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() {
713 } 719 }
714 720
715 } // namespace content 721 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/input_router_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698