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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2126323002: Add support for touch-action: pinch-zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add exception for mac Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 NOTREACHED(); 905 NOTREACHED();
906 } 906 }
907 m_client->didHandleGestureEvent(event, eventCancelled); 907 m_client->didHandleGestureEvent(event, eventCancelled);
908 return eventResult; 908 return eventResult;
909 } 909 }
910 910
911 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons t WebGestureEvent& pinchEvent) 911 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons t WebGestureEvent& pinchEvent)
912 { 912 {
913 DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate); 913 DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate);
914 914
915 // Touchscreen pinch events should not reach Blink.
916 DCHECK_EQ(pinchEvent.sourceDevice, WebGestureDeviceTouchpad);
917
918 // For pinch gesture events, match typical trackpad behavior on Windows by s ending fake 915 // For pinch gesture events, match typical trackpad behavior on Windows by s ending fake
919 // wheel events with the ctrl modifier set when we see trackpad pinch gestur es. Ideally 916 // wheel events with the ctrl modifier set when we see trackpad pinch gestur es. Ideally
920 // we'd someday get a platform 'pinch' event and send that instead. 917 // we'd someday get a platform 'pinch' event and send that instead.
921 WebMouseWheelEvent wheelEvent; 918 WebMouseWheelEvent wheelEvent;
922 wheelEvent.type = WebInputEvent::MouseWheel; 919 wheelEvent.type = WebInputEvent::MouseWheel;
923 wheelEvent.timeStampSeconds = pinchEvent.timeStampSeconds; 920 wheelEvent.timeStampSeconds = pinchEvent.timeStampSeconds;
924 wheelEvent.windowX = wheelEvent.x = pinchEvent.x; 921 wheelEvent.windowX = wheelEvent.x = pinchEvent.x;
925 wheelEvent.windowY = wheelEvent.y = pinchEvent.y; 922 wheelEvent.windowY = wheelEvent.y = pinchEvent.y;
926 wheelEvent.globalX = pinchEvent.globalX; 923 wheelEvent.globalX = pinchEvent.globalX;
927 wheelEvent.globalY = pinchEvent.globalY; 924 wheelEvent.globalY = pinchEvent.globalY;
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast< const WebMouseEvent&>(inputEvent)), 2208 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast< const WebMouseEvent&>(inputEvent)),
2212 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ; 2209 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ;
2213 return WebInputEventResult::HandledSystem; 2210 return WebInputEventResult::HandledSystem;
2214 } 2211 }
2215 2212
2216 // FIXME: This should take in the intended frame, not the local frame root. 2213 // FIXME: This should take in the intended frame, not the local frame root.
2217 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(*this, inp utEvent, mainFrameImpl()->frame()); 2214 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(*this, inp utEvent, mainFrameImpl()->frame());
2218 if (result != WebInputEventResult::NotHandled) 2215 if (result != WebInputEventResult::NotHandled)
2219 return result; 2216 return result;
2220 2217
2221 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. 2218 // Unhandled pinch events should adjust the scale.
2222 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { 2219 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) {
2223 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>( inputEvent); 2220 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>( inputEvent);
2224 2221
2225 // First, synthesize a Windows-like wheel event to send to any handlers that may exist. 2222 // For touchpad gestures synthesize a Windows-like wheel event
2226 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent); 2223 // to send to any handlers that may exist. Not necessary for touchscreen
2227 if (result != WebInputEventResult::NotHandled) 2224 // as touch events would have already been sent for the gesture.
2228 return result; 2225 if (pinchEvent.sourceDevice == WebGestureDeviceTouchpad) {
2226 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent);
2227 if (result != WebInputEventResult::NotHandled)
2228 return result;
2229 }
2229 2230
2230 if (pinchEvent.data.pinchUpdate.zoomDisabled) 2231 if (pinchEvent.data.pinchUpdate.zoomDisabled)
2231 return WebInputEventResult::NotHandled; 2232 return WebInputEventResult::NotHandled;
2232 2233
2233 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y))) 2234 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y)))
2234 return WebInputEventResult::HandledSystem; 2235 return WebInputEventResult::HandledSystem;
2235 } 2236 }
2236 2237
2237 return WebInputEventResult::NotHandled; 2238 return WebInputEventResult::NotHandled;
2238 } 2239 }
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after
4591 return nullptr; 4592 return nullptr;
4592 return focusedFrame; 4593 return focusedFrame;
4593 } 4594 }
4594 4595
4595 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4596 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4596 { 4597 {
4597 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4598 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4598 } 4599 }
4599 4600
4600 } // namespace blink 4601 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in ('k') | third_party/WebKit/public/platform/WebInputEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698