Modified: trunk/Source/WebCore/ChangeLog (190782 => 190783)
--- trunk/Source/WebCore/ChangeLog 2015-10-09 09:07:32 UTC (rev 190782)
+++ trunk/Source/WebCore/ChangeLog 2015-10-09 12:47:47 UTC (rev 190783)
@@ -1,3 +1,30 @@
+2015-10-08 Sergio Villar Senin <svil...@igalia.com>
+
+ [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:
+
2015-10-08 Chris Dumez <cdu...@apple.com>
Unreviewed, build fix for ENABLE(MEDIA_SESSION) after r190030.
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (190782 => 190783)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2015-10-09 09:07:32 UTC (rev 190782)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2015-10-09 12:47:47 UTC (rev 190783)
@@ -386,6 +386,7 @@
Vector<unsigned> flexibleSizedTracksIndex;
sizingData.contentSizedTracksIndex.shrink(0);
+ const LayoutUnit maxSize = direction == ForColumns ? contentLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0);
// 1. Initialize per Grid track variables.
for (unsigned i = 0; i < tracks.size(); ++i) {
GridTrack& track = tracks[i];
@@ -393,8 +394,8 @@
const GridLength& minTrackBreadth = trackSize.minTrackBreadth();
const GridLength& maxTrackBreadth = trackSize.maxTrackBreadth();
- track.setBaseSize(computeUsedBreadthOfMinLength(direction, minTrackBreadth));
- track.setGrowthLimit(computeUsedBreadthOfMaxLength(direction, maxTrackBreadth, track.baseSize()));
+ track.setBaseSize(computeUsedBreadthOfMinLength(minTrackBreadth, maxSize));
+ track.setGrowthLimit(computeUsedBreadthOfMaxLength(maxTrackBreadth, track.baseSize(), maxSize));
track.setInfinitelyGrowable(false);
if (trackSize.isContentSized())
@@ -470,43 +471,32 @@
}
}
-LayoutUnit RenderGrid::computeUsedBreadthOfMinLength(GridTrackSizingDirection direction, const GridLength& gridLength) const
+LayoutUnit RenderGrid::computeUsedBreadthOfMinLength(const GridLength& gridLength, LayoutUnit maxSize) const
{
if (gridLength.isFlex())
return 0;
const Length& trackLength = gridLength.length();
if (trackLength.isSpecified())
- return computeUsedBreadthOfSpecifiedLength(direction, trackLength);
+ return valueForLength(trackLength, maxSize);
ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isMaxContent());
return 0;
}
-LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(GridTrackSizingDirection direction, const GridLength& gridLength, LayoutUnit usedBreadth) const
+LayoutUnit RenderGrid::computeUsedBreadthOfMaxLength(const GridLength& gridLength, LayoutUnit usedBreadth, LayoutUnit maxSize) const
{
if (gridLength.isFlex())
return usedBreadth;
const Length& trackLength = gridLength.length();
- if (trackLength.isSpecified()) {
- LayoutUnit computedBreadth = computeUsedBreadthOfSpecifiedLength(direction, trackLength);
- ASSERT(computedBreadth != infinity);
- return computedBreadth;
- }
+ if (trackLength.isSpecified())
+ return valueForLength(trackLength, maxSize);
ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isMaxContent());
return infinity;
}
-LayoutUnit RenderGrid::computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection direction, const Length& trackLength) const
-{
- ASSERT(trackLength.isSpecified());
- if (direction == ForColumns)
- return valueForLength(trackLength, contentLogicalWidth());
- return valueForLength(trackLength, computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0));
-}
-
double RenderGrid::computeFlexFactorUnitSize(const Vector<GridTrack>& tracks, GridTrackSizingDirection direction, double flexFactorSum, LayoutUnit leftOverSpace, const Vector<unsigned, 8>& flexibleTracksIndexes, std::unique_ptr<TrackIndexSet> tracksToTreatAsInflexible) const
{
// We want to avoid the effect of flex factors sum below 1 making the factor unit size to grow exponentially.
@@ -1001,10 +991,11 @@
#ifndef NDEBUG
bool RenderGrid::tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection direction, const Vector<GridTrack>& tracks)
{
+ const LayoutUnit maxSize = direction == ForColumns ? contentLogicalWidth() : computeContentLogicalHeight(MainOrPreferredSize, style().logicalHeight(), Nullopt).valueOr(0);
for (unsigned i = 0; i < tracks.size(); ++i) {
const GridTrackSize& trackSize = gridTrackSize(direction, i);
const GridLength& minTrackBreadth = trackSize.minTrackBreadth();
- if (computeUsedBreadthOfMinLength(direction, minTrackBreadth) > tracks[i].baseSize())
+ if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].baseSize())
return false;
}
return true;
Modified: trunk/Source/WebCore/rendering/RenderGrid.h (190782 => 190783)
--- trunk/Source/WebCore/rendering/RenderGrid.h 2015-10-09 09:07:32 UTC (rev 190782)
+++ trunk/Source/WebCore/rendering/RenderGrid.h 2015-10-09 12:47:47 UTC (rev 190783)
@@ -71,9 +71,8 @@
class GridSizingData;
void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData&, LayoutUnit& availableLogicalSpace);
bool gridElementIsShrinkToFit();
- LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const GridLength&) const;
- LayoutUnit computeUsedBreadthOfMaxLength(GridTrackSizingDirection, const GridLength&, LayoutUnit usedBreadth) const;
- LayoutUnit computeUsedBreadthOfSpecifiedLength(GridTrackSizingDirection, const Length&) const;
+ LayoutUnit computeUsedBreadthOfMinLength(const GridLength&, LayoutUnit maxSize) const;
+ LayoutUnit computeUsedBreadthOfMaxLength(const GridLength&, LayoutUnit usedBreadth, LayoutUnit maxSize) const;
void resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection, GridSizingData&);
void ensureGridSize(unsigned maximumRowIndex, unsigned maximumColumnIndex);