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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 163933002: Send early ShowPress on TapDown when page isn't scrollable/pinchable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refactor into hasEarlyShowPress() Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 29bedfed385f4fade1598571b65a6635de499ce3..cb2f7401423348581d63b1a6c07dcfd142d73d6b 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -376,6 +376,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_baseBackgroundColor(Color::white)
, m_backgroundColorOverride(Color::transparent)
, m_zoomFactorOverride(0)
+ , m_sentEarlyShowPress(false)
{
Page::PageClients pageClients;
pageClients.chromeClient = &m_chromeClientImpl;
@@ -632,6 +633,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_sentEarlyShowPress)
+ return false;
+
// Queue a highlight animation, then hand off to regular handler.
if (settingsImpl()->gestureTapHighlightEnabled())
enableTapHighlightAtPoint(platformEvent);
@@ -726,10 +731,22 @@ 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_sentEarlyShowPress = false;
+ eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
+ if (earlyGestureShowPress(platformEvent)) {
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ WebGestureEvent showPressEvent = event;
+ showPressEvent.type = WebInputEvent::GestureShowPress;
+ eventSwallowed = handleGestureEvent(showPressEvent);
+ // Ignore subsequent ShowPress events until another TapDown
+ m_sentEarlyShowPress = true;
+ return eventSwallowed;
+ }
+ break;
case WebInputEvent::GestureScrollBegin:
case WebInputEvent::GesturePinchBegin:
m_client->cancelScheduledContentIntents();
- case WebInputEvent::GestureTapDown:
case WebInputEvent::GestureScrollEnd:
case WebInputEvent::GestureScrollUpdate:
case WebInputEvent::GestureScrollUpdateWithoutPropagation:
@@ -745,9 +762,32 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
ASSERT_NOT_REACHED();
}
m_client->didHandleGestureEvent(event, eventCancelled);
+
+
return eventSwallowed;
}
+// GestureShowPress is normally delayed to avoid triggering on the start of a
+// scroll, but when scrolling and pinching aren't possible we can do the
+// ShowPress early, immediately after TapDown.
+bool WebViewImpl::earlyGestureShowPress(const WebCore::PlatformGestureEvent& event)
+{
+ LocalFrame* mainFrame = mainFrameImpl()->frame();
+ FrameView* frameView = mainFrame->view();
+
+ if (frameView && !frameView->isScrollable() && !isPinchZoomable()) {
+ IntPoint adjustedPoint = event.position();
+ LocalFrame* eventFrame = mainFrame->eventHandler().frameForGestureEvent(event, adjustedPoint);
+ IntPoint hitTestPoint = eventFrame->view()->windowToContents(event.position());
+ HitTestResult result = eventFrame->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");
@@ -2928,6 +2968,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();
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698