Title: [203075] trunk
Revision
203075
Author
n_w...@apple.com
Date
2016-07-11 12:08:24 -0700 (Mon, 11 Jul 2016)

Log Message

AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
https://bugs.webkit.org/show_bug.cgi?id=158364

Reviewed by Anders Carlsson.

Source/WebCore:

Removed the internals settings for viewport force always user scalable.

Changes are covered in modified tests.

* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::Internals):
(WebCore::Internals::composedTreeAsText):
(WebCore::Internals::setLinkPreloadSupport):
(WebCore::Internals::setViewportForceAlwaysUserScalable): Deleted.
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

Added a property in WKWebViewConfiguration so that developers can toggle the ignoring
viewport scale limits setting.

Changes are covered in modified tests.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageSetResourceCachingDisabled):
(WKPageSetIgnoresViewportScaleLimits):
* UIProcess/API/C/WKPagePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(shouldAllowPictureInPictureMediaPlayback):
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _navigationGestureDidEnd]):
(forceAlwaysUserScalableChangedCallback): Deleted.
(-[WKWebView _updateForceAlwaysUserScalable]): Deleted.
* UIProcess/API/Cocoa/WKWebViewConfiguration.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration encodeWithCoder:]):
(-[WKWebViewConfiguration initWithCoder:]):
(-[WKWebViewConfiguration copyWithZone:]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):
(WebKit::WebPageProxy::setForceAlwaysUserScalable):
(WebKit::WebPageProxy::setMaximumUnobscuredSize):
(WebKit::WebPageProxy::updateForceAlwaysUserScalable): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::disableInspectorNodeSearch):
(WebKit::WebPage::setForceAlwaysUserScalable):
(WebKit::innerFrameQuad):
(WebKit::WebPage::updateForceAlwaysUserScalable): Deleted.

Tools:

Added a function in TestRunner so that we can toggle the ignoring viewport
scale limits setting. Also added a test option for that in order to change the
configuration of the webview in test.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setNavigationGesturesEnabled):
(WTR::TestRunner::setIgnoresViewportScaleLimits):
(WTR::nextUIScriptCallbackID):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::shouldDecideNavigationPolicyAfterDelay):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues):
(WTR::updateTestOptionsFromTestHeader):
(WTR::TestController::setNavigationGesturesEnabled):
(WTR::TestController::setIgnoresViewportScaleLimits):
(WTR::TestController::platformWillRunTest):
* WebKitTestRunner/TestController.h:
(WTR::TestController::setShouldDecideNavigationPolicyAfterDelay):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestOptions.h:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):

LayoutTests:

* fast/viewport/ios/force-always-user-scalable.html:
* 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203074 => 203075)


--- trunk/LayoutTests/ChangeLog	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/LayoutTests/ChangeLog	2016-07-11 19:08:24 UTC (rev 203075)
@@ -1,3 +1,14 @@
+2016-07-11  Nan Wang  <n_w...@apple.com>
+
+        AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
+        https://bugs.webkit.org/show_bug.cgi?id=158364
+
+        Reviewed by Anders Carlsson.
+
+        * fast/viewport/ios/force-always-user-scalable.html:
+        * 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:
+
 2016-07-11  Frederic Wang  <fw...@igalia.com>
 
         Use parameters from the OpenType MATH table for <munderover>

Modified: trunk/LayoutTests/fast/viewport/ios/force-always-user-scalable.html (203074 => 203075)


--- trunk/LayoutTests/fast/viewport/ios/force-always-user-scalable.html	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/LayoutTests/fast/viewport/ios/force-always-user-scalable.html	2016-07-11 19:08:24 UTC (rev 203075)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ ignoresViewportScaleLimits=true ] -->
 <html>
 <head>
 <script src=""
@@ -27,7 +27,6 @@
 <script>
     description("This tests that after we set forceAlwaysUserScalable, maximum-scale will be ignored.");
 
-    window.internals.setViewportForceAlwaysUserScalable(true);
     if (window.testRunner) {
         window.jsTestIsAsync = true;
     }
@@ -44,7 +43,7 @@
                 testRunner.runUIScript(uiScript2, function(result) {
                     debug("Maximum zoom scale was: " + result);
                     
-                    window.internals.setViewportForceAlwaysUserScalable(false);
+                    testRunner.setIgnoresViewportScaleLimits(false);
                     testRunner.runUIScript(uiScript2, function(result) {
                         debug("Maximum zoom scale was reset to: " + result);
                         finishJSTest();

Modified: trunk/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html (203074 => 203075)


--- trunk/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html	2016-07-11 19:08:24 UTC (rev 203075)
@@ -20,9 +20,9 @@
 <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;
+        testRunner.setIgnoresViewportScaleLimits(true);
     }
 
     function runTest()
@@ -29,7 +29,7 @@
     {
         if (testRunner.runUIScript) {
             var uiScript = document.getElementById('ui-script').text;
-            window.internals.setViewportForceAlwaysUserScalable(false);
+            testRunner.setIgnoresViewportScaleLimits(false);
             document.getElementById("textfield").focus();
             testRunner.runUIScript(document.getElementById('ui-script').text, function(result) {
                 debug("Maximum zoom scale was: " + result);

Modified: trunk/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html (203074 => 203075)


--- trunk/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html	2016-07-11 19:08:24 UTC (rev 203075)
@@ -20,9 +20,9 @@
 <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;
+        testRunner.setIgnoresViewportScaleLimits(true);
     }
 
     function runTest()
@@ -29,7 +29,7 @@
     {
         if (testRunner.runUIScript) {
             var uiScript = document.getElementById('ui-script').text;
-            window.internals.setViewportForceAlwaysUserScalable(false);
+            testRunner.setIgnoresViewportScaleLimits(false);
             document.getElementById("textfield").focus();
             testRunner.runUIScript(document.getElementById('ui-script').text, function(result) {
                 debug("Maximum zoom scale was: " + Number(result).toFixed(2));

Modified: trunk/Source/WebCore/ChangeLog (203074 => 203075)


--- trunk/Source/WebCore/ChangeLog	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebCore/ChangeLog	2016-07-11 19:08:24 UTC (rev 203075)
@@ -1,3 +1,23 @@
+2016-07-11  Nan Wang  <n_w...@apple.com>
+
+        AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
+        https://bugs.webkit.org/show_bug.cgi?id=158364
+
+        Reviewed by Anders Carlsson.
+
+        Removed the internals settings for viewport force always user scalable.
+
+        Changes are covered in modified tests.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::Internals::Internals):
+        (WebCore::Internals::composedTreeAsText):
+        (WebCore::Internals::setLinkPreloadSupport):
+        (WebCore::Internals::setViewportForceAlwaysUserScalable): Deleted.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2016-07-11  Frederic Wang  <fw...@igalia.com>
 
         Use parameters from the OpenType MATH table for <munderover>

Modified: trunk/Source/WebCore/testing/Internals.cpp (203074 => 203075)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -211,16 +211,6 @@
 #include "MediaPlaybackTargetContext.h"
 #endif
 
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-#if __has_include(<AccessibilitySupport.h>)
-#include <AccessibilitySupport.h>
-#else
-extern "C" {
-void _AXSSetForceAllowWebScaling(Boolean);
-}
-#endif
-#endif
-
 using JSC::CallData;
 using JSC::CallType;
 using JSC::CodeBlock;
@@ -415,10 +405,6 @@
 #endif
 
     page.setShowAllPlugins(false);
-    
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-    _AXSSetForceAllowWebScaling(false);
-#endif
 }
 
 Internals::Internals(Document& document)
@@ -3288,15 +3274,6 @@
     return WebCore::composedTreeAsText(downcast<ContainerNode>(node));
 }
 
-void Internals::setViewportForceAlwaysUserScalable(bool scalable)
-{
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-    _AXSSetForceAllowWebScaling(scalable);
-#else
-    UNUSED_PARAM(scalable);
-#endif
-}
-
 void Internals::setLinkPreloadSupport(bool enable)
 {
     RuntimeEnabledFeatures::sharedFeatures().setLinkPreloadEnabled(enable);

Modified: trunk/Source/WebCore/testing/Internals.h (203074 => 203075)


--- trunk/Source/WebCore/testing/Internals.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebCore/testing/Internals.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -469,7 +469,6 @@
 
     String composedTreeAsText(Node&);
     
-    void setViewportForceAlwaysUserScalable(bool);
     void setLinkPreloadSupport(bool);
     void setResourceTimingSupport(bool);
 

Modified: trunk/Source/WebCore/testing/Internals.idl (203074 => 203075)


--- trunk/Source/WebCore/testing/Internals.idl	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-07-11 19:08:24 UTC (rev 203075)
@@ -446,7 +446,6 @@
 
     DOMString composedTreeAsText(Node parent);
 
-    void setViewportForceAlwaysUserScalable(boolean scalable);
     void setLinkPreloadSupport(boolean scalable);
 
 #if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT

Modified: trunk/Source/WebKit2/ChangeLog (203074 => 203075)


--- trunk/Source/WebKit2/ChangeLog	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-11 19:08:24 UTC (rev 203075)
@@ -1,3 +1,54 @@
+2016-07-11  Nan Wang  <n_w...@apple.com>
+
+        AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
+        https://bugs.webkit.org/show_bug.cgi?id=158364
+
+        Reviewed by Anders Carlsson.
+
+        Added a property in WKWebViewConfiguration so that developers can toggle the ignoring
+        viewport scale limits setting.
+
+        Changes are covered in modified tests.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetResourceCachingDisabled):
+        (WKPageSetIgnoresViewportScaleLimits):
+        * UIProcess/API/C/WKPagePrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (shouldAllowPictureInPictureMediaPlayback):
+        (-[WKWebView _initializeWithConfiguration:]):
+        (-[WKWebView _navigationGestureDidEnd]):
+        (forceAlwaysUserScalableChangedCallback): Deleted.
+        (-[WKWebView _updateForceAlwaysUserScalable]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration encodeWithCoder:]):
+        (-[WKWebViewConfiguration initWithCoder:]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::setViewportConfigurationMinimumLayoutSize):
+        (WebKit::WebPageProxy::setForceAlwaysUserScalable):
+        (WebKit::WebPageProxy::setMaximumUnobscuredSize):
+        (WebKit::WebPageProxy::updateForceAlwaysUserScalable): Deleted.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::disableInspectorNodeSearch):
+        (WebKit::WebPage::setForceAlwaysUserScalable):
+        (WebKit::innerFrameQuad):
+        (WebKit::WebPage::updateForceAlwaysUserScalable): Deleted.
+
 2016-07-08  Alex Christensen  <achristen...@webkit.org>
 
         Use refs for ResourceLoaders

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (203074 => 203075)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -83,6 +83,7 @@
     encoder << screenSize;
     encoder << availableScreenSize;
     encoder << textAutosizingWidth;
+    encoder << ignoresViewportScaleLimits;
 #endif
     encoder << appleMailPaginationQuirkEnabled;
     encoder << shouldScaleViewToFitDocument;
@@ -187,6 +188,8 @@
         return false;
     if (!decoder.decode(parameters.textAutosizingWidth))
         return false;
+    if (!decoder.decode(parameters.ignoresViewportScaleLimits))
+        return false;
 #endif
 
     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (203074 => 203075)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -131,6 +131,7 @@
     WebCore::FloatSize screenSize;
     WebCore::FloatSize availableScreenSize;
     float textAutosizingWidth;
+    bool ignoresViewportScaleLimits;
 #endif
     bool appleMailPaginationQuirkEnabled;
     bool shouldScaleViewToFitDocument;

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -2744,6 +2744,13 @@
     toImpl(page)->setResourceCachingDisabled(disabled);
 }
 
+void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits)
+{
+#if PLATFORM(IOS)
+    toImpl(page)->setForceAlwaysUserScalable(ignoresViewportScaleLimits);
+#endif
+}
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 // -- DEPRECATED --

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -147,6 +147,8 @@
 
 WK_EXPORT void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef page, WKTypeRef sessionState);
 
+WK_EXPORT void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-07-11 19:08:24 UTC (rev 203075)
@@ -333,17 +333,8 @@
     return shouldAllowPictureInPictureMediaPlayback;
 }
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-static void forceAlwaysUserScalableChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
-{
-    ASSERT(observer);
-    WKWebView* webview = static_cast<WKWebView*>(observer);
-    [webview _updateForceAlwaysUserScalable];
-}
 #endif
 
-#endif
-
 #if ENABLE(DATA_DETECTION) && PLATFORM(IOS)
 static WebCore::DataDetectorTypes fromWKDataDetectorTypes(uint64_t types)
 {
@@ -533,12 +524,9 @@
     [center addObserver:self selector:@selector(_windowDidRotate:) name:UIWindowDidRotateNotification object:nil];
     [center addObserver:self selector:@selector(_contentSizeCategoryDidChange:) name:UIContentSizeCategoryDidChangeNotification object:nil];
     _page->contentSizeCategoryDidChange([self _contentSizeCategory]);
-    
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), forceAlwaysUserScalableChangedCallback, kAXSAllowForceWebScalingEnabledNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
-#endif
 
     [[_configuration _contentProviderRegistry] addPage:*_page];
+    _page->setForceAlwaysUserScalable([_configuration ignoresViewportScaleLimits]);
 #endif
 
 #if PLATFORM(MAC)
@@ -2235,11 +2223,6 @@
     _frozenUnobscuredContentRect = Nullopt;
 }
 
-- (void)_updateForceAlwaysUserScalable
-{
-    _page->updateForceAlwaysUserScalable();
-}
-
 #endif // PLATFORM(IOS)
 
 #pragma mark OS X-specific methods

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -182,6 +182,11 @@
  */
 @property (nonatomic) WKDataDetectorTypes dataDetectorTypes WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
+/*! @abstract A Boolean value indicating whether the WKWebView should always allow scaling of the web page, regardless of author intent.
+ @discussion This will override the user-scalable property.
+ */
+@property (nonatomic) BOOL ignoresViewportScaleLimits WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
 #else
 
 /*! @abstract The directionality of user interface elements.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2016-07-11 19:08:24 UTC (rev 203075)
@@ -144,6 +144,7 @@
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
     else
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
+    _ignoresViewportScaleLimits = NO;
 #else
     _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
     _mediaDataLoadsAutomatically = YES;
@@ -213,6 +214,7 @@
     [coder encodeBool:self.mediaTypesRequiringUserActionForPlayback forKey:@"mediaTypesRequiringUserActionForPlayback"];
     [coder encodeInteger:self.selectionGranularity forKey:@"selectionGranularity"];
     [coder encodeBool:self.allowsPictureInPictureMediaPlayback forKey:@"allowsPictureInPictureMediaPlayback"];
+    [coder encodeBool:self.ignoresViewportScaleLimits forKey:@"ignoresViewportScaleLimits"];
 #else
     [coder encodeInteger:self.userInterfaceDirectionPolicy forKey:@"userInterfaceDirectionPolicy"];
 #endif
@@ -239,6 +241,7 @@
     self.mediaTypesRequiringUserActionForPlayback = [coder decodeBoolForKey:@"mediaTypesRequiringUserActionForPlayback"];
     self.selectionGranularity = static_cast<WKSelectionGranularity>([coder decodeIntegerForKey:@"selectionGranularity"]);
     self.allowsPictureInPictureMediaPlayback = [coder decodeBoolForKey:@"allowsPictureInPictureMediaPlayback"];
+    self.ignoresViewportScaleLimits = [coder decodeBoolForKey:@"ignoresViewportScaleLimits"];
 #else
     auto userInterfaceDirectionPolicyCandidate = static_cast<WKUserInterfaceDirectionPolicy>([coder decodeIntegerForKey:@"userInterfaceDirectionPolicy"]);
     if (userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicyContent || userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicySystem)
@@ -289,6 +292,7 @@
     configuration->_allowsPictureInPictureMediaPlayback = self->_allowsPictureInPictureMediaPlayback;
     configuration->_alwaysRunsAtForegroundPriority = _alwaysRunsAtForegroundPriority;
     configuration->_selectionGranularity = self->_selectionGranularity;
+    configuration->_ignoresViewportScaleLimits = self->_ignoresViewportScaleLimits;
 #endif
 #if PLATFORM(MAC)
     configuration->_userInterfaceDirectionPolicy = self->_userInterfaceDirectionPolicy;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -116,8 +116,6 @@
 - (void)_navigationGestureDidBegin;
 - (void)_navigationGestureDidEnd;
 
-- (void)_updateForceAlwaysUserScalable;
-
 @property (nonatomic, readonly) BOOL _isBackground;
 
 @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -5430,6 +5430,7 @@
     parameters.availableScreenSize = availableScreenSize();
     parameters.textAutosizingWidth = textAutosizingWidth();
     parameters.mimeTypesWithCustomContentProviders = m_pageClient.mimeTypesWithCustomContentProviders();
+    parameters.ignoresViewportScaleLimits = m_forceAlwaysUserScalable;
 #endif
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -521,7 +521,7 @@
     void contentSizeCategoryDidChange(const String& contentSizeCategory);
     void getSelectionContext(std::function<void(const String&, const String&, const String&, CallbackBase::Error)>);
     void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, std::function<void(const String&, CallbackBase::Error)>);
-    void updateForceAlwaysUserScalable();
+    void setForceAlwaysUserScalable(bool);
 #endif
 #if ENABLE(DATA_DETECTION)
     void setDataDetectionResult(const DataDetectionResult&);
@@ -1855,6 +1855,7 @@
 #if PLATFORM(IOS)
     bool m_hasDeferredStartAssistingNode { false };
     std::unique_ptr<NodeAssistanceArguments> m_deferredNodeAssistanceArguments;
+    bool m_forceAlwaysUserScalable { false };
 #endif
 
 #if ENABLE(DOWNLOAD_ATTRIBUTE)

Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (203074 => 203075)


--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm	2016-07-11 19:08:24 UTC (rev 203075)
@@ -314,9 +314,12 @@
     m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
 }
 
-void WebPageProxy::updateForceAlwaysUserScalable()
+void WebPageProxy::setForceAlwaysUserScalable(bool userScalable)
 {
-    m_process->send(Messages::WebPage::UpdateForceAlwaysUserScalable(), m_pageID);
+    if (m_forceAlwaysUserScalable == userScalable)
+        return;
+    m_forceAlwaysUserScalable = userScalable;
+    m_process->send(Messages::WebPage::SetForceAlwaysUserScalable(userScalable), m_pageID);
 }
 
 void WebPageProxy::setMaximumUnobscuredSize(const WebCore::FloatSize& size)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (203074 => 203075)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -357,6 +357,7 @@
     , m_hasPendingBlurNotification(false)
     , m_useTestingViewportConfiguration(false)
     , m_isInStableState(true)
+    , m_forceAlwaysUserScalable(parameters.ignoresViewportScaleLimits)
     , m_oldestNonStableUpdateVisibleContentRectsTimestamp(std::chrono::milliseconds::zero())
     , m_estimatedLatency(std::chrono::milliseconds::zero())
     , m_screenSize(parameters.screenSize)
@@ -3196,8 +3197,7 @@
 #if PLATFORM(IOS)
     m_ignoreViewportScalingConstraints = store.getBoolValueForKey(WebPreferencesKey::ignoreViewportScalingConstraintsKey());
     m_viewportConfiguration.setCanIgnoreScalingConstraints(m_ignoreViewportScalingConstraints);
-    m_forceAlwaysUserScalable = store.getBoolValueForKey(WebPreferencesKey::forceAlwaysUserScalableKey());
-    updateForceAlwaysUserScalable();
+    setForceAlwaysUserScalable(m_forceAlwaysUserScalable || store.getBoolValueForKey(WebPreferencesKey::forceAlwaysUserScalableKey()));
 #endif
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (203074 => 203075)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -579,7 +579,7 @@
     void enableInspectorNodeSearch();
     void disableInspectorNodeSearch();
     
-    void updateForceAlwaysUserScalable();
+    void setForceAlwaysUserScalable(bool);
 #endif
 
     void setLayerTreeStateIsFrozen(bool);
@@ -1416,7 +1416,7 @@
     bool m_hasPendingBlurNotification;
     bool m_useTestingViewportConfiguration;
     bool m_isInStableState;
-    bool m_forceAlwaysUserScalable { false };
+    bool m_forceAlwaysUserScalable;
     std::chrono::milliseconds m_oldestNonStableUpdateVisibleContentRectsTimestamp;
     std::chrono::milliseconds m_estimatedLatency;
     WebCore::FloatSize m_screenSize;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (203074 => 203075)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2016-07-11 19:08:24 UTC (rev 203075)
@@ -97,7 +97,7 @@
     GetSelectionContext(uint64_t callbackID)
     SetAllowsMediaDocumentInlinePlayback(bool allows)
     HandleTwoFingerTapAtPoint(WebCore::IntPoint point, uint64_t callbackID)
-    UpdateForceAlwaysUserScalable()
+    SetForceAlwaysUserScalable(bool userScalable)
 #endif
 
     SetControlledByAutomation(bool controlled)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (203074 => 203075)


--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm	2016-07-11 19:08:24 UTC (rev 203075)
@@ -101,16 +101,6 @@
 #import <wtf/MathExtras.h>
 #import <wtf/TemporaryChange.h>
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-#if __has_include(<AccessibilitySupport.h>) 
-#include <AccessibilitySupport.h>
-#else
-extern "C" {
-Boolean _AXSForceAllowWebScaling();
-}
-#endif
-#endif
-
 using namespace WebCore;
 
 namespace WebKit {
@@ -803,13 +793,10 @@
     send(Messages::WebPageProxy::DisableInspectorNodeSearch());
 }
 
-void WebPage::updateForceAlwaysUserScalable()
+void WebPage::setForceAlwaysUserScalable(bool userScalable)
 {
-    bool forceAlwaysUserScalable = m_forceAlwaysUserScalable;
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-    forceAlwaysUserScalable |= _AXSForceAllowWebScaling();
-#endif
-    m_viewportConfiguration.setForceAlwaysUserScalable(forceAlwaysUserScalable);
+    m_forceAlwaysUserScalable = userScalable;
+    m_viewportConfiguration.setForceAlwaysUserScalable(userScalable);
 }
 
 static FloatQuad innerFrameQuad(const Frame& frame, const Node& assistedNode)

Modified: trunk/Tools/ChangeLog (203074 => 203075)


--- trunk/Tools/ChangeLog	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/ChangeLog	2016-07-11 19:08:24 UTC (rev 203075)
@@ -1,3 +1,35 @@
+2016-07-11  Nan Wang  <n_w...@apple.com>
+
+        AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
+        https://bugs.webkit.org/show_bug.cgi?id=158364
+
+        Reviewed by Anders Carlsson.
+
+        Added a function in TestRunner so that we can toggle the ignoring viewport
+        scale limits setting. Also added a test option for that in order to change the 
+        configuration of the webview in test.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setNavigationGesturesEnabled):
+        (WTR::TestRunner::setIgnoresViewportScaleLimits):
+        (WTR::nextUIScriptCallbackID):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::shouldDecideNavigationPolicyAfterDelay):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::updateTestOptionsFromTestHeader):
+        (WTR::TestController::setNavigationGesturesEnabled):
+        (WTR::TestController::setIgnoresViewportScaleLimits):
+        (WTR::TestController::platformWillRunTest):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::setShouldDecideNavigationPolicyAfterDelay):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        * WebKitTestRunner/TestOptions.h:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView):
+
 2016-07-11  Konstantin Tokarev  <annu...@yandex.ru>
 
         [GTK] install-dependencies should not install packages built by jhbuild.

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2016-07-11 19:08:24 UTC (rev 203075)
@@ -79,6 +79,7 @@
     void setPrinting();
     void setShouldDecideNavigationPolicyAfterDelay(boolean value);
     void setNavigationGesturesEnabled(boolean value);
+    void setIgnoresViewportScaleLimits(boolean value);
 
     // Special DOM functions.
     void clearBackForwardList();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -987,6 +987,13 @@
     WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
 }
 
+void TestRunner::setIgnoresViewportScaleLimits(bool value)
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetIgnoresViewportScaleLimits"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value));
+    WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get());
+}
+
 static unsigned nextUIScriptCallbackID()
 {
     static unsigned callbackID = FirstUIScriptCallbackID;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -308,6 +308,7 @@
     bool shouldDecideNavigationPolicyAfterDelay() const { return m_shouldDecideNavigationPolicyAfterDelay; }
     void setShouldDecideNavigationPolicyAfterDelay(bool);
     void setNavigationGesturesEnabled(bool);
+    void setIgnoresViewportScaleLimits(bool);
 
     void runUIScript(JSStringRef script, JSValueRef callback);
     void runUIScriptCallback(unsigned callbackID, JSStringRef result);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -784,6 +784,8 @@
     m_shouldDecideNavigationPolicyAfterDelay = false;
 
     setNavigationGesturesEnabled(false);
+    
+    setIgnoresViewportScaleLimits(options.ignoresViewportScaleLimits);
 
     WKPageLoadURL(m_mainWebView->page(), blankURL());
     runUntil(m_doneResetting, shortTimeout);
@@ -937,6 +939,8 @@
             testOptions.useMockScrollbars = parseBooleanTestHeaderValue(value);
         if (key == "needsSiteSpecificQuirks")
             testOptions.needsSiteSpecificQuirks = parseBooleanTestHeaderValue(value);
+        if (key == "ignoresViewportScaleLimits")
+            testOptions.ignoresViewportScaleLimits = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }
@@ -2124,6 +2128,11 @@
     m_mainWebView->setNavigationGesturesEnabled(value);
 }
 
+void TestController::setIgnoresViewportScaleLimits(bool ignoresViewportScaleLimits)
+{
+    WKPageSetIgnoresViewportScaleLimits(m_mainWebView->page(), ignoresViewportScaleLimits);
+}
+
 #if !PLATFORM(COCOA)
 void TestController::platformWillRunTest(const TestInvocation&)
 {

Modified: trunk/Tools/WebKitTestRunner/TestController.h (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/TestController.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -139,6 +139,7 @@
     void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
 
     void setNavigationGesturesEnabled(bool value);
+    void setIgnoresViewportScaleLimits(bool);
 
 private:
     WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2016-07-11 19:08:24 UTC (rev 203075)
@@ -647,6 +647,13 @@
         TestController::singleton().setNavigationGesturesEnabled(WKBooleanGetValue(value));
         return;
     }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "SetIgnoresViewportScaleLimits")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef value = static_cast<WKBooleanRef>(messageBody);
+        TestController::singleton().setIgnoresViewportScaleLimits(WKBooleanGetValue(value));
+        return;
+    }
 
     if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) {
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2016-07-11 19:08:24 UTC (rev 203075)
@@ -41,6 +41,7 @@
     bool useDataDetection { false };
     bool useMockScrollbars { true };
     bool needsSiteSpecificQuirks { false };
+    bool ignoresViewportScaleLimits { false };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (203074 => 203075)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2016-07-11 18:46:10 UTC (rev 203074)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2016-07-11 19:08:24 UTC (rev 203075)
@@ -86,6 +86,8 @@
 #if TARGET_OS_IPHONE
     if (options.useDataDetection)
         [copiedConfiguration setDataDetectorTypes:WKDataDetectorTypeAll];
+    if (options.ignoresViewportScaleLimits)
+        [copiedConfiguration setIgnoresViewportScaleLimits:YES];
 #endif
 
     m_mainWebView = std::make_unique<PlatformWebView>(copiedConfiguration.get(), options);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to