Title: [140432] branches/chromium/1364/Source/WebKit/chromium
Revision
140432
Author
[email protected]
Date
2013-01-22 09:24:01 -0800 (Tue, 22 Jan 2013)

Log Message

Merge 140035
As approved in http://crbug.com/167028
> [chromium] Double-tap zoom should take into account accessibility fontScaleFactor
> https://bugs.webkit.org/show_bug.cgi?id=107123
> 
> Patch by John Mellor <[email protected]> on 2013-01-17
> Reviewed by Adam Barth.
> 
> Platforms which support Text Autosizing (currently just Chrome for
> Android) may provide a textAutosizingFontScaleFactor (defaults to 1.0).
> 
> This value is intended to be chosen by the user to indicate how large
> they want text to appear, for example Chrome for Android has a "Text
> scaling" slider in Settings > Accessibility that lets you choose a value
> in the range 50% - 200% (defaults to 100%*).
> 
> For text in wide columns that typically gets autosized, this value is
> applied by multiplying the textAutosizingMultiplier computed for each
> cluster by the textAutosizingFontScaleFactor. Double-tap zoom will fit
> the column to the screen (ignoring the textAutosizingFontScaleFactor)
> since the column is wide. This part already works.
> 
> For text in narrow columns that doesn't get autosized, the
> textAutosizingFontScaleFactor is not applied through Text Autosizing,
> and instead needs to be applied by adjusting the double-tap zoom level.
> When double-tapping on narrow columns, instead of fitting the column to
> the screen (which would often zoom in excessively far), the existing
> logic in computeScaleAndScrollForHitRect applies a maximum zoom level
> called the legibleScale. This value needs to be multiplied by the
> textAutosizingFontScaleFactor, so that we zoom in proportionately
> further on non-autosized narrow columns, hence the effective text size
> (taking into account zoom) will have increased in proportion to the
> textAutosizingFontScaleFactor as expected.
> 
> * src/WebViewImpl.cpp:
> (WebKit::WebViewImpl::computeScaleAndScrollForHitRect):
>     Multiplies legibleScale (the maximum zoom level) by the
>     textAutosizingFontScaleFactor.
> * tests/WebFrameTest.cpp:
>     Added WebFrameTest.DivAutoZoomScaleFontScaleFactorTest based on
>     WebFrameTest.DivAutoZoomScaleBoundsTest to test the interaction
>     between textAutosizingFontScaleFactor and the double-tap zoom logic.
>     Also did minor cleanup to WebFrameTest.DivAutoZoomScaleBoundsTest.

[email protected]
Review URL: https://codereview.chromium.org/12045023

Modified Paths

Diff

Modified: branches/chromium/1364/Source/WebKit/chromium/src/WebViewImpl.cpp (140431 => 140432)


--- branches/chromium/1364/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-22 17:17:13 UTC (rev 140431)
+++ branches/chromium/1364/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-01-22 17:24:01 UTC (rev 140432)
@@ -1128,6 +1128,10 @@
         // be allowed to manually pinch zoom in further if they desire.
         const float defaultScaleWhenAlreadyLegible = m_minimumPageScaleFactor * doubleTapZoomAlreadyLegibleRatio;
         float legibleScale = deviceScaleFactor();
+#if ENABLE(TEXT_AUTOSIZING)
+        if (page() && page()->settings())
+            legibleScale *= page()->settings()->textAutosizingFontScaleFactor();
+#endif
         if (legibleScale < defaultScaleWhenAlreadyLegible)
             legibleScale = (scale == m_minimumPageScaleFactor) ? defaultScaleWhenAlreadyLegible : m_minimumPageScaleFactor;
 

Modified: branches/chromium/1364/Source/WebKit/chromium/tests/WebFrameTest.cpp (140431 => 140432)


--- branches/chromium/1364/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-22 17:17:13 UTC (rev 140431)
+++ branches/chromium/1364/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-01-22 17:24:01 UTC (rev 140432)
@@ -38,6 +38,7 @@
 #include "FrameView.h"
 #include "Range.h"
 #include "ResourceError.h"
+#include "Settings.h"
 #include "URLTestHelpers.h"
 #include "WebDataSource.h"
 #include "WebDocument.h"
@@ -451,7 +452,6 @@
     webView->resize(WebSize(viewportWidth, viewportHeight));
     webView->setPageScaleFactorLimits(1, 4);
     webView->layout();
-    webView->setDeviceScaleFactor(1.5f);
 
     WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
     webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
@@ -463,6 +463,7 @@
 
     // Test double tap scale bounds.
     // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
+    webViewImpl->setDeviceScaleFactor(1.5f);
     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
     EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
@@ -485,7 +486,7 @@
 
     // Zoom in to reset double_tap_zoom_in_effect flag.
     webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
-    // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
+    // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale
     webViewImpl->setDeviceScaleFactor(1.1f);
     setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
     simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
@@ -496,6 +497,83 @@
     EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
 }
 
+#if ENABLE(TEXT_AUTOSIZING)
+TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest)
+{
+    registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
+
+    int viewportWidth = 640;
+    int viewportHeight = 480;
+    float doubleTapZoomAlreadyLegibleRatio = 1.2f;
+    float textAutosizingFontScaleFactor = 1.13f;
+    WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html");
+    webView->enableFixedLayoutMode(true);
+    webView->resize(WebSize(viewportWidth, viewportHeight));
+    webView->setPageScaleFactorLimits(1, 4);
+    webView->layout();
+
+    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+    webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
+    webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosizingFontScaleFactor);
+    float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
+
+    WebRect div(200, 100, 200, 150);
+    WebPoint doubleTapPoint(div.x + 50, div.y + 50);
+    float scale;
+
+    // Test double tap scale bounds.
+    // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor
+    webViewImpl->setDeviceScaleFactor(1.5f);
+    float legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
+    setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(legibleScale, scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(legibleScale, scale);
+
+    // Zoom in to reset double_tap_zoom_in_effect flag.
+    webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
+    // deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < minimumPageScale < doubleTapZoomAlreadyLegibleScale
+    webViewImpl->setDeviceScaleFactor(0.5f);
+    legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
+    setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+
+    // Zoom in to reset double_tap_zoom_in_effect flag.
+    webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
+    // minimumPageScale < deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < doubleTapZoomAlreadyLegibleScale
+    webViewImpl->setDeviceScaleFactor(1.05f);
+    legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
+    setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+
+    // Zoom in to reset double_tap_zoom_in_effect flag.
+    webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
+    // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale * textAutosizingFontScaleFactor
+    webViewImpl->setDeviceScaleFactor(1.1f);
+    legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFactor;
+    setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(legibleScale, scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+    simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+    EXPECT_FLOAT_EQ(legibleScale, scale);
+}
+#endif
+
 // This test depends on code that is compiled conditionally. We likely need to
 // add the proper ifdef when re-enabling it. See
 // https://bugs.webkit.org/show_bug.cgi?id=98558
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to