Chromium Code Reviews| Index: Source/web/WebViewImpl.cpp |
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
| index 06e1c3efd3a9d6a137123b869811287b1502407b..6a8a33a707cb14caaa9297aab82a680ce13e6f6e 100644 |
| --- a/Source/web/WebViewImpl.cpp |
| +++ b/Source/web/WebViewImpl.cpp |
| @@ -2140,8 +2140,29 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) |
| // Unhandled touchpad gesture pinch events synthesize mouse wheel events. |
| if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { |
| - if (handleSyntheticWheelFromTouchpadPinchEvent(static_cast<const WebGestureEvent&>(inputEvent))) |
| + const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>(inputEvent); |
| + |
| + // First, synthesize a Windows-like wheel event to send to any handlers that may exist. |
| + if (handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent)) |
| return true; |
| + |
| + // If the event remains unhandled, use it pinch the viewport. |
| + const float magnifyDelta = pinchEvent.data.pinchUpdate.scale; |
| + const float oldPageScale = pageScaleFactor(); |
| + const float newPageScale = clampPageScaleFactorToLimits(magnifyDelta * oldPageScale); |
| + |
| + // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| + // position over the course of the magnify. |
| + const FloatPoint anchor(pinchEvent.x, pinchEvent.y); |
|
bokan
2015/02/03 00:45:12
Drive-by: Could you please put this logic inside P
ccameron
2015/02/03 02:29:08
I don't see where the scale factor limits are avai
aelias_OOO_until_Jul13
2015/02/03 02:37:14
You can plumb in the information from WebViewImpl
bokan
2015/02/03 03:05:16
Right, sorry, forgot about that. You can take Alex
ccameron
2015/02/03 17:03:28
Done (yeah, I prefer this too -- thanks for pointi
|
| + FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale); |
| + FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale); |
| + FloatPoint newLocation(pinchViewportOffset() + anchorAtOldScale - anchorAtNewScale); |
| + setPageScaleFactorAndLocation(newPageScale, newLocation); |
|
aelias_OOO_until_Jul13
2015/02/03 00:16:58
Sorry, I noticed another issue. Please scroll the
bokan
2015/02/03 00:45:12
Though almost dead, please be aware of the old pin
ccameron
2015/02/03 02:29:08
Done (in the PinchVirtualViewport version).
|
| + |
| + // TODO(ccameron): Always return that the event was handled. Once the pinch-zoom content scale |
| + // handlers have been removed from content, this function may return false if the page scale does |
| + // not change. |
| + return true; |
| } |
| return false; |