Changeset 199981 in webkit


Ignore:
Timestamp:
Apr 25, 2016 2:54:48 AM (8 years ago)
Author:
Manuel Rego Casasnovas
Message:

[css-grid] Fix grid-template-columns|rows computed style with content alignment
https://bugs.webkit.org/show_bug.cgi?id=156793

Reviewed by Darin Adler.

Source/WebCore:

Computed style of grid-template-columns and grid-template-rows properties
was including the distribution offset because of content alignment.
We should subtract that offset, like we do for the case of gaps,
when we're calculating the computed style.

Test: fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForGridTrackList):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::offsetBetweenTracks):
(WebCore::RenderGrid::populateGridPositions): Deleted FIXME.

  • rendering/RenderGrid.h:

LayoutTests:

  • fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment-expected.txt: Added.
  • fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199980 r199981  
     12016-04-25  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Fix grid-template-columns|rows computed style with content alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=156793
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment-expected.txt: Added.
     9        * fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html: Added.
     10
    1112016-04-25  Frederic Wang  <fwang@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r199980 r199981  
     12016-04-25  Manuel Rego Casasnovas  <rego@igalia.com>
     2
     3        [css-grid] Fix grid-template-columns|rows computed style with content alignment
     4        https://bugs.webkit.org/show_bug.cgi?id=156793
     5
     6        Reviewed by Darin Adler.
     7
     8        Computed style of grid-template-columns and grid-template-rows properties
     9        was including the distribution offset because of content alignment.
     10        We should subtract that offset, like we do for the case of gaps,
     11        when we're calculating the computed style.
     12
     13        Test: fast/css-grid-layout/grid-template-columns-rows-computed-style-gaps-content-alignment.html
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore::valueForGridTrackList):
     17        * rendering/RenderGrid.cpp:
     18        (WebCore::RenderGrid::offsetBetweenTracks):
     19        (WebCore::RenderGrid::populateGridPositions): Deleted FIXME.
     20        * rendering/RenderGrid.h:
     21
    1222016-04-25  Frederic Wang  <fwang@igalia.com>
    223
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r199964 r199981  
    10711071    unsigned insertionIndex;
    10721072    if (isRenderGrid) {
    1073         const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? downcast<RenderGrid>(*renderer).columnPositions() : downcast<RenderGrid>(*renderer).rowPositions();
     1073        auto& grid = downcast<RenderGrid>(*renderer);
     1074        const auto& trackPositions = direction == ForColumns ? grid.columnPositions() : grid.rowPositions();
    10741075        // There are at least #tracks + 1 grid lines (trackPositions). Apart from that, the grid container can generate implicit grid tracks,
    10751076        // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
     
    10771078
    10781079        unsigned i = 0;
    1079         LayoutUnit gutterSize = downcast<RenderGrid>(*renderer).guttersSize(direction, 2);
     1080        LayoutUnit gutterSize = grid.guttersSize(direction, 2);
     1081        LayoutUnit offsetBetweenTracks = grid.offsetBetweenTracks(direction);
    10801082        for (; i < trackPositions.size() - 2; ++i) {
    10811083            addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, list.get());
    1082             list.get().append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i] - gutterSize, style));
    1083         }
    1084         // Last track line does not have any gutter.
     1084            list.get().append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i] - gutterSize - offsetBetweenTracks, style));
     1085        }
     1086        // Last track line does not have any gutter or distribution offset.
    10851087        addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, list.get());
    10861088        list.get().append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPositions[i], style));
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r199964 r199981  
    429429}
    430430
     431LayoutUnit RenderGrid::offsetBetweenTracks(GridTrackSizingDirection direction) const
     432{
     433    return direction == ForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows;
     434}
     435
    431436void RenderGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    432437{
     
    16471652    // assume from now on that we just store positions of the initial grid lines of each track,
    16481653    // except the last one, which is the only one considered as a final grid line of a track.
    1649     // FIXME: This will affect the computed style value of grid tracks size, since we are
    1650     // using these positions to compute them.
    16511654
    16521655    // The grid container's frame elements (border, padding and <content-position> offset) are sensible to the
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r199964 r199981  
    6262
    6363    LayoutUnit guttersSize(GridTrackSizingDirection, size_t span) const;
     64    LayoutUnit offsetBetweenTracks(GridTrackSizingDirection) const;
    6465
    6566private:
Note: See TracChangeset for help on using the changeset viewer.