Changeset 232435 in webkit
- Timestamp:
- Jun 1, 2018 11:54:12 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r232434 r232435 1 2018-06-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Extra zoom mode] The user should always be able to double tap to zoom to a scale of at least 1 4 https://bugs.webkit.org/show_bug.cgi?id=186209 5 <rdar://problem/40529255> 6 7 Reviewed by Tim Horton. 8 9 Add a test to verify that double tapping zooms in on a page where all the text is large enough to be legible at 10 initial scale. 11 12 * fast/events/extrazoom/double-tap-to-zoom-with-large-text-expected.txt: Added. 13 * fast/events/extrazoom/double-tap-to-zoom-with-large-text.html: Added. 14 1 15 2018-06-01 Ryosuke Niwa <rniwa@webkit.org> 2 16 -
trunk/Source/WebKit/ChangeLog
r232427 r232435 1 2018-06-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Extra zoom mode] The user should always be able to double tap to zoom to a scale of at least 1 4 https://bugs.webkit.org/show_bug.cgi?id=186209 5 <rdar://problem/40529255> 6 7 Reviewed by Tim Horton. 8 9 Tweaks the way double-tap-to-zoom scales are determined in extra zoom mode. Rather than zooming to make the 50th 10 and 90th percentiles of text in the document legible, only consider the 90th percentile of text size when 11 determining zoom scale, and fix the other potential zoom scale at 1; additionally, if the zoom scales are close 12 (within 0.3 of each other), snap the lower zoom scale to the higher value. 13 14 This results in the following changes in behavior: 15 - Enables double tap to zoom in cases where all the text in the page is already legible. 16 - On pages with mobile viewports, usually allows the user to toggle between initial scale and a scale of 1. 17 - If a significant portion of text is unusually small, the zoomed-in scale may exceed 1. 18 19 Test: fast/events/extrazoom/double-tap-to-zoom-with-large-text.html 20 21 * WebProcess/WebPage/ViewGestureGeometryCollector.cpp: 22 (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture): 23 (WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales): 24 1 25 2018-06-01 Jeremy Jones <jeremyj@apple.com> 2 26 -
trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp
r231097 r232435 55 55 namespace WebKit { 56 56 57 #if PLATFORM(IOS) 58 static const double minimumScaleDifferenceForZooming = 0.3; 59 #endif 60 57 61 ViewGestureGeometryCollector::ViewGestureGeometryCollector(WebPage& webPage) 58 62 : m_webPage(webPage) … … 91 95 #if PLATFORM(IOS) 92 96 if (m_webPage.platformPrefersTextLegibilityBasedZoomScaling()) { 93 static const double minimumScaleDifferenceForZooming = 0.05;94 95 97 auto textLegibilityScales = computeTextLegibilityScales(viewportMinimumScale, viewportMaximumScale); 96 98 if (!textLegibilityScales) { … … 144 146 145 147 static const double targetLegibilityFontSize = 12; 146 static const double firstTextLegibilityScaleRatio = 0.5; 147 static const double secondTextLegibilityScaleRatio = 0.1; 148 static const double minimumDifferenceBetweenTextLegibilityScales = 0.2; 149 static const double fallbackTextLegibilityScale = 1; 148 static const double textLegibilityScaleRatio = 0.1; 149 static const double defaultTextLegibilityZoomScale = 1; 150 150 151 151 computeMinimumAndMaximumViewportScales(viewportMinimumScale, viewportMaximumScale); … … 194 194 }); 195 195 196 double firstTextLegibilityScale = 0;197 double secondTextLegibilityScale = 0;196 double defaultScale = clampTo<double>(defaultTextLegibilityZoomScale, viewportMinimumScale, viewportMaximumScale); 197 double textLegibilityScale = defaultScale; 198 198 double currentSampledTextLength = 0; 199 199 for (auto& fontSizeAndCount : sortedFontSizesAndCounts) { 200 200 currentSampledTextLength += fontSizeAndCount.count; 201 201 double ratioOfTextUnderCurrentFontSize = currentSampledTextLength / totalSampledTextLength; 202 LOG(ViewGestures, "About %.2f%% of text is smaller than font size %tu", ratioOfTextUnderCurrentFontSize * 100, fontSizeAndCount.fontSize); 203 if (!firstTextLegibilityScale && ratioOfTextUnderCurrentFontSize >= firstTextLegibilityScaleRatio) 204 firstTextLegibilityScale = targetLegibilityFontSize / fontSizeAndCount.fontSize; 205 if (!secondTextLegibilityScale && ratioOfTextUnderCurrentFontSize >= secondTextLegibilityScaleRatio) 206 secondTextLegibilityScale = targetLegibilityFontSize / fontSizeAndCount.fontSize; 207 } 208 209 if (sortedFontSizesAndCounts.isEmpty()) { 210 firstTextLegibilityScale = fallbackTextLegibilityScale; 211 secondTextLegibilityScale = fallbackTextLegibilityScale; 212 } else if (secondTextLegibilityScale - firstTextLegibilityScale < minimumDifferenceBetweenTextLegibilityScales) 202 if (ratioOfTextUnderCurrentFontSize >= textLegibilityScaleRatio) { 203 textLegibilityScale = clampTo<double>(targetLegibilityFontSize / fontSizeAndCount.fontSize, viewportMinimumScale, viewportMaximumScale); 204 break; 205 } 206 } 207 208 auto firstTextLegibilityScale = std::min<double>(textLegibilityScale, defaultScale); 209 auto secondTextLegibilityScale = std::max<double>(textLegibilityScale, defaultScale); 210 if (secondTextLegibilityScale - firstTextLegibilityScale < minimumScaleDifferenceForZooming) 213 211 firstTextLegibilityScale = secondTextLegibilityScale; 214 212 215 secondTextLegibilityScale = clampTo<double>(secondTextLegibilityScale, viewportMinimumScale, viewportMaximumScale); 216 firstTextLegibilityScale = clampTo<double>(firstTextLegibilityScale, viewportMinimumScale, viewportMaximumScale); 217 218 LOG(ViewGestures, "The computed text legibility scales are: (%.2f, %.2f)", firstTextLegibilityScale, secondTextLegibilityScale); 219 220 m_cachedTextLegibilityScales = std::optional<std::pair<double, double>> {{ firstTextLegibilityScale, secondTextLegibilityScale }}; 213 m_cachedTextLegibilityScales.emplace(std::pair<double, double> { firstTextLegibilityScale, secondTextLegibilityScale }); 221 214 return m_cachedTextLegibilityScales; 222 215 }
Note: See TracChangeset
for help on using the changeset viewer.