Skip to content
  • svillar@igalia.com's avatar
    [CSS Grid Layout] Fix positioning of grid items with margins · 21d7e2a8
    svillar@igalia.com authored
    https://bugs.webkit.org/show_bug.cgi?id=124345
    
    Reviewed by David Hyatt.
    
    From Blink r157925 and r158041 by <jchaffraix@chromium.org>
    
    Source/WebCore:
    
    Test: fast/css-grid-layout/grid-item-margin-resolution.html
    
    Adds margin start/before to the positions of grid items (removing
    several FIXME's in the current code). This means calling
    findChildLogicalPosition() after the layout in order to have the
    right values for the margins.
    
    In order to match flexbox and author's intents we're also
    including the margins of grid items in the intrinsic size of the
    grid. That's why flexbox's marginLogicalPositionForChild() is
    moved up to RenderBlock in order to share it with RenderGrid.
    
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::marginIntrinsicLogicalWidthForChild): Moved
    from RenderFlexibleBox::marginLogicalWidthForChild().
    * rendering/RenderBlock.h:
    * rendering/RenderFlexibleBox.cpp:
    (WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths):
    * rendering/RenderGrid.cpp:
    (WebCore::RenderGrid::computePreferredTrackWidth):
    (WebCore::RenderGrid::layoutGridItems):
    (WebCore::RenderGrid::findChildLogicalPosition):
    
    LayoutTests:
    
    New test case for grid items margin resolution. Extended the
    preferred logical widths checks with grid items with margins.
    
    * fast/css-grid-layout/grid-item-margin-resolution-expected.txt: Added.
    * fast/css-grid-layout/grid-item-margin-resolution.html: Added.
    * fast/css-grid-layout/grid-preferred-logical-widths-expected.txt:
    * fast/css-grid-layout/grid-preferred-logical-widths.html:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    21d7e2a8