Commit 67afbdf2 authored by jfernandez@igalia.com's avatar jfernandez@igalia.com

[CSS Grid Layout] Use Render methods, rather than style, to

 determine shrink-to-fit behavior

In order to determine whether the RemainingSpace is 
undetermined or not (shrink-to-fit) the current algorithm 
is checking out the style for clarifying if the Render object 
is float or absolute positioned.

It's better to use the Render functions instead, since the 
style might be applied or not, depending on several factors, 
like CSS properties inheritance.

BUG=79180, 234204

Review URL: https://codereview.chromium.org/181333003

git-svn-id: svn://svn.chromium.org/blink/trunk@168573 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 06aeacf3
This test checks that the shrink-to-fit behavior is applied to the float and out-of-flow positioned elements.
The following grids should be 400px * 400px, except the first one which uses 'relative' positioning.
PASS
PASS
PASS
PASS
<!DOCTYPE html>
<html>
<style>
.grid {
display: grid;
grid-template-columns: 200px 200px;
grid-template-rows: 200px 200px;
}
#absolutePos {
position: absolute;
}
#fixedPos {
position: fixed;
}
#floatPos {
float: left;
}
#one {
color: blue;
background: red;
grid-column: 1;
grid-row: 1;
}
#two {
color: yellow;
background: green;
grid-column: 2;
grid-row: 1;
}
#three {
color: gray;
background: pink;
grid-column: 1;
grid-row: 2;
}
#four {
color: orange;
background: brown;
grid-column: 2;
grid-row: 2;
}
</style>
<script src="../../resources/check-layout.js"></script>
<body onload="checkLayout('.grid')">
<p>This test checks that the shrink-to-fit behavior is applied to the float and out-of-flow positioned elements.</p>
<p>The following grids should be 400px * 400px, except the first one which uses 'relative' positioning.</p>
<div class="grid" id="regularGrid" data-expected-height="400" data-expected-width="769">
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<div id="four"></div>
</div>
<div class="grid" id="absolutePos" data-expected-height="400" data-expected-width="400">
<div class="gg" id="one"></div>
<div class="gg" id="two"></div>
<div class="gg" id="three"></div>
<div class="gg" id="four"></div>
</div>
<div class="grid" id="fixedPos" data-expected-height="400" data-expected-width="400">
<div class="gg" id="one"></div>
<div class="gg" id="two"></div>
<div class="gg" id="three"></div>
<div class="gg" id="four"></div>
</div>
<div class="grid" id="floatPos" data-expected-height="400" data-expected-width="400">
<div class="gg" id="one"></div>
<div class="gg" id="two"></div>
<div class="gg" id="three"></div>
<div class="gg" id="four"></div>
</div>
</body>
</html>
......@@ -341,9 +341,9 @@ void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
computeUsedBreadthOfGridTracks(direction, sizingData, availableLogicalSpace);
}
static bool gridElementIsShrinkToFit(const RenderStyle& style)
bool RenderGrid::gridElementIsShrinkToFit()
{
return style.isFloating() || style.position() == AbsolutePosition;
return isFloatingOrOutOfFlowPositioned();
}
void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace)
......@@ -379,7 +379,7 @@ void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
availableLogicalSpace -= tracks[i].m_usedBreadth;
}
const bool hasUndefinedRemainingSpace = (direction == ForRows) ? style()->logicalHeight().isAuto() : gridElementIsShrinkToFit(*style());
const bool hasUndefinedRemainingSpace = (direction == ForRows) ? style()->logicalHeight().isAuto() : gridElementIsShrinkToFit();
if (!hasUndefinedRemainingSpace && availableLogicalSpace <= 0)
return;
......
......@@ -72,6 +72,7 @@ private:
class GridIterator;
struct GridSizingData;
bool gridElementIsShrinkToFit();
void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData&);
void computeUsedBreadthOfGridTracks(GridTrackSizingDirection, GridSizingData&, LayoutUnit& availableLogicalSpace);
LayoutUnit computeUsedBreadthOfMinLength(GridTrackSizingDirection, const GridLength&) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment