Title: [248966] trunk
Revision
248966
Author
achristen...@apple.com
Date
2019-08-21 15:03:02 -0700 (Wed, 21 Aug 2019)

Log Message

Disabling text autosizing should prevent text autosizing
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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (248965 => 248966)


--- trunk/LayoutTests/ChangeLog	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/LayoutTests/ChangeLog	2019-08-21 22:03:02 UTC (rev 248966)
@@ -1,3 +1,16 @@
+2019-08-21  Alex Christensen  <achristen...@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  <ryanhad...@apple.com>
 
         Unreviewed test gardening, land test expectations for rdar://54561673.

Modified: trunk/LayoutTests/fast/text-autosizing/ios/text-size-adjust-inline-style.html (248965 => 248966)


--- trunk/LayoutTests/fast/text-autosizing/ios/text-size-adjust-inline-style.html	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/LayoutTests/fast/text-autosizing/ios/text-size-adjust-inline-style.html	2019-08-21 22:03:02 UTC (rev 248966)
@@ -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;

Modified: trunk/Source/WebCore/ChangeLog (248965 => 248966)


--- trunk/Source/WebCore/ChangeLog	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/Source/WebCore/ChangeLog	2019-08-21 22:03:02 UTC (rev 248966)
@@ -1,3 +1,17 @@
+2019-08-21  Alex Christensen  <achristen...@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.no...@apple.com>
 
         Adopt AVSystemController_ActiveAudioRouteDidChangeNotification

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (248965 => 248966)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2019-08-21 22:03:02 UTC (rev 248966)
@@ -1883,7 +1883,9 @@
 #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();

Modified: trunk/Tools/ChangeLog (248965 => 248966)


--- trunk/Tools/ChangeLog	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/Tools/ChangeLog	2019-08-21 22:03:02 UTC (rev 248966)
@@ -1,3 +1,15 @@
+2019-08-21  Alex Christensen  <achristen...@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  <ape...@igalia.com>
 
         [GTK][WPE] Make debug-test-runner work

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (248965 => 248966)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-08-21 21:49:00 UTC (rev 248965)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-08-21 22:03:02 UTC (rev 248966)
@@ -344,6 +344,7 @@
 		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 */; };
@@ -1838,6 +1839,7 @@
 		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>"; };
@@ -2856,6 +2858,7 @@
 				5774AA6721FBBF7800AF2A1B /* TestSOAuthorization.mm */,
 				F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */,
 				F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */,
+				5C16F8FB230C942B0074C4A8 /* TextSize.mm */,
 				C22FA32A228F8708009D7988 /* TextWidth.mm */,
 				5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */,
 				5C3A77A922F20B8A003827FF /* UploadDirectory.mm */,
@@ -4712,6 +4715,7 @@
 				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 */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm (0 => 248966)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextSize.mm	2019-08-21 22:03:02 UTC (rev 248966)
@@ -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");
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to