Changeset 232435 in webkit


Ignore:
Timestamp:
Jun 1, 2018 11:54:12 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[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.

Source/WebKit:

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):

LayoutTests:

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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232434 r232435  
     12018-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
    1152018-06-01  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebKit/ChangeLog

    r232427 r232435  
     12018-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
    1252018-06-01  Jeremy Jones  <jeremyj@apple.com>
    226
  • trunk/Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp

    r231097 r232435  
    5555namespace WebKit {
    5656
     57#if PLATFORM(IOS)
     58static const double minimumScaleDifferenceForZooming = 0.3;
     59#endif
     60
    5761ViewGestureGeometryCollector::ViewGestureGeometryCollector(WebPage& webPage)
    5862    : m_webPage(webPage)
     
    9195#if PLATFORM(IOS)
    9296    if (m_webPage.platformPrefersTextLegibilityBasedZoomScaling()) {
    93         static const double minimumScaleDifferenceForZooming = 0.05;
    94 
    9597        auto textLegibilityScales = computeTextLegibilityScales(viewportMinimumScale, viewportMaximumScale);
    9698        if (!textLegibilityScales) {
     
    144146
    145147    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;
    150150
    151151    computeMinimumAndMaximumViewportScales(viewportMinimumScale, viewportMaximumScale);
     
    194194    });
    195195
    196     double firstTextLegibilityScale = 0;
    197     double secondTextLegibilityScale = 0;
     196    double defaultScale = clampTo<double>(defaultTextLegibilityZoomScale, viewportMinimumScale, viewportMaximumScale);
     197    double textLegibilityScale = defaultScale;
    198198    double currentSampledTextLength = 0;
    199199    for (auto& fontSizeAndCount : sortedFontSizesAndCounts) {
    200200        currentSampledTextLength += fontSizeAndCount.count;
    201201        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)
    213211        firstTextLegibilityScale = secondTextLegibilityScale;
    214212
    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 });
    221214    return m_cachedTextLegibilityScales;
    222215}
Note: See TracChangeset for help on using the changeset viewer.