Index: Source/core/css/CSSComputedStyleDeclaration.cpp |
diff --git a/Source/core/css/CSSComputedStyleDeclaration.cpp b/Source/core/css/CSSComputedStyleDeclaration.cpp |
index d2aae7dff888c26e3357ccb41d925bf2ef766978..3c150c71a26cb533a8860e281119ccf099fd29d2 100644 |
--- a/Source/core/css/CSSComputedStyleDeclaration.cpp |
+++ b/Source/core/css/CSSComputedStyleDeclaration.cpp |
@@ -55,6 +55,7 @@ |
#include "core/css/resolver/StyleResolver.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExceptionCode.h" |
+#include "core/dom/NodeRenderingTraversal.h" |
#include "core/dom/PseudoElement.h" |
#include "core/rendering/RenderBox.h" |
#include "core/rendering/RenderGrid.h" |
@@ -1536,15 +1537,16 @@ Node* CSSComputedStyleDeclaration::styledNode() const |
return m_node.get(); |
} |
-static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) |
+static void resolveAlignment(Node* styledNode, ItemPosition& position, OverflowAlignment& overflow) |
{ |
- if (position != ItemPositionAuto) |
- return position; |
- |
- bool isFlexOrGrid = element && element->computedStyle() |
- && element->computedStyle()->isDisplayFlexibleOrGridBox(); |
- |
- return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart; |
+ if (position == ItemPositionAuto) { |
+ if (Node* parent = NodeRenderingTraversal::parent(styledNode)) { |
+ if (RenderStyle* parentStyle = parent->computedStyle()) { |
+ position = parentStyle->alignItems(); |
+ overflow = parentStyle->alignItemsOverflowAlignment(); |
+ } |
+ } |
+ } |
} |
static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType) |
@@ -1828,9 +1830,13 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
case CSSPropertyAlignContent: |
return cssValuePool().createValue(style->alignContent()); |
case CSSPropertyAlignItems: |
- return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->alignItems(), styledNode), style->alignItemsOverflowAlignment(), NonLegacyPosition); |
- case CSSPropertyAlignSelf: |
- return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->alignSelf(), styledNode->parentNode()), style->alignSelfOverflowAlignment(), NonLegacyPosition); |
+ return valueForItemPositionWithOverflowAlignment(style->alignItems(), style->alignItemsOverflowAlignment(), NonLegacyPosition); |
+ case CSSPropertyAlignSelf: { |
+ ItemPosition alignSelf = style->alignSelf(); |
+ OverflowAlignment overflow = style->alignSelfOverflowAlignment(); |
+ resolveAlignment(styledNode, alignSelf, overflow); |
+ return valueForItemPositionWithOverflowAlignment(alignSelf, overflow, NonLegacyPosition); |
+ } |
case CSSPropertyFlex: |
return valuesForShorthandProperty(flexShorthand()); |
case CSSPropertyFlexBasis: |
@@ -1998,9 +2004,13 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu |
case CSSPropertyIsolation: |
return cssValuePool().createValue(style->isolation()); |
case CSSPropertyJustifyItems: |
- return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->justifyItems(), styledNode), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType()); |
- case CSSPropertyJustifySelf: |
- return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(style->justifySelf(), styledNode->parentNode()), style->justifySelfOverflowAlignment(), NonLegacyPosition); |
+ return valueForItemPositionWithOverflowAlignment(style->justifyItems(), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType()); |
+ case CSSPropertyJustifySelf: { |
+ ItemPosition justifySelf = style->justifySelf(); |
+ OverflowAlignment overflow = style->justifySelfOverflowAlignment(); |
+ resolveAlignment(styledNode, justifySelf, overflow); |
+ return valueForItemPositionWithOverflowAlignment(justifySelf, overflow, NonLegacyPosition); |
+ } |
case CSSPropertyLeft: |
return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
case CSSPropertyLetterSpacing: |