Changeset 174057 in webkit


Ignore:
Timestamp:
Sep 29, 2014 3:08:34 AM (10 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Handle percentages of indefinite sizes in minmax() and grid-auto-*
https://bugs.webkit.org/show_bug.cgi?id=136453

Reviewed by Darin Adler.

Source/WebCore:

After r165048 percentages of indefinite sizes were correctly
computed to "auto". The problem is that we were not doing it when
the percentage was inside the minmax() function. In those cases it
should compute to min-content for the min track sizing function or
to max-content for the max track sizing function.

We were not doing it also for the track sizes specified in
grid-auto-{column|row} properties. Fixed as well as the code is
the same.

Tests: fast/css-grid-layout/percent-of-indefinite-track-size-in-auto.html

fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash.html
fast/css-grid-layout/percent-of-indefinite-track-size.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::gridTrackSize):

  • rendering/RenderGrid.h:
  • rendering/style/GridLength.h:

(WebCore::GridLength::isPercentage):

  • rendering/style/GridTrackSize.h:

(WebCore::GridTrackSize::GridTrackSize):

LayoutTests:

Added three new tests, one to verify that we do not assert with
percentages inside minmax() and another two to verify that we
properly compute the percentage of indefinite size in various
situations both in grid-template-* properties and in
grid-auto-{column|row} properties.

Three other tests required minimum adjustments as they were using
percentages of indefinite sizes inside minmax functions. In order
to keep the original expected behavior some definite sizes were
added.

  • fast/css-grid-layout/grid-auto-columns-rows-auto-flow-resolution.html:
  • fast/css-grid-layout/grid-auto-columns-rows-resolution.html:
  • fast/css-grid-layout/grid-auto-columns-rows-update.html:
  • fast/css-grid-layout/percent-of-indefinite-track-size-expected.txt: Added.
  • fast/css-grid-layout/percent-of-indefinite-track-size-in-auto-expected.txt: Added.
  • fast/css-grid-layout/percent-of-indefinite-track-size-in-auto.html: Added.
  • fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash-expected.txt: Added.
  • fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash.html: Added.
  • fast/css-grid-layout/percent-of-indefinite-track-size.html: Added.
Location:
trunk
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r174049 r174057  
     12014-09-02  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Handle percentages of indefinite sizes in minmax() and grid-auto-*
     4        https://bugs.webkit.org/show_bug.cgi?id=136453
     5
     6        Reviewed by Darin Adler.
     7
     8        Added three new tests, one to verify that we do not assert with
     9        percentages inside minmax() and another two to verify that we
     10        properly compute the percentage of indefinite size in various
     11        situations both in grid-template-* properties and in
     12        grid-auto-{column|row} properties.
     13
     14        Three other tests required minimum adjustments as they were using
     15        percentages of indefinite sizes inside minmax functions. In order
     16        to keep the original expected behavior some definite sizes were
     17        added.
     18
     19        * fast/css-grid-layout/grid-auto-columns-rows-auto-flow-resolution.html:
     20        * fast/css-grid-layout/grid-auto-columns-rows-resolution.html:
     21        * fast/css-grid-layout/grid-auto-columns-rows-update.html:
     22        * fast/css-grid-layout/percent-of-indefinite-track-size-expected.txt: Added.
     23        * fast/css-grid-layout/percent-of-indefinite-track-size-in-auto-expected.txt: Added.
     24        * fast/css-grid-layout/percent-of-indefinite-track-size-in-auto.html: Added.
     25        * fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash-expected.txt: Added.
     26        * fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash.html: Added.
     27        * fast/css-grid-layout/percent-of-indefinite-track-size.html: Added.
     28
    1292014-09-28  Diego Pino Garcia  <dpino@igalia.com>
    230
  • trunk/LayoutTests/fast/css-grid-layout/grid-auto-columns-rows-auto-flow-resolution.html

    r171293 r174057  
    1616.gridAutoMinMax {
    1717    font: 10/1 Ahem;
     18    width: 1000px;
    1819    -webkit-grid-auto-rows: minmax(10em, 15px);
    1920    -webkit-grid-auto-columns: minmax(30%, 100px);
  • trunk/LayoutTests/fast/css-grid-layout/grid-auto-columns-rows-resolution.html

    r168416 r174057  
    1515
    1616.gridAutoMinMax {
     17    width: 1000px;
    1718    height: 1000px;
    1819    -webkit-grid-auto-rows: minmax(10%, 15px);
  • trunk/LayoutTests/fast/css-grid-layout/grid-auto-columns-rows-update.html

    r168416 r174057  
    6868
    6969<div class="constrainedContainer" style="position: relative">
    70     <div class="grid" id="constrainedGrid" style="height: 100%">
     70    <div class="grid" id="constrainedGrid" style="height: 100%; width: 100%;">
    7171        <div class="sizedToGridArea secondRowSecondColumn" data-offset-x="10" data-offset-y="20" data-expected-width="50" data-expected-height="30">XXXXX XXXXXX</div>
    7272    </div>
     
    8080
    8181<div class="constrainedContainer" style="position: relative;">
    82     <div class="grid" id="constrainedGridUndefinedHeight">
     82    <div class="grid" id="constrainedGridUndefinedHeight" style="width: 100%;">
    8383        <div class="sizedToGridArea secondRowSecondColumn" data-offset-x="10" data-offset-y="20" data-expected-width="50" data-expected-height="30">XXXXX XXXXXX</div>
    8484    </div>
  • trunk/Source/WebCore/ChangeLog

    r174055 r174057  
     12014-09-02  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Handle percentages of indefinite sizes in minmax() and grid-auto-*
     4        https://bugs.webkit.org/show_bug.cgi?id=136453
     5
     6        Reviewed by Darin Adler.
     7
     8        After r165048 percentages of indefinite sizes were correctly
     9        computed to "auto". The problem is that we were not doing it when
     10        the percentage was inside the minmax() function. In those cases it
     11        should compute to min-content for the min track sizing function or
     12        to max-content for the max track sizing function.
     13
     14        We were not doing it also for the track sizes specified in
     15        grid-auto-{column|row} properties. Fixed as well as the code is
     16        the same.
     17
     18        Tests: fast/css-grid-layout/percent-of-indefinite-track-size-in-auto.html
     19               fast/css-grid-layout/percent-of-indefinite-track-size-in-minmax-crash.html
     20               fast/css-grid-layout/percent-of-indefinite-track-size.html
     21
     22        * rendering/RenderGrid.cpp:
     23        (WebCore::RenderGrid::gridTrackSize):
     24        * rendering/RenderGrid.h:
     25        * rendering/style/GridLength.h:
     26        (WebCore::GridLength::isPercentage):
     27        * rendering/style/GridTrackSize.h:
     28        (WebCore::GridTrackSize::GridTrackSize):
     29
    1302014-09-29  Carlos Garcia Campos  <cgarcia@igalia.com>
    231
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r174006 r174057  
    467467}
    468468
    469 const GridTrackSize& RenderGrid::gridTrackSize(GridTrackSizingDirection direction, size_t i) const
    470 {
    471     const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style().gridColumns() : style().gridRows();
    472     if (i >= trackStyles.size())
    473         return (direction == ForColumns) ? style().gridAutoColumns() : style().gridAutoRows();
    474 
    475     const GridTrackSize& trackSize = trackStyles[i];
    476     // If the logical width/height of the grid container is indefinite, percentage values are treated as <auto>.
    477     if (trackSize.isPercentage()) {
    478         Length logicalSize = direction == ForColumns ? style().logicalWidth() : style().logicalHeight();
    479         if (logicalSize.isIntrinsicOrAuto()) {
    480             static NeverDestroyed<GridTrackSize> autoTrackSize(Auto);
    481             return autoTrackSize.get();
    482         }
     469GridTrackSize RenderGrid::gridTrackSize(GridTrackSizingDirection direction, size_t i) const
     470{
     471    bool isForColumns = (direction == ForColumns);
     472    auto& trackStyles =  isForColumns ? style().gridColumns() : style().gridRows();
     473    auto& trackSize = (i >= trackStyles.size()) ? (isForColumns ? style().gridAutoColumns() : style().gridAutoRows()) : trackStyles[i];
     474
     475    // If the logical width/height of the grid container is indefinite, percentage values are treated as <auto> (or in
     476    // the case of minmax() as min-content for the first position and max-content for the second).
     477    Length logicalSize = isForColumns ? style().logicalWidth() : style().logicalHeight();
     478    if (logicalSize.isIntrinsicOrAuto()) {
     479        const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth();
     480        const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth();
     481        return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinContent) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent) : oldMaxTrackBreadth);
    483482    }
    484483
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r173620 r174057  
    9797    double computeNormalizedFractionBreadth(Vector<GridTrack>&, const GridSpan& tracksSpan, GridTrackSizingDirection, LayoutUnit availableLogicalSpace) const;
    9898
    99     const GridTrackSize& gridTrackSize(GridTrackSizingDirection, size_t) const;
     99    GridTrackSize gridTrackSize(GridTrackSizingDirection, size_t) const;
    100100
    101101    LayoutUnit logicalContentHeightForChild(RenderBox&, Vector<GridTrack>&);
  • trunk/Source/WebCore/rendering/style/GridLength.h

    r164659 r174057  
    7171    }
    7272
     73    bool isPercentage() const { return m_type == LengthType && m_length.isPercent(); }
     74
    7375    bool operator==(const GridLength& o) const
    7476    {
  • trunk/Source/WebCore/rendering/style/GridTrackSize.h

    r165607 r174057  
    5151        , m_maxTrackBreadth(type)
    5252    {
     53    }
     54
     55    GridTrackSize(const GridLength& minTrackBreadth, const GridLength& maxTrackBreadth)
     56    {
     57        setMinMax(minTrackBreadth, maxTrackBreadth);
    5358    }
    5459
Note: See TracChangeset for help on using the changeset viewer.