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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 , m_flingSourceDevice(false) 369 , m_flingSourceDevice(false)
370 , m_fullscreenController(FullscreenController::create(this)) 370 , m_fullscreenController(FullscreenController::create(this))
371 , m_showFPSCounter(false) 371 , m_showFPSCounter(false)
372 , m_showPaintRects(false) 372 , m_showPaintRects(false)
373 , m_showDebugBorders(false) 373 , m_showDebugBorders(false)
374 , m_continuousPaintingEnabled(false) 374 , m_continuousPaintingEnabled(false)
375 , m_showScrollBottleneckRects(false) 375 , m_showScrollBottleneckRects(false)
376 , m_baseBackgroundColor(Color::white) 376 , m_baseBackgroundColor(Color::white)
377 , m_backgroundColorOverride(Color::transparent) 377 , m_backgroundColorOverride(Color::transparent)
378 , m_zoomFactorOverride(0) 378 , m_zoomFactorOverride(0)
379 , m_sentEarlyShowPress(false)
379 { 380 {
380 Page::PageClients pageClients; 381 Page::PageClients pageClients;
381 pageClients.chromeClient = &m_chromeClientImpl; 382 pageClients.chromeClient = &m_chromeClientImpl;
382 pageClients.contextMenuClient = &m_contextMenuClientImpl; 383 pageClients.contextMenuClient = &m_contextMenuClientImpl;
383 pageClients.editorClient = &m_editorClientImpl; 384 pageClients.editorClient = &m_editorClientImpl;
384 pageClients.dragClient = &m_dragClientImpl; 385 pageClients.dragClient = &m_dragClientImpl;
385 pageClients.inspectorClient = &m_inspectorClientImpl; 386 pageClients.inspectorClient = &m_inspectorClientImpl;
386 pageClients.backForwardClient = &m_backForwardClientImpl; 387 pageClients.backForwardClient = &m_backForwardClientImpl;
387 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; 388 pageClients.spellCheckerClient = &m_spellCheckerClientImpl;
388 pageClients.storageClient = &m_storageClientImpl; 389 pageClients.storageClient = &m_storageClientImpl;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 default: 626 default:
626 break; 627 break;
627 } 628 }
628 629
629 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 630 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
630 631
631 // Handle link highlighting outside the main switch to avoid getting lost in the 632 // Handle link highlighting outside the main switch to avoid getting lost in the
632 // complicated set of cases handled below. 633 // complicated set of cases handled below.
633 switch (event.type) { 634 switch (event.type) {
634 case WebInputEvent::GestureShowPress: 635 case WebInputEvent::GestureShowPress:
636 // Skip if already seen a ShowPress triggered by TapDown.
637 if (m_sentEarlyShowPress)
638 return false;
639
635 // Queue a highlight animation, then hand off to regular handler. 640 // Queue a highlight animation, then hand off to regular handler.
636 if (settingsImpl()->gestureTapHighlightEnabled()) 641 if (settingsImpl()->gestureTapHighlightEnabled())
637 enableTapHighlightAtPoint(platformEvent); 642 enableTapHighlightAtPoint(platformEvent);
638 break; 643 break;
639 case WebInputEvent::GestureTapCancel: 644 case WebInputEvent::GestureTapCancel:
640 case WebInputEvent::GestureTap: 645 case WebInputEvent::GestureTap:
641 case WebInputEvent::GestureLongPress: 646 case WebInputEvent::GestureLongPress:
642 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 647 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
643 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 648 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
644 break; 649 break;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 724 }
720 case WebInputEvent::GestureDoubleTap: 725 case WebInputEvent::GestureDoubleTap:
721 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { 726 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
722 m_client->cancelScheduledContentIntents(); 727 m_client->cancelScheduledContentIntents();
723 animateDoubleTapZoom(platformEvent.position()); 728 animateDoubleTapZoom(platformEvent.position());
724 } 729 }
725 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore, 730 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore,
726 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here. 731 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here.
727 eventSwallowed = true; 732 eventSwallowed = true;
728 break; 733 break;
734 case WebInputEvent::GestureTapDown:
735 m_sentEarlyShowPress = false;
736 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
737 if (earlyGestureShowPress(platformEvent)) {
738 m_client->didHandleGestureEvent(event, eventCancelled);
739 WebGestureEvent showPressEvent = event;
740 showPressEvent.type = WebInputEvent::GestureShowPress;
741 eventSwallowed = handleGestureEvent(showPressEvent);
742 // Ignore subsequent ShowPress events until another TapDown
743 m_sentEarlyShowPress = true;
744 return eventSwallowed;
745 }
746 break;
729 case WebInputEvent::GestureScrollBegin: 747 case WebInputEvent::GestureScrollBegin:
730 case WebInputEvent::GesturePinchBegin: 748 case WebInputEvent::GesturePinchBegin:
731 m_client->cancelScheduledContentIntents(); 749 m_client->cancelScheduledContentIntents();
732 case WebInputEvent::GestureTapDown:
733 case WebInputEvent::GestureScrollEnd: 750 case WebInputEvent::GestureScrollEnd:
734 case WebInputEvent::GestureScrollUpdate: 751 case WebInputEvent::GestureScrollUpdate:
735 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 752 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
736 case WebInputEvent::GestureTapCancel: 753 case WebInputEvent::GestureTapCancel:
737 case WebInputEvent::GestureTapUnconfirmed: 754 case WebInputEvent::GestureTapUnconfirmed:
738 case WebInputEvent::GesturePinchEnd: 755 case WebInputEvent::GesturePinchEnd:
739 case WebInputEvent::GesturePinchUpdate: 756 case WebInputEvent::GesturePinchUpdate:
740 case WebInputEvent::GestureFlingStart: { 757 case WebInputEvent::GestureFlingStart: {
741 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent); 758 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
742 break; 759 break;
743 } 760 }
744 default: 761 default:
745 ASSERT_NOT_REACHED(); 762 ASSERT_NOT_REACHED();
746 } 763 }
747 m_client->didHandleGestureEvent(event, eventCancelled); 764 m_client->didHandleGestureEvent(event, eventCancelled);
765
766
748 return eventSwallowed; 767 return eventSwallowed;
749 } 768 }
750 769
770 // GestureShowPress is normally delayed to avoid triggering on the start of a
771 // scroll, but when scrolling and pinching aren't possible we can do the
772 // ShowPress early, immediately after TapDown.
773 bool WebViewImpl::earlyGestureShowPress(const WebCore::PlatformGestureEvent& eve nt)
774 {
775 LocalFrame* mainFrame = mainFrameImpl()->frame();
776 FrameView* frameView = mainFrame->view();
777
778 if (frameView && !frameView->isScrollable() && !isPinchZoomable()) {
779 IntPoint adjustedPoint = event.position();
780 LocalFrame* eventFrame = mainFrame->eventHandler().frameForGestureEvent( event, adjustedPoint);
781 IntPoint hitTestPoint = eventFrame->view()->windowToContents(event.posit ion());
782 HitTestResult result = eventFrame->eventHandler().hitTestResultAtPoint(h itTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestReq uest::AllowFrameScrollbars);
783
784 // If no ancestor is scrollable then this couldn't possibly be the start of a scroll.
785 return !eventFrame->eventHandler().hasScrollableAncestor(result.innerEle ment());
786 }
787
788 return false;
789 }
790
751 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters) 791 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters)
752 { 792 {
753 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation"); 793 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation");
754 ASSERT(!m_gestureAnimation); 794 ASSERT(!m_gestureAnimation);
755 m_positionOnFlingStart = parameters.point; 795 m_positionOnFlingStart = parameters.point;
756 m_globalPositionOnFlingStart = parameters.globalPoint; 796 m_globalPositionOnFlingStart = parameters.globalPoint;
757 m_flingModifier = parameters.modifiers; 797 m_flingModifier = parameters.modifiers;
758 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll)); 798 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
759 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime); 799 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
760 scheduleAnimation(); 800 scheduleAnimation();
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 float WebViewImpl::minimumPageScaleFactor() const 2961 float WebViewImpl::minimumPageScaleFactor() const
2922 { 2962 {
2923 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; 2963 return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
2924 } 2964 }
2925 2965
2926 float WebViewImpl::maximumPageScaleFactor() const 2966 float WebViewImpl::maximumPageScaleFactor() const
2927 { 2967 {
2928 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; 2968 return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
2929 } 2969 }
2930 2970
2971 bool WebViewImpl::isPinchZoomable() const
2972 {
2973 // This covers all cases:
2974 // * viewport user-scalable: no
2975 // * viewport minimum and maximum scale equal
2976 // * pinch disabled by command line flag
2977 return minimumPageScaleFactor() != maximumPageScaleFactor();
2978 }
2979
2931 void WebViewImpl::saveScrollAndScaleState() 2980 void WebViewImpl::saveScrollAndScaleState()
2932 { 2981 {
2933 m_savedPageScaleFactor = pageScaleFactor(); 2982 m_savedPageScaleFactor = pageScaleFactor();
2934 m_savedScrollOffset = mainFrame()->scrollOffset(); 2983 m_savedScrollOffset = mainFrame()->scrollOffset();
2935 } 2984 }
2936 2985
2937 void WebViewImpl::restoreScrollAndScaleState() 2986 void WebViewImpl::restoreScrollAndScaleState()
2938 { 2987 {
2939 if (!m_savedPageScaleFactor) 2988 if (!m_savedPageScaleFactor)
2940 return; 2989 return;
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4046 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
3998 4047
3999 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4048 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4000 return false; 4049 return false;
4001 4050
4002 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4051 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4003 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4052 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4004 } 4053 }
4005 4054
4006 } // namespace blink 4055 } // namespace blink
OLDNEW
« 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