Changeset 178701 in webkit


Ignore:
Timestamp:
Jan 20, 2015 1:19:48 AM (9 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Wrong arguments passed to computeNormalizedFractionBreadth
https://bugs.webkit.org/show_bug.cgi?id=139058

Reviewed by Andreas Kling.

Source/WebCore:

The method RenderGrid::computeNormalizedFractionBreadth() is
supposed to get as fourth argument either the grid element's
content box size or the max-size of a particular grid item. For
the former we were incorrectly passing the free space after
distributing the available space to tracks.

Apart from that, that method has a bug in its implementation. As
we were using the free space instead of the grid element's content
box size, we didn't have to subtract the usedBreadth of grid
tracks from the passed in value. That did not work for the case of
the caller passing the max-size of a particular item.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::computeNormalizedFractionBreadth):

LayoutTests:

from r148642) as the test works as expected now.

  • fast/css-grid-layout/flex-and-minmax-content-resolution-rows.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r178698 r178701  
     12015-01-19  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Wrong arguments passed to computeNormalizedFractionBreadth
     4        https://bugs.webkit.org/show_bug.cgi?id=139058
     5
     6        Reviewed by Andreas Kling.
     7
     8        * TestExpectations: Removed the test added in r148643 (missing
     9        from r148642) as the test works as expected now.
     10        * fast/css-grid-layout/flex-and-minmax-content-resolution-rows.html:
     11
    1122015-01-19  Michael Saboff  <msaboff@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r178652 r178701  
    458458
    459459webkit.org/b/140309 css3/background/background-repeat-space-content.html [ ImageOnlyFailure ]
    460 
    461 webkit.org/b/139058 fast/css-grid-layout/flex-and-minmax-content-resolution-rows.html [ Failure ]
  • trunk/LayoutTests/fast/css-grid-layout/flex-and-minmax-content-resolution-rows.html

    r168416 r178701  
    8787<div class="constrainedContainer">
    8888    <div class="grid gridMinMinContent">
    89         <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="30">XXXXX XXXX</div>
     89        <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXX</div>
    9090        <div class="sizedToGridArea secondRowFirstColumn" data-expected-width="50" data-expected-height="50">XXXXX XXXX</div>
    9191    </div>
     
    102102<div style="width: 10px; height: 40px">
    103103    <div class="grid gridMinMinContent">
    104         <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="30">XXXXX XXXX</div>
     104        <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXX</div>
    105105        <div class="sizedToGridArea secondRowFirstColumn" data-expected-width="50" data-expected-height="50">XXXXX XXXX</div>
    106106    </div>
     
    116116<div style="width: 10px; height: 110px;">
    117117    <div class="grid gridMinMinContent">
    118         <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="30">XXXXX XXXX</div>
     118        <div class="sizedToGridArea firstRowFirstColumn" data-expected-width="50" data-expected-height="20">XXXXX XXXX</div>
    119119        <div class="sizedToGridArea secondRowFirstColumn" data-expected-width="50" data-expected-height="50">XXXXX XXXX</div>
    120120    </div>
  • trunk/Source/WebCore/ChangeLog

    r178691 r178701  
     12015-01-19  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Wrong arguments passed to computeNormalizedFractionBreadth
     4        https://bugs.webkit.org/show_bug.cgi?id=139058
     5
     6        Reviewed by Andreas Kling.
     7
     8        The method RenderGrid::computeNormalizedFractionBreadth() is
     9        supposed to get as fourth argument either the grid element's
     10        content box size or the max-size of a particular grid item. For
     11        the former we were incorrectly passing the free space after
     12        distributing the available space to tracks.
     13
     14        Apart from that, that method has a bug in its implementation. As
     15        we were using the free space instead of the grid element's content
     16        box size, we didn't have to subtract the usedBreadth of grid
     17        tracks from the passed in value. That did not work for the case of
     18        the caller passing the max-size of a particular item.
     19
     20        * rendering/RenderGrid.cpp:
     21        (WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
     22        (WebCore::RenderGrid::computeNormalizedFractionBreadth):
     23
    1242015-01-19  Myles C. Maxfield  <mmaxfield@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r178642 r178701  
    298298void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace)
    299299{
     300    const LayoutUnit initialAvailableLogicalSpace = availableLogicalSpace;
    300301    Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTracks : sizingData.rowTracks;
    301302    Vector<unsigned> flexibleSizedTracksIndex;
     
    335336        return;
    336337
    337     // 3. Grow all Grid tracks in GridTracks from their UsedBreadth up to their MaxBreadth value until
    338     // availableLogicalSpace (RemainingSpace in the specs) is exhausted.
     338    // 3. Grow all Grid tracks in GridTracks from their UsedBreadth up to their MaxBreadth value until availableLogicalSpace is exhausted.
    339339    if (!hasUndefinedRemainingSpace) {
    340340        const unsigned tracksSize = tracks.size();
     
    355355    double normalizedFractionBreadth = 0;
    356356    if (!hasUndefinedRemainingSpace)
    357         normalizedFractionBreadth = computeNormalizedFractionBreadth(tracks, GridSpan(0, tracks.size() - 1), direction, availableLogicalSpace);
     357        normalizedFractionBreadth = computeNormalizedFractionBreadth(tracks, GridSpan(0, tracks.size() - 1), direction, initialAvailableLogicalSpace);
    358358    else {
    359359        for (auto trackIndex : flexibleSizedTracksIndex) {
     
    422422}
    423423
    424 double RenderGrid::computeNormalizedFractionBreadth(Vector<GridTrack>& tracks, const GridSpan& tracksSpan, GridTrackSizingDirection direction, LayoutUnit availableLogicalSpace) const
    425 {
    426     // |availableLogicalSpace| already accounts for the used breadths so no need to remove it here.
    427 
     424double RenderGrid::computeNormalizedFractionBreadth(Vector<GridTrack>& tracks, const GridSpan& tracksSpan, GridTrackSizingDirection direction, LayoutUnit spaceToFill) const
     425{
     426    LayoutUnit allocatedSpace;
    428427    Vector<GridTrackForNormalization> tracksForNormalization;
    429428    for (auto& position : tracksSpan) {
     429        GridTrack& track = tracks[position.toInt()];
     430        allocatedSpace += track.m_usedBreadth;
     431
    430432        const GridTrackSize& trackSize = gridTrackSize(direction, position.toInt());
    431433        if (!trackSize.maxTrackBreadth().isFlex())
    432434            continue;
    433435
    434         tracksForNormalization.append(GridTrackForNormalization(tracks[position.toInt()], trackSize.maxTrackBreadth().flex()));
     436        tracksForNormalization.append(GridTrackForNormalization(track, trackSize.maxTrackBreadth().flex()));
    435437    }
    436438
     
    448450    double accumulatedFractions = 0;
    449451    LayoutUnit fractionValueBasedOnGridItemsRatio = 0;
    450     LayoutUnit availableLogicalSpaceIgnoringFractionTracks = availableLogicalSpace;
     452    LayoutUnit availableLogicalSpaceIgnoringFractionTracks = spaceToFill - allocatedSpace;
    451453
    452454    for (auto& track : tracksForNormalization) {
Note: See TracChangeset for help on using the changeset viewer.