Title: [230039] trunk
Revision
230039
Author
wenson_hs...@apple.com
Date
2018-03-28 11:55:40 -0700 (Wed, 28 Mar 2018)

Log Message

[Extra zoom mode] Make boosted text autosizing values switchable at runtime
https://bugs.webkit.org/show_bug.cgi?id=184092
<rdar://problem/38939917>

Reviewed by Tim Horton.

Source/WebCore:

In r228697, we introduced a new set of boosted text autosizing constants tuned for extra zoom mode, which are
currently hard-coded as default values in SettingsBase. However, we've since identified cases where clients may
want to opt in or out of boosted text autosizing values and just use the existing values.

This replaces settings to adjust text autosizing constants with a flag to enable or disable boosted text
autosizing; when changed, we update all three text autosizing parameters to their default or boosted values, and
then trigger style recalculation.

Test: TextAutosizingBoost.ChangeAutosizingBoostAtRuntime

* page/Settings.yaml:
* page/SettingsBase.cpp:
(WebCore::SettingsBase::shouldEnableTextAutosizingBoostChanged):
(WebCore::SettingsBase::defaultOneLineTextMultiplierCoefficient): Deleted.
(WebCore::SettingsBase::defaultMultiLineTextMultiplierCoefficient): Deleted.
(WebCore::SettingsBase::defaultMaxTextAutosizingScaleIncrease): Deleted.

Changed these to constant values instead of helper functions, and also introduced boosted text autosizing
constants for use in extra zoom mode.

* page/SettingsBase.h:
(WebCore::SettingsBase::oneLineTextMultiplierCoefficient const):
(WebCore::SettingsBase::multiLineTextMultiplierCoefficient const):
(WebCore::SettingsBase::maxTextAutosizingScaleIncrease const):
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::extraDefaultStyleSheet):

Tweak the stylesheet to make `-webkit-text-size-adjust: auto` overridable by web content. Adding the !important
is breaking many websites that positioned text such that it is positioned within layout viewport bounds without
text autosizing.

Source/WebKit:

Add a private web view preference to switch between normal and boosted text autosizing mode. By default, we use
normal text autosizing values.

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setShouldEnableTextAutosizingBoost:]):
(-[WKPreferences _shouldEnableTextAutosizingBoost]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Tools:

Add an API test to check that toggling the boosted text autosizing preference causes text to lay out larger than
it would with normal text autosizing.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (230038 => 230039)


--- trunk/Source/WebCore/ChangeLog	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebCore/ChangeLog	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1,3 +1,42 @@
+2018-03-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Extra zoom mode] Make boosted text autosizing values switchable at runtime
+        https://bugs.webkit.org/show_bug.cgi?id=184092
+        <rdar://problem/38939917>
+
+        Reviewed by Tim Horton.
+
+        In r228697, we introduced a new set of boosted text autosizing constants tuned for extra zoom mode, which are
+        currently hard-coded as default values in SettingsBase. However, we've since identified cases where clients may
+        want to opt in or out of boosted text autosizing values and just use the existing values.
+
+        This replaces settings to adjust text autosizing constants with a flag to enable or disable boosted text
+        autosizing; when changed, we update all three text autosizing parameters to their default or boosted values, and
+        then trigger style recalculation.
+
+        Test: TextAutosizingBoost.ChangeAutosizingBoostAtRuntime
+
+        * page/Settings.yaml:
+        * page/SettingsBase.cpp:
+        (WebCore::SettingsBase::shouldEnableTextAutosizingBoostChanged):
+        (WebCore::SettingsBase::defaultOneLineTextMultiplierCoefficient): Deleted.
+        (WebCore::SettingsBase::defaultMultiLineTextMultiplierCoefficient): Deleted.
+        (WebCore::SettingsBase::defaultMaxTextAutosizingScaleIncrease): Deleted.
+
+        Changed these to constant values instead of helper functions, and also introduced boosted text autosizing
+        constants for use in extra zoom mode.
+
+        * page/SettingsBase.h:
+        (WebCore::SettingsBase::oneLineTextMultiplierCoefficient const):
+        (WebCore::SettingsBase::multiLineTextMultiplierCoefficient const):
+        (WebCore::SettingsBase::maxTextAutosizingScaleIncrease const):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::extraDefaultStyleSheet):
+
+        Tweak the stylesheet to make `-webkit-text-size-adjust: auto` overridable by web content. Adding the !important
+        is breaking many websites that positioned text such that it is positioned within layout viewport bounds without
+        text autosizing.
+
 2018-03-28  Brent Fulgham  <bfulg...@apple.com>
 
         Avoid uninitialized mach ports

Modified: trunk/Source/WebCore/page/Settings.yaml (230038 => 230039)


--- trunk/Source/WebCore/page/Settings.yaml	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebCore/page/Settings.yaml	2018-03-28 18:55:40 UTC (rev 230039)
@@ -715,21 +715,12 @@
   getter: isTouchEventEmulationEnabled
   conditional: TOUCH_EVENTS
 
-oneLineTextMultiplierCoefficient:
-  type: float
-  initial: defaultOneLineTextMultiplierCoefficient()
+shouldEnableTextAutosizingBoost:
+  type: bool
+  initial: false
   conditional: TEXT_AUTOSIZING
+  onChange: shouldEnableTextAutosizingBoostChanged
 
-multiLineTextMultiplierCoefficient:
-  type: float
-  initial: defaultMultiLineTextMultiplierCoefficient()
-  conditional: TEXT_AUTOSIZING
-
-maxTextAutosizingScaleIncrease:
-  type: float
-  initial: defaultMaxTextAutosizingScaleIncrease()
-  conditional: TEXT_AUTOSIZING
-
 mediaCapabilitiesEnabled:
   initial: false
 

Modified: trunk/Source/WebCore/page/SettingsBase.cpp (230038 => 230039)


--- trunk/Source/WebCore/page/SettingsBase.cpp	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebCore/page/SettingsBase.cpp	2018-03-28 18:55:40 UTC (rev 230039)
@@ -94,33 +94,6 @@
 }
 #endif
 
-float SettingsBase::defaultOneLineTextMultiplierCoefficient()
-{
-#if ENABLE(EXTRA_ZOOM_MODE)
-    return 2.23125f;
-#else
-    return 1.7f;
-#endif
-}
-
-float SettingsBase::defaultMultiLineTextMultiplierCoefficient()
-{
-#if ENABLE(EXTRA_ZOOM_MODE)
-    return 2.48125f;
-#else
-    return 1.95f;
-#endif
-}
-
-float SettingsBase::defaultMaxTextAutosizingScaleIncrease()
-{
-#if ENABLE(EXTRA_ZOOM_MODE)
-    return 5.0f;
-#else
-    return 1.7f;
-#endif
-}
-
 bool SettingsBase::defaultDownloadableBinaryFontsEnabled()
 {
 #if ENABLE(EXTRA_ZOOM_MODE)
@@ -333,6 +306,23 @@
     Page::refreshPlugins(false);
 }
 
+#if ENABLE(TEXT_AUTOSIZING)
+
+void SettingsBase::shouldEnableTextAutosizingBoostChanged()
+{
+    if (!m_page)
+        return;
+
+    bool boostAutosizing = m_page->settings().shouldEnableTextAutosizingBoost();
+    m_oneLineTextMultiplierCoefficient = boostAutosizing ? boostedOneLineTextMultiplierCoefficient : defaultOneLineTextMultiplierCoefficient;
+    m_multiLineTextMultiplierCoefficient = boostAutosizing ? boostedMultiLineTextMultiplierCoefficient : defaultMultiLineTextMultiplierCoefficient;
+    m_maxTextAutosizingScaleIncrease = boostAutosizing ? boostedMaxTextAutosizingScaleIncrease : defaultMaxTextAutosizingScaleIncrease;
+
+    setNeedsRecalcStyleInAllFrames();
+}
+
+#endif
+
 void SettingsBase::userStyleSheetLocationChanged()
 {
     if (m_page)

Modified: trunk/Source/WebCore/page/SettingsBase.h (230038 => 230039)


--- trunk/Source/WebCore/page/SettingsBase.h	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebCore/page/SettingsBase.h	2018-03-28 18:55:40 UTC (rev 230039)
@@ -114,14 +114,19 @@
 
     WEBCORE_EXPORT static bool defaultTextAutosizingEnabled();
     WEBCORE_EXPORT static float defaultMinimumZoomFontSize();
-    WEBCORE_EXPORT static float defaultOneLineTextMultiplierCoefficient();
-    WEBCORE_EXPORT static float defaultMultiLineTextMultiplierCoefficient();
-    WEBCORE_EXPORT static float defaultMaxTextAutosizingScaleIncrease();
     WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled();
 
     static const unsigned defaultMaximumHTMLParserDOMTreeDepth = 512;
     static const unsigned defaultMaximumRenderTreeDepth = 512;
 
+#if ENABLE(TEXT_AUTOSIZING)
+    constexpr static const float boostedOneLineTextMultiplierCoefficient = 2.23125f;
+    constexpr static const float boostedMultiLineTextMultiplierCoefficient = 2.48125f;
+    constexpr static const float boostedMaxTextAutosizingScaleIncrease = 5.0f;
+    constexpr static const float defaultOneLineTextMultiplierCoefficient = 1.7f;
+    constexpr static const float defaultMultiLineTextMultiplierCoefficient = 1.95f;
+    constexpr static const float defaultMaxTextAutosizingScaleIncrease = 1.7f;
+#endif
 
     WEBCORE_EXPORT void setStandardFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
     WEBCORE_EXPORT const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const;
@@ -150,6 +155,12 @@
     WEBCORE_EXPORT void setLayoutInterval(Seconds);
     Seconds layoutInterval() const { return m_layoutInterval; }
 
+#if ENABLE(TEXT_AUTOSIZING)
+    float oneLineTextMultiplierCoefficient() const { return m_oneLineTextMultiplierCoefficient; }
+    float multiLineTextMultiplierCoefficient() const { return m_multiLineTextMultiplierCoefficient; }
+    float maxTextAutosizingScaleIncrease() const { return m_maxTextAutosizingScaleIncrease; }
+#endif
+
     WEBCORE_EXPORT static const String& defaultMediaContentTypesRequiringHardwareSupport();
     WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const Vector<ContentType>&);
     WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const String&);
@@ -178,6 +189,9 @@
     void hiddenPageDOMTimerThrottlingStateChanged();
     void hiddenPageCSSAnimationSuspensionEnabledChanged();
     void resourceUsageOverlayVisibleChanged();
+#if ENABLE(TEXT_AUTOSIZING)
+    void shouldEnableTextAutosizingBoostChanged();
+#endif
 
     Page* m_page;
 
@@ -188,6 +202,12 @@
     Timer m_setImageLoadingSettingsTimer;
 
     Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport;
+
+#if ENABLE(TEXT_AUTOSIZING)
+    float m_oneLineTextMultiplierCoefficient { defaultOneLineTextMultiplierCoefficient };
+    float m_multiLineTextMultiplierCoefficient { defaultMultiLineTextMultiplierCoefficient };
+    float m_maxTextAutosizingScaleIncrease { defaultMaxTextAutosizingScaleIncrease };
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (230038 => 230039)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1803,7 +1803,7 @@
 
 String RenderThemeIOS::extraDefaultStyleSheet()
 {
-    return ASCIILiteral("* { -webkit-text-size-adjust: auto !important; -webkit-hyphens: auto !important; }");
+    return ASCIILiteral("* { -webkit-text-size-adjust: auto; -webkit-hyphens: auto !important; }");
 }
 
 #endif

Modified: trunk/Source/WebKit/ChangeLog (230038 => 230039)


--- trunk/Source/WebKit/ChangeLog	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebKit/ChangeLog	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1,3 +1,20 @@
+2018-03-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Extra zoom mode] Make boosted text autosizing values switchable at runtime
+        https://bugs.webkit.org/show_bug.cgi?id=184092
+        <rdar://problem/38939917>
+
+        Reviewed by Tim Horton.
+
+        Add a private web view preference to switch between normal and boosted text autosizing mode. By default, we use
+        normal text autosizing values.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setShouldEnableTextAutosizingBoost:]):
+        (-[WKPreferences _shouldEnableTextAutosizingBoost]):
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
 2018-03-28  Brent Fulgham  <bfulg...@apple.com>
 
         Avoid uninitialized mach ports

Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (230038 => 230039)


--- trunk/Source/WebKit/Shared/WebPreferences.yaml	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1038,6 +1038,11 @@
   defaultValue: 0
   category: debug
 
+ShouldEnableTextAutosizingBoost:
+  type: bool
+  defaultValue: false
+  condition: ENABLE(TEXT_AUTOSIZING)
+
 ShouldAllowUserInstalledFonts:
   type: bool
   defaultValue: true

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (230038 => 230039)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1229,6 +1229,22 @@
     return _preferences->domPasteAllowed();
 }
 
+- (void)_setShouldEnableTextAutosizingBoost:(BOOL)shouldEnableTextAutosizingBoost
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    _preferences->setShouldEnableTextAutosizingBoost(shouldEnableTextAutosizingBoost);
+#endif
+}
+
+- (BOOL)_shouldEnableTextAutosizingBoost
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    return _preferences->shouldEnableTextAutosizingBoost();
+#else
+    return NO;
+#endif
+}
+
 @end
 
 #endif // WK_API_ENABLED

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (230038 => 230039)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2018-03-28 18:55:40 UTC (rev 230039)
@@ -134,6 +134,8 @@
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 
+@property (nonatomic, setter=_setShouldEnableTextAutosizingBoost:) BOOL _shouldEnableTextAutosizingBoost WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 @property (nonatomic, setter=_setJavaEnabledForLocalFiles:) BOOL _javaEnabledForLocalFiles WK_API_AVAILABLE(macosx(WK_MAC_TBA));

Modified: trunk/Tools/ChangeLog (230038 => 230039)


--- trunk/Tools/ChangeLog	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Tools/ChangeLog	2018-03-28 18:55:40 UTC (rev 230039)
@@ -1,3 +1,18 @@
+2018-03-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Extra zoom mode] Make boosted text autosizing values switchable at runtime
+        https://bugs.webkit.org/show_bug.cgi?id=184092
+        <rdar://problem/38939917>
+
+        Reviewed by Tim Horton.
+
+        Add an API test to check that toggling the boosted text autosizing preference causes text to lay out larger than
+        it would with normal text autosizing.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm: Added.
+        (TEST):
+
 2018-03-28  Zalan Bujtas  <za...@apple.com>
 
         [LayoutReloaded] InlineFormattingContext::_handleText should support runs on multiple lines

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (230038 => 230039)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-03-28 18:40:00 UTC (rev 230038)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-03-28 18:55:40 UTC (rev 230039)
@@ -754,6 +754,7 @@
 		F44D06451F395C26001A0E29 /* editor-state-test-harness.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F44D06441F395C0D001A0E29 /* editor-state-test-harness.html */; };
 		F44D06471F39627A001A0E29 /* EditorStateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44D06461F395C4D001A0E29 /* EditorStateTests.mm */; };
 		F44D064A1F3962F2001A0E29 /* EditingTestHarness.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44D06491F3962E3001A0E29 /* EditingTestHarness.mm */; };
+		F45033F5206BEC95009351CE /* TextAutosizingBoost.mm in Sources */ = {isa = PBXBuildFile; fileRef = F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */; };
 		F4512E131F60C44600BB369E /* DataTransferItem-getAsEntry.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */; };
 		F4517B672054C49500C26721 /* TestWKWebViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4517B662054C49500C26721 /* TestWKWebViewController.mm */; };
 		F4517B7F2055101B00C26721 /* ClassMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4517B692054E0AC00C26721 /* ClassMethodSwizzler.mm */; };
@@ -1902,6 +1903,7 @@
 		F44D06461F395C4D001A0E29 /* EditorStateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorStateTests.mm; sourceTree = "<group>"; };
 		F44D06481F3962E3001A0E29 /* EditingTestHarness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingTestHarness.h; sourceTree = "<group>"; };
 		F44D06491F3962E3001A0E29 /* EditingTestHarness.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditingTestHarness.mm; sourceTree = "<group>"; };
+		F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextAutosizingBoost.mm; sourceTree = "<group>"; };
 		F4512E121F60C43400BB369E /* DataTransferItem-getAsEntry.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "DataTransferItem-getAsEntry.html"; sourceTree = "<group>"; };
 		F4517B652054C49500C26721 /* TestWKWebViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestWKWebViewController.h; sourceTree = "<group>"; };
 		F4517B662054C49500C26721 /* TestWKWebViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestWKWebViewController.mm; sourceTree = "<group>"; };
@@ -2350,6 +2352,7 @@
 				574F55CE204D3763002948C6 /* LocalAuthenticator.mm */,
 				7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
 				F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */,
+				F45033F4206BEC95009351CE /* TextAutosizingBoost.mm */,
 				F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
 				2E1B881E2040EE5300FFF6A9 /* ViewportSizingTests.mm */,
 				514958BD1F7427AC00E87BAD /* WKWebViewAutofillTests.mm */,
@@ -3710,6 +3713,7 @@
 				7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */,
 				2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */,
 				F4517B672054C49500C26721 /* TestWKWebViewController.mm in Sources */,
+				F45033F5206BEC95009351CE /* TextAutosizingBoost.mm in Sources */,
 				93E6193B1F931B3A00AF245E /* TextCodec.cpp in Sources */,
 				CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
 				7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm (0 => 230039)


--- trunk/Tools/TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm	2018-03-28 18:55:40 UTC (rev 230039)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 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 "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+
+#if WK_API_ENABLED && PLATFORM(IOS)
+
+TEST(TextAutosizingBoost, ChangeAutosizingBoostAtRuntime)
+{
+    static NSString *testMarkup = @"<meta name='viewport' content='width=device-width'><body style='margin: 0'><span id='top'>Hello world</span><br><span id='bottom'>Goodbye world</span></body>";
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 960, 360)]);
+    [webView synchronouslyLoadHTMLString:testMarkup];
+    CGSize regularSize {
+        roundf([[webView objectByEvaluatingJavaScript:@"document.getElementById('top').getBoundingClientRect().width"] floatValue]),
+        roundf([[webView objectByEvaluatingJavaScript:@"document.getElementById('top').getBoundingClientRect().height"] floatValue])
+    };
+
+    [webView configuration].preferences._shouldEnableTextAutosizingBoost = YES;
+    [webView waitForNextPresentationUpdate];
+    CGSize boostedSize {
+        roundf([[webView objectByEvaluatingJavaScript:@"document.getElementById('top').getBoundingClientRect().width"] floatValue]),
+        roundf([[webView objectByEvaluatingJavaScript:@"document.getElementById('top').getBoundingClientRect().height"] floatValue])
+    };
+
+    EXPECT_EQ(125, regularSize.width);
+    EXPECT_EQ(30, regularSize.height);
+    EXPECT_EQ(159, boostedSize.width);
+    EXPECT_EQ(38, boostedSize.height);
+}
+
+#endif // WK_API_ENABLED && PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to