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

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: Modify event_sender.cc 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.
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 451 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
449 // - a formula that's relatively easy to use from JavaScript 452 // - a formula that's relatively easy to use from JavaScript
450 // Note that 'wheel' event deltaY values have their sign inverted. So to 453 // 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). 454 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100).
452 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0); 455 DCHECK_GT(pinch_event.event.data.pinchUpdate.scale, 0);
453 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale); 456 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale);
454 wheelEvent.hasPreciseScrollingDeltas = true; 457 wheelEvent.hasPreciseScrollingDeltas = true;
455 wheelEvent.wheelTicksX = 0; 458 wheelEvent.wheelTicksX = 0;
456 wheelEvent.wheelTicksY = 459 wheelEvent.wheelTicksY =
457 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1; 460 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1;
458 461 wheelEvent.canScroll = false;
459 SendWheelEvent(QueuedWheelEvent( 462 SendWheelEvent(QueuedWheelEvent(
460 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true)); 463 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true));
461 } 464 }
462 465
463 void InputRouterImpl::OnInputEventAck( 466 void InputRouterImpl::OnInputEventAck(
464 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { 467 const InputHostMsg_HandleInputEvent_ACK_Params& ack) {
465 client_->DecrementInFlightEventCount(); 468 client_->DecrementInFlightEventCount();
466 469
467 // Log the time delta for processing an input event. 470 // Log the time delta for processing an input event.
468 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 471 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( 709 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent(
707 const MouseWheelEventWithLatencyInfo& event, 710 const MouseWheelEventWithLatencyInfo& event,
708 bool synthesized_from_pinch) 711 bool synthesized_from_pinch)
709 : event(event), synthesized_from_pinch(synthesized_from_pinch) { 712 : event(event), synthesized_from_pinch(synthesized_from_pinch) {
710 } 713 }
711 714
712 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { 715 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() {
713 } 716 }
714 717
715 } // namespace content 718 } // 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