[Extra zoom mode] Make boosted text autosizing values switchable at runtime
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 18:55:40 +0000 (18:55 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Mar 2018 18:55:40 +0000 (18:55 +0000)
commit21163afedc1ac52f0f04b5eb5e7fc4b8b8ab02d7
tree927fb50b72baa013ca4f2ceaaf7f0413daed0151
parent0af34ba8aef0f3098d7f6570308e9ae5899fd810
[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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230039 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.yaml
Source/WebCore/page/SettingsBase.cpp
Source/WebCore/page/SettingsBase.h
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm [new file with mode: 0644]