Title: [276745] trunk
Revision
276745
Author
[email protected]
Date
2021-04-28 18:00:26 -0700 (Wed, 28 Apr 2021)

Log Message

[aspect-ratio] Treat border/padding correctly for box-sizing: border-box
https://bugs.webkit.org/show_bug.cgi?id=225015

Patch by Rob Buis <[email protected]> on 2021-04-28
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import WPT test for this.

* web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035-expected.xht: Added.
* web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html: Added.

Source/WebCore:

When computing logical height in aspect-ratio case, to compute the automatic
minimum size [1] for min-height: auto, the padding was always subtracted,
however it should only be subtracted in the box-sizing: content-box case.

Test: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html

[1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight const):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276744 => 276745)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-29 00:51:46 UTC (rev 276744)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-04-29 01:00:26 UTC (rev 276745)
@@ -1,3 +1,15 @@
+2021-04-28  Rob Buis  <[email protected]>
+
+        [aspect-ratio] Treat border/padding correctly for box-sizing: border-box
+        https://bugs.webkit.org/show_bug.cgi?id=225015
+
+        Reviewed by Darin Adler.
+
+        Import WPT test for this.
+
+        * web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035-expected.xht: Added.
+        * web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html: Added.
+
 2021-04-28  Ziran Sun  <[email protected]>
 
         [css-grid] Accurize expected result to 0.5 pixel for some contentSpaceAround tests in abspos

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035-expected.xht (0 => 276745)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035-expected.xht	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035-expected.xht	2021-04-29 01:00:26 UTC (rev 276745)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Gérard Talbot" href="" />
+  <style type="text/css"><![CDATA[
+  div
+  {
+  background-color: green;
+  height: 100px;
+  width: 100px;
+  }
+  ]]></style>
+ </head>
+ <body>
+  <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+  <div></div>
+ </body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html (0 => 276745)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html	2021-04-29 01:00:26 UTC (rev 276745)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<title>CSS aspect-ratio: div block size + min-height: auto</title>
+<link rel="author" title="Ting-Yu Lin" href=""
+<link rel="author" title="Mozilla" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+
+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
+<div style="background: green; box-sizing: border-box; aspect-ratio: 2/1;
+            width: 100px; border: 10px solid green; padding: 10px;">
+  <div style="height: 60px"></div>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (276744 => 276745)


--- trunk/Source/WebCore/ChangeLog	2021-04-29 00:51:46 UTC (rev 276744)
+++ trunk/Source/WebCore/ChangeLog	2021-04-29 01:00:26 UTC (rev 276745)
@@ -1,3 +1,21 @@
+2021-04-28  Rob Buis  <[email protected]>
+
+        [aspect-ratio] Treat border/padding correctly for box-sizing: border-box
+        https://bugs.webkit.org/show_bug.cgi?id=225015
+
+        Reviewed by Darin Adler.
+
+        When computing logical height in aspect-ratio case, to compute the automatic
+        minimum size [1] for min-height: auto, the padding was always subtracted,
+        however it should only be subtracted in the box-sizing: content-box case.
+
+        Test: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-035.html
+
+        [1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeLogicalHeight const):
+
 2021-04-28  Devin Rousso  <[email protected]>
 
         experiment with averaging sampling colors across the top of the page as the scroll area background

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (276744 => 276745)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-04-29 00:51:46 UTC (rev 276744)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-04-29 01:00:26 UTC (rev 276745)
@@ -2942,11 +2942,16 @@
             // translate this to a nullopt intrinsic height for further logical height computations.
             Optional<LayoutUnit> intrinsicHeight;
             if (computedValues.m_extent != LayoutUnit::max())
-                intrinsicHeight = computedValues.m_extent - borderAndPaddingLogicalHeight();
-            if (shouldComputeLogicalHeightFromAspectRatio())
+                intrinsicHeight = computedValues.m_extent;
+            if (shouldComputeLogicalHeightFromAspectRatio()) {
+                if (intrinsicHeight && style().boxSizingForAspectRatio() == BoxSizing::ContentBox)
+                    *intrinsicHeight -= borderAndPaddingLogicalHeight();
                 heightResult = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
-            else
+            } else {
+                if (intrinsicHeight)
+                    *intrinsicHeight -= borderAndPaddingLogicalHeight();
                 heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style().logicalHeight(), intrinsicHeight).valueOr(computedValues.m_extent);
+            }
             heightResult = constrainLogicalHeightByMinMax(heightResult, intrinsicHeight);
         } else {
             ASSERT(h.isFixed());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to