Chromium Code Reviews| Index: Source/web/WebViewImpl.cpp |
| diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
| index 0357f7dff29e05cb63ba935b5f90958435923a95..5f6f51368008b6c3ed0da5bb17107fd532c59c98 100644 |
| --- a/Source/web/WebViewImpl.cpp |
| +++ b/Source/web/WebViewImpl.cpp |
| @@ -382,6 +382,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) |
| , m_backgroundColorOverride(Color::transparent) |
| , m_zoomFactorOverride(0) |
| , m_helperPluginCloseTimer(this, &WebViewImpl::closePendingHelperPlugins) |
| + , m_gestureTapDownTriggeredActive(false) |
| { |
| Page::PageClients pageClients; |
| pageClients.chromeClient = &m_chromeClientImpl; |
| @@ -639,6 +640,10 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) |
| // complicated set of cases handled below. |
| switch (event.type) { |
| case WebInputEvent::GestureShowPress: |
| + // Skip if already seen a ShowPress triggered by TapDown. |
| + if (m_gestureTapDownTriggeredActive) |
| + return false; |
| + |
| // Queue a highlight animation, then hand off to regular handler. |
| if (settingsImpl()->gestureTapHighlightEnabled()) |
| enableTapHighlightAtPoint(platformEvent); |
| @@ -733,10 +738,13 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) |
| // GestureTap with tap count = 2 is used instead. So we drop GestureDoubleTap here. |
| eventSwallowed = true; |
| break; |
| + case WebInputEvent::GestureTapDown: |
| + m_gestureTapDownTriggeredActive = false; |
| + eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent); |
| + break; |
| case WebInputEvent::GestureScrollBegin: |
| case WebInputEvent::GesturePinchBegin: |
| m_client->cancelScheduledContentIntents(); |
| - case WebInputEvent::GestureTapDown: |
| case WebInputEvent::GestureScrollEnd: |
| case WebInputEvent::GestureScrollUpdate: |
| case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
| @@ -752,9 +760,39 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) |
| ASSERT_NOT_REACHED(); |
| } |
| m_client->didHandleGestureEvent(event, eventCancelled); |
| + |
| + if (event.type == WebInputEvent::GestureTapDown |
| + && shouldGestureTapDownTriggerActive(platformEvent)) { |
| + WebGestureEvent showPressEvent = event; |
| + showPressEvent.type = WebInputEvent::GestureShowPress; |
| + eventSwallowed = handleGestureEvent(showPressEvent); |
|
Rick Byers
2014/02/21 03:35:52
nit: 2 spaces
Zeeshan Qureshi
2014/02/24 03:14:26
Oh wow, would have never caught this, Thanks.
|
| + // Ignore subsequent ShowPress events until another TapDown |
| + m_gestureTapDownTriggeredActive = true; |
| + } |
| + |
| return eventSwallowed; |
| } |
| +bool WebViewImpl::shouldGestureTapDownTriggerActive(const WebCore::PlatformGestureEvent& event) |
| +{ |
| + Frame* mainFrame = mainFrameImpl()->frame(); |
| + FrameView* frameView = mainFrame->view(); |
| + |
| + // Only activate on TapDown if page isn't scrollable or pinchable and |
|
Rick Byers
2014/02/21 03:35:52
A little more explanation is probably in order aro
|
| + // this isn't the start of a scroll. |
| + if (frameView && !frameView->isScrollable() && !isPinchZoomable()) { |
| + IntPoint adjustedPoint = event.position(); |
| + Frame* eventFrame = mainFrame->eventHandler().frameForGestureEvent(event, adjustedPoint); |
| + IntPoint hitTestPoint = eventFrame->view()->windowToContents(event.position()); |
| + HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequest::AllowFrameScrollbars); |
| + |
| + // If no ancestor is scrollable then this couldn't possibly be the start of a scroll. |
| + return !eventFrame->eventHandler().hasScrollableAncestor(result.innerElement()); |
| + } |
| + |
| + return false; |
| +} |
| + |
| void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters& parameters) |
| { |
| TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation"); |
| @@ -2950,6 +2988,15 @@ float WebViewImpl::maximumPageScaleFactor() const |
| return m_pageScaleConstraintsSet.finalConstraints().maximumScale; |
| } |
| +bool WebViewImpl::isPinchZoomable() const |
| +{ |
| + // This covers all cases: |
| + // * viewport user-scalable: no |
| + // * viewport minimum and maximum scale equal |
| + // * pinch disabled by command line flag |
| + return minimumPageScaleFactor() != maximumPageScaleFactor(); |
| +} |
| + |
| void WebViewImpl::saveScrollAndScaleState() |
| { |
| m_savedPageScaleFactor = pageScaleFactor(); |