⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276228 in webkit


Ignore:
Timestamp:
Apr 18, 2021, 5:45:33 AM (5 years ago)
Author:
cathiechen
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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r276216 r276228  
     12021-04-18  Cathie Chen  <cathiechen@igalia.com>
     2
     3        The implicit aspect-ratio from width and height attributes with float value is not accurate enough
     4        https://bugs.webkit.org/show_bug.cgi?id=224664
     5
     6        Reviewed by Darin Adler.
     7
     8        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
     9        the original aspect ratio test case(`assert_ratio(images[5], 133/106)`) which is related to bug 206161.
     10
     11        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
     12
    1132021-04-17  Tim Nguyen  <ntim@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt

    r267646 r276228  
    11
    22
    3 FAIL Image width and height attributes are used to infer aspect-ratio assert_approx_equals: expected 4 +/- 0.001 but got 4.166666666666667
     3FAIL Image width and height attributes are used to infer aspect-ratio assert_approx_equals: expected 1.2547169811320755 +/- 0.001 but got 1.25
    44
  • trunk/Source/WebCore/ChangeLog

    r276225 r276228  
     12021-04-18  Cathie Chen  <cathiechen@igalia.com>
     2
     3        The implicit aspect-ratio from width and height attributes with float value is not accurate enough
     4        https://bugs.webkit.org/show_bug.cgi?id=224664
     5
     6        Reviewed by Darin Adler.
     7
     8        The width and height attributes should impact the aspect ratio only not the intrinsic size which should be from the content.
     9        Since computeAspectRatioInformationForRenderBox doesn't change the intrinsic size now, so we can remove it from computePreferredLogicalWidths.
     10
     11        * rendering/RenderReplaced.cpp:
     12        (WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Width and height attributes change intrinsicRatio only, not intrinsicSize.
     13        (WebCore::RenderReplaced::computePreferredLogicalWidths): computeAspectRatioInformationForRenderBox doesn't change intrinsicSize now, so we can remove this.
     14
    1152021-04-17  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r275772 r276228  
    503503            return;
    504504
    505         intrinsicSize.setWidth(parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::widthAttr)).valueOr(0));
    506         intrinsicSize.setHeight(parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::heightAttr)).valueOr(0));
    507         if (intrinsicSize.isEmpty())
    508             return;
     505        double attributeWidth = parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::widthAttr)).valueOr(0);
     506        double attributeHeight = parseValidHTMLFloatingPointNumber(node->getAttribute(HTMLNames::heightAttr)).valueOr(0);
     507        if (attributeWidth > 0 && attributeHeight > 0)
     508            intrinsicRatio = attributeWidth / attributeHeight;
     509        return;
    509510    }
    510511
     
    673674    // We cannot resolve any percent logical width here as the available logical
    674675    // width may not be set on our containing block.
    675     if (style().logicalWidth().isPercentOrCalculated()) {
    676         double intrinsicRatio = 0;
    677         FloatSize constrainedSize;
    678         // For images with explicit width/height this updates the instrinsic size as a side effect.
    679         computeAspectRatioInformationForRenderBox(embeddedContentBox(), constrainedSize, intrinsicRatio);
    680 
     676    if (style().logicalWidth().isPercentOrCalculated())
    681677        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    682     } else
     678    else
    683679        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);
    684680
Note: See TracChangeset for help on using the changeset viewer.