AX: iOS: when bringing focus to a text field we may zoom the page even if author...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 May 2016 20:44:06 +0000 (20:44 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 May 2016 20:44:06 +0000 (20:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157771

Reviewed by Tim Horton.

Source/WebCore:

If the author requests scaling not to be enabled, we should not scale in when keyboard focus moves to a text field.
Scaling should only happen when the user performs a gesture to do so in this case.

Tests: fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html
       fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html

* page/ViewportConfiguration.h:
(WebCore::ViewportConfiguration::maximumScale):

Source/WebKit2:

* Shared/AssistedNodeInformation.cpp:
(WebKit::AssistedNodeInformation::encode):
(WebKit::AssistedNodeInformation::decode):
* Shared/AssistedNodeInformation.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _displayFormNodeInputView]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201294 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html [new file with mode: 0644]
LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale-expected.txt [new file with mode: 0644]
LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/ViewportConfiguration.cpp
Source/WebCore/page/ViewportConfiguration.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/AssistedNodeInformation.cpp
Source/WebKit2/Shared/AssistedNodeInformation.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

diff --git a/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale-expected.txt b/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale-expected.txt
new file mode 100644 (file)
index 0000000..5186606
--- /dev/null
@@ -0,0 +1,13 @@
+This test has to run in iOS WebKitTestRunner.
+
+
+This tests that even though force user scalable = true, we won't scale if a text field gets focus by default.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Maximum zoom scale was: 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html b/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html
new file mode 100644 (file)
index 0000000..1ad4f4a
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<meta name="viewport" content="width=device-width, maximum-scale=1">
+<script id="ui-script" type="text/plain">
+    (function() {
+       uiController.uiScriptComplete(uiController.zoomScale);
+    })();
+</script></head>
+
+<body onload="runTest();">
+<p id="result">This test has to run in iOS WebKitTestRunner.</p>
+
+<input type="text" id="textfield">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that even though force user scalable = true, we won't scale if a text field gets focus by default.");
+
+    window.internals.setViewportForceAlwaysUserScalable(true);
+    if (window.testRunner) {
+        window.jsTestIsAsync = true;
+    }
+
+    function runTest()
+    {
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            window.internals.setViewportForceAlwaysUserScalable(false);
+            document.getElementById("textfield").focus();
+            testRunner.runUIScript(document.getElementById('ui-script').text, function(result) {
+                debug("Maximum zoom scale was: " + result);
+                finishJSTest();
+            });
+        }
+    }
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale-expected.txt b/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale-expected.txt
new file mode 100644 (file)
index 0000000..cca6323
--- /dev/null
@@ -0,0 +1,13 @@
+This test has to run in iOS WebKitTestRunner.
+
+
+This tests that when the author does not define a scale or width, that zooming in on focused nodes changes the scale.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Maximum zoom scale was: 0.33
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html b/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html
new file mode 100644 (file)
index 0000000..f5a41fe
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<meta name="viewport">
+<script id="ui-script" type="text/plain">
+    (function() {
+       uiController.uiScriptComplete(uiController.zoomScale);
+    })();
+</script></head>
+
+<body onload="runTest();">
+<p id="result">This test has to run in iOS WebKitTestRunner.</p>
+
+<input type="text" id="textfield">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that when the author does not define a scale or width, that zooming in on focused nodes changes the scale.");
+
+    window.internals.setViewportForceAlwaysUserScalable(true);
+    if (window.testRunner) {
+        window.jsTestIsAsync = true;
+    }
+
+    function runTest()
+    {
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            window.internals.setViewportForceAlwaysUserScalable(false);
+            document.getElementById("textfield").focus();
+            testRunner.runUIScript(document.getElementById('ui-script').text, function(result) {
+                debug("Maximum zoom scale was: " + Number(result).toFixed(2));
+                finishJSTest();
+            });
+        }
+    }
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 71b0b31..a94eb0c 100644 (file)
@@ -1,3 +1,19 @@
+2016-05-23  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: iOS: when bringing focus to a text field we may zoom the page even if author wanted max scale = 1
+        https://bugs.webkit.org/show_bug.cgi?id=157771
+
+        Reviewed by Tim Horton.
+
+        If the author requests scaling not to be enabled, we should not scale in when keyboard focus moves to a text field.
+        Scaling should only happen when the user performs a gesture to do so in this case.
+
+        Tests: fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html
+               fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html
+
+        * page/ViewportConfiguration.h:
+        (WebCore::ViewportConfiguration::maximumScale):
+
 2016-05-23  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r200414.
index 140f23c..3a637f5 100644 (file)
@@ -209,7 +209,12 @@ double ViewportConfiguration::minimumScale() const
 
 bool ViewportConfiguration::allowsUserScaling() const
 {
-    return m_forceAlwaysUserScalable || shouldIgnoreScalingConstraints() || m_configuration.allowsUserScaling;
+    return m_forceAlwaysUserScalable || allowsUserScalingIgnoringForceAlwaysScaling();
+}
+    
+bool ViewportConfiguration::allowsUserScalingIgnoringForceAlwaysScaling() const
+{
+    return shouldIgnoreScalingConstraints() || m_configuration.allowsUserScaling;
 }
 
 ViewportConfiguration::Parameters ViewportConfiguration::webpageParameters()
index dcf6a6d..351e1a4 100644 (file)
@@ -93,6 +93,7 @@ public:
     WEBCORE_EXPORT double minimumScale() const;
     double maximumScale() const { return m_forceAlwaysUserScalable ? forceAlwaysUserScalableMaximumScale : m_configuration.maximumScale; }
     WEBCORE_EXPORT bool allowsUserScaling() const;
+    WEBCORE_EXPORT bool allowsUserScalingIgnoringForceAlwaysScaling() const;
     bool allowsShrinkToFit() const;
 
     WEBCORE_EXPORT static Parameters webpageParameters();
index 5abeaf9..5af8e62 100644 (file)
@@ -1,3 +1,19 @@
+2016-05-23  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: iOS: when bringing focus to a text field we may zoom the page even if author wanted max scale = 1
+        https://bugs.webkit.org/show_bug.cgi?id=157771
+
+        Reviewed by Tim Horton.
+
+        * Shared/AssistedNodeInformation.cpp:
+        (WebKit::AssistedNodeInformation::encode):
+        (WebKit::AssistedNodeInformation::decode):
+        * Shared/AssistedNodeInformation.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _displayFormNodeInputView]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getAssistedNodeInformation):
+
 2016-05-23  Miguel Gomez  <magomez@igalia.com>
 
         [ThreadedCompositor] Ensure that the BitmapTexture used by CoordinatedBackingStoreTile matches the opacity of the painted surface
index ba22f37..f66cbfc 100644 (file)
@@ -80,6 +80,7 @@ void AssistedNodeInformation::encode(IPC::ArgumentEncoder& encoder) const
     encoder << isMultiSelect;
     encoder << isReadOnly;
     encoder << allowsUserScaling;
+    encoder << allowsUserScalingIgnoringForceAlwaysScaling;
     encoder << insideFixedPosition;
     encoder << value;
     encoder << valueAsNumber;
@@ -139,6 +140,9 @@ bool AssistedNodeInformation::decode(IPC::ArgumentDecoder& decoder, AssistedNode
 
     if (!decoder.decode(result.allowsUserScaling))
         return false;
+    
+    if (!decoder.decode(result.allowsUserScalingIgnoringForceAlwaysScaling))
+        return false;
 
     if (!decoder.decode(result.insideFixedPosition))
         return false;
index 62b0c16..26198d1 100644 (file)
@@ -99,6 +99,7 @@ struct AssistedNodeInformation {
     bool isMultiSelect { false };
     bool isReadOnly {false };
     bool allowsUserScaling { false };
+    bool allowsUserScalingIgnoringForceAlwaysScaling { false };
     bool insideFixedPosition { false };
     WebAutocapitalizeType autocapitalizeType { WebAutocapitalizeTypeDefault };
     InputType elementType { InputType::None };
index 03ecb32..668b4a1 100644 (file)
@@ -1045,12 +1045,14 @@ static NSValue *nsSizeForTapHighlightBorderRadius(WebCore::IntSize borderRadius,
 
 - (void)_displayFormNodeInputView
 {
+    // In case user scaling is force enabled, do not use that scaling when zooming in with an input field.
+    // Zooming above the page's default scale factor should only happen when the user performs it.
     [self _zoomToFocusRect:_assistedNodeInformation.elementRect
              selectionRect: _didAccessoryTabInitiateFocus ? IntRect() : _assistedNodeInformation.selectionRect
                   fontSize:_assistedNodeInformation.nodeFontSize
               minimumScale:_assistedNodeInformation.minimumScaleFactor
               maximumScale:_assistedNodeInformation.maximumScaleFactor
-              allowScaling:(_assistedNodeInformation.allowsUserScaling && !UICurrentUserInterfaceIdiomIsPad())
+              allowScaling:(_assistedNodeInformation.allowsUserScalingIgnoringForceAlwaysScaling && !UICurrentUserInterfaceIdiomIsPad())
                forceScroll:[self requiresAccessoryView]];
     _didAccessoryTabInitiateFocus = NO;
     [self _ensureFormAccessoryView];
index 8083c9e..9e80db0 100644 (file)
@@ -2547,6 +2547,7 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
     information.minimumScaleFactor = minimumPageScaleFactor();
     information.maximumScaleFactor = maximumPageScaleFactor();
     information.allowsUserScaling = m_viewportConfiguration.allowsUserScaling();
+    information.allowsUserScalingIgnoringForceAlwaysScaling = m_viewportConfiguration.allowsUserScalingIgnoringForceAlwaysScaling();
     information.hasNextNode = hasAssistableElement(m_assistedNode.get(), *m_page, true);
     information.hasPreviousNode = hasAssistableElement(m_assistedNode.get(), *m_page, false);