Source/WebCore:
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2020 19:19:39 +0000 (19:19 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2020 19:19:39 +0000 (19:19 +0000)
[iPadOS] -webkit-text-size-adjust:percentage doesn't work
https://bugs.webkit.org/show_bug.cgi?id=212122
<rdar://problem/54560875>

Reviewed by Wenson Hsieh.

We've gotten many bug reports that -webkit-text-size-adjust:X% no longer works in
WebKit on iPads. We don't want to just start honoring the value, because our
testing indicates that, with desktop-class browsing on iPad, more sites work better
when we don't honor percentages. However, if Safari is using the mobile content mode,
or if a native app has local content, it should be possible to get the old behavior
of honoring percentages.

This patch adds a new Setting, idempotentModeAutosizingOnlyHonorsPercentages, which
is hooked up to the desktop-class browsing feature. When
WebPageProxy::effectiveContentModeAfterAdjustingPolicies() determines that the
WebContentMode::Mobile mode should be used, it sets the new setting, which
causes idempotent text autosizing mode to have the same behavior that WKWebViews
on iPadOS used to have: -w-t-s-a:auto and -w-t-s-a:none have no effect, but
-w-t-s-a:X% is honored. This affects both Safari and WKWebView apps.

If a native app wants the old behavior, they can set
WKWebpagePreferences.preferredContentMode = WKContentModeMobile to force the old
iPad behavior. It's expected that apps with legacy content would be doing this
anyway.

Tests: fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html
       TestWebKitAPI.PreferredContentMode.IdempotentModeAutosizingOnlyHonorsPercentages

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::applyPoliciesToSettings):
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setIdempotentModeAutosizingOnlyHonorsPercentages):
(WebCore::DocumentLoader::idempotentModeAutosizingOnlyHonorsPercentages const):
* page/Settings.yaml:
* style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjustmentForTextAutosizing):
* style/StyleBuilderCustom.h:
(WebCore::Style::computeBaseSpecifiedFontSize):
* style/StyleBuilderState.cpp:
(WebCore::Style::BuilderState::updateFontForTextSizeAdjust):

Source/WebKit:
[iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
https://bugs.webkit.org/show_bug.cgi?id=212122
<rdar://problem/54560875>

Reviewed by Wenson Hsieh.

* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::encode const):
(WebKit::WebsitePoliciesData::decode):
(WebKit::WebsitePoliciesData::applyToDocumentLoader):
* Shared/WebsitePoliciesData.h:
* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::copy const):
(API::WebsitePolicies::data):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):

Tools:
[iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
https://bugs.webkit.org/show_bug.cgi?id=212122
<rdar://problem/54560875>

Reviewed by Wenson Hsieh.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/idempotent-mode-autosizing-only-honors-percentages.html: Added.
* TestWebKitAPI/ios/PreferredContentMode.mm:

LayoutTests:
[iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
https://bugs.webkit.org/show_bug.cgi?id=212122
<rdar://problem/54560875>

Reviewed by Wenson Hsieh.

Update existing idempotent autosizing tests to force desktop mode.
Also add idempotent-percentage.html which doesn't force any mode.

* fast/text-autosizing/ios/idempotentmode/css-exposure.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidate-special-cases.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-identity.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-reaches-stable-state.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing.html:
* fast/text-autosizing/ios/idempotentmode/idempotent-percentage-expected.txt: Added.
* fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html: Added.
* fast/text-autosizing/ios/idempotentmode/line-height-boosting.html:
* fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html:

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text-autosizing/ios/idempotentmode/css-exposure.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidate-special-cases.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-identity.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-reaches-stable-state.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage-expected.txt [new file with mode: 0644]
LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html [new file with mode: 0644]
LayoutTests/fast/text-autosizing/ios/idempotentmode/line-height-boosting.html
LayoutTests/fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/page/Settings.yaml
Source/WebCore/style/StyleAdjuster.cpp
Source/WebCore/style/StyleBuilderCustom.h
Source/WebCore/style/StyleBuilderState.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebsitePoliciesData.cpp
Source/WebKit/Shared/WebsitePoliciesData.h
Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp
Source/WebKit/UIProcess/API/APIWebsitePolicies.h
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit/idempotent-mode-autosizing-only-honors-percentages.html [new file with mode: 0644]
Tools/TestWebKitAPI/ios/PreferredContentMode.mm

index 70c748f..01aff62 100644 (file)
@@ -1,3 +1,26 @@
+2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
+        https://bugs.webkit.org/show_bug.cgi?id=212122
+        <rdar://problem/54560875>
+
+        Reviewed by Wenson Hsieh.
+
+        Update existing idempotent autosizing tests to force desktop mode.
+        Also add idempotent-percentage.html which doesn't force any mode.
+
+        * fast/text-autosizing/ios/idempotentmode/css-exposure.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-after-changing-initial-scale.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidate-special-cases.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-identity.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-reaches-stable-state.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing.html:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-percentage-expected.txt: Added.
+        * fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html: Added.
+        * fast/text-autosizing/ios/idempotentmode/line-height-boosting.html:
+        * fast/text-autosizing/ios/idempotentmode/viewport-change-relayout.html:
+
 2020-05-20  Ryan Haddad  <ryanhaddad@apple.com>
 
         Disable support for BeforeLoadEvent
index 2013485..17b25a9 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ contentMode=desktop ] -->
 <html>
 <head>
 <script src="../../../../resources/js-test-pre.js"></script>
index 87745d2..9f85609 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true contentMode=mobile ] -->
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="width=device-width, initial-scale=1">
@@ -154,4 +154,4 @@ addEventListener("load", async () => {
         </div>
     </div>
 </body>
-</html>
\ No newline at end of file
+</html>
index 6c107c3..3011b96 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="initial-scale=0.6666">
index 8a74ad6..ccbf4de 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="initial-scale=0.6666">
index 34215c5..c86a34b 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="width=device-width, initial-scale=1">
index b4e1d76..50379c3 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <script src="../../../../resources/js-test.js"></script>
index fc0c678..0dc6aa6 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="initial-scale=0.6666">
diff --git a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage-expected.txt b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage-expected.txt
new file mode 100644 (file)
index 0000000..8d33aa0
--- /dev/null
@@ -0,0 +1,15 @@
+PASS result is 12
+PASS result is 6
+PASS result is 6
+PASS result is 12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Test
+Test
+Test
+Test
+Test
+Test
+Test
+Test
diff --git a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html
new file mode 100644 (file)
index 0000000..04bfbac
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
+<html>
+<head>
+<meta name="viewport" content="initial-scale=0.6666">
+<script>
+if (window.internals) {
+    window.internals.settings.setTextAutosizingEnabled(true);
+    window.internals.settings.setTextAutosizingUsesIdempotentMode(true);
+    window.internals.settings.setIdempotentModeAutosizingOnlyHonorsPercentages(true);
+}
+</script>
+<script src="../../../../resources/js-test.js"></script>
+</head>
+<body>
+<div style="background: green;"><span id="target" style="font-size: 12px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 12px;">Test</span></div>
+<div style="background: green;"><span id="target2" style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span id="target3" style="-webkit-text-size-adjust: none; font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span id="target4" style="-webkit-text-size-adjust: 200%; font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+<script>
+let target = document.getElementById("target");
+target.offsetWidth;
+let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+shouldBeEqualToNumber("result", 12);
+
+target = document.getElementById("target2");
+target.offsetWidth;
+result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+shouldBeEqualToNumber("result", 6);
+
+target = document.getElementById("target3");
+target.offsetWidth;
+result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+shouldBeEqualToNumber("result", 6);
+
+target = document.getElementById("target4");
+target.offsetWidth;
+result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+shouldBeEqualToNumber("result", 12);
+</script>
+</body>
+</html>
index 79babd6..00aaf18 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta name="viewport" content="initial-scale=0.6666">
index 314063a..a15cddf 100644 (file)
@@ -1,4 +1,4 @@
-<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true contentMode=desktop ] -->
 <html>
 <head>
 <meta id="viewport" name="viewport" content="width=400, initial-scale=1">
index 7284372..6af4899 100644 (file)
@@ -1,3 +1,47 @@
+2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iPadOS] -webkit-text-size-adjust:percentage doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=212122
+        <rdar://problem/54560875>
+
+        Reviewed by Wenson Hsieh.
+
+        We've gotten many bug reports that -webkit-text-size-adjust:X% no longer works in
+        WebKit on iPads. We don't want to just start honoring the value, because our
+        testing indicates that, with desktop-class browsing on iPad, more sites work better
+        when we don't honor percentages. However, if Safari is using the mobile content mode,
+        or if a native app has local content, it should be possible to get the old behavior
+        of honoring percentages.
+
+        This patch adds a new Setting, idempotentModeAutosizingOnlyHonorsPercentages, which
+        is hooked up to the desktop-class browsing feature. When
+        WebPageProxy::effectiveContentModeAfterAdjustingPolicies() determines that the
+        WebContentMode::Mobile mode should be used, it sets the new setting, which
+        causes idempotent text autosizing mode to have the same behavior that WKWebViews
+        on iPadOS used to have: -w-t-s-a:auto and -w-t-s-a:none have no effect, but
+        -w-t-s-a:X% is honored. This affects both Safari and WKWebView apps.
+
+        If a native app wants the old behavior, they can set
+        WKWebpagePreferences.preferredContentMode = WKContentModeMobile to force the old
+        iPad behavior. It's expected that apps with legacy content would be doing this
+        anyway.
+
+        Tests: fast/text-autosizing/ios/idempotentmode/idempotent-percentage.html
+               TestWebKitAPI.PreferredContentMode.IdempotentModeAutosizingOnlyHonorsPercentages
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::applyPoliciesToSettings):
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setIdempotentModeAutosizingOnlyHonorsPercentages):
+        (WebCore::DocumentLoader::idempotentModeAutosizingOnlyHonorsPercentages const):
+        * page/Settings.yaml:
+        * style/StyleAdjuster.cpp:
+        (WebCore::Style::Adjuster::adjustmentForTextAutosizing):
+        * style/StyleBuilderCustom.h:
+        (WebCore::Style::computeBaseSpecifiedFontSize):
+        * style/StyleBuilderState.cpp:
+        (WebCore::Style::BuilderState::updateFontForTextSizeAdjust):
+
 2020-05-20  ChangSeok Oh  <changseok@webkit.org>
 
         Move the TextStream logging definition in VisibleSelection.cpp to the outside of the TREE_DEBUGGING guard
index 77790ce..1670ebd 100644 (file)
@@ -1239,6 +1239,9 @@ void DocumentLoader::applyPoliciesToSettings()
 #if ENABLE(MEDIA_SOURCE)
     m_frame->settings().setMediaSourceEnabled(m_mediaSourcePolicy == MediaSourcePolicy::Default ? Settings::platformDefaultMediaSourceEnabled() : m_mediaSourcePolicy == MediaSourcePolicy::Enable);
 #endif
+#if ENABLE(TEXT_AUTOSIZING)
+    m_frame->settings().setIdempotentModeAutosizingOnlyHonorsPercentages(m_idempotentModeAutosizingOnlyHonorsPercentages);
+#endif
 }
 
 void DocumentLoader::attachToFrame(Frame& frame)
index 048c1d5..c694e0e 100644 (file)
@@ -414,6 +414,9 @@ public:
     void setAllowContentChangeObserverQuirk(bool allow) { m_allowContentChangeObserverQuirk = allow; }
     bool allowContentChangeObserverQuirk() const { return m_allowContentChangeObserverQuirk; }
 
+    void setIdempotentModeAutosizingOnlyHonorsPercentages(bool idempotentModeAutosizingOnlyHonorsPercentages) { m_idempotentModeAutosizingOnlyHonorsPercentages = idempotentModeAutosizingOnlyHonorsPercentages; }
+    bool idempotentModeAutosizingOnlyHonorsPercentages() const { return m_idempotentModeAutosizingOnlyHonorsPercentages; }
+
 #if ENABLE(SERVICE_WORKER)
     WEBCORE_EXPORT bool setControllingServiceWorkerRegistration(ServiceWorkerRegistrationData&&);
 #endif
@@ -630,6 +633,7 @@ private:
     String m_customUserAgent;
     String m_customUserAgentAsSiteSpecificQuirks;
     bool m_allowContentChangeObserverQuirk { false };
+    bool m_idempotentModeAutosizingOnlyHonorsPercentages { false };
     String m_customNavigatorPlatform;
     bool m_userContentExtensionsEnabled { true };
 #if ENABLE(DEVICE_ORIENTATION)
index 0b49ad7..7907cfe 100644 (file)
@@ -471,6 +471,10 @@ textAutosizingUsesIdempotentMode:
   initial: false
   onChange: setNeedsRecalcStyleInAllFrames
   conditional: TEXT_AUTOSIZING
+idempotentModeAutosizingOnlyHonorsPercentages:
+  initial: false
+  onChange: setNeedsRecalcStyleInAllFrames
+  conditional: TEXT_AUTOSIZING
 
 subpixelAntialiasedLayerTextEnabled:
   initial: false
index 7fb4d2b..140625f 100644 (file)
@@ -637,7 +637,9 @@ auto Adjuster::adjustmentForTextAutosizing(const RenderStyle& style, const Eleme
     AdjustmentForTextAutosizing adjustmentForTextAutosizing;
 
     auto& document = element.document();
-    if (!document.settings().textAutosizingEnabled() || !document.settings().textAutosizingUsesIdempotentMode())
+    if (!document.settings().textAutosizingEnabled()
+        || !document.settings().textAutosizingUsesIdempotentMode()
+        || document.settings().idempotentModeAutosizingOnlyHonorsPercentages())
         return adjustmentForTextAutosizing;
 
     auto newStatus = AutosizeStatus::computeStatus(style);
index ea15157..da06bc5 100644 (file)
@@ -621,7 +621,8 @@ static inline float computeBaseSpecifiedFontSize(const Document& document, const
     if (frame && style.textZoom() != TextZoom::Reset)
         result *= frame->textZoomFactor();
     result *= style.effectiveZoom();
-    if (percentageAutosizingEnabled && !document.settings().textAutosizingUsesIdempotentMode())
+    if (percentageAutosizingEnabled
+        && (!document.settings().textAutosizingUsesIdempotentMode() || document.settings().idempotentModeAutosizingOnlyHonorsPercentages()))
         result *= style.textSizeAdjust().multiplier();
     return result;
 }
index b15a4e9..8f9979b 100644 (file)
@@ -375,7 +375,9 @@ void BuilderState::updateFontForTextSizeAdjust()
 {
     if (m_style.textSizeAdjust().isAuto()
         || !document().settings().textAutosizingEnabled()
-        || (document().settings().textAutosizingUsesIdempotentMode() && !m_style.textSizeAdjust().isNone()))
+        || (document().settings().textAutosizingUsesIdempotentMode()
+            && !m_style.textSizeAdjust().isNone()
+            && !document().settings().idempotentModeAutosizingOnlyHonorsPercentages()))
         return;
 
     auto newFontDescription = m_style.fontDescription();
index 4c3cf08..5389c5b 100644 (file)
@@ -1,3 +1,23 @@
+2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
+        https://bugs.webkit.org/show_bug.cgi?id=212122
+        <rdar://problem/54560875>
+
+        Reviewed by Wenson Hsieh.
+
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::encode const):
+        (WebKit::WebsitePoliciesData::decode):
+        (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+        * Shared/WebsitePoliciesData.h:
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::copy const):
+        (API::WebsitePolicies::data):
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::effectiveContentModeAfterAdjustingPolicies):
+
 2020-05-20  Kate Cheney  <katherine_cheney@apple.com>
 
         REGRESSION (r261892) [ Mac Debug ] 4 API tests failing related to ResourceLoadStatistics
index 92b655c..a8c601d 100644 (file)
@@ -54,6 +54,7 @@ void WebsitePoliciesData::encode(IPC::Encoder& encoder) const
     encoder << allowContentChangeObserverQuirk;
     encoder << allowsContentJavaScript;
     encoder << mouseEventPolicy;
+    encoder << idempotentModeAutosizingOnlyHonorsPercentages;
 }
 
 Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
@@ -140,6 +141,11 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
     if (!mouseEventPolicy)
         return WTF::nullopt;
 
+    Optional<bool> idempotentModeAutosizingOnlyHonorsPercentages;
+    decoder >> idempotentModeAutosizingOnlyHonorsPercentages;
+    if (!idempotentModeAutosizingOnlyHonorsPercentages)
+        return WTF::nullopt;
+
     return { {
         WTFMove(*contentBlockersEnabled),
         WTFMove(*allowedAutoplayQuirks),
@@ -159,6 +165,7 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
         WTFMove(*allowContentChangeObserverQuirk),
         WTFMove(*allowsContentJavaScript),
         WTFMove(*mouseEventPolicy),
+        WTFMove(*idempotentModeAutosizingOnlyHonorsPercentages),
     } };
 }
 
@@ -281,6 +288,7 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
     }
 
     documentLoader.setAllowContentChangeObserverQuirk(websitePolicies.allowContentChangeObserverQuirk);
+    documentLoader.setIdempotentModeAutosizingOnlyHonorsPercentages(websitePolicies.idempotentModeAutosizingOnlyHonorsPercentages);
 
     auto* frame = documentLoader.frame();
     if (!frame)
index 57aa822..3a8c850 100644 (file)
@@ -70,6 +70,7 @@ struct WebsitePoliciesData {
     bool allowContentChangeObserverQuirk { false };
     WebCore::AllowsContentJavaScript allowsContentJavaScript { WebCore::AllowsContentJavaScript::Yes };
     WebCore::MouseEventPolicy mouseEventPolicy { WebCore::MouseEventPolicy::Default };
+    bool idempotentModeAutosizingOnlyHonorsPercentages { false };
 
     void encode(IPC::Encoder&) const;
     static Optional<WebsitePoliciesData> decode(IPC::Decoder&);
index aa56c0a..7191693 100644 (file)
@@ -56,6 +56,7 @@ Ref<WebsitePolicies> WebsitePolicies::copy() const
     policies->setAllowContentChangeObserverQuirk(m_allowContentChangeObserverQuirk);
     policies->setWebsiteDataStore(m_websiteDataStore.get());
     policies->setUserContentController(m_userContentController.get());
+    policies->setIdempotentModeAutosizingOnlyHonorsPercentages(m_idempotentModeAutosizingOnlyHonorsPercentages);
     
     Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields;
     legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size());
@@ -116,7 +117,8 @@ WebKit::WebsitePoliciesData WebsitePolicies::data()
         m_legacyOverflowScrollingTouchPolicy,
         m_allowContentChangeObserverQuirk,
         m_allowsContentJavaScript,
-        m_mouseEventPolicy
+        m_mouseEventPolicy,
+        m_idempotentModeAutosizingOnlyHonorsPercentages
     };
 }
 
index 48b19a5..cde0753 100644 (file)
@@ -128,6 +128,9 @@ public:
     WebCore::MouseEventPolicy mouseEventPolicy() const { return m_mouseEventPolicy; }
     void setMouseEventPolicy(WebCore::MouseEventPolicy policy) { m_mouseEventPolicy = policy; }
 
+    bool idempotentModeAutosizingOnlyHonorsPercentages() const { return m_idempotentModeAutosizingOnlyHonorsPercentages; }
+    void setIdempotentModeAutosizingOnlyHonorsPercentages(bool idempotentModeAutosizingOnlyHonorsPercentages) { m_idempotentModeAutosizingOnlyHonorsPercentages = idempotentModeAutosizingOnlyHonorsPercentages; }
+
 private:
     bool m_contentBlockersEnabled { true };
     OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks;
@@ -153,6 +156,7 @@ private:
     bool m_allowContentChangeObserverQuirk { false };
     WebCore::AllowsContentJavaScript m_allowsContentJavaScript { WebCore::AllowsContentJavaScript::Yes };
     WebCore::MouseEventPolicy m_mouseEventPolicy { WebCore::MouseEventPolicy::Default };
+    bool m_idempotentModeAutosizingOnlyHonorsPercentages { false };
 };
 
 } // namespace API
index 24b57ea..9ba0f8f 100644 (file)
@@ -1511,6 +1511,7 @@ WebContentMode WebPageProxy::effectiveContentModeAfterAdjustingPolicies(API::Web
 
     if (!useDesktopBrowsingMode) {
         policies.setAllowContentChangeObserverQuirk(true);
+        policies.setIdempotentModeAutosizingOnlyHonorsPercentages(true);
         return WebContentMode::Mobile;
     }
 
index 025256d..3aca390 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iPadOS] -webkit-text-size-adjust:percentage doesn't work in native apps
+        https://bugs.webkit.org/show_bug.cgi?id=212122
+        <rdar://problem/54560875>
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/idempotent-mode-autosizing-only-honors-percentages.html: Added.
+        * TestWebKitAPI/ios/PreferredContentMode.mm:
+
 2020-05-20  Lauro Moura  <lmoura@igalia.com>
 
         [WPE][WebDriver] Allow subviews to create new views
index 5b48555..511706c 100644 (file)
                1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */; };
                1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; };
                1CACADA1230620AE0007D54C /* WKWebViewOpaque.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */; };
+               1CC80CEA2474F249004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CC80CE92474F1F7004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html */; };
                1CE6FAC32320267C00E48F6E /* rich-color-filtered.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CE6FAC12320264F00E48F6E /* rich-color-filtered.html */; };
                1CF59AE221E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF59AE021E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm */; };
                1CF59AE321E68932006E37EC /* ForceLightAppearanceInBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF59ADF21E68925006E37EC /* ForceLightAppearanceInBundle.mm */; };
                                5110FCF11E01CD64006F8D0B /* IDBIndexUpgradeToV2.html in Copy Resources */,
                                937B569E23CD23DB002AE640 /* IDBObjectStoreInfoUpgrade.sqlite3 in Copy Resources */,
                                93BCBC8423CC6F4400CA2221 /* IDBObjectStoreInfoUpgradeToV2.html in Copy Resources */,
+                               1CC80CEA2474F249004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html in Copy Resources */,
                                F41AB9A41EF4696B0083FA08 /* image-and-contenteditable.html in Copy Resources */,
                                F4E0A2B42122402B00AF7C7F /* image-and-file-upload.html in Copy Resources */,
                                F41AB9A51EF4696B0083FA08 /* image-and-textarea.html in Copy Resources */,
                1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
                1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewOpaque.mm; sourceTree = "<group>"; };
                1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = "<group>"; };
+               1CC80CE92474F1F7004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "idempotent-mode-autosizing-only-honors-percentages.html"; sourceTree = "<group>"; };
                1CE6FAC12320264F00E48F6E /* rich-color-filtered.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "rich-color-filtered.html"; sourceTree = "<group>"; };
                1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRetainPtr.cpp; sourceTree = "<group>"; };
                1CF59ADF21E68925006E37EC /* ForceLightAppearanceInBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ForceLightAppearanceInBundle.mm; sourceTree = "<group>"; };
                                4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
                                4A410F4D19AF7BEF002EBAC5 /* getUserMediaAudioVideoCapture.html */,
                                BCBD372E125ABBE600D2C29F /* icon.png */,
+                               1CC80CE92474F1F7004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html */,
                                CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
                                C9B4AD2B1ECA6F7600F5FEA0 /* js-autoplay-audio.html */,
                                C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */,
                                7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */,
                                7C8BFF7123C0107A00C009B3 /* HexNumber.cpp in Sources */,
                                7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */,
-                               FE2BCDC72470FDA300DEC33B /* StdLibExtras.cpp in Sources */,
                                53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */,
                                7CEB62AB223609DE0069CBB0 /* IteratorRange.cpp in Sources */,
                                7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */,
                                7C83DF3D1D0A590C00FEBCF3 /* SetForScope.cpp in Sources */,
                                7C83DF2A1D0A590C00FEBCF3 /* SHA1.cpp in Sources */,
                                E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */,
+                               FE2BCDC72470FDA300DEC33B /* StdLibExtras.cpp in Sources */,
                                7C83DF321D0A590C00FEBCF3 /* StringBuilder.cpp in Sources */,
                                7CD4C26E1E2C0E6E00929470 /* StringConcatenate.cpp in Sources */,
                                7C83DF361D0A590C00FEBCF3 /* StringHasher.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit/idempotent-mode-autosizing-only-honors-percentages.html b/Tools/TestWebKitAPI/Tests/WebKit/idempotent-mode-autosizing-only-honors-percentages.html
new file mode 100644 (file)
index 0000000..ebe08d4
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+function run1() {
+    let target = document.getElementById("target");
+    target.offsetWidth;
+    let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+    return result;
+}
+function run2() {
+    let target = document.getElementById("target2");
+    target.offsetWidth;
+    let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+    return result;
+}
+function run3() {
+    let target = document.getElementById("target3");
+    target.offsetWidth;
+    let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+    return result;
+}
+function run4() {
+    let target = document.getElementById("target4");
+    target.offsetWidth;
+    let result = Number.parseInt(window.getComputedStyle(target).getPropertyValue("font-size"));
+    return result;
+}
+</script>
+</head>
+<body>
+<div style="background: green;"><span id="target" style="font-size: 12px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 12px;">Test</span></div>
+<div style="background: green;"><span id="target2" style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span id="target3" style="-webkit-text-size-adjust: none; font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+<div style="background: green;"><span id="target4" style="-webkit-text-size-adjust: 200%; font-size: 6px;">Test</span></div>
+<div style="background: green;"><span style="font-size: 6px;">Test</span></div>
+</body>
+</html>
index fb60a6a..96f2455 100644 (file)
@@ -435,6 +435,19 @@ TEST(PreferredContentMode, ApplicationNameForDesktopUserAgent)
     }
 }
 
+TEST(PreferredContentMode, IdempotentModeAutosizingOnlyHonorsPercentages)
+{
+    IPadUserInterfaceSwizzler iPadUserInterface;
+    {
+        auto [webView, delegate] = setUpWebViewForPreferredContentModeTesting<WKWebView>(WKContentModeMobile);
+        [webView loadTestPageNamed:@"idempotent-mode-autosizing-only-honors-percentages" andExpectEffectiveContentMode:WKContentModeMobile withPolicyDecisionHandler:nil];
+        EXPECT_EQ(static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"run1()"]).intValue, 12);
+        EXPECT_EQ(static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"run2()"]).intValue, 6);
+        EXPECT_EQ(static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"run3()"]).intValue, 6);
+        EXPECT_EQ(static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"run4()"]).intValue, 12);
+    }
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS_FAMILY)