Minor Refactor in RenderFlexbox

This is a minor refactoring which moves the case of calculation
of cross-size of flex line for single line flex-container from
RenderFlexibleBox::repositionLogicalHeightDependentFlexItems
to RenderFlexibleBox::alignFlexLines which is more appropriate
and saves us from doing unnecessary work.  The old code was doing 
align-content for a single line, then reposition 
everything when aligning children.

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176399 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7b943879
...@@ -316,11 +316,6 @@ void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineCon ...@@ -316,11 +316,6 @@ void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(Vector<LineCon
LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? LayoutUnit() : lineContexts[0].crossAxisOffset; LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? LayoutUnit() : lineContexts[0].crossAxisOffset;
alignFlexLines(lineContexts); alignFlexLines(lineContexts);
// If we have a single line flexbox or a multiline line flexbox with only one flex line,
// the line height is all the available space.
// For flex-direction: row, this means we need to use the height, so we do this after calling updateLogicalHeight.
if (lineContexts.size() == 1)
lineContexts[0].crossAxisExtent = crossAxisContentExtent();
alignChildren(lineContexts); alignChildren(lineContexts);
if (style()->flexWrap() == FlexWrapReverse) if (style()->flexWrap() == FlexWrapReverse)
...@@ -1240,7 +1235,15 @@ static LayoutUnit alignContentSpaceBetweenChildren(LayoutUnit availableFreeSpace ...@@ -1240,7 +1235,15 @@ static LayoutUnit alignContentSpaceBetweenChildren(LayoutUnit availableFreeSpace
void RenderFlexibleBox::alignFlexLines(Vector<LineContext>& lineContexts) void RenderFlexibleBox::alignFlexLines(Vector<LineContext>& lineContexts)
{ {
if (!isMultiline() || style()->alignContent() == AlignContentFlexStart) // If we have a single line flexbox or a multiline line flexbox with only one flex line,
// the line height is all the available space.
// For flex-direction: row, this means we need to use the height, so we do this after calling updateLogicalHeight.
if (lineContexts.size() == 1) {
lineContexts[0].crossAxisExtent = crossAxisContentExtent();
return;
}
if (style()->alignContent() == AlignContentFlexStart)
return; return;
LayoutUnit availableCrossAxisSpace = crossAxisContentExtent(); LayoutUnit availableCrossAxisSpace = crossAxisContentExtent();
......
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