Changeset 173868 in webkit


Ignore:
Timestamp:
Sep 23, 2014 1:37:10 AM (10 years ago)
Author:
svillar@igalia.com
Message:

[CSS Grid Layout] Do not grow tracks when the growth factor is 0
https://bugs.webkit.org/show_bug.cgi?id=136575

Reviewed by Darin Adler.

A couple of performance optimizations for the track sizing
algorithm. On the one hand we avoid the computation of the
available logical space share if the track has no growth potential
(the current breadth is the maximum breadth) and on the other
hand, we avoid calling RenderGrid::distributeSpaceToTracks() if
the available logical space is not greater than 0.

The combined effect of these two changes is an impressive +16%
improvement in auto-grid-lots-of-data.html performance test.

No new tests as there is no change in the functionality.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
(WebCore::RenderGrid::distributeSpaceToTracks):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173867 r173868  
     12014-09-15  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [CSS Grid Layout] Do not grow tracks when the growth factor is 0
     4        https://bugs.webkit.org/show_bug.cgi?id=136575
     5
     6        Reviewed by Darin Adler.
     7
     8        A couple of performance optimizations for the track sizing
     9        algorithm. On the one hand we avoid the computation of the
     10        available logical space share if the track has no growth potential
     11        (the current breadth is the maximum breadth) and on the other
     12        hand, we avoid calling RenderGrid::distributeSpaceToTracks() if
     13        the available logical space is not greater than 0.
     14
     15        The combined effect of these two changes is an impressive +16%
     16        improvement in auto-grid-lots-of-data.html performance test.
     17
     18        No new tests as there is no change in the functionality.
     19
     20        * rendering/RenderGrid.cpp:
     21        (WebCore::RenderGrid::resolveContentBasedTrackSizingFunctionsForItems):
     22        (WebCore::RenderGrid::distributeSpaceToTracks):
     23
    1242014-09-23  Ion Rosca  <rosca@adobe.com>
    225
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r173620 r173868  
    610610
    611611    // FIXME: We should pass different values for |tracksForGrowthAboveMaxBreadth|.
    612     distributeSpaceToTracks(sizingData.filteredTracks, &sizingData.filteredTracks, trackGetter, trackGrowthFunction, sizingData, additionalBreadthSpace);
     612    // Specs mandate to floor additionalBreadthSpace (extra-space in specs) to 0. Instead we directly avoid the function
     613    // call in those cases as it will be a noop in terms of track sizing.
     614    if (additionalBreadthSpace > 0)
     615        distributeSpaceToTracks(sizingData.filteredTracks, &sizingData.filteredTracks, trackGetter, trackGrowthFunction, sizingData, additionalBreadthSpace);
    613616}
    614617
     
    620623void RenderGrid::distributeSpaceToTracks(Vector<GridTrack*>& tracks, Vector<GridTrack*>* tracksForGrowthAboveMaxBreadth, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace)
    621624{
     625    ASSERT(availableLogicalSpace > 0);
    622626    std::sort(tracks.begin(), tracks.end(), sortByGridTrackGrowthPotential);
    623627
     
    627631    for (size_t i = 0; i < tracksSize; ++i) {
    628632        GridTrack& track = *tracks[i];
    629         LayoutUnit availableLogicalSpaceShare = availableLogicalSpace / (tracksSize - i);
    630633        LayoutUnit trackBreadth = (tracks[i]->*trackGetter)();
    631         LayoutUnit growthShare = std::max(LayoutUnit(), std::min(availableLogicalSpaceShare, track.m_maxBreadth - trackBreadth));
    632         // We should never shrink any grid track or else we can't guarantee we abide by our min-sizing function.
    633         sizingData.distributeTrackVector[i] = trackBreadth + growthShare;
    634         availableLogicalSpace -= growthShare;
     634        LayoutUnit trackGrowthPotential = track.m_maxBreadth - trackBreadth;
     635        sizingData.distributeTrackVector[i] = trackBreadth;
     636        if (trackGrowthPotential > 0) {
     637            LayoutUnit availableLogicalSpaceShare = availableLogicalSpace / (tracksSize - i);
     638            LayoutUnit growthShare = std::min(availableLogicalSpaceShare, trackGrowthPotential);
     639            // We should never shrink any grid track or else we can't guarantee we abide by our min-sizing function.
     640            sizingData.distributeTrackVector[i] += growthShare;
     641            availableLogicalSpace -= growthShare;
     642        }
    635643    }
    636644
Note: See TracChangeset for help on using the changeset viewer.