Changeset 272338 in webkit


Ignore:
Timestamp:
Feb 3, 2021 1:22:30 PM (18 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-03
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.

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.

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
6 edited

Legend:

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

    r272315 r272338  
     12021-02-03  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
    1132021-02-03  Rob Buis  <rbuis@igalia.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log

    r272309 r272338  
    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.html
    2122/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-automatic-minimum-intrinsic-aspect-ratio-001.html
    2223/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-img-item-percent-max-height-001.html
  • trunk/Source/WebCore/ChangeLog

    r272337 r272338  
     12021-02-03  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        This is an import of Chromium change at
     13        https://chromium-review.googlesource.com/c/chromium/src/+/2503910
     14        This change also imported needsPreferredWidthsRecalculation() from Chromium to RenderReplaced to
     15        address the test case specified here.
     16       
     17        Test: imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html
     18
     19        * rendering/GridTrackSizingAlgorithm.cpp:
     20        (WebCore::GridTrackSizingAlgorithmStrategy::minContentForChild const):
     21        (WebCore::GridTrackSizingAlgorithmStrategy::maxContentForChild const):
     22        * rendering/RenderReplaced.cpp:
     23        (WebCore::RenderReplaced::needsPreferredWidthsRecalculation const):
     24        * rendering/RenderReplaced.h:
     25
    1262021-02-03  Sihui Liu  <sihui_liu@appe.com>
    227
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r269509 r272338  
    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

    r271638 r272338  
    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

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