Modified: trunk/LayoutTests/ChangeLog (232434 => 232435)
--- trunk/LayoutTests/ChangeLog 2018-06-02 04:09:30 UTC (rev 232434)
+++ trunk/LayoutTests/ChangeLog 2018-06-02 06:54:12 UTC (rev 232435)
@@ -1,3 +1,17 @@
+2018-06-01 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Extra zoom mode] The user should always be able to double tap to zoom to a scale of at least 1
+ https://bugs.webkit.org/show_bug.cgi?id=186209
+ <rdar://problem/40529255>
+
+ Reviewed by Tim Horton.
+
+ Add a test to verify that double tapping zooms in on a page where all the text is large enough to be legible at
+ initial scale.
+
+ * fast/events/extrazoom/double-tap-to-zoom-with-large-text-expected.txt: Added.
+ * fast/events/extrazoom/double-tap-to-zoom-with-large-text.html: Added.
+
2018-06-01 Ryosuke Niwa <rn...@webkit.org>
Editor can hold references to Documents after you navigate away
Added: trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text-expected.txt (0 => 232435)
--- trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text-expected.txt 2018-06-02 06:54:12 UTC (rev 232435)
@@ -0,0 +1,4 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Even though this text is large enough to be legible at initial scale, we should still allow double tapping to zoom for consistent behavior.
Added: trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text.html (0 => 232435)
--- trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text.html (rev 0)
+++ trunk/LayoutTests/fast/events/extrazoom/double-tap-to-zoom-with-large-text.html 2018-06-02 06:54:12 UTC (rev 232435)
@@ -0,0 +1,17 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<script src=""
+<script src=""
+<meta name="viewport" content="width=device-width">
+<body style="margin: 0;">
+ <div style="background-color: red; width: 150px; height: 150px;"></div>
+ <h1 style="font-size: 2em;">
+ Even though this text is large enough to be legible at initial scale, we should
+ still allow double tapping to zoom for consistent behavior.
+ </h1>
+</body>
+<script>
+ jsTestIsAsync = true;
+ doubleTapToZoomAtPoint(75, 75).then(finishJSTest);
+</script>
+</html>
Modified: trunk/Source/WebKit/ChangeLog (232434 => 232435)
--- trunk/Source/WebKit/ChangeLog 2018-06-02 04:09:30 UTC (rev 232434)
+++ trunk/Source/WebKit/ChangeLog 2018-06-02 06:54:12 UTC (rev 232435)
@@ -1,3 +1,27 @@
+2018-06-01 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Extra zoom mode] The user should always be able to double tap to zoom to a scale of at least 1
+ https://bugs.webkit.org/show_bug.cgi?id=186209
+ <rdar://problem/40529255>
+
+ Reviewed by Tim Horton.
+
+ Tweaks the way double-tap-to-zoom scales are determined in extra zoom mode. Rather than zooming to make the 50th
+ and 90th percentiles of text in the document legible, only consider the 90th percentile of text size when
+ determining zoom scale, and fix the other potential zoom scale at 1; additionally, if the zoom scales are close
+ (within 0.3 of each other), snap the lower zoom scale to the higher value.
+
+ This results in the following changes in behavior:
+ - Enables double tap to zoom in cases where all the text in the page is already legible.
+ - On pages with mobile viewports, usually allows the user to toggle between initial scale and a scale of 1.
+ - If a significant portion of text is unusually small, the zoomed-in scale may exceed 1.
+
+ Test: fast/events/extrazoom/double-tap-to-zoom-with-large-text.html
+
+ * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
+ (WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
+ (WebKit::ViewGestureGeometryCollector::computeTextLegibilityScales):
+
2018-06-01 Jeremy Jones <jere...@apple.com>
Keyboard focus should exit fullscreen.
Modified: trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp (232434 => 232435)
--- trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp 2018-06-02 04:09:30 UTC (rev 232434)
+++ trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp 2018-06-02 06:54:12 UTC (rev 232435)
@@ -54,6 +54,10 @@
namespace WebKit {
+#if PLATFORM(IOS)
+static const double minimumScaleDifferenceForZooming = 0.3;
+#endif
+
ViewGestureGeometryCollector::ViewGestureGeometryCollector(WebPage& webPage)
: m_webPage(webPage)
#if PLATFORM(MAC)
@@ -90,8 +94,6 @@
#if PLATFORM(IOS)
if (m_webPage.platformPrefersTextLegibilityBasedZoomScaling()) {
- static const double minimumScaleDifferenceForZooming = 0.05;
-
auto textLegibilityScales = computeTextLegibilityScales(viewportMinimumScale, viewportMaximumScale);
if (!textLegibilityScales) {
dispatchDidCollectGeometryForSmartMagnificationGesture({ }, { }, { }, false, 0, 0);
@@ -143,10 +145,8 @@
static const double maximumNumberOfTextRunsToConsider = 200;
static const double targetLegibilityFontSize = 12;
- static const double firstTextLegibilityScaleRatio = 0.5;
- static const double secondTextLegibilityScaleRatio = 0.1;
- static const double minimumDifferenceBetweenTextLegibilityScales = 0.2;
- static const double fallbackTextLegibilityScale = 1;
+ static const double textLegibilityScaleRatio = 0.1;
+ static const double defaultTextLegibilityZoomScale = 1;
computeMinimumAndMaximumViewportScales(viewportMinimumScale, viewportMaximumScale);
if (m_cachedTextLegibilityScales)
@@ -193,31 +193,24 @@
return first.fontSize < second.fontSize;
});
- double firstTextLegibilityScale = 0;
- double secondTextLegibilityScale = 0;
+ double defaultScale = clampTo<double>(defaultTextLegibilityZoomScale, viewportMinimumScale, viewportMaximumScale);
+ double textLegibilityScale = defaultScale;
double currentSampledTextLength = 0;
for (auto& fontSizeAndCount : sortedFontSizesAndCounts) {
currentSampledTextLength += fontSizeAndCount.count;
double ratioOfTextUnderCurrentFontSize = currentSampledTextLength / totalSampledTextLength;
- LOG(ViewGestures, "About %.2f%% of text is smaller than font size %tu", ratioOfTextUnderCurrentFontSize * 100, fontSizeAndCount.fontSize);
- if (!firstTextLegibilityScale && ratioOfTextUnderCurrentFontSize >= firstTextLegibilityScaleRatio)
- firstTextLegibilityScale = targetLegibilityFontSize / fontSizeAndCount.fontSize;
- if (!secondTextLegibilityScale && ratioOfTextUnderCurrentFontSize >= secondTextLegibilityScaleRatio)
- secondTextLegibilityScale = targetLegibilityFontSize / fontSizeAndCount.fontSize;
+ if (ratioOfTextUnderCurrentFontSize >= textLegibilityScaleRatio) {
+ textLegibilityScale = clampTo<double>(targetLegibilityFontSize / fontSizeAndCount.fontSize, viewportMinimumScale, viewportMaximumScale);
+ break;
+ }
}
- if (sortedFontSizesAndCounts.isEmpty()) {
- firstTextLegibilityScale = fallbackTextLegibilityScale;
- secondTextLegibilityScale = fallbackTextLegibilityScale;
- } else if (secondTextLegibilityScale - firstTextLegibilityScale < minimumDifferenceBetweenTextLegibilityScales)
+ auto firstTextLegibilityScale = std::min<double>(textLegibilityScale, defaultScale);
+ auto secondTextLegibilityScale = std::max<double>(textLegibilityScale, defaultScale);
+ if (secondTextLegibilityScale - firstTextLegibilityScale < minimumScaleDifferenceForZooming)
firstTextLegibilityScale = secondTextLegibilityScale;
- secondTextLegibilityScale = clampTo<double>(secondTextLegibilityScale, viewportMinimumScale, viewportMaximumScale);
- firstTextLegibilityScale = clampTo<double>(firstTextLegibilityScale, viewportMinimumScale, viewportMaximumScale);
-
- LOG(ViewGestures, "The computed text legibility scales are: (%.2f, %.2f)", firstTextLegibilityScale, secondTextLegibilityScale);
-
- m_cachedTextLegibilityScales = std::optional<std::pair<double, double>> {{ firstTextLegibilityScale, secondTextLegibilityScale }};
+ m_cachedTextLegibilityScales.emplace(std::pair<double, double> { firstTextLegibilityScale, secondTextLegibilityScale });
return m_cachedTextLegibilityScales;
}