Changeset 272711 in webkit


Ignore:
Timestamp:
Feb 11, 2021 12:44:54 AM (17 months ago)
Author:
commit-queue@webkit.org
Message:

the nested grid container which has replaced item with 'max-height' has wrong width(0px).
https://bugs.webkit.org/show_bug.cgi?id=219194

Patch by Ziran Sun <Ziran Sun> on 2021-02-11
Reviewed by Javier Fernandez.
LayoutTests/imported/w3c:

The test is imported from WPT.

  • web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001-expected.html: Added.
  • web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html: Added.
  • web-platform-tests/css/css-sizing/percentage-height-in-flexbox-expected.txt: Added.

Source/WebCore:

Width of a nested grid container with margin:auto returns 0 when their item has "max-height".
This causes the grid item's position wrong due to the wrongly comuputed auto-margin value.
This change is to check whether the preferred logical width is dirty when the grid area changes.

It's a reland of r272338, which got reverted because it broken
imported/w3c/web-platform-tests/css/css-sizing/percentage-height-in-flexbox.html on ios. This change
actually fixes the test failure in the flexbox test. Hence, updating test expectation file of
the flexbox test seems working.

This is an import of Chromium change at
https://chromium-review.googlesource.com/c/chromium/src/+/2503910
This change also imported needsPreferredWidthsRecalculation() from Chromium to RenderReplaced to
address the test case specified here.

Test: imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html

  • rendering/GridTrackSizingAlgorithm.cpp:

(WebCore::GridTrackSizingAlgorithmStrategy::minContentForChild const):
(WebCore::GridTrackSizingAlgorithmStrategy::maxContentForChild const):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::needsPreferredWidthsRecalculation const):

  • rendering/RenderReplaced.h:
Location:
trunk
Files:
2 added
7 edited

Legend:

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

    r272651 r272711  
     12021-02-11  Ziran Sun  <zsun@igalia.com>
     2
     3        the nested grid container which has replaced item with 'max-height' has wrong width(0px).
     4        https://bugs.webkit.org/show_bug.cgi?id=219194
     5
     6        Reviewed by Javier Fernandez.
     7
     8        The test is imported from WPT.
     9
     10        * web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001-expected.html: Added.
     11        * web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html: Added.
     12        * web-platform-tests/css/css-sizing/percentage-height-in-flexbox-expected.txt: Added.
     13
     14
    1152021-02-10  Manuel Rego Casasnovas  <rego@igalia.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log

    r272367 r272711  
    1919/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/explicitly-sized-grid-item-as-table-expected.html
    2020/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/explicitly-sized-grid-item-as-table.html
     21/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001-expected.html
     22/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html
    2123/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-automatic-minimum-intrinsic-aspect-ratio-001.html
    2224/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-img-item-percent-max-height-001.html
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/percentage-height-in-flexbox-expected.txt

    r270578 r272711  
    22
    33PASS #target offsetSize matches #container offsetSize
    4 FAIL #target offsetSize matches #container offsetSize after resize assert_equals: expected 50 but got 100
     4PASS #target offsetSize matches #container offsetSize after resize
    55
  • trunk/Source/WebCore/ChangeLog

    r272709 r272711  
     12021-02-11  Ziran Sun  <zsun@igalia.com>
     2
     3        the nested grid container which has replaced item with 'max-height' has wrong width(0px).
     4        https://bugs.webkit.org/show_bug.cgi?id=219194
     5
     6        Reviewed by Javier Fernandez.
     7     
     8        Width of a nested grid container with margin:auto returns 0 when their item has "max-height".
     9        This causes the grid item's position wrong due to the wrongly comuputed auto-margin value.
     10        This change is to check whether the preferred logical width is dirty when the grid area changes.
     11
     12        It's a reland of r272338, which got reverted because it broken
     13        imported/w3c/web-platform-tests/css/css-sizing/percentage-height-in-flexbox.html on ios. This change
     14        actually fixes the test failure in the flexbox test. Hence, updating test expectation file of
     15        the flexbox test seems working.
     16
     17        This is an import of Chromium change at
     18        https://chromium-review.googlesource.com/c/chromium/src/+/2503910
     19        This change also imported needsPreferredWidthsRecalculation() from Chromium to RenderReplaced to
     20        address the test case specified here.
     21       
     22        Test: imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html
     23
     24        * rendering/GridTrackSizingAlgorithm.cpp:
     25        (WebCore::GridTrackSizingAlgorithmStrategy::minContentForChild const):
     26        (WebCore::GridTrackSizingAlgorithmStrategy::maxContentForChild const):
     27        * rendering/RenderReplaced.cpp:
     28        (WebCore::RenderReplaced::needsPreferredWidthsRecalculation const):
     29        * rendering/RenderReplaced.h:
     30
    1312021-02-10  Jer Noble  <jer.noble@apple.com>
    232
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r272367 r272711  
    776776        // FIXME: It's unclear if we should return the intrinsic width or the preferred width.
    777777        // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
     778        if (child.needsPreferredWidthsRecalculation())
     779            child.setPreferredLogicalWidthsDirty(true);
    778780        return child.minPreferredLogicalWidth() + GridLayoutFunctions::marginLogicalSizeForChild(*renderGrid(), childInlineDirection, child) + m_algorithm.baselineOffsetForChild(child, gridAxisForDirection(direction()));
    779781    }
     
    790792        // FIXME: It's unclear if we should return the intrinsic width or the preferred width.
    791793        // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
     794        if (child.needsPreferredWidthsRecalculation())
     795            child.setPreferredLogicalWidthsDirty(true);
    792796        return child.maxPreferredLogicalWidth() + GridLayoutFunctions::marginLogicalSizeForChild(*renderGrid(), childInlineDirection, child) + m_algorithm.baselineOffsetForChild(child, gridAxisForDirection(direction()));
    793797    }
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r272367 r272711  
    793793}
    794794
    795 }
     795bool RenderReplaced::needsPreferredWidthsRecalculation() const
     796{
     797    // If the height is a percentage and the width is auto, then the containingBlocks's height changing can cause this node to change it's preferred width because it maintains aspect ratio.
     798    return hasRelativeLogicalHeight() && style().logicalWidth().isAuto();
     799}
     800
     801}
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r272367 r272711  
    4646   
    4747    bool isContentLikelyVisibleInViewport();
     48    bool needsPreferredWidthsRecalculation() const override;
    4849
    4950protected:
Note: See TracChangeset for help on using the changeset viewer.