AX: Force allow user zoom
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Mar 2016 16:13:12 +0000 (16:13 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Mar 2016 16:13:12 +0000 (16:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155056

Reviewed by Chris Fleizach.

Source/WebCore:

Override the maximum scale factor when forceAlwaysUserScalable is true.

Test: accessibility/ios-simulator/force-user-scalable.html

* page/ViewportConfiguration.h:
(WebCore::ViewportConfiguration::maximumScale):
* testing/Internals.cpp:
(WebCore::Internals::composedTreeAsText):
(WebCore::Internals::setViewportForceAlwaysUserScalable):
(WebCore::Internals::viewportConfigurationMaximumScale):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

Soft linked libAccessibility library so that we can observe the accessibility
setting change for the force always user scalable feature.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::forceAlwaysUserScalableChangedCallback):
(WebKit::WebPage::create):
(WebKit::m_shouldDispatchFakeMouseMoveEvents):
(WebKit::WebPage::~WebPage):
(WebKit::WebPage::preferencesDidChange):
(WebKit::WebPage::updateForceAlwaysUserScalable):
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/WebPage.h:

LayoutTests:

* accessibility/ios-simulator/force-user-scalable-expected.txt: Added.
* accessibility/ios-simulator/force-user-scalable.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/force-user-scalable-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/force-user-scalable.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/ViewportConfiguration.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h

index e48bc0b70ab6448ef714a75b31873a7adfa9d054..78d3cee5ad25b299f7a2ac0b83ae549133010ab7 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-08  Nan Wang  <n_wang@apple.com>
+
+        AX: Force allow user zoom
+        https://bugs.webkit.org/show_bug.cgi?id=155056
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/force-user-scalable-expected.txt: Added.
+        * accessibility/ios-simulator/force-user-scalable.html: Added.
+
 2016-03-08  Andreas Kling  <akling@apple.com>
 
         ImageDocuments leak their world.
diff --git a/LayoutTests/accessibility/ios-simulator/force-user-scalable-expected.txt b/LayoutTests/accessibility/ios-simulator/force-user-scalable-expected.txt
new file mode 100644 (file)
index 0000000..1f2ecd2
--- /dev/null
@@ -0,0 +1,10 @@
+This tests that when we set force always user scalable, the maximum scale will be changed too.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.internals.viewportConfigurationMaximumScale() is 10
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/force-user-scalable.html b/LayoutTests/accessibility/ios-simulator/force-user-scalable.html
new file mode 100644 (file)
index 0000000..c13489f
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+</script>
+<meta name="viewport" content="width=device-width, user-scalable=no, maximum-scale=3, minimum-scale=1">
+</head>
+<body id="body">
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that when we set force always user scalable, the maximum scale will be changed too.");
+
+    if (window.accessibilityController) {
+        window.internals.setViewportForceAlwaysUserScalable(true);
+        shouldBe("window.internals.viewportConfigurationMaximumScale()", "10");
+    }
+    
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
index 8d2950e876c56e0fe06af4d66958924db08b52ac..ceed007afa5b8bb1563711c2e1f1cdbecff4b5cc 100644 (file)
@@ -1,3 +1,23 @@
+2016-03-08  Nan Wang  <n_wang@apple.com>
+
+        AX: Force allow user zoom
+        https://bugs.webkit.org/show_bug.cgi?id=155056
+
+        Reviewed by Chris Fleizach.
+
+        Override the maximum scale factor when forceAlwaysUserScalable is true.
+
+        Test: accessibility/ios-simulator/force-user-scalable.html
+
+        * page/ViewportConfiguration.h:
+        (WebCore::ViewportConfiguration::maximumScale):
+        * testing/Internals.cpp:
+        (WebCore::Internals::composedTreeAsText):
+        (WebCore::Internals::setViewportForceAlwaysUserScalable):
+        (WebCore::Internals::viewportConfigurationMaximumScale):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2016-03-08  Andreas Kling  <akling@apple.com>
 
         ImageDocuments leak their world.
index a0fbdc36362f8040bf4d683c76553f1935af40e7..a9a16c99ecfe2b57fa9751cf84a25263aeda634c 100644 (file)
@@ -33,6 +33,8 @@
 
 namespace WebCore {
 
+static const double forceAlwaysUserScalableMaximumScale = 10.0;
+
 class TextStream;
 
 class ViewportConfiguration {
@@ -88,7 +90,7 @@ public:
     WEBCORE_EXPORT double initialScale() const;
     WEBCORE_EXPORT double initialScaleIgnoringContentSize() const;
     WEBCORE_EXPORT double minimumScale() const;
-    double maximumScale() const { return m_configuration.maximumScale; }
+    double maximumScale() const { return m_forceAlwaysUserScalable ? forceAlwaysUserScalableMaximumScale : m_configuration.maximumScale; }
     WEBCORE_EXPORT bool allowsUserScaling() const;
     bool allowsShrinkToFit() const;
 
index d6d034e209e56c79a3e730a0103c85374ffc9f91..6e7da507026eb09f91844d0f177127353c91c693 100644 (file)
@@ -3518,4 +3518,22 @@ String Internals::composedTreeAsText(Node* node)
     return WebCore::composedTreeAsText(downcast<ContainerNode>(*node));
 }
 
+void Internals::setViewportForceAlwaysUserScalable(bool forceAlwaysUserScalableEnabled)
+{
+#if PLATFORM(IOS) || PLATFORM(MAC)
+    m_viewportConfiguration.setForceAlwaysUserScalable(forceAlwaysUserScalableEnabled);
+#else
+    UNUSED_PARAM(forceAlwaysUserScalableEnabled);
+#endif
+}
+
+double Internals::viewportConfigurationMaximumScale()
+{
+#if PLATFORM(IOS) || PLATFORM(MAC)
+    return m_viewportConfiguration.maximumScale();
+#else
+    return 0;
+#endif
+}
+
 }
index f3942998e26e824a1a8f0908c64988213ddf54a5..4cb8fd7c1c185f924575dcfcfa4779884e977b93 100644 (file)
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(IOS) || PLATFORM(MAC)
+#include "ViewportConfiguration.h"
+#endif
+
 namespace WebCore {
 
 class AudioContext;
@@ -476,6 +480,9 @@ public:
 
     String composedTreeAsText(Node*);
 
+    void setViewportForceAlwaysUserScalable(bool);
+    double viewportConfigurationMaximumScale();
+
 private:
     explicit Internals(Document*);
     Document* contextDocument() const;
@@ -484,6 +491,9 @@ private:
     RenderedDocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
 
     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
+#if PLATFORM(IOS) || PLATFORM(MAC)
+    ViewportConfiguration m_viewportConfiguration;
+#endif
 };
 
 } // namespace WebCore
index 766182450370808abb2b1dfe540d2152360d916b..afbfe09439bb185af5cfafdf06ecce769ee71d54 100644 (file)
@@ -443,4 +443,7 @@ enum AutoFillButtonType {
     [RaisesException] void setCanShowModalDialogOverride(boolean allow);
 
     DOMString composedTreeAsText(Node parent);
+
+    void setViewportForceAlwaysUserScalable(boolean enable);
+    double viewportConfigurationMaximumScale();
 };
index d459d892c3adfd499e32d88884d9b1ba94f3ebd9..6647ecd2960024d709afd14cc89fbef8eaa4e093 100644 (file)
@@ -1,3 +1,23 @@
+2016-03-08  Nan Wang  <n_wang@apple.com>
+
+        AX: Force allow user zoom
+        https://bugs.webkit.org/show_bug.cgi?id=155056
+
+        Reviewed by Chris Fleizach.
+
+        Soft linked libAccessibility library so that we can observe the accessibility
+        setting change for the force always user scalable feature.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::forceAlwaysUserScalableChangedCallback):
+        (WebKit::WebPage::create):
+        (WebKit::m_shouldDispatchFakeMouseMoveEvents):
+        (WebKit::WebPage::~WebPage):
+        (WebKit::WebPage::preferencesDidChange):
+        (WebKit::WebPage::updateForceAlwaysUserScalable):
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/WebPage.h:
+
 2016-03-08  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         One more unreviewed speculative buildfix after r197728.
index a193d982195e7efefd055fae003a8e542b34f657..5db70ce903f7d02d22e8253cc83e6398f84296e0 100644 (file)
 #include <CoreGraphics/CoreGraphics.h>
 #include <WebCore/CoreTextSPI.h>
 #include <WebCore/Icon.h>
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+#include <WebCore/SoftLinking.h>
+SOFT_LINK_LIBRARY(libAccessibility)
+SOFT_LINK(libAccessibility, _AXSForceAllowWebScaling, Boolean, (), ())
+SOFT_LINK_CONSTANT(libAccessibility, kAXSAllowForceWebScalingEnabledNotification, CFStringRef)
+#define kAXSAllowForceWebScalingEnabledNotification getkAXSAllowForceWebScalingEnabledNotification()
+#endif
+
 #endif
 
 #ifndef NDEBUG
@@ -261,6 +270,15 @@ private:
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageCounter, ("WebPage"));
 
+#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+static void forceAlwaysUserScalableChangedCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT(observer);
+    static_cast<WebPage*>(observer)->updateForceAlwaysUserScalable();
+}
+#endif
+
+    
 Ref<WebPage> WebPage::create(uint64_t pageID, const WebPageCreationParameters& parameters)
 {
     Ref<WebPage> page = adoptRef(*new WebPage(pageID, parameters));
@@ -546,6 +564,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 
 #if PLATFORM(IOS)
     m_page->settings().setContentDispositionAttachmentSandboxEnabled(true);
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, forceAlwaysUserScalableChangedCallback, kAXSAllowForceWebScalingEnabledNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+#endif
 #endif
 }
 
@@ -578,6 +599,10 @@ void WebPage::updateUserActivity()
 
 WebPage::~WebPage()
 {
+#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+    CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, nullptr, nullptr);
+#endif
+    
     if (m_backForwardList)
         m_backForwardList->detach();
 
@@ -2798,6 +2823,17 @@ void WebPage::preferencesDidChange(const WebPreferencesStore& store)
     updatePreferences(store);
 }
 
+#if PLATFORM(IOS)
+void WebPage::updateForceAlwaysUserScalable()
+{
+    bool forceAlwaysUserScalableEnabled = m_forceAlwaysUserScalable;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+    forceAlwaysUserScalableEnabled |= _AXSForceAllowWebScaling();
+#endif
+    m_viewportConfiguration.setForceAlwaysUserScalable(forceAlwaysUserScalableEnabled);
+}
+#endif
+
 void WebPage::updatePreferences(const WebPreferencesStore& store)
 {
     Settings& settings = m_page->settings();
@@ -3071,7 +3107,8 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 #if PLATFORM(IOS)
     m_ignoreViewportScalingConstraints = store.getBoolValueForKey(WebPreferencesKey::ignoreViewportScalingConstraintsKey());
     m_viewportConfiguration.setCanIgnoreScalingConstraints(m_ignoreViewportScalingConstraints);
-    m_viewportConfiguration.setForceAlwaysUserScalable(store.getBoolValueForKey(WebPreferencesKey::forceAlwaysUserScalableKey()));
+    m_forceAlwaysUserScalable = store.getBoolValueForKey(WebPreferencesKey::forceAlwaysUserScalableKey());
+    updateForceAlwaysUserScalable();
 #endif
 }
 
index 8eef82e475c73f1010ba7db1c03fa4160ab80c29..938c41fdbb089e2c2bac7735d54e906923cad9ac 100644 (file)
@@ -931,6 +931,10 @@ public:
 
     bool isControlledByAutomation() const;
     void setControlledByAutomation(bool);
+    
+#if PLATFORM(IOS)
+    void updateForceAlwaysUserScalable();
+#endif
 
     void insertNewlineInQuotedContent();
 
@@ -1439,6 +1443,10 @@ private:
     bool m_inputMethodEnabled { false };
 #endif
 
+#if PLATFORM(IOS)
+    bool m_forceAlwaysUserScalable { false };
+#endif
+
 #if ENABLE(VIDEO) && USE(GSTREAMER)
     RefPtr<WebCore::MediaPlayerRequestInstallMissingPluginsCallback> m_installMediaPluginsCallback;
 #endif