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

Side by Side 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: Add tests Created 6 years, 10 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 | Annotate | Revision Log
« Source/web/WebViewImpl.h ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 , m_fullscreenController(FullscreenController::create(this)) 375 , m_fullscreenController(FullscreenController::create(this))
376 , m_showFPSCounter(false) 376 , m_showFPSCounter(false)
377 , m_showPaintRects(false) 377 , m_showPaintRects(false)
378 , m_showDebugBorders(false) 378 , m_showDebugBorders(false)
379 , m_continuousPaintingEnabled(false) 379 , m_continuousPaintingEnabled(false)
380 , m_showScrollBottleneckRects(false) 380 , m_showScrollBottleneckRects(false)
381 , m_baseBackgroundColor(Color::white) 381 , m_baseBackgroundColor(Color::white)
382 , m_backgroundColorOverride(Color::transparent) 382 , m_backgroundColorOverride(Color::transparent)
383 , m_zoomFactorOverride(0) 383 , m_zoomFactorOverride(0)
384 , m_helperPluginCloseTimer(this, &WebViewImpl::closePendingHelperPlugins) 384 , m_helperPluginCloseTimer(this, &WebViewImpl::closePendingHelperPlugins)
385 , m_gestureTapDownTriggeredActive(false)
385 { 386 {
386 Page::PageClients pageClients; 387 Page::PageClients pageClients;
387 pageClients.chromeClient = &m_chromeClientImpl; 388 pageClients.chromeClient = &m_chromeClientImpl;
388 pageClients.contextMenuClient = &m_contextMenuClientImpl; 389 pageClients.contextMenuClient = &m_contextMenuClientImpl;
389 pageClients.editorClient = &m_editorClientImpl; 390 pageClients.editorClient = &m_editorClientImpl;
390 pageClients.dragClient = &m_dragClientImpl; 391 pageClients.dragClient = &m_dragClientImpl;
391 pageClients.inspectorClient = &m_inspectorClientImpl; 392 pageClients.inspectorClient = &m_inspectorClientImpl;
392 pageClients.backForwardClient = &m_backForwardClientImpl; 393 pageClients.backForwardClient = &m_backForwardClientImpl;
393 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; 394 pageClients.spellCheckerClient = &m_spellCheckerClientImpl;
394 pageClients.storageClient = &m_storageClientImpl; 395 pageClients.storageClient = &m_storageClientImpl;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 default: 633 default:
633 break; 634 break;
634 } 635 }
635 636
636 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 637 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
637 638
638 // Handle link highlighting outside the main switch to avoid getting lost in the 639 // Handle link highlighting outside the main switch to avoid getting lost in the
639 // complicated set of cases handled below. 640 // complicated set of cases handled below.
640 switch (event.type) { 641 switch (event.type) {
641 case WebInputEvent::GestureShowPress: 642 case WebInputEvent::GestureShowPress:
643 // Skip if already seen a ShowPress triggered by TapDown.
644 if (m_gestureTapDownTriggeredActive)
645 return false;
646
642 // Queue a highlight animation, then hand off to regular handler. 647 // Queue a highlight animation, then hand off to regular handler.
643 if (settingsImpl()->gestureTapHighlightEnabled()) 648 if (settingsImpl()->gestureTapHighlightEnabled())
644 enableTapHighlightAtPoint(platformEvent); 649 enableTapHighlightAtPoint(platformEvent);
645 break; 650 break;
646 case WebInputEvent::GestureTapCancel: 651 case WebInputEvent::GestureTapCancel:
647 case WebInputEvent::GestureTap: 652 case WebInputEvent::GestureTap:
648 case WebInputEvent::GestureLongPress: 653 case WebInputEvent::GestureLongPress:
649 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 654 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
650 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 655 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
651 break; 656 break;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 731 }
727 case WebInputEvent::GestureDoubleTap: 732 case WebInputEvent::GestureDoubleTap:
728 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { 733 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
729 m_client->cancelScheduledContentIntents(); 734 m_client->cancelScheduledContentIntents();
730 animateDoubleTapZoom(platformEvent.position()); 735 animateDoubleTapZoom(platformEvent.position());
731 } 736 }
732 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore, 737 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore,
733 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here. 738 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here.
734 eventSwallowed = true; 739 eventSwallowed = true;
735 break; 740 break;
741 case WebInputEvent::GestureTapDown:
742 m_gestureTapDownTriggeredActive = false;
743 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
744 break;
736 case WebInputEvent::GestureScrollBegin: 745 case WebInputEvent::GestureScrollBegin:
737 case WebInputEvent::GesturePinchBegin: 746 case WebInputEvent::GesturePinchBegin:
738 m_client->cancelScheduledContentIntents(); 747 m_client->cancelScheduledContentIntents();
739 case WebInputEvent::GestureTapDown:
740 case WebInputEvent::GestureScrollEnd: 748 case WebInputEvent::GestureScrollEnd:
741 case WebInputEvent::GestureScrollUpdate: 749 case WebInputEvent::GestureScrollUpdate:
742 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 750 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
743 case WebInputEvent::GestureTapCancel: 751 case WebInputEvent::GestureTapCancel:
744 case WebInputEvent::GestureTapUnconfirmed: 752 case WebInputEvent::GestureTapUnconfirmed:
745 case WebInputEvent::GesturePinchEnd: 753 case WebInputEvent::GesturePinchEnd:
746 case WebInputEvent::GesturePinchUpdate: 754 case WebInputEvent::GesturePinchUpdate:
747 case WebInputEvent::GestureFlingStart: { 755 case WebInputEvent::GestureFlingStart: {
748 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent); 756 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
749 break; 757 break;
750 } 758 }
751 default: 759 default:
752 ASSERT_NOT_REACHED(); 760 ASSERT_NOT_REACHED();
753 } 761 }
754 m_client->didHandleGestureEvent(event, eventCancelled); 762 m_client->didHandleGestureEvent(event, eventCancelled);
763
764 if (event.type == WebInputEvent::GestureTapDown
765 && shouldGestureTapDownTriggerActive(platformEvent)) {
766 WebGestureEvent showPressEvent = event;
767 showPressEvent.type = WebInputEvent::GestureShowPress;
768 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.
769 // Ignore subsequent ShowPress events until another TapDown
770 m_gestureTapDownTriggeredActive = true;
771 }
772
755 return eventSwallowed; 773 return eventSwallowed;
756 } 774 }
757 775
776 bool WebViewImpl::shouldGestureTapDownTriggerActive(const WebCore::PlatformGestu reEvent& event)
777 {
778 Frame* mainFrame = mainFrameImpl()->frame();
779 FrameView* frameView = mainFrame->view();
780
781 // 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
782 // this isn't the start of a scroll.
783 if (frameView && !frameView->isScrollable() && !isPinchZoomable()) {
784 IntPoint adjustedPoint = event.position();
785 Frame* eventFrame = mainFrame->eventHandler().frameForGestureEvent(event , adjustedPoint);
786 IntPoint hitTestPoint = eventFrame->view()->windowToContents(event.posit ion());
787 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(hi tTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestRequ est::AllowFrameScrollbars);
788
789 // If no ancestor is scrollable then this couldn't possibly be the start of a scroll.
790 return !eventFrame->eventHandler().hasScrollableAncestor(result.innerEle ment());
791 }
792
793 return false;
794 }
795
758 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters) 796 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters)
759 { 797 {
760 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation"); 798 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation");
761 ASSERT(!m_gestureAnimation); 799 ASSERT(!m_gestureAnimation);
762 m_positionOnFlingStart = parameters.point; 800 m_positionOnFlingStart = parameters.point;
763 m_globalPositionOnFlingStart = parameters.globalPoint; 801 m_globalPositionOnFlingStart = parameters.globalPoint;
764 m_flingModifier = parameters.modifiers; 802 m_flingModifier = parameters.modifiers;
765 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll)); 803 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
766 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime); 804 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
767 scheduleAnimation(); 805 scheduleAnimation();
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 float WebViewImpl::minimumPageScaleFactor() const 2981 float WebViewImpl::minimumPageScaleFactor() const
2944 { 2982 {
2945 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; 2983 return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
2946 } 2984 }
2947 2985
2948 float WebViewImpl::maximumPageScaleFactor() const 2986 float WebViewImpl::maximumPageScaleFactor() const
2949 { 2987 {
2950 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; 2988 return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
2951 } 2989 }
2952 2990
2991 bool WebViewImpl::isPinchZoomable() const
2992 {
2993 // This covers all cases:
2994 // * viewport user-scalable: no
2995 // * viewport minimum and maximum scale equal
2996 // * pinch disabled by command line flag
2997 return minimumPageScaleFactor() != maximumPageScaleFactor();
2998 }
2999
2953 void WebViewImpl::saveScrollAndScaleState() 3000 void WebViewImpl::saveScrollAndScaleState()
2954 { 3001 {
2955 m_savedPageScaleFactor = pageScaleFactor(); 3002 m_savedPageScaleFactor = pageScaleFactor();
2956 m_savedScrollOffset = mainFrame()->scrollOffset(); 3003 m_savedScrollOffset = mainFrame()->scrollOffset();
2957 } 3004 }
2958 3005
2959 void WebViewImpl::restoreScrollAndScaleState() 3006 void WebViewImpl::restoreScrollAndScaleState()
2960 { 3007 {
2961 if (!m_savedPageScaleFactor) 3008 if (!m_savedPageScaleFactor)
2962 return; 3009 return;
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
3985 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4032 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
3986 4033
3987 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4034 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
3988 return false; 4035 return false;
3989 4036
3990 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4037 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
3991 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4038 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
3992 } 4039 }
3993 4040
3994 } // namespace blink 4041 } // namespace blink
OLDNEW
« Source/web/WebViewImpl.h ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698