Title: [289272] branches/safari-613-branch
Revision
289272
Author
[email protected]
Date
2022-02-07 18:53:05 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r288003. rdar://problem/85505101

    Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
    https://bugs.webkit.org/show_bug.cgi?id=235058
    <rdar://85505101>

    Reviewed by Alan Bujtas.

    Source/WebCore:

    The rules in https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
    that define the automatic minimum size of an element subject to an
    aspect-ratio only apply if the element is non-replaced.

    In constrainLogicalHeightByMinMax specifically, when min-height is
    auto, after applying the aspect-ratio to produce an automatic minimum
    height, we bump it up to the content height if the element has
    children. This, presumably, is to account for the way the height of a
    block is computed in CSS 2.2. (As CSS 2.2 doesn't have an auto value
    for min-height, and a CSS Block Layout module has not been written in
    terms of CSS Sizing concepts, there is no clear definition of
    automatic minimum sizing for blocks at the moment.) If we erroneously
    apply this to a replaced element, such as an image or video, it can
    get a computed min-height equal to the intrinsic height of the image,
    which may be much larger than expected.

    This commit adds an is<RenderReplaced>() check for both automatic
    minimum logical width and height calculations, although I was unable to
    produce a test to exercise the logical width case (which does not take
    the intrinsic size into account when computing the automatic minimum).

    Test: fast/css/aspect-ratio-min-height-replaced.html

    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
    (WebCore::RenderBox::constrainLogicalHeightByMinMax const):

    LayoutTests:

    Test that replaced elements with child content (in this case, a
    <video> element's controls in the UA shadow tree) don't influence the
    automatic minimum size calculation.

    * fast/css/aspect-ratio-min-height-replaced-expected.html: Added.
    * fast/css/aspect-ratio-min-height-replaced.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (289271 => 289272)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-02-08 02:53:01 UTC (rev 289271)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-02-08 02:53:05 UTC (rev 289272)
@@ -1,5 +1,71 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288003. rdar://problem/85505101
+
+    Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
+    https://bugs.webkit.org/show_bug.cgi?id=235058
+    <rdar://85505101>
+    
+    Reviewed by Alan Bujtas.
+    
+    Source/WebCore:
+    
+    The rules in https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
+    that define the automatic minimum size of an element subject to an
+    aspect-ratio only apply if the element is non-replaced.
+    
+    In constrainLogicalHeightByMinMax specifically, when min-height is
+    auto, after applying the aspect-ratio to produce an automatic minimum
+    height, we bump it up to the content height if the element has
+    children. This, presumably, is to account for the way the height of a
+    block is computed in CSS 2.2. (As CSS 2.2 doesn't have an auto value
+    for min-height, and a CSS Block Layout module has not been written in
+    terms of CSS Sizing concepts, there is no clear definition of
+    automatic minimum sizing for blocks at the moment.) If we erroneously
+    apply this to a replaced element, such as an image or video, it can
+    get a computed min-height equal to the intrinsic height of the image,
+    which may be much larger than expected.
+    
+    This commit adds an is<RenderReplaced>() check for both automatic
+    minimum logical width and height calculations, although I was unable to
+    produce a test to exercise the logical width case (which does not take
+    the intrinsic size into account when computing the automatic minimum).
+    
+    Test: fast/css/aspect-ratio-min-height-replaced.html
+    
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
+    (WebCore::RenderBox::constrainLogicalHeightByMinMax const):
+    
+    LayoutTests:
+    
+    Test that replaced elements with child content (in this case, a
+    <video> element's controls in the UA shadow tree) don't influence the
+    automatic minimum size calculation.
+    
+    * fast/css/aspect-ratio-min-height-replaced-expected.html: Added.
+    * fast/css/aspect-ratio-min-height-replaced.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-13  Cameron McCormack  <[email protected]>
+
+            Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
+            https://bugs.webkit.org/show_bug.cgi?id=235058
+            <rdar://85505101>
+
+            Reviewed by Alan Bujtas.
+
+            Test that replaced elements with child content (in this case, a
+            <video> element's controls in the UA shadow tree) don't influence the
+            automatic minimum size calculation.
+
+            * fast/css/aspect-ratio-min-height-replaced-expected.html: Added.
+            * fast/css/aspect-ratio-min-height-replaced.html: Added.
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r287981. rdar://problem/84069534
 
     REGRESSION (r278561): Right clicking a link selects the full line with unrelated text

Added: branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced-expected.html (0 => 289272)


--- branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced-expected.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced-expected.html	2022-02-08 02:53:05 UTC (rev 289272)
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div style="display: flex;">
+  <video controls width="100" height="100" style="background-color: yellow;"></video>
+</div>

Added: branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced.html (0 => 289272)


--- branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/css/aspect-ratio-min-height-replaced.html	2022-02-08 02:53:05 UTC (rev 289272)
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<div style="display: flex; flex-direction: column; align-items: start;">
+  <video controls width="300" height="300" style="width: auto; max-height: 100px; aspect-ratio: 1 / 1; background-color: yellow;"></video>
+</div>

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (289271 => 289272)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:53:01 UTC (rev 289271)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:53:05 UTC (rev 289272)
@@ -1,5 +1,91 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288003. rdar://problem/85505101
+
+    Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
+    https://bugs.webkit.org/show_bug.cgi?id=235058
+    <rdar://85505101>
+    
+    Reviewed by Alan Bujtas.
+    
+    Source/WebCore:
+    
+    The rules in https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
+    that define the automatic minimum size of an element subject to an
+    aspect-ratio only apply if the element is non-replaced.
+    
+    In constrainLogicalHeightByMinMax specifically, when min-height is
+    auto, after applying the aspect-ratio to produce an automatic minimum
+    height, we bump it up to the content height if the element has
+    children. This, presumably, is to account for the way the height of a
+    block is computed in CSS 2.2. (As CSS 2.2 doesn't have an auto value
+    for min-height, and a CSS Block Layout module has not been written in
+    terms of CSS Sizing concepts, there is no clear definition of
+    automatic minimum sizing for blocks at the moment.) If we erroneously
+    apply this to a replaced element, such as an image or video, it can
+    get a computed min-height equal to the intrinsic height of the image,
+    which may be much larger than expected.
+    
+    This commit adds an is<RenderReplaced>() check for both automatic
+    minimum logical width and height calculations, although I was unable to
+    produce a test to exercise the logical width case (which does not take
+    the intrinsic size into account when computing the automatic minimum).
+    
+    Test: fast/css/aspect-ratio-min-height-replaced.html
+    
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
+    (WebCore::RenderBox::constrainLogicalHeightByMinMax const):
+    
+    LayoutTests:
+    
+    Test that replaced elements with child content (in this case, a
+    <video> element's controls in the UA shadow tree) don't influence the
+    automatic minimum size calculation.
+    
+    * fast/css/aspect-ratio-min-height-replaced-expected.html: Added.
+    * fast/css/aspect-ratio-min-height-replaced.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-13  Cameron McCormack  <[email protected]>
+
+            Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
+            https://bugs.webkit.org/show_bug.cgi?id=235058
+            <rdar://85505101>
+
+            Reviewed by Alan Bujtas.
+
+            The rules in https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
+            that define the automatic minimum size of an element subject to an
+            aspect-ratio only apply if the element is non-replaced.
+
+            In constrainLogicalHeightByMinMax specifically, when min-height is
+            auto, after applying the aspect-ratio to produce an automatic minimum
+            height, we bump it up to the content height if the element has
+            children. This, presumably, is to account for the way the height of a
+            block is computed in CSS 2.2. (As CSS 2.2 doesn't have an auto value
+            for min-height, and a CSS Block Layout module has not been written in
+            terms of CSS Sizing concepts, there is no clear definition of
+            automatic minimum sizing for blocks at the moment.) If we erroneously
+            apply this to a replaced element, such as an image or video, it can
+            get a computed min-height equal to the intrinsic height of the image,
+            which may be much larger than expected.
+
+            This commit adds an is<RenderReplaced>() check for both automatic
+            minimum logical width and height calculations, although I was unable to
+            produce a test to exercise the logical width case (which does not take
+            the intrinsic size into account when computing the automatic minimum).
+
+            Test: fast/css/aspect-ratio-min-height-replaced.html
+
+            * rendering/RenderBox.cpp:
+            (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
+            (WebCore::RenderBox::constrainLogicalHeightByMinMax const):
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r287992. rdar://problem/74845918
 
     Crash in Document::updateStyleIfNeeded() when removing a node containing the drag caret

Modified: branches/safari-613-branch/Source/WebCore/rendering/RenderBox.cpp (289271 => 289272)


--- branches/safari-613-branch/Source/WebCore/rendering/RenderBox.cpp	2022-02-08 02:53:01 UTC (rev 289271)
+++ branches/safari-613-branch/Source/WebCore/rendering/RenderBox.cpp	2022-02-08 02:53:05 UTC (rev 289272)
@@ -673,13 +673,12 @@
         logicalWidth = std::min(logicalWidth, computeLogicalWidthInFragmentUsing(MaxSize, styleToUse.logicalMaxWidth(), availableWidth, cb, fragment));
     if (allowIntrinsic == AllowIntrinsic::No && styleToUse.logicalMinWidth().isIntrinsic())
         return logicalWidth;
-    auto minLength = styleToUse.logicalMinWidth();
-    if (styleToUse.hasAspectRatio() && minLength.isAuto() && (styleToUse.logicalWidth().isAuto() || styleToUse.logicalWidth().isMinContent() || styleToUse.logicalWidth().isMaxContent()) && effectiveOverflowInlineDirection() == Overflow::Visible) {
+    auto logicalMinWidth = styleToUse.logicalMinWidth();
+    if (logicalMinWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio() && (styleToUse.logicalWidth().isAuto() || styleToUse.logicalWidth().isMinContent() || styleToUse.logicalWidth().isMaxContent()) && !is<RenderReplaced>(*this) && effectiveOverflowInlineDirection() == Overflow::Visible) {
         // Make sure we actually used the aspect ratio.
-        if (shouldComputeLogicalWidthFromAspectRatio())
-            minLength = Length(LengthType::MinContent);
+        logicalMinWidth = Length(LengthType::MinContent);
     }
-    return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, minLength, availableWidth, cb, fragment));
+    return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, logicalMinWidth, availableWidth, cb, fragment));
 }
 
 LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, std::optional<LayoutUnit> intrinsicContentHeight) const
@@ -690,7 +689,7 @@
             logicalHeight = std::min(logicalHeight, maxH.value());
     }
     auto logicalMinHeight = styleToUse.logicalMinHeight();
-    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && effectiveOverflowBlockDirection() == Overflow::Visible) {
+    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && !is<RenderReplaced>(*this) && effectiveOverflowBlockDirection() == Overflow::Visible) {
         auto heightFromAspectRatio = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizingForAspectRatio(), logicalWidth()) - borderAndPaddingLogicalHeight();
         if (firstChild())
             heightFromAspectRatio = std::max(heightFromAspectRatio, *intrinsicContentHeight);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to