Index: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp |
index 60d2e274f07a9216e201e9cb52986dcd891c4e46..ef23be5d587deb2357895fd54d9b8f41ca3897b4 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp |
@@ -42,6 +42,8 @@ |
namespace blink { |
+static const ItemPosition selfAlignmentNormalBehavior = ItemPositionStretch; |
+ |
static bool hasAspectRatio(const LayoutBox& child) |
{ |
return child.isImage() || child.isCanvas() || child.isVideo(); |
@@ -75,7 +77,6 @@ struct LayoutFlexibleBox::Violation { |
LayoutUnit childInnerFlexBaseSize; |
}; |
- |
LayoutFlexibleBox::LayoutFlexibleBox(Element* element) |
: LayoutBlock(element) |
, m_orderIterator(this) |
@@ -181,7 +182,7 @@ int LayoutFlexibleBox::baselinePosition(FontBaseline, bool, LineDirectionMode di |
return beforeMarginInLineDirection(direction) + baseline; |
} |
-static const StyleContentAlignmentData& normalValueBehavior() |
+static const StyleContentAlignmentData& contentAlignmentNormalBehavior() |
{ |
// The justify-content property applies along the main axis, but since flexing |
// in the main axis is controlled by flex, stretch behaves as flex-start (ignoring |
@@ -251,12 +252,14 @@ void LayoutFlexibleBox::styleDidChange(StyleDifference diff, const ComputedStyle |
{ |
LayoutBlock::styleDidChange(diff, oldStyle); |
- if (oldStyle && oldStyle->alignItemsPosition() == ItemPositionStretch && diff.needsFullLayout()) { |
+ if (oldStyle && oldStyle->resolvedAlignItems(selfAlignmentNormalBehavior).position() == ItemPositionStretch && diff.needsFullLayout()) { |
// Flex items that were previously stretching need to be relayed out so we can compute new available cross axis space. |
// This is only necessary for stretching since other alignment values don't change the size of the box. |
+ const ComputedStyle& newStyle = styleRef(); |
for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { |
- ItemPosition previousAlignment = ComputedStyle::resolveAlignment(*oldStyle, child->styleRef(), ItemPositionStretch); |
- if (previousAlignment == ItemPositionStretch && previousAlignment != ComputedStyle::resolveAlignment(styleRef(), child->styleRef(), ItemPositionStretch)) |
+ const ComputedStyle& childStyle = child->styleRef(); |
+ ItemPosition previousAlignment = childStyle.resolvedAlignSelf(*oldStyle, selfAlignmentNormalBehavior).position(); |
+ if (previousAlignment == ItemPositionStretch && previousAlignment != childStyle.resolvedAlignSelf(newStyle, selfAlignmentNormalBehavior).position()) |
child->setChildNeedsLayout(MarkOnlyThis); |
} |
} |
@@ -1219,7 +1222,7 @@ void LayoutFlexibleBox::prepareChildForPositionedLayout(LayoutBox& child, Layout |
ItemPosition LayoutFlexibleBox::alignmentForChild(const LayoutBox& child) const |
{ |
- ItemPosition align = ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch); |
+ ItemPosition align = child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).position(); |
if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) |
align = ItemPositionFlexStart; |
@@ -1312,8 +1315,8 @@ void LayoutFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons |
{ |
ASSERT(childSizes.size() == children.size()); |
- ContentPosition position = styleRef().resolvedJustifyContentPosition(normalValueBehavior()); |
- ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(normalValueBehavior()); |
+ ContentPosition position = styleRef().resolvedJustifyContentPosition(contentAlignmentNormalBehavior()); |
+ ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()); |
size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren(children); |
LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, availableFreeSpace); |
@@ -1406,8 +1409,8 @@ void LayoutFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons |
void LayoutFlexibleBox::layoutColumnReverse(const OrderedFlexItemList& children, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace) |
{ |
- ContentPosition position = styleRef().resolvedJustifyContentPosition(normalValueBehavior()); |
- ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(normalValueBehavior()); |
+ ContentPosition position = styleRef().resolvedJustifyContentPosition(contentAlignmentNormalBehavior()); |
+ ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()); |
// This is similar to the logic in layoutAndPlaceChildren, except we place the children |
// starting from the end of the flexbox. We also don't need to layout anything since we're |
@@ -1467,8 +1470,8 @@ static LayoutUnit alignContentSpaceBetweenChildren(LayoutUnit availableFreeSpace |
void LayoutFlexibleBox::alignFlexLines(Vector<LineContext>& lineContexts) |
{ |
- ContentPosition position = styleRef().resolvedAlignContentPosition(normalValueBehavior()); |
- ContentDistributionType distribution = styleRef().resolvedAlignContentDistribution(normalValueBehavior()); |
+ ContentPosition position = styleRef().resolvedAlignContentPosition(contentAlignmentNormalBehavior()); |
+ ContentDistributionType distribution = styleRef().resolvedAlignContentDistribution(contentAlignmentNormalBehavior()); |
// 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. |
@@ -1538,6 +1541,7 @@ void LayoutFlexibleBox::alignChildren(const Vector<LineContext>& lineContexts) |
switch (alignmentForChild(*child)) { |
case ItemPositionAuto: |
+ case ItemPositionNormal: |
ASSERT_NOT_REACHED(); |
break; |
case ItemPositionStretch: { |