Changeset 191309 in webkit
- Timestamp:
- Oct 19, 2015 12:53:45 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r191307 r191309 1 2015-10-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Extend fast-clicking behavior to trigger on elements that have negligible zoom 4 https://bugs.webkit.org/show_bug.cgi?id=150248 5 <rdar://problem/23140069> 6 7 Reviewed by Simon Fraser. 8 9 Currently, fast-clicking only triggers on pages that have unscalable viewports. To allow more websites to benefit from fast-clicking 10 behavior, we generalize fast-clicking to also occur when tapping on elements for which double-tap-to-zoom would zoom the element in 11 or out by an insignificant amount. We define an insignificant amount of zoom to mean that zooming would increase the viewport scale 12 by less than a configurable threshold, or decrease the viewport scale by more than a configurable threshold. We accomplish this by 13 temporarily disabling the double tap gesture recognizer for the duration of the tap. This patch refactors some logic used to compute 14 zoomed viewports to make it possible to predict the change in viewport scale when double tapping to zoom. See the changes in 15 SmartMagnificationController and ViewGestureGeometryCollector for more details. 16 17 There are no new tests, since this patch does not change existing behavior. Instead, this patch adds the machinery needed for zoom- 18 dependent fast-clicking: by setting the preferences WebKitFastClickingEnabled and WebKitFastClickZoomThreshold, we will be able to tweak 19 the behavior dynamically. 20 21 * UIProcess/API/Cocoa/WKWebView.mm: 22 (-[WKWebView _didCommitLayerTree:]): 23 (-[WKWebView _contentZoomScale]): 24 (-[WKWebView _targetContentZoomScaleForRect:currentScale:fitEntireRect:minimumScale:maximumScale:]): 25 (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]): 26 (-[WKWebView _viewportIsUserScalable]): 27 * UIProcess/API/Cocoa/WKWebViewInternal.h: 28 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 29 * UIProcess/PageClient.h: 30 * UIProcess/WebPageProxy.h: 31 * UIProcess/WebPageProxy.messages.in: 32 * UIProcess/ios/PageClientImplIOS.h: 33 * UIProcess/ios/PageClientImplIOS.mm: 34 (WebKit::PageClientImpl::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): 35 * UIProcess/ios/SmartMagnificationController.h: 36 * UIProcess/ios/SmartMagnificationController.mm: 37 (WebKit::SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales): 38 (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture): 39 (WebKit::SmartMagnificationController::magnify): 40 * UIProcess/ios/WKContentViewInteraction.h: 41 * UIProcess/ios/WKContentViewInteraction.mm: 42 (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:]): 43 (-[WKContentView _fastClickZoomThreshold]): 44 (-[WKContentView _allowDoubleTapToZoomForCurrentZoomScale:andTargetZoomScale:]): 45 (-[WKContentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:allowsDoubleTapZoom:targetRect:isReplaced:minimumScale:maximumScale:]): 46 (-[WKContentView _highlightLongPressRecognized:]): 47 (-[WKContentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]): 48 (-[WKContentView _singleTapRecognized:]): 49 (cancelPotentialTapIfNecessary): 50 (-[WKContentView _singleTapCommited:]): 51 (-[WKContentView webSelectionRects]): Deleted. 52 * UIProcess/ios/WebPageProxyIOS.mm: 53 (WebKit::WebPageProxy::disableDoubleTapGesturesUntilTapIsFinishedIfNecessary): 54 * WebProcess/WebPage/ViewGestureGeometryCollector.cpp: 55 (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture): 56 (WebKit::ViewGestureGeometryCollector::computeZoomInformationForNode): 57 * WebProcess/WebPage/ViewGestureGeometryCollector.h: 58 * WebProcess/WebPage/ios/WebPageIOS.mm: 59 (WebKit::WebPage::potentialTapAtPosition): 60 1 61 2015-10-19 Tim Horton <timothy_horton@apple.com> 2 62 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r191228 r191309 998 998 [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()]; 999 999 1000 [_contentView _setDoubleTapGesturesEnabled: [_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale]];1000 [_contentView _setDoubleTapGesturesEnabled:self._viewportIsUserScalable]; 1001 1001 1002 1002 [self _updateScrollViewBackground]; … … 1396 1396 } 1397 1397 1398 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance 1399 { 1400 const float maximumScaleFactorDeltaForPanScroll = 0.02; 1401 1402 double currentScale = contentZoomScale(self); 1403 1398 - (CGFloat)_contentZoomScale 1399 { 1400 return contentZoomScale(self); 1401 } 1402 1403 - (CGFloat)_targetContentZoomScaleForRect:(const WebCore::FloatRect&)targetRect currentScale:(double)currentScale fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale 1404 { 1404 1405 WebCore::FloatSize unobscuredContentSize([self _contentRectForUserInteraction].size); 1405 1406 double horizontalScale = unobscuredContentSize.width() * currentScale / targetRect.width(); … … 1409 1410 verticalScale = std::min(std::max(verticalScale, minimumScale), maximumScale); 1410 1411 1411 double targetScale = fitEntireRect ? std::min(horizontalScale, verticalScale) : horizontalScale; 1412 return fitEntireRect ? std::min(horizontalScale, verticalScale) : horizontalScale; 1413 } 1414 1415 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance 1416 { 1417 const float maximumScaleFactorDeltaForPanScroll = 0.02; 1418 1419 double currentScale = contentZoomScale(self); 1420 double targetScale = [self _targetContentZoomScaleForRect:targetRect currentScale:currentScale fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale]; 1421 1412 1422 if (fabs(targetScale - currentScale) < maximumScaleFactorDeltaForPanScroll) { 1413 1423 if ([self _scrollToRect:targetRect origin:origin minimumScrollDistance:minimumScrollDistance]) … … 3067 3077 } 3068 3078 3079 - (BOOL)_viewportIsUserScalable 3080 { 3081 return [_scrollView isZoomEnabled] && [_scrollView minimumZoomScale] < [_scrollView maximumZoomScale]; 3082 } 3083 3069 3084 - (_WKWebViewPrintFormatter *)_webViewPrintFormatter 3070 3085 { -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r191183 r191309 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 115 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset; 113 116 #else -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r191228 r191309 136 136 // The viewport meta tag width is negative if the value is not defined. 137 137 @property (nonatomic, readonly) CGFloat _viewportMetaTagWidth; 138 @property (nonatomic, readonly) BOOL _viewportIsUserScalable; 138 139 139 140 @property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter; -
trunk/Source/WebKit2/UIProcess/PageClient.h
r191299 r191309 295 295 virtual void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale) = 0; 296 296 virtual void didChangeViewportMetaTagWidth(float) = 0; 297 virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) = 0; 297 298 virtual double minimumZoomScale() const = 0; 298 299 virtual WebCore::FloatRect documentRect() const = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r191299 r191309 510 510 void didNotHandleTapAsClick(const WebCore::IntPoint&); 511 511 void viewportMetaTagWidthDidChange(float width); 512 void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale); 512 513 void didFinishDrawingPagesToPDF(const IPC::DataReference&); 513 514 void contentSizeCategoryDidChange(const String& contentSizeCategory); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r191181 r191309 189 189 DidNotHandleTapAsClick(WebCore::IntPoint point) 190 190 ViewportMetaTagWidthDidChange(float width) 191 DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, WebCore::FloatRect targetRect, bool isReplacedElement, double minimumScale, double maximumScale) 191 192 DidFinishDrawingPagesToPDF(IPC::DataReference pdfData) 192 193 #endif -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r191146 r191309 135 135 virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override; 136 136 virtual void didChangeViewportMetaTagWidth(float) override; 137 virtual void disableDoubleTapGesturesUntilTapIsFinishedIfNecessary(uint64_t requestID, bool allowsDoubleTapZoom, const WebCore::FloatRect& targetRect, bool isReplacedElement, double minimumScale, double maximumScale) override; 137 138 virtual double minimumZoomScale() const override; 138 139 virtual WebCore::FloatRect documentRect() const override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r191146 r191309 260 260 } 261 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) 265 return; 266 267 [m_contentView _disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:requestID allowsDoubleTapZoom:allowsDoubleTapZoom targetRect:targetRect isReplaced:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale]; 268 } 269 262 270 double PageClientImpl::minimumZoomScale() const 263 271 { -
trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.h
r184149 r191309 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); 51 52 52 53 private: -
trunk/Source/WebKit2/UIProcess/ios/SmartMagnificationController.mm
r184149 r191309 79 79 } 80 80 81 void SmartMagnificationController::adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale) 82 { 83 if (addMagnificationPadding) { 84 targetRect.inflateX(smartMagnificationElementPadding * targetRect.width()); 85 targetRect.inflateY(smartMagnificationElementPadding * targetRect.height()); 86 } 87 88 minimumScale = std::max(minimumScale, smartMagnificationMinimumScale); 89 maximumScale = std::min(maximumScale, smartMagnificationMaximumScale); 90 } 91 81 92 void SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale) 82 93 { … … 86 97 return; 87 98 } 88 89 if (!isReplacedElement) { 90 targetRect.inflateX(smartMagnificationElementPadding * targetRect.width()); 91 targetRect.inflateY(smartMagnificationElementPadding * targetRect.height()); 92 } 93 94 double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale); 95 double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale); 99 double minimumScale = viewportMinimumScale; 100 double maximumScale = viewportMaximumScale; 101 adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale); 96 102 97 103 // FIXME: Check if text selection wants to consume the double tap before we attempt magnification. … … 119 125 void SmartMagnificationController::magnify(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale) 120 126 { 121 targetRect.inflateX(smartMagnificationElementPadding * targetRect.width()); 122 targetRect.inflateY(smartMagnificationElementPadding * targetRect.height()); 123 124 double maximumScale = std::min(viewportMaximumScale, smartMagnificationMaximumScale); 125 double minimumScale = std::max(viewportMinimumScale, smartMagnificationMinimumScale); 126 127 double maximumScale = viewportMaximumScale; 128 double minimumScale = viewportMinimumScale; 129 adjustSmartMagnificationTargetRectAndZoomScales(true, targetRect, minimumScale, maximumScale); 127 130 [m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:NO minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0]; 128 131 } -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
r191072 r191309 127 127 id <UITextInputDelegate> _inputDelegate; 128 128 129 uint64_t _latestTap HighlightID;129 uint64_t _latestTapID; 130 130 struct TapHighlightInformation { 131 131 WebCore::Color color; … … 183 183 - (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; 184 184 185 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale; 185 186 - (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject; 186 187 - (void)_stopAssistingNode; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r191228 r191309 832 832 - (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 833 833 { 834 if (!_isTapHighlightIDValid || _latestTap HighlightID != requestID)834 if (!_isTapHighlightIDValid || _latestTapID != requestID) 835 835 return; 836 836 … … 850 850 851 851 [self _showTapHighlight]; 852 } 853 854 - (CGFloat)_fastClickZoomThreshold 855 { 856 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 857 if (![defaults boolForKey:@"WebKitFastClickingEnabled"]) 858 return 0; 859 860 return [defaults floatForKey:@"WebKitFastClickZoomThreshold"]; 861 } 862 863 - (BOOL)_allowDoubleTapToZoomForCurrentZoomScale:(CGFloat)currentZoomScale andTargetZoomScale:(CGFloat)targetZoomScale 864 { 865 CGFloat zoomThreshold = [self _fastClickZoomThreshold]; 866 if (!zoomThreshold) 867 return YES; 868 869 CGFloat minimumZoomRatioForDoubleTapToZoomIn = 1 + zoomThreshold; 870 CGFloat maximumZoomRatioForDoubleTapToZoomOut = 1 / minimumZoomRatioForDoubleTapToZoomIn; 871 CGFloat zoomRatio = targetZoomScale / currentZoomScale; 872 return zoomRatio < maximumZoomRatioForDoubleTapToZoomOut || zoomRatio > minimumZoomRatioForDoubleTapToZoomIn; 873 } 874 875 - (void)_disableDoubleTapGesturesUntilTapIsFinishedIfNecessary:(uint64_t)requestID allowsDoubleTapZoom:(bool)allowsDoubleTapZoom targetRect:(WebCore::FloatRect)targetRect isReplaced:(BOOL)isReplacedElement minimumScale:(double)minimumScale maximumScale:(double)maximumScale 876 { 877 if (!_potentialTapInProgress || _latestTapID != requestID) 878 return; 879 880 if (allowsDoubleTapZoom) { 881 // 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. 882 _smartMagnificationController->adjustSmartMagnificationTargetRectAndZoomScales(!isReplacedElement, targetRect, minimumScale, maximumScale); 883 CGFloat currentZoomScale = [_webView _contentZoomScale]; 884 CGFloat targetZoomScale = [_webView _targetContentZoomScaleForRect:targetRect currentScale:currentZoomScale fitEntireRect:isReplacedElement minimumScale:minimumScale maximumScale:maximumScale]; 885 if ([self _allowDoubleTapToZoomForCurrentZoomScale:currentZoomScale andTargetZoomScale:targetZoomScale]) 886 return; 887 } 888 889 [self _setDoubleTapGesturesEnabled:NO]; 852 890 } 853 891 … … 1156 1194 _highlightLongPressCanClick = YES; 1157 1195 cancelPotentialTapIfNecessary(self); 1158 _page->tapHighlightAtPosition([gestureRecognizer startPoint], ++_latestTap HighlightID);1196 _page->tapHighlightAtPosition([gestureRecognizer startPoint], ++_latestTapID); 1159 1197 _isTapHighlightIDValid = YES; 1160 1198 break; … … 1191 1229 } 1192 1230 1231 - (void)_endPotentialTapAndEnableDoubleTapGesturesIfNecessary 1232 { 1233 if (_webView._viewportIsUserScalable) 1234 [self _setDoubleTapGesturesEnabled:YES]; 1235 1236 _potentialTapInProgress = NO; 1237 } 1238 1193 1239 - (void)_singleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer 1194 1240 { … … 1196 1242 ASSERT(!_potentialTapInProgress); 1197 1243 1198 _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTap HighlightID);1244 _page->potentialTapAtPosition(gestureRecognizer.location, ++_latestTapID); 1199 1245 _potentialTapInProgress = YES; 1200 1246 _isTapHighlightIDValid = YES; … … 1204 1250 { 1205 1251 if (contentView->_potentialTapInProgress) { 1206 contentView->_potentialTapInProgress = NO;1252 [contentView _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]; 1207 1253 [contentView _cancelInteraction]; 1208 1254 contentView->_page->cancelPotentialTap(); … … 1243 1289 _lastInteractionLocation = gestureRecognizer.location; 1244 1290 1245 _potentialTapInProgress = NO;1291 [self _endPotentialTapAndEnableDoubleTapGesturesIfNecessary]; 1246 1292 1247 1293 if (_hasTapHighlightForPotentialTap) { -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r190604 r191309 938 938 } 939 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); 943 } 944 940 945 void WebPageProxy::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfData) 941 946 { -
trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.cpp
r179409 r191309 87 87 88 88 m_webPage.mainFrameView()->renderView()->hitTest(HitTestRequest(), hitTestResult); 89 90 if (Node* node = hitTestResult.innerNode()) { 91 bool isReplaced; 92 FloatRect renderRect = node->renderRect(&isReplaced); 93 94 if (node->document().isImageDocument()) { 95 if (HTMLImageElement* imageElement = static_cast<ImageDocument&>(node->document()).imageElement()) { 96 if (node != imageElement) { 97 renderRect = imageElement->renderRect(&isReplaced); 98 FloatPoint newOrigin = origin; 99 if (origin.x() < renderRect.x() || origin.x() > renderRect.maxX()) 100 newOrigin.setX(renderRect.x() + renderRect.width() / 2); 101 if (origin.y() < renderRect.y() || origin.y() > renderRect.maxY()) 102 newOrigin.setY(renderRect.y() + renderRect.height() / 2); 103 origin = newOrigin; 104 } 105 isReplaced = true; 106 } 107 } 108 109 #if PLATFORM(MAC) 110 double viewportMinimumScale = 0; 111 double viewportMaximumScale = std::numeric_limits<double>::max(); 112 #else 113 double viewportMinimumScale = m_webPage.minimumPageScaleFactor(); 114 double viewportMaximumScale = m_webPage.maximumPageScaleFactor(); 115 #endif 116 117 dispatchDidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 89 Node* node = hitTestResult.innerNode(); 90 if (!node) { 91 dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint(), FloatRect(), FloatRect(), false, 0, 0); 118 92 return; 119 93 } 120 94 121 dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint(), FloatRect(), FloatRect(), false, 0, 0); 95 bool isReplaced; 96 FloatRect renderRect; 97 double viewportMinimumScale; 98 double viewportMaximumScale; 99 100 computeZoomInformationForNode(*node, origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 101 dispatchDidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 102 } 103 104 void ViewGestureGeometryCollector::computeZoomInformationForNode(Node& node, FloatPoint& origin, FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale) 105 { 106 renderRect = node.renderRect(&isReplaced); 107 if (node.document().isImageDocument()) { 108 if (HTMLImageElement* imageElement = static_cast<ImageDocument&>(node.document()).imageElement()) { 109 if (&node != imageElement) { 110 renderRect = imageElement->renderRect(&isReplaced); 111 FloatPoint newOrigin = origin; 112 if (origin.x() < renderRect.x() || origin.x() > renderRect.maxX()) 113 newOrigin.setX(renderRect.x() + renderRect.width() / 2); 114 if (origin.y() < renderRect.y() || origin.y() > renderRect.maxY()) 115 newOrigin.setY(renderRect.y() + renderRect.height() / 2); 116 origin = newOrigin; 117 } 118 isReplaced = true; 119 } 120 } 121 #if PLATFORM(MAC) 122 viewportMinimumScale = 0; 123 viewportMaximumScale = std::numeric_limits<double>::max(); 124 #else 125 viewportMinimumScale = m_webPage.minimumPageScaleFactor(); 126 viewportMaximumScale = m_webPage.maximumPageScaleFactor(); 127 #endif 122 128 } 123 129 -
trunk/Source/WebKit2/WebProcess/WebPage/ViewGestureGeometryCollector.h
r177917 r191309 33 33 class FloatPoint; 34 34 class FloatRect; 35 class Node; 35 36 } 36 37 … … 45 46 46 47 void mainFrameDidLayout(); 48 void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale); 47 49 48 50 private: -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r191049 r191309 663 663 m_potentialTapNode = m_page->mainFrame().nodeRespondingToClickEvents(position, m_potentialTapLocation); 664 664 sendTapHighlightForNodeIfNecessary(requestID, m_potentialTapNode.get()); 665 if (m_potentialTapNode) { 666 FloatPoint origin = position; 667 FloatRect renderRect; 668 bool isReplaced; 669 double viewportMinimumScale; 670 double viewportMaximumScale; 671 672 m_viewGestureGeometryCollector.computeZoomInformationForNode(*m_potentialTapNode.get(), origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 673 send(Messages::WebPageProxy::DisableDoubleTapGesturesUntilTapIsFinishedIfNecessary(requestID, true, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale)); 674 } 665 675 } 666 676
Note: See TracChangeset
for help on using the changeset viewer.