Changeset 145758 in webkit


Ignore:
Timestamp:
Mar 13, 2013 2:50:11 PM (11 years ago)
Author:
jchaffraix@webkit.org
Message:

[CSS Grid Layout] Handle min-width / max-width on the grid element
https://bugs.webkit.org/show_bug.cgi?id=112269

Reviewed by Ojan Vafai.

Source/WebCore:

Test: fast/css-grid-layout/grid-element-min-max-width.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::GridIterator::GridIterator):
Added some sanity checks that the starting indexes are in the grid.

(WebCore::RenderGrid::computeIntrinsicLogicalWidths):
Updated the code to use m_grid to iterate: this is the correct way to
go as it will handle implicit rows / columns properly. Added a comment
about the current way being inefficient and incorrect with spanning grid
items.

(WebCore::RenderGrid::computePreferredLogicalWidths):
Updated the comments.

(WebCore::RenderGrid::gridTrackSize):

  • rendering/RenderGrid.h:

Constified gridTrackSize.

LayoutTests:

  • fast/css-grid-layout/grid-element-min-max-width-expected.txt: Added.
  • fast/css-grid-layout/grid-element-min-max-width.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145750 r145758  
     12013-03-13  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        [CSS Grid Layout] Handle min-width / max-width on the grid element
     4        https://bugs.webkit.org/show_bug.cgi?id=112269
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * fast/css-grid-layout/grid-element-min-max-width-expected.txt: Added.
     9        * fast/css-grid-layout/grid-element-min-max-width.html: Added.
     10
    1112013-03-13  Tao Bai  <michaelbai@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r145756 r145758  
     12013-03-13  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        [CSS Grid Layout] Handle min-width / max-width on the grid element
     4        https://bugs.webkit.org/show_bug.cgi?id=112269
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Test: fast/css-grid-layout/grid-element-min-max-width.html
     9
     10        * rendering/RenderGrid.cpp:
     11        (WebCore::RenderGrid::GridIterator::GridIterator):
     12        Added some sanity checks that the starting indexes are in the grid.
     13
     14        (WebCore::RenderGrid::computeIntrinsicLogicalWidths):
     15        Updated the code to use m_grid to iterate: this is the correct way to
     16        go as it will handle implicit rows / columns properly. Added a comment
     17        about the current way being inefficient and incorrect with spanning grid
     18        items.
     19
     20        (WebCore::RenderGrid::computePreferredLogicalWidths):
     21        Updated the comments.
     22
     23        (WebCore::RenderGrid::gridTrackSize):
     24        * rendering/RenderGrid.h:
     25        Constified gridTrackSize.
     26
    1272013-03-13  Simon Hausmann  <simon.hausmann@digia.com>
    228
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r145378 r145758  
    7979        , m_childIndex(0)
    8080    {
     81        ASSERT(m_rowIndex < m_grid.size());
     82        ASSERT(m_columnIndex < m_grid[0].size());
    8183    }
    8284
     
    191193    const_cast<RenderGrid*>(this)->placeItemsOnGrid();
    192194
    193     const Vector<GridTrackSize>& trackStyles = style()->gridColumns();
    194     for (size_t i = 0; i < trackStyles.size(); ++i) {
    195         LayoutUnit minTrackBreadth = computePreferredTrackWidth(trackStyles[i].minTrackBreadth(), i);
    196         LayoutUnit maxTrackBreadth = computePreferredTrackWidth(trackStyles[i].maxTrackBreadth(), i);
     195    // FIXME: This is an inefficient way to fill our sizes as it will try every grid areas, when we would
     196    // only want to account for fixed grid tracks and grid items. Also this will be incorrect if we have spanning
     197    // grid items.
     198    for (size_t i = 0; i < gridColumnCount(); ++i) {
     199        const GridTrackSize& trackSize = gridTrackSize(ForColumns, i);
     200        LayoutUnit minTrackBreadth = computePreferredTrackWidth(trackSize.minTrackBreadth(), i);
     201        LayoutUnit maxTrackBreadth = computePreferredTrackWidth(trackSize.maxTrackBreadth(), i);
    197202        maxTrackBreadth = std::max(maxTrackBreadth, minTrackBreadth);
    198203
     
    213218    m_maxPreferredLogicalWidth = 0;
    214219
    215     // FIXME: We don't take our own logical width into account.
     220    // FIXME: We don't take our own logical width into account. Once we do, we need to make sure
     221    // we apply (and test the interaction with) min-width / max-width.
     222
    216223    computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    217     // FIXME: We should account for min / max logical width.
    218224
    219225    LayoutUnit borderAndPaddingInInlineDirection = borderAndPaddingLogicalWidth();
     
    317323}
    318324
    319 const GridTrackSize& RenderGrid::gridTrackSize(TrackSizingDirection direction, size_t i)
     325const GridTrackSize& RenderGrid::gridTrackSize(TrackSizingDirection direction, size_t i) const
    320326{
    321327    const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows();
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r145378 r145758  
    108108    void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracksForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, LayoutUnit& availableLogicalSpace);
    109109
    110     const GridTrackSize& gridTrackSize(TrackSizingDirection, size_t);
     110    const GridTrackSize& gridTrackSize(TrackSizingDirection, size_t) const;
    111111    size_t maximumIndexInDirection(TrackSizingDirection) const;
    112112
Note: See TracChangeset for help on using the changeset viewer.