REGRESSION (r254669): Expand media button doesn't work on first try on photos on...
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Mar 2020 17:44:44 +0000 (17:44 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Mar 2020 17:44:44 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209590
<rdar://problem/60461809>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:

Failure here shifts to a different subtest. This one uses fractional pixels and LayoutUnit accuracy is not sufficient to compute the exact ratio.

Source/WebCore:

Image intrinsic size computed from width/height attributes is ignored during preferred width computation
(used for float sizing in this case). This creates a mismatch between layout and preferred width computation,
causing the final image size to be miscomputed.

Test: fast/images/preferred-width-computation-with-attribute-intrinsic-size.html

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computePreferredLogicalWidths const):

Compute attribute based intrinsic size already during preferred width computation if needed.

LayoutTests:

* fast/images/preferred-width-computation-with-attribute-intrinsic-size-expected.html: Added.
* fast/images/preferred-width-computation-with-attribute-intrinsic-size.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size-expected.html [new file with mode: 0644]
LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderReplaced.cpp

index f8372ab..f9ac754 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-26  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (r254669): Expand media button doesn't work on first try on photos on reddit.com
+        https://bugs.webkit.org/show_bug.cgi?id=209590
+        <rdar://problem/60461809>
+
+        Reviewed by Darin Adler.
+
+        * fast/images/preferred-width-computation-with-attribute-intrinsic-size-expected.html: Added.
+        * fast/images/preferred-width-computation-with-attribute-intrinsic-size.html: Added.
+
 2020-03-26  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, make GC a bit less aggressive on test to decrease runtime.
diff --git a/LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size-expected.html b/LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size-expected.html
new file mode 100644 (file)
index 0000000..6bb072e
--- /dev/null
@@ -0,0 +1 @@
+<div style="float:left; border:10px solid blue"><img src=resources/red-100x100.png style="width:100%; height:auto; border:10px solid green"></div>
diff --git a/LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size.html b/LayoutTests/fast/images/preferred-width-computation-with-attribute-intrinsic-size.html
new file mode 100644 (file)
index 0000000..90561f2
--- /dev/null
@@ -0,0 +1 @@
+<div style="float:left; border:10px solid blue"><img src=resources/red-100x100.png width=100 height=100 style="width:100%; height:auto; border:10px solid green"></div>
index cfd1f70..9a3ce6d 100644 (file)
@@ -1,3 +1,15 @@
+2020-03-26  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (r254669): Expand media button doesn't work on first try on photos on reddit.com
+        https://bugs.webkit.org/show_bug.cgi?id=209590
+        <rdar://problem/60461809>
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
+
+        Failure here shifts to a different subtest. This one uses fractional pixels and LayoutUnit accuracy is not sufficient to compute the exact ratio.
+
 2020-03-25  Frank Yang  <guowei_yang@apple.com>
         
         WebKit uses Alphabetic Baseline when "-webkit-text-orientation" is "mixed" in Vertical Writing Mode 
index cd43356..c815b95 100644 (file)
@@ -1,3 +1,22 @@
+2020-03-26  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (r254669): Expand media button doesn't work on first try on photos on reddit.com
+        https://bugs.webkit.org/show_bug.cgi?id=209590
+        <rdar://problem/60461809>
+
+        Reviewed by Darin Adler.
+
+        Image intrinsic size computed from width/height attributes is ignored during preferred width computation
+        (used for float sizing in this case). This creates a mismatch between layout and preferred width computation,
+        causing the final image size to be miscomputed.
+
+        Test: fast/images/preferred-width-computation-with-attribute-intrinsic-size.html
+
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computePreferredLogicalWidths const):
+
+        Compute attribute based intrinsic size already during preferred width computation if needed.
+
 2020-03-26  Nikos Mouchtaris  <nmouchtaris@apple.com>
 
         Remove manual redacting of billing contact after wallet fix for rdar://problem/59075234
index 3607467..ae05a14 100644 (file)
@@ -590,9 +590,14 @@ void RenderReplaced::computePreferredLogicalWidths()
 
     // We cannot resolve any percent logical width here as the available logical
     // width may not be set on our containing block.
-    if (style().logicalWidth().isPercentOrCalculated())
+    if (style().logicalWidth().isPercentOrCalculated()) {
+        double intrinsicRatio = 0;
+        FloatSize constrainedSize;
+        // For images with explicit width/height this updates the instrinsic size as a side effect.
+        computeAspectRatioInformationForRenderBox(embeddedContentBox(), constrainedSize, intrinsicRatio);
+
         computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
-    else
+    else
         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);
 
     const RenderStyle& styleToUse = style();