Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_mac.mm |
| diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| index 22707f03bb721077c3e1e9261eaefbff4b6743a0..30aaf1c45c601a2d03c031692f34f65483dad9ac 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -1756,7 +1756,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| canBeKeyView_ = YES; |
| opaque_ = YES; |
| focusedPluginIdentifier_ = -1; |
| - lastUsedPinchEventTimestamp_ = 0; |
| + pinchLastGestureTimestamp_ = 0; |
| + pinchHasReachedZoomThreshold_ = false; |
| // OpenGL support: |
| if ([self respondsToSelector: |
| @@ -2288,7 +2289,15 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| [responderDelegate_ beginGestureWithEvent:event]; |
| gestureBeginEvent_.reset( |
| new WebGestureEvent(WebInputEventFactory::gestureEvent(event, self))); |
| - unusedPinchAmount_ = 0; |
| + |
| + // If more than 1 second has passed since the last pinch gesture ended, reset |
|
aelias_OOO_until_Jul13
2015/05/06 23:20:24
I don't like timeouts as a rule. Why not reset th
ccameron
2015/05/07 17:09:05
If someone is doing several pinches in a row, to z
aelias_OOO_until_Jul13
2015/05/07 18:16:16
I see. How about checking if page_scale_factor ==
|
| + // the zoom threshold levels. |
| + const NSTimeInterval kSecondsUntilZoomThresholdReEnabled = 1; |
| + if ([event timestamp] - pinchLastGestureTimestamp_ > |
| + kSecondsUntilZoomThresholdReEnabled) { |
| + pinchHasReachedZoomThreshold_ = false; |
| + pinchUnusedAmount_ = 0; |
| + } |
| } |
| - (void)endGestureWithEvent:(NSEvent*)event { |
| @@ -2303,7 +2312,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| endEvent.type = WebInputEvent::GesturePinchEnd; |
| renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(endEvent); |
| gestureBeginPinchSent_ = NO; |
| - lastUsedPinchEventTimestamp_ = [event timestamp]; |
| + if (pinchHasReachedZoomThreshold_) |
| + pinchLastGestureTimestamp_ = [event timestamp]; |
| } |
| } |
| @@ -2416,22 +2426,14 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| if (!gestureBeginEvent_) |
| return; |
| + if (!pinchHasReachedZoomThreshold_) { |
| + pinchUnusedAmount_ += [event magnification]; |
|
aelias_OOO_until_Jul13
2015/05/06 23:20:24
Please make this multiplicative. Otherwise this w
ccameron
2015/05/07 17:09:06
Done. I had made it additive to match the earlier
|
| + if (pinchUnusedAmount_ < -0.4 || pinchUnusedAmount_ > 0.4) |
| + pinchHasReachedZoomThreshold_ = true; |
| + } |
| + |
| // Send a GesturePinchBegin event if none has been sent yet. |
| if (!gestureBeginPinchSent_) { |
| - // If less than 1 second has passed since an intentional pinch zoom |
| - // was done, don't threshold zooms, because subsequent zooms are likely |
| - // intentional. |
| - const NSTimeInterval kSecondsUntilZoomThresholdReEnabled = 1; |
| - if ([event timestamp] - lastUsedPinchEventTimestamp_ > |
| - kSecondsUntilZoomThresholdReEnabled) { |
| - // Require that a 40% zoom be hit before actually zooming the page, |
| - // to avoid accidental zooms. |
| - // http://crbug.com/478981 |
| - unusedPinchAmount_ += [event magnification]; |
| - if (unusedPinchAmount_ > -0.4 && unusedPinchAmount_ < 0.4) |
| - return; |
| - } |
| - |
| WebGestureEvent beginEvent(*gestureBeginEvent_); |
| beginEvent.type = WebInputEvent::GesturePinchBegin; |
| renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(beginEvent); |
| @@ -2439,8 +2441,9 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| } |
| // Send a GesturePinchUpdate event. |
| - const WebGestureEvent& updateEvent = |
| + WebGestureEvent updateEvent = |
| WebInputEventFactory::gestureEvent(event, self); |
| + updateEvent.data.pinchUpdate.zoomDisabled = !pinchHasReachedZoomThreshold_; |
| renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent); |
| } |