Changeset 145378 in webkit


Ignore:
Timestamp:
Mar 11, 2013 12:07:54 PM (11 years ago)
Author:
jchaffraix@webkit.org
Message:

[CSS Grid Layout] Handle spanning grid items over specified grid tracks
https://bugs.webkit.org/show_bug.cgi?id=111918

Reviewed by Tony Chang.

Source/WebCore:

This change updates the containing block override logic to handle multiple
spanned tracks. This makes the multiple specified grid tracks case work and
will enable us to handle the minmax case once the computation logic has been
updated.

Test: fast/css-grid-layout/grid-item-spanning-resolution.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::logicalContentHeightForChild):
(WebCore::RenderGrid::layoutGridItems):
Updated these functions to use gridAreaBreadthForChild.

(WebCore::RenderGrid::gridAreaBreadthForChild):
Added this helper function to handle multiple spanned grid tracks.

  • rendering/RenderGrid.h: Added the previous function.

LayoutTests:

  • fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:

We now pass all the tests.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145364 r145378  
     12013-03-11  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        [CSS Grid Layout] Handle spanning grid items over specified grid tracks
     4        https://bugs.webkit.org/show_bug.cgi?id=111918
     5
     6        Reviewed by Tony Chang.
     7
     8        * fast/css-grid-layout/grid-item-spanning-resolution-expected.txt:
     9        We now pass all the tests.
     10
    1112013-03-11  Christian Biesinger  <cbiesinger@chromium.org>
    212
  • trunk/LayoutTests/fast/css-grid-layout/grid-item-spanning-resolution-expected.txt

    r145240 r145378  
    11Test that spannig rows / columns inside percentage sized grid areas get properly sized.
    22
    3 FAIL:
    4 Expected 400 for width, but got 160.
    5 
    6 <div class="grid" data-expected-width="400" data-expected-height="300">
    7     <div class="sizedToGridArea firstRowBothColumn" data-offset-x="0" data-offset-y="0" data-expected-width="400" data-expected-height="90"></div>
    8 </div>
    9 FAIL:
    10 Expected 400 for width, but got 160.
    11 
    12 <div class="grid" data-expected-width="400" data-expected-height="300">
    13     <div class="sizedToGridArea secondRowBothColumn" data-offset-x="0" data-offset-y="90" data-expected-width="400" data-expected-height="210"></div>
    14 </div>
    15 FAIL:
    16 Expected 300 for height, but got 90.
    17 
    18 <div class="grid" data-expected-width="400" data-expected-height="300">
    19     <div class="sizedToGridArea bothRowFirstColumn" data-offset-x="0" data-offset-y="0" data-expected-width="160" data-expected-height="300"></div>
    20 </div>
    21 FAIL:
    22 Expected 300 for height, but got 90.
    23 
    24 <div class="grid" data-expected-width="400" data-expected-height="300">
    25     <div class="sizedToGridArea bothRowSecondColumn" data-offset-x="160" data-offset-y="0" data-expected-width="240" data-expected-height="300"></div>
    26 </div>
    27 FAIL:
    28 Expected 400 for width, but got 160.
    29 Expected 300 for height, but got 90.
    30 
    31 <div class="grid" data-expected-width="400" data-expected-height="300">
    32     <div class="sizedToGridArea bothRowBothColumn" data-offset-x="0" data-offset-y="0" data-expected-width="400" data-expected-height="300"></div>
    33 </div>
     3PASS
     4PASS
     5PASS
     6PASS
     7PASS
    348PASS
    359PASS
  • trunk/Source/WebCore/ChangeLog

    r145377 r145378  
     12013-03-11  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        [CSS Grid Layout] Handle spanning grid items over specified grid tracks
     4        https://bugs.webkit.org/show_bug.cgi?id=111918
     5
     6        Reviewed by Tony Chang.
     7
     8        This change updates the containing block override logic to handle multiple
     9        spanned tracks. This makes the multiple specified grid tracks case work and
     10        will enable us to handle the minmax case once the computation logic has been
     11        updated.
     12
     13        Test: fast/css-grid-layout/grid-item-spanning-resolution.html
     14
     15        * rendering/RenderGrid.cpp:
     16        (WebCore::RenderGrid::logicalContentHeightForChild):
     17        (WebCore::RenderGrid::layoutGridItems):
     18        Updated these functions to use gridAreaBreadthForChild.
     19
     20        (WebCore::RenderGrid::gridAreaBreadthForChild):
     21        Added this helper function to handle multiple spanned grid tracks.
     22
     23        * rendering/RenderGrid.h: Added the previous function.
     24
    1252013-03-11  Philip Rogers  <pdr@google.com>
    226
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r145297 r145378  
    360360        child->setNeedsLayout(true, MarkOnlyThis);
    361361
    362     const GridCoordinate& coordinate = cachedGridCoordinate(child);
    363     child->setOverrideContainingBlockContentLogicalWidth(columnTracks[coordinate.columnIndex].m_usedBreadth);
     362    child->setOverrideContainingBlockContentLogicalWidth(gridAreaBreadthForChild(child, ForColumns, columnTracks));
    364363    child->clearOverrideContainingBlockContentLogicalHeight();
    365364    child->layout();
     
    646645        LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks, rowTracks);
    647646
    648         const GridCoordinate& childCoordinate = cachedGridCoordinate(child);
    649 
    650647        // Because the grid area cannot be styled, we don't need to adjust
    651648        // the grid breadth to account for 'box-sizing'.
     
    655652        // FIXME: For children in a content sized track, we clear the overrideContainingBlockContentLogicalHeight
    656653        // in minContentForChild / maxContentForChild which means that we will always relayout the child.
    657         if (oldOverrideContainingBlockContentLogicalWidth != columnTracks[childCoordinate.columnIndex].m_usedBreadth || oldOverrideContainingBlockContentLogicalHeight != rowTracks[childCoordinate.rowIndex].m_usedBreadth)
     654        LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks);
     655        LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadthForChild(child, ForRows, rowTracks);
     656        if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingBlockContentLogicalWidth || oldOverrideContainingBlockContentLogicalHeight != overrideContainingBlockContentLogicalHeight)
    658657            child->setNeedsLayout(true, MarkOnlyThis);
    659658
    660         child->setOverrideContainingBlockContentLogicalWidth(columnTracks[childCoordinate.columnIndex].m_usedBreadth);
    661         child->setOverrideContainingBlockContentLogicalHeight(rowTracks[childCoordinate.rowIndex].m_usedBreadth);
     659        child->setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth);
     660        child->setOverrideContainingBlockContentLogicalHeight(overrideContainingBlockContentLogicalHeight);
    662661
    663662        // FIXME: Grid items should stretch to fill their cells. Once we
     
    741740    ASSERT_NOT_REACHED();
    742741    return 0;
     742}
     743
     744LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection direction, const Vector<GridTrack>& tracks) const
     745{
     746    const GridCoordinate& coordinate = cachedGridCoordinate(child);
     747    size_t trackIndex = (direction == ForColumns) ? coordinate.columnIndex : coordinate.rowIndex;
     748    OwnPtr<GridSpan> span = resolveGridPositionsFromStyle(child, direction);
     749    if (!span) {
     750        // FIXME: We don't support spanning with auto positions yet. Once we do, this is wrong.
     751        span = adoptPtr(new GridSpan(trackIndex, trackIndex));
     752    }
     753
     754    ASSERT(span->initialPositionIndex == trackIndex);
     755    LayoutUnit gridAreaBreadth = 0;
     756    for (; trackIndex <= span->finalPositionIndex; ++trackIndex)
     757        gridAreaBreadth += tracks[trackIndex].m_usedBreadth;
     758    return gridAreaBreadth;
    743759}
    744760
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r145297 r145378  
    126126    size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) const;
    127127
     128    LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection, const Vector<GridTrack>&) const;
     129
    128130#ifndef NDEBUG
    129131    bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<GridTrack>&);
Note: See TracChangeset for help on using the changeset viewer.