[Text autosizing] [iPadOS] Paragraph text on the front page of LinkedIn.com is not boosted
https://bugs.webkit.org/show_bug.cgi?id=199827
<rdar://problem/53152660>

Reviewed by Zalan Bujtas.

Source/WebCore:

After r247467, we try to avoid boosting some text that might cause vertical overflow due to line height
increasing inside a container that expects a fixed integer number of lines. However, in the case of
linkedin.com, the line height specified is a fixed value of 26px, which greatly exceeds the specified font size
of 14px. In this case, it's safe to boost font size, since doing so would not affect the line height at all.

To handle this case, don't avoid text autosizing due to the "fixed number of lines" heuristic if the line height
is fixed, and is much larger than the font size.

Test: fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html

* rendering/style/TextSizeAdjustment.cpp:
(WebCore::AutosizeStatus::updateStatus):

LayoutTests:

Add a new test case, inspired by paragraph text in a post on linkedin.com. This text should get autosized.

* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt:
* fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247484 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f77d092..ffd7769 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2019-07-16  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Text autosizing] [iPadOS] Paragraph text on the front page of LinkedIn.com is not boosted
+        https://bugs.webkit.org/show_bug.cgi?id=199827
+        <rdar://problem/53152660>
+
+        Reviewed by Zalan Bujtas.
+
+        Add a new test case, inspired by paragraph text in a post on linkedin.com. This text should get autosized.
+
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt:
+        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html:
+
 2019-07-16  Rob Buis  <rbuis@igalia.com>
 
         Remove support for beforeload on link=prefetch
diff --git a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt
index 464d944..cb7bf68 100644
--- a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt
+++ b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates-expected.txt
@@ -34,6 +34,8 @@
 PASS result is 12
 Checking target18:
 PASS result is 12
+Checking target19:
+PASS result is >= 13
 PASS successfullyParsed is true
 
 TEST COMPLETE
@@ -56,3 +58,4 @@
 Test 
 Test 
 Test
+Test
diff --git a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html
index 8c588ef..8a74ad6 100644
--- a/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html
+++ b/LayoutTests/fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html
@@ -35,6 +35,7 @@
     <br>
     <span>Test</span>
 </div>
+<div style="background: green; line-height: 20px; max-height: 20px; font-size: 12px;" id="target19">Test</div>
 <script>
 let result;
 function check(name, shouldGetAutosized) {
@@ -77,6 +78,7 @@
 check("target16", true);
 check("target17", false);
 check("target18", false);
+check("target19", true);
 </script>
 <script src="../../../../resources/js-test-post.js"></script>
 </body>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 1c39ffc..c0d7c77 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2019-07-16  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Text autosizing] [iPadOS] Paragraph text on the front page of LinkedIn.com is not boosted
+        https://bugs.webkit.org/show_bug.cgi?id=199827
+        <rdar://problem/53152660>
+
+        Reviewed by Zalan Bujtas.
+
+        After r247467, we try to avoid boosting some text that might cause vertical overflow due to line height
+        increasing inside a container that expects a fixed integer number of lines. However, in the case of
+        linkedin.com, the line height specified is a fixed value of 26px, which greatly exceeds the specified font size
+        of 14px. In this case, it's safe to boost font size, since doing so would not affect the line height at all.
+
+        To handle this case, don't avoid text autosizing due to the "fixed number of lines" heuristic if the line height
+        is fixed, and is much larger than the font size.
+
+        Test: fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-candidates.html
+
+        * rendering/style/TextSizeAdjustment.cpp:
+        (WebCore::AutosizeStatus::updateStatus):
+
 2019-07-16  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Cancel ongoing content observation when tap is failed/cancelled
diff --git a/Source/WebCore/rendering/style/TextSizeAdjustment.cpp b/Source/WebCore/rendering/style/TextSizeAdjustment.cpp
index 0528027..f13877d 100644
--- a/Source/WebCore/rendering/style/TextSizeAdjustment.cpp
+++ b/Source/WebCore/rendering/style/TextSizeAdjustment.cpp
@@ -53,6 +53,10 @@
         if (!style.lineHeight().isSpecified() || style.whiteSpace() == WhiteSpace::NoWrap)
             return false;
 
+        const float maximumDifferenceBetweenFixedLineHeightAndFontSize = 6;
+        if (style.lineHeight().isFixed() && style.lineHeight().value() - style.fontDescription().specifiedSize() > maximumDifferenceBetweenFixedLineHeightAndFontSize)
+            return false;
+
         Optional<Length> heightOrMaxHeightAsLength;
         if (style.height().isFixed() && style.maxHeight().isAuto())
             heightOrMaxHeightAsLength = style.height();