Changeset 191644 in webkit
- Timestamp:
- Oct 27, 2015 4:34:54 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r191638 r191644 1 2015-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Implement viewport-width-based fast-click heuristic 4 https://bugs.webkit.org/show_bug.cgi?id=150604 5 <rdar://problem/23267308> 6 7 Reviewed by Simon Fraser. 8 9 Implement a new fast-click heuristic that applies to viewports with width = device-width. Adds 10 new tests to check various fast-clicking behaviors. These three tests check (for pages with width= 11 device-width) that: 12 13 - Double-tapping to zoom still works when the scale is not the initial scale. 14 - If the page is at initial scale, we fire fast-clicks instead of zooming. 15 - When zooming out from element scale, we end up at initial scale instead of minimum scale. 16 17 * fast/events/ios/viewport-device-width-allows-double-tap-zoom-out-expected.txt: Added. 18 * fast/events/ios/viewport-device-width-allows-double-tap-zoom-out.html: Added. 19 * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks-expected.txt: Added. 20 * fast/events/ios/viewport-device-width-at-initial-scale-fast-clicks.html: Added. 21 * fast/events/ios/viewport-zooms-from-element-to-initial-scale-expected.txt: Added. 22 * fast/events/ios/viewport-zooms-from-element-to-initial-scale.html: Added. 23 1 24 2015-10-27 Ryan Haddad <ryanhaddad@apple.com> 2 25 -
trunk/Source/WebKit2/ChangeLog
r191637 r191644 1 2015-10-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Implement viewport-width-based fast-click heuristic 4 https://bugs.webkit.org/show_bug.cgi?id=150604 5 <rdar://problem/23267308> 6 7 Reviewed by Simon Fraser. 8 9 Implement a new fast-click heuristic that applies to viewports with width = device-width. The basic rules are 10 as follows: when a page has viewport width = device-width and is at initial zoom scale, we disable double-tapping 11 in favor of fast-clicking. However, if the viewport scale is not the initial scale, we allow double tapping. For 12 fast-clicking to remain useful after the user pinch-zooms, we change our double-tap to zoom out behavior to zoom 13 to the initial scale rather than the minimum scale. For unscalable viewports, we default to fast-clicking behavior, 14 and for all other viewports not at device-width, we double-tap to zoom and scroll as normal. 15 16 This patch removes some logic previously used for our scroll- and zoom-based fast-clicking heuristic, and adds 17 information about the viewport width and initial scale to RemoteLayerTreeTransactions. This information is then 18 used by the UI process to determine whether double tapping should be disabled or enabled. 19 20 The fast-click heuristic can be turned off through user default preferences, and a tap highlight for debugging 21 fast-clicking can also be enabled through a user default preference. A red highlight indicates that a single- 22 tap was slow, whereas a green highlight indicates a fast single-tap. 23 24 * Shared/mac/RemoteLayerTreeTransaction.h: 25 (WebKit::RemoteLayerTreeTransaction::initialScaleFactor): 26 (WebKit::RemoteLayerTreeTransaction::setInitialScaleFactor): 27 (WebKit::RemoteLayerTreeTransaction::viewportMetaTagWidth): 28 (WebKit::RemoteLayerTreeTransaction::setViewportMetaTagWidth): 29 * Shared/mac/RemoteLayerTreeTransaction.mm: 30 (WebKit::RemoteLayerTreeTransaction::encode): 31 (WebKit::RemoteLayerTreeTransaction::decode): 32 * UIProcess/API/Cocoa/WKWebView.mm: 33 (-[WKWebView initWithFrame:configuration:]): 34 (-[WKWebView _processDidExit]): 35 (-[WKWebView _didCommitLayerTree:]): 36 (-[WKWebView _zoomToInitialScaleWithOrigin:animated:]): 37 (-[WKWebView _allowsDoubleTapGestures]): 38 (-[WKWebView _setViewportMetaTagWidth:]): Deleted. 39 (-[WKWebView _contentZoomScale]): Deleted. 40 (-[WKWebView _viewportMetaTagWidth]): Deleted. 41 (-[WKWebView _viewportIsUserScalable]): Deleted. 42 * UIProcess/API/Cocoa/WKWebViewInternal.h: 43 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 44 * UIProcess/PageClient.h: 45 * UIProcess/WebPageProxy.h: 46 * UIProcess/WebPageProxy.messages.in: 47 * UIProcess/ios/PageClientImplIOS.h: 48 * UIProcess/ios/PageClientImplIOS.mm: 49 (WebKit::PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary): 50 (WebKit::PageClientImpl::didChangeViewportMetaTagWidth): Deleted. 51 (WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted. 52 * UIProcess/ios/SmartMagnificationController.h: 53 * UIProcess/ios/SmartMagnificationController.mm: 54 (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture): 55 * UIProcess/ios/WKContentView.h: 56 * UIProcess/ios/WKContentView.mm: 57 (-[WKContentView _zoomToInitialScaleWithOrigin:]): 58 * UIProcess/ios/WKContentViewInteraction.h: 59 * UIProcess/ios/WKContentViewInteraction.mm: 60 (-[WKContentView setupInteraction]): 61 (-[WKContentView _showTapHighlight]): 62 (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]): 63 (-[WKContentView _mayDisableDoubleTapGesturesDuringSingleTap]): 64 (-[WKContentView _disableDoubleTapGesturesDuringTapIfNecessary:]): 65 (-[WKContentView _finishInteraction]): 66 (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]): 67 (-[WKContentView _tapHighlightColorForFastClick:]): 68 (-[WKContentView _setDoubleTapGesturesEnabled:]): 69 (-[WKContentView _fastClickZoomThreshold]): Deleted. 70 (-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]): Deleted. 71 (-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]): Deleted. 72 * UIProcess/ios/WebPageProxyIOS.mm: 73 (WebKit::WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary): 74 (WebKit::WebPageProxy::viewportMetaTagWidthDidChange): Deleted. 75 (WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): Deleted. 76 * WebProcess/WebPage/ViewGestureGeometryCollector.h: 77 * WebProcess/WebPage/WebPage.cpp: 78 (WebKit::WebPage::willCommitLayerTree): 79 * WebProcess/WebPage/ios/WebPageIOS.mm: 80 (WebKit::WebPage::potentialTapAtPosition): 81 (WebKit::WebPage::viewportPropertiesDidChange): Deleted. 82 1 83 2015-10-27 Tim Horton <timothy_horton@apple.com> 2 84 -
trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
r190064 r191644 225 225 void setMaximumScaleFactor(double scale) { m_maximumScaleFactor = scale; } 226 226 227 double initialScaleFactor() const { return m_initialScaleFactor; } 228 void setInitialScaleFactor(double scale) { m_initialScaleFactor = scale; } 229 230 double viewportMetaTagWidth() const { return m_viewportMetaTagWidth; } 231 void setViewportMetaTagWidth(double width) { m_viewportMetaTagWidth = width; } 232 227 233 bool allowsUserScaling() const { return m_allowsUserScaling; } 228 234 void setAllowsUserScaling(bool allowsUserScaling) { m_allowsUserScaling = allowsUserScaling; } … … 259 265 double m_minimumScaleFactor { 1 }; 260 266 double m_maximumScaleFactor { 1 }; 267 double m_initialScaleFactor { 1 }; 268 double m_viewportMetaTagWidth { -1 }; 261 269 uint64_t m_renderTreeSize { 0 }; 262 270 uint64_t m_transactionID { 0 }; -
trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
r191243 r191644 518 518 encoder << m_minimumScaleFactor; 519 519 encoder << m_maximumScaleFactor; 520 encoder << m_initialScaleFactor; 521 encoder << m_viewportMetaTagWidth; 520 522 521 523 encoder << m_renderTreeSize; … … 596 598 597 599 if (!decoder.decode(result.m_maximumScaleFactor)) 600 return false; 601 602 if (!decoder.decode(result.m_initialScaleFactor)) 603 return false; 604 605 if (!decoder.decode(result.m_viewportMetaTagWidth)) 598 606 return false; 599 607 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r191600 r191644 175 175 CGRect _inputViewBounds; 176 176 CGFloat _viewportMetaTagWidth; 177 CGFloat _initialScaleFactor; 178 BOOL _fastClickingIsDisabled; 179 177 180 BOOL _allowsLinkPreview; 178 181 … … 354 357 [self _updateScrollViewBackground]; 355 358 356 _viewportMetaTagWidth = -1; 359 _viewportMetaTagWidth = WebCore::ViewportArguments::ValueAuto; 360 _initialScaleFactor = 1; 361 _fastClickingIsDisabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitFastClickingDisabled"]; 357 362 358 363 [self _frameOrBoundsChanged]; … … 815 820 } 816 821 817 - (void)_setViewportMetaTagWidth:(float)newWidth818 {819 _viewportMetaTagWidth = newWidth;820 }821 822 822 - (void)_willInvokeUIScrollViewDelegateCallback 823 823 { … … 932 932 [_scrollView setZoomScale:1]; 933 933 934 _viewportMetaTagWidth = -1; 934 _viewportMetaTagWidth = WebCore::ViewportArguments::ValueAuto; 935 _initialScaleFactor = 1; 935 936 _hasCommittedLoadForMainFrame = NO; 936 937 _needsResetViewStateAfterCommitLoadForMainFrame = NO; … … 1014 1015 [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()]; 1015 1016 1016 [_contentView _setDoubleTapGesturesEnabled:self._viewportIsUserScalable]; 1017 _viewportMetaTagWidth = layerTreeTransaction.viewportMetaTagWidth(); 1018 _initialScaleFactor = layerTreeTransaction.initialScaleFactor(); 1019 if (![_contentView _mayDisableDoubleTapGesturesDuringSingleTap]) 1020 [_contentView _setDoubleTapGesturesEnabled:self._allowsDoubleTapGestures]; 1017 1021 1018 1022 [self _updateScrollViewBackground]; … … 1293 1297 } 1294 1298 1299 - (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated 1300 { 1301 ASSERT(_initialScaleFactor > 0); 1302 [self _zoomToPoint:origin atScale:_initialScaleFactor animated:animated]; 1303 } 1304 1295 1305 // focusedElementRect and selectionRect are both in document coordinates. 1296 1306 - (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRectInDocumentCoordinates selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll … … 1410 1420 duration:UIWebFormAnimationDuration 1411 1421 force:YES]; 1412 }1413 1414 - (CGFloat)_contentZoomScale1415 {1416 return contentZoomScale(self);1417 1422 } 1418 1423 … … 3097 3102 } 3098 3103 3099 - (CGFloat)_viewportMetaTagWidth 3100 { 3101 return _viewportMetaTagWidth; 3102 } 3103 3104 - (BOOL)_viewportIsUserScalable 3105 { 3106 return [_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale]; 3104 - (BOOL)_allowsDoubleTapGestures 3105 { 3106 if (_fastClickingIsDisabled) 3107 return YES; 3108 3109 // If the page is not user scalable, we don't allow double tap gestures. 3110 if (![_scrollView isZoomEnabled] || [_scrollView minimumZoomScale] >= [_scrollView maximumZoomScale]) 3111 return NO; 3112 3113 // For scalable viewports, only disable double tap gestures if the viewport width is device width. 3114 if (_viewportMetaTagWidth != WebCore::ViewportArguments::ValueDeviceWidth) 3115 return YES; 3116 3117 return !areEssentiallyEqualAsFloat(contentZoomScale(self), _initialScaleFactor); 3107 3118 } 3108 3119 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r191309 r191644 88 88 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance; 89 89 - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated; 90 - (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated; 90 91 91 92 - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType; 92 93 - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data; 93 - (void)_setViewportMetaTagWidth:(float)newWidth;94 94 95 95 - (void)_willInvokeUIScrollViewDelegateCallback; … … 110 110 - (void)_navigationGestureDidEnd; 111 111 112 - (CGFloat)_contentZoomScale; 113 - (CGFloat)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale; 114 112 @property (nonatomic, readonly) BOOL _allowsDoubleTapGestures; 115 113 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset; 116 114 #else -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r191479 r191644 135 135 @property (nonatomic, readonly) NSString *_suggestedFilenameForDisplayedPDF; 136 136 137 // The viewport meta tag width is negative if the value is not defined.138 @property (nonatomic, readonly) CGFloat _viewportMetaTagWidth;139 @property (nonatomic, readonly) BOOL _viewportIsUserScalable;140 141 137 @property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter; 142 138 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r191402 r191644 295 295 virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) = 0; 296 296 virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0; 297 virtual void didChangeViewportMetaTagWidth(float) = 0; 298 virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) = 0; 297 virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) = 0; 299 298 virtual double minimumZoomScale() const = 0; 300 299 virtual WebCore::FloatRect documentRect() const = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r191543 r191644 511 511 void commitPotentialTapFailed(); 512 512 void didNotHandleTapAsClick(const WebCore::IntPoint&); 513 void viewportMetaTagWidthDidChange(float width); 514 void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale); 513 void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID); 515 514 void didFinishDrawingPagesToPDF(const IPC::DataReference&); 516 515 void contentSizeCategoryDidChange(const String& contentSizeCategory); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r191543 r191644 184 184 CommitPotentialTapFailed() 185 185 DidNotHandleTapAsClick(WebCore::IntPoint point) 186 ViewportMetaTagWidthDidChange(float width) 187 DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, WebCore::FloatRect targetRect, bool isReplacedElement, double minimumScale, double maximumScale) 186 DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) 188 187 DidFinishDrawingPagesToPDF(IPC::DataReference pdfData) 189 188 #endif -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r191402 r191644 135 135 136 136 virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override; 137 virtual void didChangeViewportMetaTagWidth(float) override; 138 virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) override; 137 virtual void disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) override; 139 138 virtual double minimumZoomScale() const override; 140 139 virtual WebCore::FloatRect documentRect() const override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r191402 r191644 255 255 } 256 256 257 void PageClientImpl::didChangeViewportMetaTagWidth(float newWidth) 258 { 259 [m_webView _setViewportMetaTagWidth:newWidth]; 260 } 261 262 void PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) 263 { 264 if (!m_webView._viewportIsUserScalable) 257 void PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) 258 { 259 if (!m_webView._allowsDoubleTapGestures) 265 260 return; 266 261 267 [m_contentView _disableDoubleTapGestures UntilTapIsFinishedIfNecessary:requestID allowsDoubleTapZoom:allowsDoubleTapZoom targetRect:targetRect isReplaced:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];262 [m_contentView _disableDoubleTapGesturesDuringTapIfNecessary:requestID]; 268 263 } 269 264 -
trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h
r191309 r191644 49 49 void handleSmartMagnificationGesture(WebCore::FloatPoint origin); 50 50 void handleResetMagnificationGesture(WebCore::FloatPoint origin); 51 void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale);52 51 53 52 private: … … 57 56 void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale); 58 57 void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale); 58 void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale); 59 59 60 60 WebPageProxy& m_webPageProxy; -
trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm
r191309 r191644 94 94 if (targetRect.isEmpty()) { 95 95 // FIXME: If we don't zoom, send the tap along to text selection (see <rdar://problem/6810344>). 96 [m_contentView _zoom OutWithOrigin:origin];96 [m_contentView _zoomToInitialScaleWithOrigin:origin]; 97 97 return; 98 98 } … … 120 120 121 121 // FIXME: If we still don't zoom, send the tap along to text selection (see <rdar://problem/6810344>). 122 [m_contentView _zoom OutWithOrigin:origin];122 [m_contentView _zoomToInitialScaleWithOrigin:origin]; 123 123 } 124 124 -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.h
r188892 r191644 93 93 - (BOOL)_zoomToRect:(CGRect)targetRect withOrigin:(CGPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(CGFloat)minimumScrollDistance; 94 94 - (void)_zoomOutWithOrigin:(CGPoint)origin; 95 - (void)_zoomToInitialScaleWithOrigin:(CGPoint)origin; 95 96 96 97 @end -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm
r188892 r191644 541 541 } 542 542 543 - (void)_zoomToInitialScaleWithOrigin:(CGPoint)origin 544 { 545 return [_webView _zoomToInitialScaleWithOrigin:origin animated:YES]; 546 } 547 543 548 - (void)_applicationWillResignActive:(NSNotification*)notification 544 549 { -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
r191409 r191644 160 160 BOOL _didAccessoryTabInitiateFocus; 161 161 BOOL _isExpectingFastSingleTapCommit; 162 BOOL _showDebugTapHighlightsForFastClicking; 162 163 } 163 164 … … 184 185 - (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius; 185 186 186 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale; 187 - (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap; 188 - (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID; 187 189 - (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject; 188 190 - (void)_stopAssistingNode; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r191535 r191644 477 477 _smartMagnificationController = std::make_unique<SmartMagnificationController>(self); 478 478 _isExpectingFastSingleTapCommit = NO; 479 _showDebugTapHighlightsForFastClicking = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitShowFastClickDebugTapHighlights"]; 479 480 } 480 481 … … 841 842 - (void)_showTapHighlight 842 843 { 843 if (!highlightedQuadsAreSmallerThanRect(_tapHighlightInformation.quads, _page->unobscuredContentRect()) )844 if (!highlightedQuadsAreSmallerThanRect(_tapHighlightInformation.quads, _page->unobscuredContentRect()) && !_showDebugTapHighlightsForFastClicking) 844 845 return; 845 846 … … 861 862 _isTapHighlightIDValid = NO; 862 863 863 _tapHighlightInformation.color = color;864 864 _tapHighlightInformation.quads = highlightedQuads; 865 865 _tapHighlightInformation.topLeftRadius = topLeftRadius; … … 867 867 _tapHighlightInformation.bottomLeftRadius = bottomLeftRadius; 868 868 _tapHighlightInformation.bottomRightRadius = bottomRightRadius; 869 if (_showDebugTapHighlightsForFastClicking) 870 _tapHighlightInformation.color = [self _tapHighlightColorForFastClick:![_doubleTapGestureRecognizer isEnabled]]; 871 else 872 _tapHighlightInformation.color = color; 869 873 870 874 if (_potentialTapInProgress) { … … 881 885 } 882 886 883 - (CGFloat)_fastClickZoomThreshold 884 { 885 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 886 if (![defaults boolForKey:@"WebKitFastClickingEnabled"]) 887 return 0; 888 889 return [defaults floatForKey:@"WebKitFastClickZoomThreshold"]; 890 } 891 892 - (BOOL)_allowDoubleTapToZoomForCurrentZoomScale:(CGFloat)currentZoomScale andTargetZoomScale:(CGFloat)targetZoomScale 893 { 894 CGFloat zoomThreshold = [self _fastClickZoomThreshold]; 895 if (!zoomThreshold) 896 return YES; 897 898 CGFloat minimumZoomRatioForDoubleTapToZoomIn = 1 + zoomThreshold; 899 CGFloat maximumZoomRatioForDoubleTapToZoomOut = 1 / minimumZoomRatioForDoubleTapToZoomIn; 900 CGFloat zoomRatio = targetZoomScale / currentZoomScale; 901 return zoomRatio < maximumZoomRatioForDoubleTapToZoomOut || zoomRatio > minimumZoomRatioForDoubleTapToZoomIn; 902 } 903 904 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale 887 - (BOOL)_mayDisableDoubleTapGesturesDuringSingleTap 888 { 889 return _potentialTapInProgress; 890 } 891 892 - (void)_disableDoubleTapGesturesDuringTapIfNecessary:(uint64_t)requestID 905 893 { 906 894 if (!_potentialTapInProgress || _latestTapID != requestID) 907 895 return; 908 909 if (allowsDoubleTapZoom) {910 // Though the element allows us to zoom in on double tap, we avoid this behavior in favor of fast clicking if the difference in scale is insignificant.911 _smartMagnificationController->adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale);912 CGFloat currentZoomScale = [_webView _contentZoomScale];913 CGFloat targetZoomScale = [_webView _targetContentZoomScaleForRect:targetRect currentScale:currentZoomScale fitEntireRect:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale];914 if ([self _allowDoubleTapToZoomForCurrentZoomScale:currentZoomScale andTargetZoomScale:targetZoomScale])915 return;916 }917 896 918 897 [self _setDoubleTapGesturesEnabled:NO]; … … 1154 1133 { 1155 1134 _isTapHighlightIDValid = NO; 1156 [UIView animateWithDuration:0.1 1135 CGFloat tapHighlightFadeDuration = _showDebugTapHighlightsForFastClicking ? 0.25 : 0.1; 1136 [UIView animateWithDuration:tapHighlightFadeDuration 1157 1137 animations:^{ 1158 1138 [_highlightView layer].opacity = 0; … … 1260 1240 - (void)_endPotentialTapAndEnableDoubleTapGesturesIfNecessary 1261 1241 { 1262 if (_webView._ viewportIsUserScalable)1242 if (_webView._allowsDoubleTapGestures) 1263 1243 [self _setDoubleTapGesturesEnabled:YES]; 1264 1244 … … 2415 2395 } 2416 2396 2397 - (WebCore::Color)_tapHighlightColorForFastClick:(BOOL)forFastClick 2398 { 2399 ASSERT(_showDebugTapHighlightsForFastClicking); 2400 return forFastClick ? WebCore::Color(0, 225, 0, 127) : WebCore::Color(225, 0, 0, 127); 2401 } 2402 2417 2403 - (void)_setDoubleTapGesturesEnabled:(BOOL)enabled 2418 2404 { … … 2424 2410 [self _createAndConfigureDoubleTapGestureRecognizer]; 2425 2411 } 2412 2413 if (_showDebugTapHighlightsForFastClicking && !enabled) 2414 _tapHighlightInformation.color = [self _tapHighlightColorForFastClick:YES]; 2415 2426 2416 [_doubleTapGestureRecognizer setEnabled:enabled]; 2427 2417 } -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r191309 r191644 933 933 } 934 934 935 void WebPageProxy::viewportMetaTagWidthDidChange(float width) 936 { 937 m_pageClient.didChangeViewportMetaTagWidth(width); 938 } 939 940 void WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) 941 { 942 m_pageClient.disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, allowsDoubleTapZoom, targetRect, isReplacedElement, minimumScale, maximumScale); 935 void WebPageProxy::disableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) 936 { 937 m_pageClient.disableDoubleTapGesturesDuringTapIfNecessary(requestID); 943 938 } 944 939 -
trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h
r191309 r191644 46 46 47 47 void mainFrameDidLayout(); 48 void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale);49 48 50 49 private: … … 63 62 64 63 void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale); 64 void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale); 65 65 66 66 WebPage& m_webPage; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r191543 r191644 2944 2944 layerTransaction.setMinimumScaleFactor(m_viewportConfiguration.minimumScale()); 2945 2945 layerTransaction.setMaximumScaleFactor(m_viewportConfiguration.maximumScale()); 2946 layerTransaction.setInitialScaleFactor(m_viewportConfiguration.initialScale()); 2947 layerTransaction.setViewportMetaTagWidth(m_viewportConfiguration.viewportArguments().width); 2946 2948 layerTransaction.setAllowsUserScaling(allowsUserScaling()); 2947 2949 #endif -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r191452 r191644 234 234 return; 235 235 236 float oldWidth = m_viewportConfiguration.viewportArguments().width;237 238 236 m_viewportConfiguration.setViewportArguments(viewportArguments); 239 237 viewportConfigurationChanged(); 240 241 if (oldWidth != viewportArguments.width)242 send(Messages::WebPageProxy::ViewportMetaTagWidthDidChange(viewportArguments.width));243 238 } 244 239 … … 665 660 m_potentialTapNode = m_page->mainFrame().nodeRespondingToClickEvents(position, m_potentialTapLocation); 666 661 sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get()); 667 if (m_potentialTapNode) {668 662 #if ENABLE(TOUCH_EVENTS) 669 if (!m_potentialTapNode->allowsDoubleTapGesture()) { 670 send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, false, FloatRect(), false, 0, 0)); 671 return; 672 } 663 if (m_potentialTapNode && !m_potentialTapNode->allowsDoubleTapGesture()) 664 send(Messages::WebPageProxy::DisableDoubleTapGesturesDuringTapIfNecessary(requestID)); 673 665 #endif 674 FloatPoint origin = position;675 FloatRect renderRect;676 bool isReplaced;677 double viewportMinimumScale;678 double viewportMaximumScale;679 680 m_viewGestureGeometryCollector.computeZoomInformationForNode(*m_potentialTapNode.get(), origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale);681 send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, true, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale));682 }683 666 } 684 667
Note: See TracChangeset
for help on using the changeset viewer.