[webkit-changes] [WebKit/WebKit] 0599c1: Resolve cases when border and padding are added tw...

EWS noreply at github.com
Tue Sep 6 10:23:58 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0599c10f90042d00785952e18f8897082d655ca3
      https://github.com/WebKit/WebKit/commit/0599c10f90042d00785952e18f8897082d655ca3
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M LayoutTests/TestExpectations
    A LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-item-transferred-sizes-padding-border-sizing-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-item-transferred-sizes-padding-border-sizing.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-item-transferred-sizes-padding-content-sizing-expected.html
    A LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-item-transferred-sizes-padding-content-sizing.html
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBox.cpp

  Log Message:
  -----------
  Resolve cases when border and padding are added twice to computed min and max sizes
https://bugs.webkit.org/show_bug.cgi?id=243887
rdar://98577125

Reviewed by Rob Buis.

This patch fixes a miscellaneous bug which would result in the
border and padding on boxes to get added twice in certain cases. This
is because inlineSizeFromAspectRatio returns the sizes of the border
box when the box sizing is content box. This is what is used to
compute logicalMinWidth and logicalMaxWidth, so those become
border box values. If the border and padding is not removed it is
possible for m_minPreferredLogicalWidth or m_maxPreferredLogicalWidth
to get clamped to one of those values. At the end of the method the
border and padding would once again get added on, which would result
in an incorrect box size. This could also happen in
RenderBlock::computePreferredLogicalWidths if the width is calculated
from the aspect ratio. This is because this branch of the code uses the
same inlineSizeFromAspectRatio method to do so.

Some of the logic inside of RenderBox::computePreferredLogicalWidths has
also been adjusted to no longer bother with checking transferred sizes
if a definite width is provided. This is because m_minPreferredLogicalWidth
and m_maxPreferredLogicalWidth will be set to the defined logical width
in RenderBlock::computePreferredLogicalWidths. If this is done, then
the transferred sizes will have no impact on these values. This is
because:

1.) If m_minPreferredLogicalWidth is greater than the logical width or
m_maxPreferredLogicalWidth is smaller than the logical width, they would
have been sized to the logical width anyway
2.) The clamping will have no effect if 1 does or does not occur. If 1
does occur, then m_minPreferredLogicalWidth and/or m_maxPreferredLogicalWidth
will already be the value of the logical width. If 1 does not ocur, then
m_minPreferredLogicalWidth and m_maxPreferredLogicalWidth are already
within the bounds of the transferred sizes and nothing will happen.

Transferred sizes spec: https://drafts.csswg.org/css-sizing-4/#aspect-ratio-size-transfers

* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::computePreferredLogicalWidths):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computePreferredLogicalWidths):

Canonical link: https://commits.webkit.org/254190@main




More information about the webkit-changes mailing list