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

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: Get element coordinates programmatically 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
« Source/core/page/EventHandler.cpp ('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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 , m_flingSourceDevice(false) 368 , m_flingSourceDevice(false)
369 , m_fullscreenController(FullscreenController::create(this)) 369 , m_fullscreenController(FullscreenController::create(this))
370 , m_showFPSCounter(false) 370 , m_showFPSCounter(false)
371 , m_showPaintRects(false) 371 , m_showPaintRects(false)
372 , m_showDebugBorders(false) 372 , m_showDebugBorders(false)
373 , m_continuousPaintingEnabled(false) 373 , m_continuousPaintingEnabled(false)
374 , m_showScrollBottleneckRects(false) 374 , m_showScrollBottleneckRects(false)
375 , m_baseBackgroundColor(Color::white) 375 , m_baseBackgroundColor(Color::white)
376 , m_backgroundColorOverride(Color::transparent) 376 , m_backgroundColorOverride(Color::transparent)
377 , m_zoomFactorOverride(0) 377 , m_zoomFactorOverride(0)
378 , m_sentEarlyShowPress(false)
378 { 379 {
379 Page::PageClients pageClients; 380 Page::PageClients pageClients;
380 pageClients.chromeClient = &m_chromeClientImpl; 381 pageClients.chromeClient = &m_chromeClientImpl;
381 pageClients.contextMenuClient = &m_contextMenuClientImpl; 382 pageClients.contextMenuClient = &m_contextMenuClientImpl;
382 pageClients.editorClient = &m_editorClientImpl; 383 pageClients.editorClient = &m_editorClientImpl;
383 pageClients.dragClient = &m_dragClientImpl; 384 pageClients.dragClient = &m_dragClientImpl;
384 pageClients.inspectorClient = &m_inspectorClientImpl; 385 pageClients.inspectorClient = &m_inspectorClientImpl;
385 pageClients.backForwardClient = &m_backForwardClientImpl; 386 pageClients.backForwardClient = &m_backForwardClientImpl;
386 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; 387 pageClients.spellCheckerClient = &m_spellCheckerClientImpl;
387 pageClients.storageClient = &m_storageClientImpl; 388 pageClients.storageClient = &m_storageClientImpl;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 default: 624 default:
624 break; 625 break;
625 } 626 }
626 627
627 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 628 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
628 629
629 // Handle link highlighting outside the main switch to avoid getting lost in the 630 // Handle link highlighting outside the main switch to avoid getting lost in the
630 // complicated set of cases handled below. 631 // complicated set of cases handled below.
631 switch (event.type) { 632 switch (event.type) {
632 case WebInputEvent::GestureShowPress: 633 case WebInputEvent::GestureShowPress:
634 // Skip if already seen a ShowPress triggered by TapDown.
635 if (m_sentEarlyShowPress)
636 return false;
637
633 // Queue a highlight animation, then hand off to regular handler. 638 // Queue a highlight animation, then hand off to regular handler.
634 if (settingsImpl()->gestureTapHighlightEnabled()) 639 if (settingsImpl()->gestureTapHighlightEnabled())
635 enableTapHighlightAtPoint(platformEvent); 640 enableTapHighlightAtPoint(platformEvent);
636 break; 641 break;
637 case WebInputEvent::GestureTapCancel: 642 case WebInputEvent::GestureTapCancel:
638 case WebInputEvent::GestureTap: 643 case WebInputEvent::GestureTap:
639 case WebInputEvent::GestureLongPress: 644 case WebInputEvent::GestureLongPress:
640 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 645 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
641 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); 646 m_linkHighlights[i]->startHighlightAnimationIfNeeded();
642 break; 647 break;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 722 }
718 case WebInputEvent::GestureDoubleTap: 723 case WebInputEvent::GestureDoubleTap:
719 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) { 724 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor() != maximumPageScaleFactor()) {
720 m_client->cancelScheduledContentIntents(); 725 m_client->cancelScheduledContentIntents();
721 animateDoubleTapZoom(platformEvent.position()); 726 animateDoubleTapZoom(platformEvent.position());
722 } 727 }
723 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore, 728 // GestureDoubleTap is currently only used by Android for zooming. For W ebCore,
724 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here. 729 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub leTap here.
725 eventSwallowed = true; 730 eventSwallowed = true;
726 break; 731 break;
732 case WebInputEvent::GestureTapDown:
733 m_sentEarlyShowPress = false;
734 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
735 break;
727 case WebInputEvent::GestureScrollBegin: 736 case WebInputEvent::GestureScrollBegin:
728 case WebInputEvent::GesturePinchBegin: 737 case WebInputEvent::GesturePinchBegin:
729 m_client->cancelScheduledContentIntents(); 738 m_client->cancelScheduledContentIntents();
730 case WebInputEvent::GestureTapDown:
731 case WebInputEvent::GestureScrollEnd: 739 case WebInputEvent::GestureScrollEnd:
732 case WebInputEvent::GestureScrollUpdate: 740 case WebInputEvent::GestureScrollUpdate:
733 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 741 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
734 case WebInputEvent::GestureTapCancel: 742 case WebInputEvent::GestureTapCancel:
735 case WebInputEvent::GestureTapUnconfirmed: 743 case WebInputEvent::GestureTapUnconfirmed:
736 case WebInputEvent::GesturePinchEnd: 744 case WebInputEvent::GesturePinchEnd:
737 case WebInputEvent::GesturePinchUpdate: 745 case WebInputEvent::GesturePinchUpdate:
738 case WebInputEvent::GestureFlingStart: { 746 case WebInputEvent::GestureFlingStart: {
739 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent); 747 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
740 break; 748 break;
741 } 749 }
742 default: 750 default:
743 ASSERT_NOT_REACHED(); 751 ASSERT_NOT_REACHED();
744 } 752 }
745 m_client->didHandleGestureEvent(event, eventCancelled); 753 m_client->didHandleGestureEvent(event, eventCancelled);
754
755 if (event.type == WebInputEvent::GestureTapDown
756 && earlyGestureShowPress(platformEvent)) {
Rick Byers 2014/03/13 01:40:06 might as well move this up into the switch (since
Zeeshan Qureshi 2014/03/24 21:37:43 Done, although I'm not sure if having a return ins
757 WebGestureEvent showPressEvent = event;
758 showPressEvent.type = WebInputEvent::GestureShowPress;
759 eventSwallowed = handleGestureEvent(showPressEvent);
760 // Ignore subsequent ShowPress events until another TapDown
761 m_sentEarlyShowPress = true;
762 }
763
746 return eventSwallowed; 764 return eventSwallowed;
747 } 765 }
748 766
767 // GestureShowPress is normally delayed to avoid triggering on the start of a
768 // scroll, but when scrolling and pinching aren't possible we can do the
769 // ShowPress early, immediately after TapDown.
770 bool WebViewImpl::earlyGestureShowPress(const WebCore::PlatformGestureEvent& eve nt)
771 {
772 LocalFrame* mainFrame = mainFrameImpl()->frame();
773 FrameView* frameView = mainFrame->view();
774
775 if (frameView && !frameView->isScrollable() && !isPinchZoomable()) {
776 IntPoint adjustedPoint = event.position();
777 LocalFrame* eventFrame = mainFrame->eventHandler().frameForGestureEvent( event, adjustedPoint);
778 IntPoint hitTestPoint = eventFrame->view()->windowToContents(event.posit ion());
779 HitTestResult result = eventFrame->eventHandler().hitTestResultAtPoint(h itTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ReadOnly | HitTestReq uest::AllowFrameScrollbars);
780
781 // If no ancestor is scrollable then this couldn't possibly be the start of a scroll.
782 return !eventFrame->eventHandler().hasScrollableAncestor(result.innerEle ment());
783 }
784
785 return false;
786 }
787
749 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters) 788 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters)
750 { 789 {
751 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation"); 790 TRACE_EVENT0("webkit", "WebViewImpl::transferActiveWheelFlingAnimation");
752 ASSERT(!m_gestureAnimation); 791 ASSERT(!m_gestureAnimation);
753 m_positionOnFlingStart = parameters.point; 792 m_positionOnFlingStart = parameters.point;
754 m_globalPositionOnFlingStart = parameters.globalPoint; 793 m_globalPositionOnFlingStart = parameters.globalPoint;
755 m_flingModifier = parameters.modifiers; 794 m_flingModifier = parameters.modifiers;
756 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll)); 795 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
757 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime); 796 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
758 scheduleAnimation(); 797 scheduleAnimation();
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 float WebViewImpl::minimumPageScaleFactor() const 2945 float WebViewImpl::minimumPageScaleFactor() const
2907 { 2946 {
2908 return m_pageScaleConstraintsSet.finalConstraints().minimumScale; 2947 return m_pageScaleConstraintsSet.finalConstraints().minimumScale;
2909 } 2948 }
2910 2949
2911 float WebViewImpl::maximumPageScaleFactor() const 2950 float WebViewImpl::maximumPageScaleFactor() const
2912 { 2951 {
2913 return m_pageScaleConstraintsSet.finalConstraints().maximumScale; 2952 return m_pageScaleConstraintsSet.finalConstraints().maximumScale;
2914 } 2953 }
2915 2954
2955 bool WebViewImpl::isPinchZoomable() const
2956 {
2957 // This covers all cases:
2958 // * viewport user-scalable: no
2959 // * viewport minimum and maximum scale equal
2960 // * pinch disabled by command line flag
2961 return minimumPageScaleFactor() != maximumPageScaleFactor();
2962 }
2963
2916 void WebViewImpl::saveScrollAndScaleState() 2964 void WebViewImpl::saveScrollAndScaleState()
2917 { 2965 {
2918 m_savedPageScaleFactor = pageScaleFactor(); 2966 m_savedPageScaleFactor = pageScaleFactor();
2919 m_savedScrollOffset = mainFrame()->scrollOffset(); 2967 m_savedScrollOffset = mainFrame()->scrollOffset();
2920 } 2968 }
2921 2969
2922 void WebViewImpl::restoreScrollAndScaleState() 2970 void WebViewImpl::restoreScrollAndScaleState()
2923 { 2971 {
2924 if (!m_savedPageScaleFactor) 2972 if (!m_savedPageScaleFactor)
2925 return; 2973 return;
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4030 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
3983 4031
3984 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4032 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
3985 return false; 4033 return false;
3986 4034
3987 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4035 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
3988 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4036 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
3989 } 4037 }
3990 4038
3991 } // namespace blink 4039 } // namespace blink
OLDNEW
« Source/core/page/EventHandler.cpp ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698