Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed repaint tests. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 dceebd5cf7119240022fc76bdec3777d13ef43b9..253d39911b6c191a12cb9b0f84a76468d3357415 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
@@ -305,21 +307,6 @@ void LayoutFlexibleBox::removeChild(LayoutObject* child)
m_intrinsicSizeAlongMainAxis.remove(child);
}
-void LayoutFlexibleBox::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle)
-{
- LayoutBlock::styleDidChange(diff, oldStyle);
-
- if (oldStyle && oldStyle->alignItemsPosition() == 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.
- 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))
- child->setChildNeedsLayout(MarkOnlyThis);
- }
- }
-}
-
void LayoutFlexibleBox::layoutBlock(bool relayoutChildren)
{
ASSERT(needsLayout());
@@ -1371,6 +1358,7 @@ static LayoutUnit alignmentOffset(LayoutUnit availableFreeSpace, ItemPosition po
{
switch (position) {
case ItemPositionAuto:
+ case ItemPositionNormal:
ASSERT_NOT_REACHED();
break;
case ItemPositionStretch:
@@ -1419,8 +1407,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 +1480,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(selfAlignmentNormalBehavior).position();
+ DCHECK(align != ItemPositionAuto && align != ItemPositionNormal);
if (align == ItemPositionBaseline && hasOrthogonalFlow(child))
align = ItemPositionFlexStart;
@@ -1585,8 +1574,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 +1676,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 +1736,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.

Powered by Google App Engine
This is Rietveld 408576698