Changeset 178895 in webkit


Ignore:
Timestamp:
Jan 22, 2015 12:56:13 AM (9 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Skip items spanning flex tracks when sizing content based tracks
https://bugs.webkit.org/show_bug.cgi?id=140720

Reviewed by David Hyatt.

Source/WebCore:

Section "11.5. Resolve Intrinsic Track Sizes" of the specs forces
us to ignore items spanning tracks with flex sizing functions when
resolving the content-based track sizing functions. Items with
span < 2 are not affected by this rule (as they will belong to a
single track). This way the algorithm ensures that min-content and
max-content restrictions are fulfilled before distributing the
extra space.

Test: fast/css-grid-layout/flex-and-content-sized-resolution-columns.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::spanningItemCrossesFlexibleSizedTracks):
(WebCore::integerSpanForDirection):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):

  • rendering/RenderGrid.h:

LayoutTests:

  • fast/css-grid-layout/flex-and-content-sized-resolution-columns-expected.txt: Added.
  • fast/css-grid-layout/flex-and-content-sized-resolution-columns.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r178894 r178895  
     12015-01-21  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Skip items spanning flex tracks when sizing content based tracks
     4        https://bugs.webkit.org/show_bug.cgi?id=140720
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/css-grid-layout/flex-and-content-sized-resolution-columns-expected.txt: Added.
     9        * fast/css-grid-layout/flex-and-content-sized-resolution-columns.html: Added.
     10
    1112015-01-22  Yusuke Suzuki  <utatane.tea@gmail.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r178894 r178895  
     12015-01-21  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Skip items spanning flex tracks when sizing content based tracks
     4        https://bugs.webkit.org/show_bug.cgi?id=140720
     5
     6        Reviewed by David Hyatt.
     7
     8        Section "11.5. Resolve Intrinsic Track Sizes" of the specs forces
     9        us to ignore items spanning tracks with flex sizing functions when
     10        resolving the content-based track sizing functions. Items with
     11        span < 2 are not affected by this rule (as they will belong to a
     12        single track). This way the algorithm ensures that min-content and
     13        max-content restrictions are fulfilled before distributing the
     14        extra space.
     15
     16        Test: fast/css-grid-layout/flex-and-content-sized-resolution-columns.html
     17
     18        * rendering/RenderGrid.cpp:
     19        (WebCore::RenderGrid::spanningItemCrossesFlexibleSizedTracks):
     20        (WebCore::integerSpanForDirection):
     21        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
     22        * rendering/RenderGrid.h:
     23
    1242015-01-22  Yusuke Suzuki  <utatane.tea@gmail.com>
    225
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r178893 r178895  
    560560};
    561561
     562bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridCoordinate& coordinate, GridTrackSizingDirection direction) const
     563{
     564    const GridSpan itemSpan = (direction == ForColumns) ? coordinate.columns : coordinate.rows;
     565    for (auto trackPosition : itemSpan) {
     566        const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.toInt());
     567        if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().isFlex())
     568            return true;
     569    }
     570
     571    return false;
     572}
     573
     574static inline unsigned integerSpanForDirection(const GridCoordinate& coordinate, GridTrackSizingDirection direction)
     575{
     576    return (direction == ForRows) ? coordinate.rows.integerSpan() : coordinate.columns.integerSpan();
     577}
     578
    562579void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection direction, GridSizingData& sizingData)
    563580{
    564     // FIXME: Split the grid tracks into groups that doesn't overlap a <flex> grid track.
    565581    sizingData.itemsSortedByIncreasingSpan.shrink(0);
    566582    HashSet<RenderBox*> itemsSet;
     
    569585
    570586        while (RenderBox* gridItem = iterator.nextGridItem()) {
    571             if (itemsSet.add(gridItem).isNewEntry)
    572                 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, cachedGridCoordinate(*gridItem), direction));
     587            if (itemsSet.add(gridItem).isNewEntry) {
     588                const GridCoordinate& coordinate = cachedGridCoordinate(*gridItem);
     589                // We should not include items spanning more than one track that span tracks with flexible sizing functions.
     590                if (integerSpanForDirection(coordinate, direction) == 1 || !spanningItemCrossesFlexibleSizedTracks(coordinate, direction))
     591                    sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, coordinate, direction));
     592            }
    573593        }
    574594    }
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r177259 r178895  
    115115    bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmpty(); }
    116116
     117    bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrackSizingDirection) const;
     118
    117119    unsigned gridColumnCount() const
    118120    {
Note: See TracChangeset for help on using the changeset viewer.