Title: [276228] trunk
Revision
276228
Author
[email protected]
Date
2021-04-18 05:45:33 -0700 (Sun, 18 Apr 2021)

Log Message

The implicit aspect-ratio from width and height attributes with float value is not accurate enough
https://bugs.webkit.org/show_bug.cgi?id=224664

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

The aspect ratio test case with width "0.8" and height "0.2" in img-aspect-ratio.html has passed. This patch doesn't change the behavior of
the original aspect ratio test case(`assert_ratio(images[5], 133/106)`) which is related to bug 206161.

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

Source/WebCore:

The width and height attributes should impact the aspect ratio only not the intrinsic size which should be from the content.
Since computeAspectRatioInformationForRenderBox doesn't change the intrinsic size now, so we can remove it from computePreferredLogicalWidths.

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Width and height attributes change intrinsicRatio only, not intrinsicSize.
(WebCore::RenderReplaced::computePreferredLogicalWidths): computeAspectRatioInformationForRenderBox doesn't change intrinsicSize now, so we can remove this.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276227 => 276228)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-18 08:35:29 UTC (rev 276227)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-18 12:45:33 UTC (rev 276228)
@@ -1,3 +1,15 @@
+2021-04-18  Cathie Chen  <[email protected]>
+
+        The implicit aspect-ratio from width and height attributes with float value is not accurate enough
+        https://bugs.webkit.org/show_bug.cgi?id=224664
+
+        Reviewed by Darin Adler.
+
+        The aspect ratio test case with width "0.8" and height "0.2" in img-aspect-ratio.html has passed. This patch doesn't change the behavior of
+        the original aspect ratio test case(`assert_ratio(images[5], 133/106)`) which is related to bug 206161.
+
+        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
+
 2021-04-17  Tim Nguyen  <[email protected]>
 
         Add support for inline-{start/end} values to float & clear properties

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt (276227 => 276228)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt	2021-04-18 08:35:29 UTC (rev 276227)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt	2021-04-18 12:45:33 UTC (rev 276228)
@@ -1,4 +1,4 @@
 
 
-FAIL Image width and height attributes are used to infer aspect-ratio assert_approx_equals: expected 4 +/- 0.001 but got 4.166666666666667
+FAIL Image width and height attributes are used to infer aspect-ratio assert_approx_equals: expected 1.2547169811320755 +/- 0.001 but got 1.25
 

Modified: trunk/Source/WebCore/ChangeLog (276227 => 276228)


--- trunk/Source/WebCore/ChangeLog	2021-04-18 08:35:29 UTC (rev 276227)
+++ trunk/Source/WebCore/ChangeLog	2021-04-18 12:45:33 UTC (rev 276228)
@@ -1,3 +1,17 @@
+2021-04-18  Cathie Chen  <[email protected]>
+
+        The implicit aspect-ratio from width and height attributes with float value is not accurate enough
+        https://bugs.webkit.org/show_bug.cgi?id=224664
+
+        Reviewed by Darin Adler.
+
+        The width and height attributes should impact the aspect ratio only not the intrinsic size which should be from the content.
+        Since computeAspectRatioInformationForRenderBox doesn't change the intrinsic size now, so we can remove it from computePreferredLogicalWidths.
+
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Width and height attributes change intrinsicRatio only, not intrinsicSize.
+        (WebCore::RenderReplaced::computePreferredLogicalWidths): computeAspectRatioInformationForRenderBox doesn't change intrinsicSize now, so we can remove this.
+
 2021-04-17  Yusuke Suzuki  <[email protected]>
 
         Use binary-search in LocaleToScriptMapping

Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (276227 => 276228)


--- trunk/Source/WebCore/rendering/RenderReplaced.cpp	2021-04-18 08:35:29 UTC (rev 276227)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp	2021-04-18 12:45:33 UTC (rev 276228)
@@ -502,10 +502,11 @@
         if (!is<RenderImage>(*this) || !downcast<RenderImage>(*this).cachedImage())
             return;
 
-        intrinsicSize.setWidth(parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::widthAttr)).valueOr(0));
-        intrinsicSize.setHeight(parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::heightAttr)).valueOr(0));
-        if (intrinsicSize.isEmpty())
-            return;
+        double attributeWidth = parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::widthAttr)).valueOr(0);
+        double attributeHeight = parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::heightAttr)).valueOr(0);
+        if (attributeWidth > 0 && attributeHeight > 0)
+            intrinsicRatio = attributeWidth / attributeHeight;
+        return;
     }
 
     intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
@@ -672,14 +673,9 @@
 
     // 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()) {
-        double intrinsicRatio = 0;
-        FloatSize constrainedSize;
-        // For images with explicit width/height this updates the instrinsic size as a side effect.
-        computeAspectRatioInformationForRenderBox(embeddedContentBox(), constrainedSize, intrinsicRatio);
-
+    if (style().logicalWidth().isPercentOrCalculated())
         computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
-    } else
+    else
         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);
 
     const RenderStyle& styleToUse = style();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to