Changeset 230506 in webkit
- Timestamp:
- Apr 10, 2018 6:02:53 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230504 r230506 1 2018-04-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Extra zoom mode] Add a mechanism to zoom to fixed scales when double tapping in extra zoom mode 4 https://bugs.webkit.org/show_bug.cgi?id=184435 5 <rdar://problem/38726260> 6 7 Reviewed by Dean Jackson. 8 9 Expose the size of the platform view. By default, in extra zoom mode, this *not* the same as the minimum layout 10 size, since we lay out at a large width and then shrink down to real device dimensions when computing the 11 initial scale (see r229063). 12 13 ViewGestureGeometryCollector uses this in the process of computing a target zoom scale when double tapping. 14 15 * page/ViewportConfiguration.h: 16 (WebCore::ViewportConfiguration::viewSize const): 17 1 18 2018-04-10 Fujii Hironori <Hironori.Fujii@sony.com> 2 19 -
trunk/Source/WebCore/page/ViewportConfiguration.h
r229063 r230506 75 75 WEBCORE_EXPORT bool setContentsSize(const IntSize&); 76 76 77 WEBCORE_EXPORT FloatSize viewSize() const { return m_viewSize; } 78 77 79 const FloatSize& minimumLayoutSize() const { return m_minimumLayoutSize; } 78 80 WEBCORE_EXPORT bool setMinimumLayoutSize(const FloatSize&, const FloatSize& viewSize); -
trunk/Source/WebKit/ChangeLog
r230505 r230506 1 2018-04-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Extra zoom mode] Add a mechanism to zoom to fixed scales when double tapping in extra zoom mode 4 https://bugs.webkit.org/show_bug.cgi?id=184435 5 <rdar://problem/38726260> 6 7 Reviewed by Dean Jackson. 8 9 Adds support for an alternate codepath when computing a zoom rect when double tapping that doesn't take the hit- 10 tested node into account, and instead cycles the zoom scale between 2 fixed values (in addition to the initial 11 scale). In the next patch, these fixed scales will be determined by computing zoom scales needed to make most of 12 the text on the page legible (i.e. the first text legibility zoom scale), and another to make all of the text on 13 the page legible, with the exception of outliers (this is the second text legibility zoom scale). 14 15 See comments below for more detail. 16 17 * UIProcess/Cocoa/ViewGestureController.h: 18 * UIProcess/Cocoa/ViewGestureController.messages.in: 19 * UIProcess/ios/SmartMagnificationController.h: 20 * UIProcess/ios/SmartMagnificationController.messages.in: 21 * UIProcess/ios/SmartMagnificationController.mm: 22 (WebKit::SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture): 23 * UIProcess/mac/ViewGestureControllerMac.mm: 24 (WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture): 25 * WebProcess/WebPage/ViewGestureGeometryCollector.cpp: 26 (WebKit::ViewGestureGeometryCollector::dispatchDidCollectGeometryForSmartMagnificationGesture): 27 28 Rename the boolean `isReplacedElement` argument to `fitEntireRect` instead. The UI process only uses this on iOS 29 to determine whether or not to fit the entire element rect to the viewport and add padding. This patch renames 30 this variable because we are not zooming to a replaced element in the case where text legibility on the page 31 (rather than element geometry) is being used to figure out the zoom scale, but we still want to fit the entire 32 target rect to the viewport. 33 34 (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture): 35 36 If text legiblity zoom scaling is preferred, then compute first and second-level text legibility zoom scales to 37 zoom to upon double tap (where the second zoom scale is greater than the first). To choose a target zoom 38 scale, choose the lowest target zoom scale that is at least a small amount less than the current scale. If 39 neither of the two scales fulfill this description, then zoom back out to the initial scale. This has the effect 40 of consistently cycling between all three zoom scales as the user double taps. 41 42 (WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales): 43 44 Introduce a new helper method that computes and caches target scales to zoom to when double tapping to zoom. If 45 a cached pair of target scales is already present, it skips this computation and immediately returns it. 46 47 (WebKit::ViewGestureGeometryCollector::computeZoomInformationForNode): 48 (WebKit::ViewGestureGeometryCollector::computeMinimumAndMaximumViewportScales const): 49 50 Factor out logic to compute min and max zoom scales into a separate helper, and call it from both 51 computeZoomInformationForNode and computeTextLegibilityScales. 52 53 (WebKit::ViewGestureGeometryCollector::mainFrameDidLayout): 54 55 Invalidate cached text legibility scales when layout is triggered. 56 57 * WebProcess/WebPage/ViewGestureGeometryCollector.h: 58 * WebProcess/WebPage/WebPage.cpp: 59 (WebKit::WebPage::mainFrameDidLayout): 60 * WebProcess/WebPage/WebPage.h: 61 (WebKit::WebPage::viewportConfiguration const): 62 63 Expose WebPage's ViewportConfiguration as a const reference. 64 65 * WebProcess/WebPage/ios/WebPageIOS.mm: 66 (WebKit::WebPage::platformPrefersTextLegibilityBasedZoomScaling const): 67 68 Adds a platform hook for opting into text-legibility-based zoom scaling instead of regular hit-testing-based 69 zoom scaling heuristics. 70 1 71 2018-04-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 72 -
trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.h
r226750 r230506 192 192 // Message handlers. 193 193 void didCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture); 194 void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);194 void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale); 195 195 196 196 void endMagnificationGesture(); -
trunk/Source/WebKit/UIProcess/Cocoa/ViewGestureController.messages.in
r206936 r230506 24 24 #if PLATFORM(MAC) 25 25 DidCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture) 26 DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)26 DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) 27 27 DidHitRenderTreeSizeThreshold() 28 28 #endif -
trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.h
r204668 r230506 53 53 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; 54 54 55 void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);55 void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale); 56 56 void magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale); 57 57 void adjustSmartMagnificationTargetRectAndZoomScales(bool addMagnificationPadding, WebCore::FloatRect& targetRect, double& minimumScale, double& maximumScale); -
trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.messages.in
r184149 r230506 24 24 25 25 messages -> SmartMagnificationController { 26 DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)26 DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) 27 27 Magnify(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, double viewportMinimumScale, double viewportMaximumScale) 28 28 } -
trunk/Source/WebKit/UIProcess/ios/SmartMagnificationController.mm
r226335 r230506 90 90 } 91 91 92 void SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)92 void SmartMagnificationController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) 93 93 { 94 94 if (targetRect.isEmpty()) { … … 99 99 double minimumScale = viewportMinimumScale; 100 100 double maximumScale = viewportMaximumScale; 101 adjustSmartMagnificationTargetRectAndZoomScales(! isReplacedElement, targetRect, minimumScale, maximumScale);101 adjustSmartMagnificationTargetRectAndZoomScales(!fitEntireRect, targetRect, minimumScale, maximumScale); 102 102 103 103 // FIXME: Check if text selection wants to consume the double tap before we attempt magnification. … … 116 116 // in the view, so scale it down enough to make both dimensions fit if possible. 117 117 // For other elements, try to fit them horizontally. 118 if ([m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect: isReplacedElement minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:minimumScrollDistance])118 if ([m_contentView _zoomToRect:targetRect withOrigin:origin fitEntireRect:fitEntireRect minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:minimumScrollDistance]) 119 119 return; 120 120 -
trunk/Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
r229926 r230506 208 208 } 209 209 210 void ViewGestureController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect renderRect, FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)210 void ViewGestureController::didCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect renderRect, FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) 211 211 { 212 212 double currentScaleFactor = m_webPageProxy.pageScaleFactor(); … … 236 236 // For replaced elements like images, we want to fit the whole element 237 237 // in the view, so scale it down enough to make both dimensions fit if possible. 238 if ( isReplacedElement)238 if (fitEntireRect) 239 239 targetMagnification = std::min(targetMagnification, static_cast<double>(visibleContentRect.height() / viewportConstrainedUnscaledTargetRect.height())); 240 240 -
trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp
r192332 r230506 65 65 } 66 66 67 void ViewGestureGeometryCollector::dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)68 { 69 #if PLATFORM(MAC) 70 m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForSmartMagnificationGesture(origin, targetRect, visibleContentRect, isReplacedElement, viewportMinimumScale, viewportMaximumScale));71 #endif 72 #if PLATFORM(IOS) 73 m_webPage.send(Messages::SmartMagnificationController::DidCollectGeometryForSmartMagnificationGesture(origin, targetRect, visibleContentRect, isReplacedElement, viewportMinimumScale, viewportMaximumScale));67 void ViewGestureGeometryCollector::dispatchDidCollectGeometryForSmartMagnificationGesture(FloatPoint origin, FloatRect targetRect, FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale) 68 { 69 #if PLATFORM(MAC) 70 m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForSmartMagnificationGesture(origin, targetRect, visibleContentRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale)); 71 #endif 72 #if PLATFORM(IOS) 73 m_webPage.send(Messages::SmartMagnificationController::DidCollectGeometryForSmartMagnificationGesture(origin, targetRect, visibleContentRect, fitEntireRect, viewportMinimumScale, viewportMaximumScale)); 74 74 #endif 75 75 } … … 81 81 if (m_webPage.mainWebFrame()->handlesPageScaleGesture()) 82 82 return; 83 84 double viewportMinimumScale; 85 double viewportMaximumScale; 86 87 #if PLATFORM(IOS) 88 if (m_webPage.platformPrefersTextLegibilityBasedZoomScaling()) { 89 static const double minimumScaleDifferenceForZooming = 0.05; 90 91 auto textLegibilityScales = computeTextLegibilityScales(viewportMinimumScale, viewportMaximumScale); 92 if (!textLegibilityScales) { 93 dispatchDidCollectGeometryForSmartMagnificationGesture({ }, { }, { }, false, 0, 0); 94 return; 95 } 96 97 float targetScale = m_webPage.viewportConfiguration().initialScale(); 98 float currentScale = m_webPage.pageScaleFactor(); 99 if (currentScale < textLegibilityScales->first - minimumScaleDifferenceForZooming) 100 targetScale = textLegibilityScales->first; 101 else if (currentScale < textLegibilityScales->second - minimumScaleDifferenceForZooming) 102 targetScale = textLegibilityScales->second; 103 104 FloatRect targetRectInContentCoordinates { origin, FloatSize() }; 105 targetRectInContentCoordinates.inflate(m_webPage.viewportConfiguration().viewSize() / (2 * targetScale)); 106 107 dispatchDidCollectGeometryForSmartMagnificationGesture(origin, targetRectInContentCoordinates, visibleContentRect, true, viewportMinimumScale, viewportMaximumScale); 108 return; 109 } 110 #endif // PLATFORM(IOS) 83 111 84 112 IntPoint originInContentsSpace = m_webPage.mainFrameView()->windowToContents(roundedIntPoint(origin)); … … 94 122 bool isReplaced; 95 123 FloatRect renderRect; 96 double viewportMinimumScale;97 double viewportMaximumScale;98 124 99 125 computeZoomInformationForNode(*node, origin, renderRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 100 126 dispatchDidCollectGeometryForSmartMagnificationGesture(origin, renderRect, visibleContentRect, isReplaced, viewportMinimumScale, viewportMaximumScale); 101 127 } 128 129 #if PLATFORM(IOS) 130 131 std::optional<std::pair<double, double>> ViewGestureGeometryCollector::computeTextLegibilityScales(double& viewportMinimumScale, double& viewportMaximumScale) 132 { 133 static const double defaultMaximumTextLegibilityScale = 1; 134 135 computeMinimumAndMaximumViewportScales(viewportMinimumScale, viewportMaximumScale); 136 if (m_cachedTextLegibilityScales) 137 return m_cachedTextLegibilityScales; 138 139 auto document = makeRefPtr(m_webPage.mainFrame()->document()); 140 if (!document) 141 return std::nullopt; 142 143 document->updateLayoutIgnorePendingStylesheets(); 144 145 // FIXME: Determine appropriate text legibility scales by examining text runs in the document. For now, hard code the second text legibility scale to be 1, 146 // and set the first text legibility scale to be the halfway point between the initial scale and 1. 147 double firstTextLegibilityScale = clampTo<double>((m_webPage.viewportConfiguration().initialScale() + defaultMaximumTextLegibilityScale) / 2, viewportMinimumScale, viewportMaximumScale); 148 double secondTextLegibilityScale = clampTo<double>(defaultMaximumTextLegibilityScale, viewportMinimumScale, viewportMaximumScale); 149 150 m_cachedTextLegibilityScales = std::optional<std::pair<double, double>> {{ firstTextLegibilityScale, secondTextLegibilityScale }}; 151 return m_cachedTextLegibilityScales; 152 } 153 154 #endif // PLATFORM(IOS) 102 155 103 156 void ViewGestureGeometryCollector::computeZoomInformationForNode(Node& node, FloatPoint& origin, FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale) … … 118 171 } 119 172 } 173 computeMinimumAndMaximumViewportScales(viewportMinimumScale, viewportMaximumScale); 174 } 175 176 void ViewGestureGeometryCollector::computeMinimumAndMaximumViewportScales(double& viewportMinimumScale, double& viewportMaximumScale) const 177 { 120 178 #if PLATFORM(MAC) 121 179 viewportMinimumScale = 0; … … 134 192 m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForMagnificationGesture(visibleContentRect, frameHandlesMagnificationGesture)); 135 193 } 194 #endif 136 195 137 196 void ViewGestureGeometryCollector::mainFrameDidLayout() 138 197 { 198 #if PLATFORM(IOS) 199 m_cachedTextLegibilityScales.reset(); 200 #endif 201 #if PLATFORM(MAC) 139 202 if (m_renderTreeSizeNotificationThreshold && m_webPage.renderTreeSize() >= m_renderTreeSizeNotificationThreshold) { 140 203 m_webPage.send(Messages::ViewGestureController::DidHitRenderTreeSizeThreshold()); 141 204 m_renderTreeSizeNotificationThreshold = 0; 142 205 } 143 } 144 #endif 206 #endif 207 } 145 208 146 209 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.h
r204668 r230506 61 61 #endif 62 62 63 void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);63 void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale); 64 64 void computeZoomInformationForNode(WebCore::Node&, WebCore::FloatPoint& origin, WebCore::FloatRect& renderRect, bool& isReplaced, double& viewportMinimumScale, double& viewportMaximumScale); 65 void computeMinimumAndMaximumViewportScales(double& viewportMinimumScale, double& viewportMaximumScale) const; 66 67 #if PLATFORM(IOS) 68 std::optional<std::pair<double, double>> computeTextLegibilityScales(double& viewportMinimumScale, double& viewportMaximumScale); 69 #endif 65 70 66 71 WebPage& m_webPage; … … 69 74 uint64_t m_renderTreeSizeNotificationThreshold; 70 75 #endif 76 #if PLATFORM(IOS) 77 std::optional<std::pair<double, double>> m_cachedTextLegibilityScales; 78 #endif 71 79 }; 72 80 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r230280 r230506 3821 3821 } 3822 3822 3823 #if PLATFORM( MAC)3823 #if PLATFORM(COCOA) 3824 3824 m_viewGestureGeometryCollector->mainFrameDidLayout(); 3825 3825 #endif -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r230293 r230506 892 892 void applicationDidBecomeActive(); 893 893 void completePendingSyntheticClickForContentChangeObserver(); 894 895 bool platformPrefersTextLegibilityBasedZoomScaling() const; 896 const WebCore::ViewportConfiguration& viewportConfiguration() const { return m_viewportConfiguration; } 894 897 #endif 895 898 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r230293 r230506 3472 3472 #endif 3473 3473 3474 bool WebPage::platformPrefersTextLegibilityBasedZoomScaling() const 3475 { 3476 #if ENABLE(EXTRA_ZOOM_MODE) 3477 return true; 3478 #else 3479 return false; 3480 #endif 3481 } 3482 3474 3483 #if ENABLE(MEDIA_STREAM) 3475 3484 void WebPage::prepareToSendUserMediaPermissionRequest()
Note: See TracChangeset
for help on using the changeset viewer.