AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 19:08:24 +0000 (19:08 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 19:08:24 +0000 (19:08 +0000)
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:

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

33 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/viewport/ios/force-always-user-scalable.html
LayoutTests/fast/viewport/ios/user-scalable-does-not-scale-for-keyboard-focus-with-author-defined-scale.html
LayoutTests/fast/viewport/ios/user-scalable-scales-for-keyboard-focus-with-no-author-defined-scale.html
Source/WebCore/ChangeLog
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestOptions.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 2182bc8..476ec4f 100644 (file)
@@ -1,3 +1,14 @@
+2016-07-11  Nan Wang  <n_wang@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  <fwang@igalia.com>
 
         Use parameters from the OpenType MATH table for <munderover>
index 5f353c0..b6cb1da 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ ignoresViewportScaleLimits=true ] -->
 <html>
 <head>
 <script src="../../../resources/js-test-pre.js"></script>
@@ -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();
index 1ad4f4a..2ea68f1 100644 (file)
 <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()
     {
         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);
index f5a41fe..144630e 100644 (file)
 <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()
     {
         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));
index e677319..582a183 100644 (file)
@@ -1,3 +1,23 @@
+2016-07-11  Nan Wang  <n_wang@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  <fwang@igalia.com>
 
         Use parameters from the OpenType MATH table for <munderover>
index 978c073..f32f678 100644 (file)
 #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 @@ void Internals::resetToConsistentState(Page& page)
 #endif
 
     page.setShowAllPlugins(false);
-    
-#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
-    _AXSSetForceAllowWebScaling(false);
-#endif
 }
 
 Internals::Internals(Document& document)
@@ -3288,15 +3274,6 @@ String Internals::composedTreeAsText(Node& node)
     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);
index 1f7e8bf..6d69aac 100644 (file)
@@ -469,7 +469,6 @@ public:
 
     String composedTreeAsText(Node&);
     
-    void setViewportForceAlwaysUserScalable(bool);
     void setLinkPreloadSupport(bool);
     void setResourceTimingSupport(bool);
 
index 1a67759..bc3435e 100644 (file)
@@ -446,7 +446,6 @@ enum UserInterfaceLayoutDirection {
 
     DOMString composedTreeAsText(Node parent);
 
-    void setViewportForceAlwaysUserScalable(boolean scalable);
     void setLinkPreloadSupport(boolean scalable);
 
 #if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
index 74b1015..f107563 100644 (file)
@@ -1,3 +1,54 @@
+2016-07-11  Nan Wang  <n_wang@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  <achristensen@webkit.org>
 
         Use refs for ResourceLoaders
index 097da02..17f5641 100644 (file)
@@ -83,6 +83,7 @@ void WebPageCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder << screenSize;
     encoder << availableScreenSize;
     encoder << textAutosizingWidth;
+    encoder << ignoresViewportScaleLimits;
 #endif
     encoder << appleMailPaginationQuirkEnabled;
     encoder << shouldScaleViewToFitDocument;
@@ -187,6 +188,8 @@ bool WebPageCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebPageCre
         return false;
     if (!decoder.decode(parameters.textAutosizingWidth))
         return false;
+    if (!decoder.decode(parameters.ignoresViewportScaleLimits))
+        return false;
 #endif
 
     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
index 9b910d3..d336da8 100644 (file)
@@ -131,6 +131,7 @@ struct WebPageCreationParameters {
     WebCore::FloatSize screenSize;
     WebCore::FloatSize availableScreenSize;
     float textAutosizingWidth;
+    bool ignoresViewportScaleLimits;
 #endif
     bool appleMailPaginationQuirkEnabled;
     bool shouldScaleViewToFitDocument;
index 401a106..4b6e554 100644 (file)
@@ -2744,6 +2744,13 @@ void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled)
     toImpl(page)->setResourceCachingDisabled(disabled);
 }
 
+void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits)
+{
+#if PLATFORM(IOS)
+    toImpl(page)->setForceAlwaysUserScalable(ignoresViewportScaleLimits);
+#endif
+}
+
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
 // -- DEPRECATED --
index bd4d1ca..1a838ca 100644 (file)
@@ -147,6 +147,8 @@ WK_EXPORT void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled);
 
 WK_EXPORT void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef page, WKTypeRef sessionState);
 
+WK_EXPORT void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits);
+
 #ifdef __cplusplus
 }
 #endif
index 32307c9..1d90450 100644 (file)
@@ -333,15 +333,6 @@ static bool shouldAllowPictureInPictureMediaPlayback()
     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)
@@ -533,12 +524,9 @@ static uint32_t convertSystemLayoutDirection(NSUserInterfaceLayoutDirection dire
     [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 @@ static bool scrollViewCanScroll(UIScrollView *scrollView)
     _frozenUnobscuredContentRect = Nullopt;
 }
 
-- (void)_updateForceAlwaysUserScalable
-{
-    _page->updateForceAlwaysUserScalable();
-}
-
 #endif // PLATFORM(IOS)
 
 #pragma mark OS X-specific methods
index a66941e..8105a8d 100644 (file)
@@ -182,6 +182,11 @@ WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
  */
 @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.
index aa51ad0..5545375 100644 (file)
@@ -144,6 +144,7 @@ private:
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
     else
         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
+    _ignoresViewportScaleLimits = NO;
 #else
     _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
     _mediaDataLoadsAutomatically = YES;
@@ -213,6 +214,7 @@ private:
     [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 @@ private:
     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 @@ private:
     configuration->_allowsPictureInPictureMediaPlayback = self->_allowsPictureInPictureMediaPlayback;
     configuration->_alwaysRunsAtForegroundPriority = _alwaysRunsAtForegroundPriority;
     configuration->_selectionGranularity = self->_selectionGranularity;
+    configuration->_ignoresViewportScaleLimits = self->_ignoresViewportScaleLimits;
 #endif
 #if PLATFORM(MAC)
     configuration->_userInterfaceDirectionPolicy = self->_userInterfaceDirectionPolicy;
index bc6af7d..6e414af 100644 (file)
@@ -116,8 +116,6 @@ struct PrintInfo;
 - (void)_navigationGestureDidBegin;
 - (void)_navigationGestureDidEnd;
 
-- (void)_updateForceAlwaysUserScalable;
-
 @property (nonatomic, readonly) BOOL _isBackground;
 
 @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
index aa8115b..cbb4e2d 100644 (file)
@@ -5430,6 +5430,7 @@ WebPageCreationParameters WebPageProxy::creationParameters()
     parameters.availableScreenSize = availableScreenSize();
     parameters.textAutosizingWidth = textAutosizingWidth();
     parameters.mimeTypesWithCustomContentProviders = m_pageClient.mimeTypesWithCustomContentProviders();
+    parameters.ignoresViewportScaleLimits = m_forceAlwaysUserScalable;
 #endif
 
 #if PLATFORM(MAC)
index d306ec8..0b0669e 100644 (file)
@@ -521,7 +521,7 @@ public:
     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 @@ private:
 #if PLATFORM(IOS)
     bool m_hasDeferredStartAssistingNode { false };
     std::unique_ptr<NodeAssistanceArguments> m_deferredNodeAssistanceArguments;
+    bool m_forceAlwaysUserScalable { false };
 #endif
 
 #if ENABLE(DOWNLOAD_ATTRIBUTE)
index 4a66bff..8dd57b7 100644 (file)
@@ -314,9 +314,12 @@ void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::Floa
     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)
index 414d3d8..78b97f5 100644 (file)
@@ -357,6 +357,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , 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 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 #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
 }
 
index ae51cfe..cae6bf7 100644 (file)
@@ -579,7 +579,7 @@ public:
     void enableInspectorNodeSearch();
     void disableInspectorNodeSearch();
     
-    void updateForceAlwaysUserScalable();
+    void setForceAlwaysUserScalable(bool);
 #endif
 
     void setLayerTreeStateIsFrozen(bool);
@@ -1416,7 +1416,7 @@ private:
     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;
index be546c1..751231d 100644 (file)
@@ -97,7 +97,7 @@ messages -> WebPage LegacyReceiver {
     GetSelectionContext(uint64_t callbackID)
     SetAllowsMediaDocumentInlinePlayback(bool allows)
     HandleTwoFingerTapAtPoint(WebCore::IntPoint point, uint64_t callbackID)
-    UpdateForceAlwaysUserScalable()
+    SetForceAlwaysUserScalable(bool userScalable)
 #endif
 
     SetControlledByAutomation(bool controlled)
index 41687a1..48ca470 100644 (file)
 #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 @@ void WebPage::disableInspectorNodeSearch()
     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)
index 6948d78..3a44083 100644 (file)
@@ -1,3 +1,35 @@
+2016-07-11  Nan Wang  <n_wang@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  <annulen@yandex.ru>
 
         [GTK] install-dependencies should not install packages built by jhbuild.
index cb59c7e..5a59cd5 100644 (file)
@@ -79,6 +79,7 @@ interface TestRunner {
     void setPrinting();
     void setShouldDecideNavigationPolicyAfterDelay(boolean value);
     void setNavigationGesturesEnabled(boolean value);
+    void setIgnoresViewportScaleLimits(boolean value);
 
     // Special DOM functions.
     void clearBackForwardList();
index c5ede37..25d679c 100644 (file)
@@ -987,6 +987,13 @@ void TestRunner::setNavigationGesturesEnabled(bool value)
     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;
index d4add18..cc4f953 100644 (file)
@@ -308,6 +308,7 @@ public:
     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);
index b4dbe0e..1cc2d08 100644 (file)
@@ -784,6 +784,8 @@ bool TestController::resetStateToConsistentValues(const TestOptions& options)
     m_shouldDecideNavigationPolicyAfterDelay = false;
 
     setNavigationGesturesEnabled(false);
+    
+    setIgnoresViewportScaleLimits(options.ignoresViewportScaleLimits);
 
     WKPageLoadURL(m_mainWebView->page(), blankURL());
     runUntil(m_doneResetting, shortTimeout);
@@ -937,6 +939,8 @@ static void updateTestOptionsFromTestHeader(TestOptions& testOptions, const std:
             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 @@ void TestController::setNavigationGesturesEnabled(bool value)
     m_mainWebView->setNavigationGesturesEnabled(value);
 }
 
+void TestController::setIgnoresViewportScaleLimits(bool ignoresViewportScaleLimits)
+{
+    WKPageSetIgnoresViewportScaleLimits(m_mainWebView->page(), ignoresViewportScaleLimits);
+}
+
 #if !PLATFORM(COCOA)
 void TestController::platformWillRunTest(const TestInvocation&)
 {
index ed95282..d6e366e 100644 (file)
@@ -139,6 +139,7 @@ public:
     void setShouldDecideNavigationPolicyAfterDelay(bool value) { m_shouldDecideNavigationPolicyAfterDelay = value; }
 
     void setNavigationGesturesEnabled(bool value);
+    void setIgnoresViewportScaleLimits(bool);
 
 private:
     WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(WKContextConfigurationRef);
index 1d1c919..dfba1a1 100644 (file)
@@ -647,6 +647,13 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         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);
index 771269e..963a714 100644 (file)
@@ -41,6 +41,7 @@ struct TestOptions {
     bool useDataDetection { false };
     bool useMockScrollbars { true };
     bool needsSiteSpecificQuirks { false };
+    bool ignoresViewportScaleLimits { false };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;
index 101f660..e798cae 100644 (file)
@@ -86,6 +86,8 @@ void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOpt
 #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);