HTML Form Validation bubble should take minimum font size setting into consideration
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Feb 2017 23:11:06 +0000 (23:11 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Feb 2017 23:11:06 +0000 (23:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168271
<rdar://problem/29869869>

Reviewed by Simon Fraser.

Source/WebCore:

HTML Form Validation bubble should take minimum font size setting into consideration
for better accessibility.

Test: fast/forms/validation-message-minimum-font-size.html

* platform/ValidationBubble.h:
(WebCore::ValidationBubble::create):
(WebCore::ValidationBubble::fontSize):
* platform/ios/ValidationBubbleIOS.mm:
(WebCore::ValidationBubble::ValidationBubble):
* platform/mac/ValidationBubbleMac.mm:
(WebCore::ValidationBubble::ValidationBubble):
Update the ValidationBubble constructor to take in Settings. For now, there is a
single setting that is the minimum font size and that is taken into account when
setting the font size of the validation bubble text.

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _contentsOfUserInterfaceItem:]):
Return font size used in the validation bubble.

(-[WebView showFormValidationMessage:withAnchorRect:]):
Pass minimum font size setting when constructing the validation bubble.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _contentsOfUserInterfaceItem:]):
Return font size used in the validation bubble.

* UIProcess/PageClient.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::createValidationBubble):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::showValidationMessage):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::createValidationBubble):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::showValidationMessage):
Pass minimum font size setting when constructing the form validation bubble.

Tools:

Extend UIScriptController's contentsOfUserInterfaceItem() to also return the
font size of the validation bubble.

Add an overridePreference() method to UIScriptController. This is currently
used to override the value of the minimumFontSize setting. testRunner's
overridePreference() is not usable on WK2 because it does not update the
value of the preference on the UIProcess side.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::overridePreference):
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::overridePreference):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::overridePreference):
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::contentsOfUserInterfaceItem):
(WTR::UIScriptController::overridePreference):

LayoutTests:

Add layout test coverage.

* fast/forms/validation-message-minimum-font-size-expected.txt: Added.
* fast/forms/validation-message-minimum-font-size.html: Added.

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

27 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/validation-message-minimum-font-size-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/validation-message-minimum-font-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ValidationBubble.h
Source/WebCore/platform/ios/ValidationBubbleIOS.mm
Source/WebCore/platform/mac/ValidationBubbleMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm

index 7058ce1..4695913 100644 (file)
@@ -1,3 +1,16 @@
+2017-02-14  Chris Dumez  <cdumez@apple.com>
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        https://bugs.webkit.org/show_bug.cgi?id=168271
+        <rdar://problem/29869869>
+
+        Reviewed by Simon Fraser.
+
+        Add layout test coverage.
+
+        * fast/forms/validation-message-minimum-font-size-expected.txt: Added.
+        * fast/forms/validation-message-minimum-font-size.html: Added.
+
 2017-02-14  Ryan Haddad  <ryanhaddad@apple.com>
 
         Remove debug flag from flaky test imported/w3c/web-platform-tests/dom/events/EventListener-invoke-legacy.html.
diff --git a/LayoutTests/fast/forms/validation-message-minimum-font-size-expected.txt b/LayoutTests/fast/forms/validation-message-minimum-font-size-expected.txt
new file mode 100644 (file)
index 0000000..66bcf1a
--- /dev/null
@@ -0,0 +1,12 @@
+Required text input: 
+Tests that the font used for validation bubble is aware of the minimumFontSize setting.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS validationBubbleContents.fontSize > 0 is true
+PASS validationBubbleContents.fontSize < 24 is true
+PASS validationBubbleContents.fontSize is 24
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/validation-message-minimum-font-size.html b/LayoutTests/fast/forms/validation-message-minimum-font-size.html
new file mode 100644 (file)
index 0000000..acb2f4f
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<form>
+  Required text input: <input type="text" id="required_text_input" required><input id="required_text_input_submit" type="submit">
+</form>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("Tests that the font used for validation bubble is aware of the minimumFontSize setting.");
+jsTestIsAsync = true;
+
+function getValidationBubbleContents()
+{
+    return `
+    (function() {
+        return JSON.stringify(uiController.contentsOfUserInterfaceItem('validationBubble'));
+    })();`
+}
+
+function setMinimumFontSize()
+{
+    return `
+    (function() {
+        uiController.overridePreference('WebKitMinimumFontSize', '24');
+        uiController.uiScriptComplete("Done");
+    })();`
+}
+
+onload = function() {
+    input = document.getElementById("required_text_input");
+    submit = document.getElementById("required_text_input_submit");
+    submit.click();
+
+    testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+        validationBubbleContents = JSON.parse(result).validationBubble;
+        shouldBeTrue("validationBubbleContents.fontSize > 0");
+        shouldBeTrue("validationBubbleContents.fontSize < 24");
+
+        testRunner.runUIScript(setMinimumFontSize(), function() {
+            submit.click();
+
+            testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+                validationBubbleContents = JSON.parse(result).validationBubble;
+                shouldBe("validationBubbleContents.fontSize", "24");
+                finishJSTest();
+            });
+        });
+    });
+}
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+<html>
index c0b893c..bb67234 100644 (file)
@@ -1,3 +1,27 @@
+2017-02-14  Chris Dumez  <cdumez@apple.com>
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        https://bugs.webkit.org/show_bug.cgi?id=168271
+        <rdar://problem/29869869>
+
+        Reviewed by Simon Fraser.
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        for better accessibility.
+
+        Test: fast/forms/validation-message-minimum-font-size.html
+
+        * platform/ValidationBubble.h:
+        (WebCore::ValidationBubble::create):
+        (WebCore::ValidationBubble::fontSize):
+        * platform/ios/ValidationBubbleIOS.mm:
+        (WebCore::ValidationBubble::ValidationBubble):
+        * platform/mac/ValidationBubbleMac.mm:
+        (WebCore::ValidationBubble::ValidationBubble):
+        Update the ValidationBubble constructor to take in Settings. For now, there is a
+        single setting that is the minimum font size and that is taken into account when
+        setting the font size of the validation bubble text.
+
 2017-02-14  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] add navigator.getUserMedia for compatibility with legacy content
index b9aa75c..d19fb12 100644 (file)
@@ -55,14 +55,19 @@ namespace WebCore {
 
 class ValidationBubble : public RefCounted<ValidationBubble> {
 public:
-    static Ref<ValidationBubble> create(PlatformView* view, const String& message)
+    struct Settings {
+        double minimumFontSize { 0 };
+    };
+
+    static Ref<ValidationBubble> create(PlatformView* view, const String& message, const Settings& settings)
     {
-        return adoptRef(*new ValidationBubble(view, message));
+        return adoptRef(*new ValidationBubble(view, message, settings));
     }
 
     WEBCORE_EXPORT ~ValidationBubble();
 
     const String& message() const { return m_message; }
+    double fontSize() const { return m_fontSize; }
 
 #if PLATFORM(IOS)
     WEBCORE_EXPORT void setAnchorRect(const IntRect& anchorRect, UIViewController* presentingViewController = nullptr);
@@ -72,10 +77,11 @@ public:
 #endif
 
 private:
-    WEBCORE_EXPORT ValidationBubble(PlatformView*, const String& message);
+    WEBCORE_EXPORT ValidationBubble(PlatformView*, const String& message, const Settings&);
 
     PlatformView* m_view;
     String m_message;
+    double m_fontSize { 0 };
 #if PLATFORM(MAC)
     RetainPtr<NSPopover> m_popover;
 #elif PLATFORM(IOS)
index 9cdfb28..a51d9f9 100644 (file)
@@ -97,7 +97,7 @@ static const CGFloat horizontalPadding = 17;
 static const CGFloat verticalPadding = 9;
 static const CGFloat maxLabelWidth = 300;
 
-ValidationBubble::ValidationBubble(UIView* view, const String& message)
+ValidationBubble::ValidationBubble(UIView* view, const String& message, const Settings& settings)
     : m_view(view)
     , m_message(message)
 {
@@ -110,7 +110,8 @@ ValidationBubble::ValidationBubble(UIView* view, const String& message)
 
     RetainPtr<UILabel> label = adoptNS([[getUILabelClass() alloc] initWithFrame:CGRectZero]);
     [label setText:message];
-    [label setFont:[getUIFontClass() systemFontOfSize:14.0]];
+    m_fontSize = std::max(settings.minimumFontSize, 14.0);
+    [label setFont:[getUIFontClass() systemFontOfSize:m_fontSize]];
     [label setLineBreakMode:NSLineBreakByTruncatingTail];
     [label setNumberOfLines:4];
     [popoverView addSubview:label.get()];
index 042e27d..71c724f 100644 (file)
@@ -50,7 +50,7 @@ static const CGFloat horizontalPadding = 5;
 static const CGFloat verticalPadding = 5;
 static const CGFloat maxLabelWidth = 300;
 
-ValidationBubble::ValidationBubble(NSView* view, const String& message)
+ValidationBubble::ValidationBubble(NSView* view, const String& message, const Settings& settings)
     : m_view(view)
     , m_message(message)
 {
@@ -64,6 +64,8 @@ ValidationBubble::ValidationBubble(NSView* view, const String& message)
     [label setDrawsBackground:NO];
     [label setBordered:NO];
     [label setStringValue:message];
+    m_fontSize = std::max(settings.minimumFontSize, 13.0);
+    [label setFont:[NSFont systemFontOfSize:m_fontSize]];
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     [label setMaximumNumberOfLines:4];
 #endif
index fc16baa..8917555 100644 (file)
@@ -1,3 +1,18 @@
+2017-02-14  Chris Dumez  <cdumez@apple.com>
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        https://bugs.webkit.org/show_bug.cgi?id=168271
+        <rdar://problem/29869869>
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebView.mm:
+        (-[WebView _contentsOfUserInterfaceItem:]):
+        Return font size used in the validation bubble.
+
+        (-[WebView showFormValidationMessage:withAnchorRect:]):
+        Pass minimum font size setting when constructing the validation bubble.
+
 2017-02-14  Anders Carlsson  <andersca@apple.com>
 
         Remove an unused delegate method
index eab4e0f..5c82cc2 100644 (file)
@@ -4341,7 +4341,8 @@ static inline IMP getMethod(id o, SEL s)
     if ([userInterfaceItem isEqualToString:@"validationBubble"]) {
         auto* validationBubble = _private->formValidationBubble.get();
         String message = validationBubble ? validationBubble->message() : emptyString();
-        return @{ userInterfaceItem: @{ @"message": (NSString *)message } };
+        double fontSize = validationBubble ? validationBubble->fontSize() : 0;
+        return @{ userInterfaceItem: @{ @"message": (NSString *)message, @"fontSize": [NSNumber numberWithDouble:fontSize] } };
     }
 
     return nil;
@@ -9326,7 +9327,8 @@ bool LayerFlushController::flushLayers()
 {
     // FIXME: We should enable this on iOS as well.
 #if PLATFORM(MAC)
-    _private->formValidationBubble = ValidationBubble::create(self, message);
+    double minimumFontSize = _private->page ? _private->page->settings().minimumFontSize() : 0;
+    _private->formValidationBubble = ValidationBubble::create(self, message, { minimumFontSize });
     _private->formValidationBubble->showRelativeTo(enclosingIntRect([self _convertRectFromRootView:anchorRect]));
 #else
     UNUSED_PARAM(message);
index 78f57a9..1e04824 100644 (file)
@@ -1,3 +1,28 @@
+2017-02-14  Chris Dumez  <cdumez@apple.com>
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        https://bugs.webkit.org/show_bug.cgi?id=168271
+        <rdar://problem/29869869>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _contentsOfUserInterfaceItem:]):
+        Return font size used in the validation bubble.
+
+        * UIProcess/PageClient.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::createValidationBubble):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::showValidationMessage):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::createValidationBubble):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::showValidationMessage):
+        Pass minimum font size setting when constructing the form validation bubble.
+
 2017-02-14  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r211879.
index ba04654..3be8170 100644 (file)
@@ -4876,7 +4876,8 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
     if ([userInterfaceItem isEqualToString:@"validationBubble"]) {
         auto* validationBubble = _page->validationBubble();
         String message = validationBubble ? validationBubble->message() : emptyString();
-        return @{ userInterfaceItem: @{ @"message": (NSString *)message } };
+        double fontSize = validationBubble ? validationBubble->fontSize() : 0;
+        return @{ userInterfaceItem: @{ @"message": (NSString *)message, @"fontSize": [NSNumber numberWithDouble:fontSize] } };
     }
 
 #if PLATFORM(IOS)
index 06d33c7..4a572df 100644 (file)
@@ -32,6 +32,7 @@
 #include <WebCore/AlternativeTextClient.h>
 #include <WebCore/EditorClient.h>
 #include <WebCore/UserInterfaceLayoutDirection.h>
+#include <WebCore/ValidationBubble.h>
 #include <wtf/Forward.h>
 
 #if PLATFORM(COCOA)
@@ -48,7 +49,6 @@ OBJC_CLASS NSTextAlternatives;
 namespace WebCore {
 class Cursor;
 class TextIndicator;
-class ValidationBubble;
 class WebMediaSessionManager;
 enum class TextIndicatorWindowLifetime : uint8_t;
 enum class TextIndicatorWindowDismissalAnimation : uint8_t;
@@ -229,7 +229,7 @@ public:
 #endif
 
 #if PLATFORM(COCOA)
-    virtual Ref<WebCore::ValidationBubble> createValidationBubble(const String& message) = 0;
+    virtual Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) = 0;
 #endif
 
 #if PLATFORM(COCOA)
index f72b752..e91617b 100644 (file)
@@ -97,7 +97,7 @@ private:
 #if ENABLE(CONTEXT_MENUS)
     std::unique_ptr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override;
 #endif
-    Ref<WebCore::ValidationBubble> createValidationBubble(const String& message) final;
+    Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
 
     void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
     void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
index b910d0d..3c0d7b8 100644 (file)
@@ -757,9 +757,9 @@ WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirecti
     return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:[m_webView semanticContentAttribute]] == UIUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
 }
 
-Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message)
+Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
 {
-    return ValidationBubble::create(m_contentView, message);
+    return ValidationBubble::create(m_contentView, message, settings);
 }
 
 #if ENABLE(DATA_INTERACTION)
index fb4ca0d..97bfb56 100644 (file)
@@ -1095,7 +1095,7 @@ void WebPageProxy::editorStateChanged(const EditorState& editorState)
 
 void WebPageProxy::showValidationMessage(const IntRect& anchorClientRect, const String& message)
 {
-    m_validationBubble = m_pageClient.createValidationBubble(message);
+    m_validationBubble = m_pageClient.createValidationBubble(message, { m_preferences->minimumFontSize() });
     m_validationBubble->setAnchorRect(anchorClientRect, uiClient().presentingViewController());
 
     // If we are currently doing a scrolling / zoom animation, then we'll delay showing the validation
index 0d2ddaa..e7322be 100644 (file)
@@ -131,7 +131,7 @@ private:
     RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override;
 #endif
 
-    Ref<WebCore::ValidationBubble> createValidationBubble(const String& message) final;
+    Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
 
     void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
     void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
index b0e4676..b06f74b 100644 (file)
@@ -440,9 +440,9 @@ RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, con
 }
 #endif
 
-Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message)
+Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
 {
-    return ValidationBubble::create(m_view, message);
+    return ValidationBubble::create(m_view, message, settings);
 }
 
 void PageClientImpl::setTextIndicator(Ref<TextIndicator> textIndicator, WebCore::TextIndicatorWindowLifetime lifetime)
index 6013b97..897689c 100644 (file)
@@ -597,7 +597,7 @@ void WebPageProxy::rootViewToWindow(const WebCore::IntRect& viewRect, WebCore::I
 
 void WebPageProxy::showValidationMessage(const IntRect& anchorClientRect, const String& message)
 {
-    m_validationBubble = m_pageClient.createValidationBubble(message);
+    m_validationBubble = m_pageClient.createValidationBubble(message, { m_preferences->minimumFontSize() });
     m_validationBubble->showRelativeTo(anchorClientRect);
 }
 
index d01b9b6..1ba8b92 100644 (file)
@@ -1,3 +1,33 @@
+2017-02-14  Chris Dumez  <cdumez@apple.com>
+
+        HTML Form Validation bubble should take minimum font size setting into consideration
+        https://bugs.webkit.org/show_bug.cgi?id=168271
+        <rdar://problem/29869869>
+
+        Reviewed by Simon Fraser.
+
+        Extend UIScriptController's contentsOfUserInterfaceItem() to also return the
+        font size of the validation bubble.
+
+        Add an overridePreference() method to UIScriptController. This is currently
+        used to override the value of the minimumFontSize setting. testRunner's
+        overridePreference() is not usable on WK2 because it does not update the
+        value of the preference on the UIProcess side.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::overridePreference):
+        * DumpRenderTree/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::overridePreference):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::overridePreference):
+        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::contentsOfUserInterfaceItem):
+        (WTR::UIScriptController::overridePreference):
+
 2017-02-14  Florian Bruhin  <git@the-compiler.org>
 
         Use a set instead of a list for tests when parsing expectations
index e98114a..e20140e 100644 (file)
@@ -159,6 +159,10 @@ JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfac
     return nullptr;
 }
 
+void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef)
+{
+}
+
 static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoint contentOffset)
 {
     UIEdgeInsets contentInsets = scrollView.contentInset;
index fb982cd..3dc279f 100644 (file)
@@ -94,6 +94,15 @@ JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfac
 #endif
 }
 
+void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef)
+{
+    WebPreferences *preferences = mainFrame.webView.preferences;
+
+    RetainPtr<CFStringRef> value = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, valueRef));
+    if (JSStringIsEqualToUTF8CString(preferenceRef, "WebKitMinimumFontSize"))
+        preferences.minimumFontSize = [(NSString *)value.get() doubleValue];
+}
+
 void UIScriptController::removeViewFromWindow(JSValueRef callback)
 {
     unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
index eaf0d7e..330290d 100644 (file)
@@ -222,4 +222,5 @@ interface UIScriptController {
     void removeViewFromWindow(object callback);
     void addViewToWindow(object callback);
 
+    void overridePreference(DOMString preference, DOMString value);
 };
index 0bb13fa..17412a1 100644 (file)
@@ -397,6 +397,10 @@ void UIScriptController::addViewToWindow(JSValueRef)
 {
 }
 
+void UIScriptController::overridePreference(JSStringRef, JSStringRef)
+{
+}
+
 #endif // !PLATFORM(COCOA)
 
 #if !PLATFORM(MAC)
index 0bbf661..ff0f841 100644 (file)
@@ -87,6 +87,7 @@ public:
     void selectFormAccessoryPickerRow(long);
     
     JSObjectRef contentsOfUserInterfaceItem(JSStringRef) const;
+    void overridePreference(JSStringRef preference, JSStringRef value);
     
     void scrollToOffset(long x, long y);
 
index c38a9c7..2ae93ce 100644 (file)
@@ -678,6 +678,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica");
     static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times");
 
+    WKPreferencesSetMinimumFontSize(preferences, 0);
     WKPreferencesSetStandardFontFamily(preferences, standardFontFamily);
     WKPreferencesSetCursiveFontFamily(preferences, cursiveFontFamily);
     WKPreferencesSetFantasyFontFamily(preferences, fantasyFontFamily);
index d87ef32..f30bb0c 100644 (file)
@@ -651,6 +651,17 @@ void UIScriptController::platformClearAllCallbacks()
     webView.didEndScrollingCallback = nil;
 }
 
+void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    WKPreferences *preferences = webView.configuration.preferences;
+
+    String preference = toWTFString(toWK(preferenceRef));
+    String value = toWTFString(toWK(valueRef));
+    if (preference == "WebKitMinimumFontSize")
+        preferences.minimumFontSize = value.toDouble();
+}
+
 }
 
 #endif // PLATFORM(IOS)
index 2261ed7..07cb6e2 100644 (file)
@@ -131,6 +131,22 @@ JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfac
 #endif
 }
 
+void UIScriptController::overridePreference(JSStringRef preferenceRef, JSStringRef valueRef)
+{
+#if WK_API_ENABLED
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    WKPreferences *preferences = webView.configuration.preferences;
+
+    String preference = toWTFString(toWK(preferenceRef));
+    String value = toWTFString(toWK(valueRef));
+    if (preference == "WebKitMinimumFontSize")
+        preferences.minimumFontSize = value.toDouble();
+#else
+    UNUSED_PARAM(preferenceRef);
+    UNUSED_PARAM(valueRef);
+#endif
+}
+
 void UIScriptController::removeViewFromWindow(JSValueRef callback)
 {
 #if WK_API_ENABLED