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 e8134f47117114199ad7eba49d503d2795bde7cc..a6b584ce0a6d985d3537fcdef18107a66379f004 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(); |
@@ -181,7 +183,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 |
@@ -309,12 +311,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); |
} |
} |
@@ -1371,6 +1375,7 @@ static LayoutUnit alignmentOffset(LayoutUnit availableFreeSpace, ItemPosition po |
{ |
switch (position) { |
case ItemPositionAuto: |
+ case ItemPositionNormal: |
ASSERT_NOT_REACHED(); |
break; |
case ItemPositionStretch: |
@@ -1419,8 +1424,8 @@ LayoutUnit LayoutFlexibleBox::staticMainAxisPositionForPositionedChild(const Lay |
{ |
const LayoutUnit availableSpace = mainAxisContentExtent(contentLogicalHeight()) - mainAxisExtentForChild(child); |
- ContentPosition position = styleRef().resolvedJustifyContentPosition(normalValueBehavior()); |
- ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(normalValueBehavior()); |
+ ContentPosition position = styleRef().resolvedJustifyContentPosition(contentAlignmentNormalBehavior()); |
+ ContentDistributionType distribution = styleRef().resolvedJustifyContentDistribution(contentAlignmentNormalBehavior()); |
LayoutUnit offset = initialJustifyContentOffset(availableSpace, position, distribution, 1); |
if (styleRef().flexDirection() == FlowRowReverse || styleRef().flexDirection() == FlowColumnReverse) |
offset = availableSpace - offset; |
@@ -1492,7 +1497,8 @@ void LayoutFlexibleBox::prepareChildForPositionedLayout(LayoutBox& child) |
ItemPosition LayoutFlexibleBox::alignmentForChild(const LayoutBox& child) const |
{ |
- ItemPosition align = ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositionStretch); |
+ ItemPosition align = child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavior).position(); |
+ DCHECK(align != ItemPositionAuto && align != ItemPositionNormal); |
if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) |
align = ItemPositionFlexStart; |
@@ -1585,8 +1591,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); |
@@ -1687,8 +1693,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 |
@@ -1747,8 +1753,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. |