<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277997] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277997">277997</a></dd>
<dt>Author</dt> <dd>cathiechen@igalia.com</dd>
<dt>Date</dt> <dd>2021-05-24 22:39:12 -0700 (Mon, 24 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use the parsed width and height attributes as a presentational hint for aspect-ratio CSS property
https://bugs.webkit.org/show_bug.cgi?id=217529

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Update the expected results of test_computed_style which are passed now.

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

Source/WebCore:

The feature "mapping attributes width and height to aspect ratio" currently is handled by RenderReplaced::computeIntrinsicRatioInformation.
However, per [1], the non-negative width and height attributes are expected to be used as a presentational hint for the aspect-ratio property.
This patch addes HTMLElement::applyAspectRatioFromWidthAndHeightAttributesToStyle to apply the attributes to m_presentationAttributeStyle.
Also this patch supports the feature for <video> and <input> with type="image".

[1] https://html.spec.whatwg.org/#map-to-the-aspect-ratio-property-(using-dimension-rules)

* html/HTMLElement.cpp:
(WebCore::HTMLElement::applyAspectRatioFromWidthAndHeightAttributesToStyle): Apply attributes width / height to aspectRatio of style if they aren't negative.
* html/HTMLElement.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::collectStyleForPresentationAttribute): Use attributes width and height as a presentational hint for aspect-ratio.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::collectStyleForPresentationAttribute): If isImageButton(), collect attributes width and height as aspect-ratio of m_presentationAttributeStyle.
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::collectStyleForPresentationAttribute): Ditto.
* rendering/RenderImage.cpp:
(WebCore::RenderImage::computeIntrinsicRatioInformation const): The intrinsicRatio is logicalAspectRatio()
if error image is not showing alt text.
(WebCore::RenderImage::canMapWidthHeightToAspectRatio const): Deleted. Remove the legacy code.
* rendering/RenderImage.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Ditto.
(WebCore::RenderReplaced::intrinsicAspectRatioFromWidthHeight const): Deleted. Ditto.
* rendering/RenderReplaced.h:
(WebCore::RenderReplaced::canMapWidthHeightToAspectRatio const): Deleted. Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlrenderingreplacedelementsattributesforembeddedcontentandimagesimgaspectratioexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlrenderingreplacedelementsattributesforembeddedcontentandimagesvideoaspectratioexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementh">trunk/Source/WebCore/html/HTMLElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLImageElementcpp">trunk/Source/WebCore/html/HTMLImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementcpp">trunk/Source/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLVideoElementcpp">trunk/Source/WebCore/html/HTMLVideoElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImagecpp">trunk/Source/WebCore/rendering/RenderImage.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImageh">trunk/Source/WebCore/rendering/RenderImage.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderReplacedcpp">trunk/Source/WebCore/rendering/RenderReplaced.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderReplacedh">trunk/Source/WebCore/rendering/RenderReplaced.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-05-24  Cathie Chen  <cathiechen@igalia.com>
+
+        Use the parsed width and height attributes as a presentational hint for aspect-ratio CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=217529
+
+        Reviewed by Antti Koivisto.
+
+        Update the expected results of test_computed_style which are passed now.
+
+        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
+        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt:
+
</ins><span class="cx"> 2021-05-24  Cameron McCormack  <heycam@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add missing operators.woff that a few WPTs reference.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlrenderingreplacedelementsattributesforembeddedcontentandimagesimgaspectratioexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt      2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt 2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -4,20 +4,20 @@
</span><span class="cx"> PASS Create, append and test immediately: <img> with attributes width=250, height=100
</span><span class="cx"> PASS Create, append and test immediately: <img> with attributes width=0.8, height=0.2
</span><span class="cx"> PASS Create, append and test immediately: <img> with attributes width=50% height=25%
</span><del>-FAIL Computed style test: img with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
-FAIL Computed style test: input with {"type":"image","width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
</del><ins>+PASS Computed style test: img with {"width":"10","height":"20"}
+PASS Computed style test: input with {"type":"image","width":"10","height":"20"}
</ins><span class="cx"> PASS Computed style test: input with {"type":"submit","width":"10","height":"20"}
</span><del>-FAIL Computed style test: img with {"width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
-FAIL Computed style test: input with {"type":"image","width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
</del><ins>+PASS Computed style test: img with {"width":"0","height":"1"}
+PASS Computed style test: input with {"type":"image","width":"0","height":"1"}
</ins><span class="cx"> PASS Computed style test: input with {"type":"submit","width":"0","height":"1"}
</span><del>-FAIL Computed style test: img with {"width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
-FAIL Computed style test: input with {"type":"image","width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
</del><ins>+PASS Computed style test: img with {"width":"1","height":"0"}
+PASS Computed style test: input with {"type":"image","width":"1","height":"0"}
</ins><span class="cx"> PASS Computed style test: input with {"type":"submit","width":"1","height":"0"}
</span><del>-FAIL Computed style test: img with {"width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
-FAIL Computed style test: input with {"type":"image","width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
</del><ins>+PASS Computed style test: img with {"width":"0","height":"0"}
+PASS Computed style test: input with {"type":"image","width":"0","height":"0"}
</ins><span class="cx"> PASS Computed style test: input with {"type":"submit","width":"0","height":"0"}
</span><del>-FAIL Computed style test: img with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
-FAIL Computed style test: input with {"type":"image","width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
</del><ins>+PASS Computed style test: img with {"width":"0.5","height":"1.5"}
+PASS Computed style test: input with {"type":"image","width":"0.5","height":"1.5"}
</ins><span class="cx"> PASS Computed style test: input with {"type":"submit","width":"0.5","height":"1.5"}
</span><span class="cx"> PASS Computed style test: img with {"width":null,"height":null}
</span><span class="cx"> PASS Computed style test: input with {"type":"image","width":null,"height":null}
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlrenderingreplacedelementsattributesforembeddedcontentandimagesvideoaspectratioexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt    2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt       2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-FAIL Video width and height attributes are not used to infer aspect-ratio assert_approx_equals: expected 2.5 +/- 0.001 but got Infinity
-FAIL Computed style test: video with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
-FAIL Computed style test: video with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
</del><ins>+PASS Video width and height attributes are not used to infer aspect-ratio
+PASS Computed style test: video with {"width":"10","height":"20"}
+PASS Computed style test: video with {"width":"0.5","height":"1.5"}
</ins><span class="cx"> PASS Computed style test: video with {"width":"0","height":"1"}
</span><span class="cx"> PASS Computed style test: video with {"width":"1","height":"0"}
</span><span class="cx"> PASS Computed style test: video with {"width":"0","height":"0"}
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/ChangeLog      2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2021-05-24  Cathie Chen  <cathiechen@igalia.com>
+
+        Use the parsed width and height attributes as a presentational hint for aspect-ratio CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=217529
+
+        Reviewed by Antti Koivisto.
+
+        The feature "mapping attributes width and height to aspect ratio" currently is handled by RenderReplaced::computeIntrinsicRatioInformation.
+        However, per [1], the non-negative width and height attributes are expected to be used as a presentational hint for the aspect-ratio property.
+        This patch addes HTMLElement::applyAspectRatioFromWidthAndHeightAttributesToStyle to apply the attributes to m_presentationAttributeStyle.
+        Also this patch supports the feature for <video> and <input> with type="image".
+
+        [1] https://html.spec.whatwg.org/#map-to-the-aspect-ratio-property-(using-dimension-rules)
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::applyAspectRatioFromWidthAndHeightAttributesToStyle): Apply attributes width / height to aspectRatio of style if they aren't negative.
+        * html/HTMLElement.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::collectStyleForPresentationAttribute): Use attributes width and height as a presentational hint for aspect-ratio.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::collectStyleForPresentationAttribute): If isImageButton(), collect attributes width and height as aspect-ratio of m_presentationAttributeStyle.
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::collectStyleForPresentationAttribute): Ditto.
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::computeIntrinsicRatioInformation const): The intrinsicRatio is logicalAspectRatio()
+        if error image is not showing alt text.
+        (WebCore::RenderImage::canMapWidthHeightToAspectRatio const): Deleted. Remove the legacy code.
+        * rendering/RenderImage.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Ditto.
+        (WebCore::RenderReplaced::intrinsicAspectRatioFromWidthHeight const): Deleted. Ditto.
+        * rendering/RenderReplaced.h:
+        (WebCore::RenderReplaced::canMapWidthHeightToAspectRatio const): Deleted. Ditto.
+
</ins><span class="cx"> 2021-05-24  Commit Queue  <commit-queue@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r277867.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/html/HTMLElement.cpp   2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "CSSMarkup.h"
</span><span class="cx"> #include "CSSPropertyNames.h"
</span><span class="cx"> #include "CSSValueKeywords.h"
</span><ins>+#include "CSSValueList.h"
</ins><span class="cx"> #include "CSSValuePool.h"
</span><span class="cx"> #include "Chrome.h"
</span><span class="cx"> #include "ChromeClient.h"
</span><span class="lines">@@ -620,6 +621,28 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLElement::applyAspectRatioFromWidthAndHeightAttributesToStyle(MutableStyleProperties& style)
+{
+    if (!document().settings().aspectRatioOfImgFromWidthAndHeightEnabled())
+        return;
+
+    double width = parseValidHTMLFloatingPointNumber(attributeWithoutSynchronization(widthAttr)).valueOr(-1);
+    if (width < 0)
+        return;
+    double height = parseValidHTMLFloatingPointNumber(attributeWithoutSynchronization(heightAttr)).valueOr(-1);
+    if (height < 0)
+        return;
+
+    auto ratioList = CSSValueList::createSlashSeparated();
+    ratioList->append(CSSValuePool::singleton().createValue(width, CSSUnitType::CSS_NUMBER));
+    ratioList->append(CSSValuePool::singleton().createValue(height, CSSUnitType::CSS_NUMBER));
+    auto list = CSSValueList::createSpaceSeparated();
+    list->append(CSSValuePool::singleton().createIdentifierValue(CSSValueAuto));
+    list->append(ratioList);
+
+    style.setProperty(CSSPropertyAspectRatio, RefPtr<CSSValue>(WTFMove(list)));
+}
+
</ins><span class="cx"> void HTMLElement::applyAlignmentAttributeToStyle(const AtomString& alignment, MutableStyleProperties& style)
</span><span class="cx"> {
</span><span class="cx">     // Vertical alignment with respect to the current baseline of the text
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.h (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.h  2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/html/HTMLElement.h     2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -154,6 +154,7 @@
</span><span class="cx">     void addHTMLLengthToStyle(MutableStyleProperties&, CSSPropertyID, const String& value);
</span><span class="cx">     void addHTMLColorToStyle(MutableStyleProperties&, CSSPropertyID, const String& color);
</span><span class="cx"> 
</span><ins>+    void applyAspectRatioFromWidthAndHeightAttributesToStyle(MutableStyleProperties&);
</ins><span class="cx">     void applyAlignmentAttributeToStyle(const AtomString&, MutableStyleProperties&);
</span><span class="cx">     void applyBorderAttributeToStyle(const AtomString&, MutableStyleProperties&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLImageElement.cpp   2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp      2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -115,11 +115,13 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLImageElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style)
</span><span class="cx"> {
</span><del>-    if (name == widthAttr)
</del><ins>+    if (name == widthAttr) {
</ins><span class="cx">         addHTMLLengthToStyle(style, CSSPropertyWidth, value);
</span><del>-    else if (name == heightAttr)
</del><ins>+        applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
+    } else if (name == heightAttr) {
</ins><span class="cx">         addHTMLLengthToStyle(style, CSSPropertyHeight, value);
</span><del>-    else if (name == borderAttr)
</del><ins>+        applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
+    } else if (name == borderAttr)
</ins><span class="cx">         applyBorderAttributeToStyle(value, style);
</span><span class="cx">     else if (name == vspaceAttr) {
</span><span class="cx">         addHTMLLengthToStyle(style, CSSPropertyMarginTop, value);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp   2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp      2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -707,9 +707,13 @@
</span><span class="cx">     } else if (name == widthAttr) {
</span><span class="cx">         if (m_inputType->shouldRespectHeightAndWidthAttributes())
</span><span class="cx">             addHTMLLengthToStyle(style, CSSPropertyWidth, value);
</span><ins>+        if (isImageButton())
+            applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
</ins><span class="cx">     } else if (name == heightAttr) {
</span><span class="cx">         if (m_inputType->shouldRespectHeightAndWidthAttributes())
</span><span class="cx">             addHTMLLengthToStyle(style, CSSPropertyHeight, value);
</span><ins>+        if (isImageButton())
+            applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
</ins><span class="cx">     } else if (name == borderAttr && isImageButton())
</span><span class="cx">         applyBorderAttributeToStyle(value, style);
</span><span class="cx">     else
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLVideoElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLVideoElement.cpp   2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp      2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -113,11 +113,13 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLVideoElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style)
</span><span class="cx"> {
</span><del>-    if (name == widthAttr)
</del><ins>+    if (name == widthAttr) {
</ins><span class="cx">         addHTMLLengthToStyle(style, CSSPropertyWidth, value);
</span><del>-    else if (name == heightAttr)
</del><ins>+        applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
+    } else if (name == heightAttr) {
</ins><span class="cx">         addHTMLLengthToStyle(style, CSSPropertyHeight, value);
</span><del>-    else
</del><ins>+        applyAspectRatioFromWidthAndHeightAttributesToStyle(style);
+    } else
</ins><span class="cx">         HTMLMediaElement::collectStyleForPresentationAttribute(name, value, style);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.cpp   2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp      2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -842,12 +842,6 @@
</span><span class="cx">     clearChildNeedsLayout();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderImage::canMapWidthHeightToAspectRatio() const
-{
-    // The aspectRatioOfImgFromWidthAndHeight only applies to <img>.
-    return is<HTMLImageElement>(element()) && !isShowingAltText();
-}
-
</del><span class="cx"> void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!shouldApplySizeContainment(*this));
</span><span class="lines">@@ -865,11 +859,11 @@
</span><span class="cx"> 
</span><span class="cx">     // Don't compute an intrinsic ratio to preserve historical WebKit behavior if we're painting alt text and/or a broken image.
</span><span class="cx">     if (shouldDisplayBrokenImageIcon()) {
</span><del>-        if (!style().hasAspectRatio()) {
-            intrinsicRatio = intrinsicAspectRatioFromWidthHeight().valueOr(1);
-            return;
-        }
-        intrinsicRatio = 1;
</del><ins>+        if (settings().aspectRatioOfImgFromWidthAndHeightEnabled()
+            && style().aspectRatioType() == AspectRatioType::AutoAndRatio && !isShowingAltText())
+            intrinsicRatio = style().logicalAspectRatio();
+        else
+            intrinsicRatio = 1;
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.h (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.h     2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/rendering/RenderImage.h        2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -103,8 +103,6 @@
</span><span class="cx">         imageChanged(imageResource().imagePtr());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool canMapWidthHeightToAspectRatio() const override;
-
</del><span class="cx"> private:
</span><span class="cx">     const char* renderName() const override { return "RenderImage"; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderReplacedcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderReplaced.cpp        2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp   2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -478,23 +478,6 @@
</span><span class="cx">         borderLeft() + paddingLeft(), borderRight() + paddingRight());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Optional<double> RenderReplaced::intrinsicAspectRatioFromWidthHeight() const
-{
-    if (!settings().aspectRatioOfImgFromWidthAndHeightEnabled())
-        return Optional<double>();
-
-    if (!canMapWidthHeightToAspectRatio())
-        return Optional<double>();
-
-    ASSERT(element());
-    double attributeWidth = parseValidHTMLFloatingPointNumber(element()->getAttribute(HTMLNames::widthAttr)).valueOr(0);
-    double attributeHeight = parseValidHTMLFloatingPointNumber(element()->getAttribute(HTMLNames::heightAttr)).valueOr(0);
-    if (attributeWidth > 0 && attributeHeight > 0)
-        return attributeWidth / attributeHeight;
-
-    return Optional<double>();
-}
-
</del><span class="cx"> void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
</span><span class="cx"> {
</span><span class="cx">     // If there's an embeddedContentBox() of a remote, referenced document available, this code-path should never be used.
</span><span class="lines">@@ -510,10 +493,8 @@
</span><span class="cx">     if (!hasIntrinsicAspectRatio())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (intrinsicSize.isEmpty()) {
-        intrinsicRatio = intrinsicAspectRatioFromWidthHeight().valueOr(0);
</del><ins>+    if (intrinsicSize.isEmpty())
</ins><span class="cx">         return;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderReplacedh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderReplaced.h (277996 => 277997)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderReplaced.h  2021-05-25 04:13:26 UTC (rev 277996)
+++ trunk/Source/WebCore/rendering/RenderReplaced.h     2021-05-25 05:39:12 UTC (rev 277997)
</span><span class="lines">@@ -63,10 +63,6 @@
</span><span class="cx"> 
</span><span class="cx">     void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const final;
</span><span class="cx"> 
</span><del>-    // This function determines if the object is allowed to compute aspect ratio from attributes width and height.
-    virtual bool canMapWidthHeightToAspectRatio() const { return false; }
-    Optional<double> intrinsicAspectRatioFromWidthHeight() const;
-
</del><span class="cx">     virtual LayoutUnit minimumReplacedHeight() const { return 0_lu; }
</span><span class="cx"> 
</span><span class="cx">     bool isSelected() const;
</span></span></pre>
</div>
</div>

</body>
</html>