Disabling text autosizing should prevent text autosizing
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Aug 2019 22:03:02 +0000 (22:03 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Aug 2019 22:03:02 +0000 (22:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200955
<rdar://problem/48095374>

Reviewed by Simon Fraser.

Source/WebCore:

Before this change there was no way to reliably change the text size on iOS when a -webkit-text-size-adjust:none style was applied
because it would ignore the WKPreferences value for _textAutosizingEnabled.  Now that value has the desired effect when laying out.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::checkForTextSizeAdjust):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm: Added.
(TEST):

LayoutTests:

* fast/text-autosizing/ios/text-size-adjust-inline-style.html:
The comment was incorrect because we call WKPreferencesSetTextAutosizingEnabled(preferences, false) in TestController::platformResetPreferencesToConsistentValues.
In order to test the effect of text autosizing in this test, we need to explicitly turn it on.  The disabling of text autosizing didn't do anything before this
patch, so it wasn't needed before now.

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

LayoutTests/ChangeLog
LayoutTests/fast/text-autosizing/ios/text-size-adjust-inline-style.html
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm [new file with mode: 0644]

index a13ebb1..4feb7e2 100644 (file)
@@ -1,3 +1,16 @@
+2019-08-21  Alex Christensen  <achristensen@webkit.org>
+
+        Disabling text autosizing should prevent text autosizing
+        https://bugs.webkit.org/show_bug.cgi?id=200955
+        <rdar://problem/48095374>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text-autosizing/ios/text-size-adjust-inline-style.html:
+        The comment was incorrect because we call WKPreferencesSetTextAutosizingEnabled(preferences, false) in TestController::platformResetPreferencesToConsistentValues.
+        In order to test the effect of text autosizing in this test, we need to explicitly turn it on.  The disabling of text autosizing didn't do anything before this
+        patch, so it wasn't needed before now.
+
 2019-08-21  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed test gardening, land test expectations for rdar://54561673.
index 15679e8..1902faf 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
 <head>
-<!-- We intentionally do not call window.internal.settings.setTextAutosizingEnabled(true) to test the default port behavior. -->
+<script>internals.settings.setTextAutosizingEnabled(true)</script>
 <style>
 @font-face {
     font-family: Ahem;
index 26efe93..4edf00b 100644 (file)
@@ -1,3 +1,17 @@
+2019-08-21  Alex Christensen  <achristensen@webkit.org>
+
+        Disabling text autosizing should prevent text autosizing
+        https://bugs.webkit.org/show_bug.cgi?id=200955
+        <rdar://problem/48095374>
+
+        Reviewed by Simon Fraser.
+
+        Before this change there was no way to reliably change the text size on iOS when a -webkit-text-size-adjust:none style was applied
+        because it would ignore the WKPreferences value for _textAutosizingEnabled.  Now that value has the desired effect when laying out.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::checkForTextSizeAdjust):
+
 2019-08-21  Jer Noble  <jer.noble@apple.com>
 
         Adopt AVSystemController_ActiveAudioRouteDidChangeNotification
index de4da5f..20e7b2a 100644 (file)
@@ -1883,7 +1883,9 @@ RefPtr<StyleImage> StyleResolver::styleImage(CSSValue& value)
 #if ENABLE(TEXT_AUTOSIZING)
 void StyleResolver::checkForTextSizeAdjust(RenderStyle& style)
 {
-    if (style.textSizeAdjust().isAuto() || (settings().textAutosizingUsesIdempotentMode() && !style.textSizeAdjust().isNone()))
+    if (style.textSizeAdjust().isAuto()
+        || !settings().textAutosizingEnabled()
+        || (settings().textAutosizingUsesIdempotentMode() && !style.textSizeAdjust().isNone()))
         return;
 
     auto newFontDescription = style.fontDescription();
index fa431d1..abc0597 100644 (file)
@@ -1,3 +1,15 @@
+2019-08-21  Alex Christensen  <achristensen@webkit.org>
+
+        Disabling text autosizing should prevent text autosizing
+        https://bugs.webkit.org/show_bug.cgi?id=200955
+        <rdar://problem/48095374>
+
+        Reviewed by Simon Fraser.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm: Added.
+        (TEST):
+
 2019-08-21  Adrian Perez de Castro  <aperez@igalia.com>
 
         [GTK][WPE] Make debug-test-runner work
index 7c65a21..ba71451 100644 (file)
                5C0BF8931DD599BD00B00328 /* IsNavigationActionTrusted.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */; };
                5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A99D9931AD4A29D00373141 /* MenuTypesForMouseEvents.mm */; };
                5C0BF8951DD599CD00B00328 /* NavigatorLanguage.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */; };
+               5C16F8FC230C94370074C4A8 /* TextSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C16F8FB230C942B0074C4A8 /* TextSize.mm */; };
                5C19A5241FD0F60100EEA323 /* CookiePrivateBrowsing.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C19A5231FD0F32600EEA323 /* CookiePrivateBrowsing.mm */; };
                5C23DF0B2246015800F454B6 /* Challenge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C23DF0A2245C9D700F454B6 /* Challenge.mm */; };
                5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */; };
                5C0160C021A132320077FA32 /* JITEnabled.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JITEnabled.mm; sourceTree = "<group>"; };
                5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandler.mm; sourceTree = "<group>"; };
                5C0BF88F1DD5999B00B00328 /* WebViewCanPasteZeroPng.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteZeroPng.mm; sourceTree = "<group>"; };
+               5C16F8FB230C942B0074C4A8 /* TextSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextSize.mm; sourceTree = "<group>"; };
                5C19A5231FD0F32600EEA323 /* CookiePrivateBrowsing.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookiePrivateBrowsing.mm; sourceTree = "<group>"; };
                5C23DF0A2245C9D700F454B6 /* Challenge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Challenge.mm; sourceTree = "<group>"; };
                5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieAcceptPolicy.mm; sourceTree = "<group>"; };
                                5774AA6721FBBF7800AF2A1B /* TestSOAuthorization.mm */,
                                F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */,
                                F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */,
+                               5C16F8FB230C942B0074C4A8 /* TextSize.mm */,
                                C22FA32A228F8708009D7988 /* TextWidth.mm */,
                                5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */,
                                5C3A77A922F20B8A003827FF /* UploadDirectory.mm */,
                                F45033F5206BEC95009351CE /* TextAutosizingBoost.mm in Sources */,
                                93E6193B1F931B3A00AF245E /* TextCodec.cpp in Sources */,
                                CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
+                               5C16F8FC230C94370074C4A8 /* TextSize.mm in Sources */,
                                C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */,
                                7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
                                7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm
new file mode 100644 (file)
index 0000000..36a43d7
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import "Utilities.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+TEST(WebKit, TextSize)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    [webView configuration].preferences._textAutosizingEnabled = NO;
+    [webView synchronouslyLoadHTMLString:
+        @"<!DOCTYPE html>"
+        "<html lang='en-US'>"
+        "<head> <style>"
+            "@font-face { font-family: customFont; src: url(Ahem.ttf); }"
+            "body { font-family: customFont; -webkit-text-size-adjust:none; }"
+        "</style> </head>"
+        "<body> <p> <span id='testspan'>This is a test string</span> </p> </body>"
+        "</html>"
+    ];
+    EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"document.getElementById('testspan').offsetWidth"], "336");
+    [webView _setTextZoomFactor:2.0];
+    EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"document.getElementById('testspan').offsetWidth"], "672");
+}