Changeset 190783 in webkit


Ignore:
Timestamp:
Oct 9, 2015 5:47:47 AM (9 years ago)
Author:
svillar@igalia.com
Message:

[css-grid] Remove unneeded calls to compute(Content)LogicalWidth(Height)
https://bugs.webkit.org/show_bug.cgi?id=149926

Reviewed by Darin Adler.

In order to resolve a Length to a LayoutUnit we need to
provide a maximum value so that i.e. percentages are correctly
computed. That maximum value was computeLogicalWidth() for
columns and computeContentLogicalHeight() for rows. We were
calling it for every single track with a definite size instead
of computing it once and reusing it multiple times.

This brings some nice performance improvements:

  • 2.9% in /Layout/fixed-grid-lots-of-data
  • 2.95% in /Layout/fixed-grid-lots-of-stretched-data

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

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
(WebCore::RenderGrid::computeUsedBreadthOfMinLength):
(WebCore::RenderGrid::computeUsedBreadthOfMaxLength):
(WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):

  • rendering/RenderGrid.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r190763 r190783  
     12015-10-08  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-grid] Remove unneeded calls to compute(Content)LogicalWidth(Height)
     4        https://bugs.webkit.org/show_bug.cgi?id=149926
     5
     6        Reviewed by Darin Adler.
     7
     8        In order to resolve a Length to a LayoutUnit we need to
     9        provide a maximum value so that i.e. percentages are correctly
     10        computed. That maximum value was computeLogicalWidth() for
     11        columns and computeContentLogicalHeight() for rows. We were
     12        calling it for every single track with a definite size instead
     13        of computing it once and reusing it multiple times.
     14
     15        This brings some nice performance improvements:
     16        - 2.9%  in /Layout/fixed-grid-lots-of-data
     17        - 2.95% in /Layout/fixed-grid-lots-of-stretched-data
     18
     19        No new tests required as there is no change in functionality.
     20
     21        * rendering/RenderGrid.cpp:
     22        (WebCore::RenderGrid::computeUsedBreadthOfGridTracks):
     23        (WebCore::RenderGrid::computeUsedBreadthOfMinLength):
     24        (WebCore::RenderGrid::computeUsedBreadthOfMaxLength):
     25        (WebCore::RenderGrid::tracksAreWiderThanMinTrackBreadth):
     26        * rendering/RenderGrid.h:
     27
    1282015-10-08  Chris Dumez  <cdumez@apple.com>
    229
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r190721 r190783  
    387387    sizingData.contentSizedTracksIndex.shrink(0);
    388388
     389    const LayoutUnit maxSize = direction == ForColumns ? contentLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0);
    389390    // 1. Initialize per Grid track variables.
    390391    for (unsigned i = 0; i < tracks.size(); ++i) {
     
    394395        const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth();
    395396
    396         track.setBaseSize(computeUsedBreadthOfMinLength(direction, minTrackBreadth));
    397         track.setGrowthLimit(computeUsedBreadthOfMaxLength(direction, maxTrackBreadth, track.baseSize()));
     397        track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize));
     398        track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, track.baseSize(), maxSize));
    398399        track.setInfinitelyGrowable(false);
    399400
     
    471472}
    472473
    473 LayoutUnit RenderGrid::computeUsedBreadthOfMinLength(GridTrackSizingDirection direction, const GridLength& gridLength) const
     474LayoutUnit RenderGrid::computeUsedBreadthOfMinLength(const GridLength& gridLength, LayoutUnit maxSize) const
    474475{
    475476    if (gridLength.isFlex())
     
    478479    const Length& trackLength = gridLength.length();
    479480    if (trackLength.isSpecified())
    480         return computeUsedBreadthOfSpecifiedLength(direction, trackLength);
     481        return valueForLength(trackLength, maxSize);
    481482
    482483    ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isMaxContent());
     
    484485}
    485486
    486 LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(GridTrackSizingDirection direction, const GridLength& gridLength, LayoutUnit usedBreadth) const
     487LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(const GridLength& gridLength, LayoutUnit usedBreadth, LayoutUnit maxSize) const
    487488{
    488489    if (gridLength.isFlex())
     
    490491
    491492    const Length& trackLength = gridLength.length();
    492     if (trackLength.isSpecified()) {
    493         LayoutUnit computedBreadth = computeUsedBreadthOfSpecifiedLength(direction, trackLength);
    494         ASSERT(computedBreadth != infinity);
    495         return computedBreadth;
    496     }
     493    if (trackLength.isSpecified())
     494        return valueForLength(trackLength, maxSize);
    497495
    498496    ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isMaxContent());
    499497    return infinity;
    500 }
    501 
    502 LayoutUnit RenderGrid::computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection direction, const Length& trackLength) const
    503 {
    504     ASSERT(trackLength.isSpecified());
    505     if (direction == ForColumns)
    506         return valueForLength(trackLength, contentLogicalWidth());
    507     return valueForLength(trackLength, computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0));
    508498}
    509499
     
    1002992bool RenderGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection direction, const Vector<GridTrack>& tracks)
    1003993{
     994    const LayoutUnit maxSize = direction == ForColumns ? contentLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0);
    1004995    for (unsigned i = 0; i < tracks.size(); ++i) {
    1005996        const GridTrackSize& trackSize = gridTrackSize(direction, i);
    1006997        const GridLength& minTrackBreadth = trackSize.minTrackBreadth();
    1007         if (computeUsedBreadthOfMinLength(direction, minTrackBreadth) > tracks[i].baseSize())
     998        if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].baseSize())
    1008999            return false;
    10091000    }
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r190663 r190783  
    7272    void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData&, LayoutUnit& availableLogicalSpace);
    7373    bool gridElementIsShrinkToFit();
    74     LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const GridLength&) const;
    75     LayoutUnit computeUsedBreadthOfMaxLength(GridTrackSizingDirection, const GridLength&, LayoutUnit usedBreadth) const;
    76     LayoutUnit computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection, const Length&) const;
     74    LayoutUnit computeUsedBreadthOfMinLength(const GridLength&, LayoutUnit maxSize) const;
     75    LayoutUnit computeUsedBreadthOfMaxLength(const GridLength&, LayoutUnit usedBreadth, LayoutUnit maxSize) const;
    7776    void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridSizingData&);
    7877
Note: See TracChangeset for help on using the changeset viewer.