Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
index b4b82fb03e0b3883c3d476a5e3105d67cc38cb20..a3d2251f604ddcf99a55b211e97605c555f5ae2a 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -97,66 +97,11 @@ |
DirtyGrid(); |
} |
-StyleSelfAlignmentData LayoutGrid::SelfAlignmentForChild( |
- GridAxis axis, |
- const LayoutBox& child, |
- const ComputedStyle* style) const { |
- return axis == kGridRowAxis ? JustifySelfForChild(child, style) |
- : AlignSelfForChild(child, style); |
-} |
- |
-bool LayoutGrid::SelfAlignmentChangedToStretch(GridAxis axis, |
- const ComputedStyle& old_style, |
- const ComputedStyle& new_style, |
- const LayoutBox& child) const { |
- return SelfAlignmentForChild(axis, child, &old_style).GetPosition() != |
- kItemPositionStretch && |
- SelfAlignmentForChild(axis, child, &new_style).GetPosition() == |
- kItemPositionStretch; |
-} |
- |
-bool LayoutGrid::SelfAlignmentChangedFromStretch(GridAxis axis, |
- const ComputedStyle& old_style, |
- const ComputedStyle& new_style, |
- const LayoutBox& child) const { |
- return SelfAlignmentForChild(axis, child, &old_style).GetPosition() == |
- kItemPositionStretch && |
- SelfAlignmentForChild(axis, child, &new_style).GetPosition() != |
- kItemPositionStretch; |
-} |
- |
void LayoutGrid::StyleDidChange(StyleDifference diff, |
const ComputedStyle* old_style) { |
LayoutBlock::StyleDidChange(diff, old_style); |
if (!old_style) |
return; |
- |
- const ComputedStyle& new_style = StyleRef(); |
- if (old_style && |
- old_style->ResolvedAlignItems(SelfAlignmentNormalBehavior(this)) |
- .GetPosition() == kItemPositionStretch && |
- diff.NeedsFullLayout()) { |
- // Style changes on the grid container implying stretching (to-stretch) or |
- // shrinking (from-stretch) require the affected items to be laid out again. |
- // These logic only applies to 'stretch' since the rest of the alignment |
- // values don't change the size of the box. |
- // In any case, the items' overrideSize will be cleared and recomputed (if |
- // necessary) as part of the Grid layout logic, triggered by this style |
- // change. |
- for (LayoutBox* child = FirstInFlowChildBox(); child; |
- child = child->NextInFlowSiblingBox()) { |
- if (SelfAlignmentChangedToStretch(kGridRowAxis, *old_style, new_style, |
- *child) || |
- SelfAlignmentChangedFromStretch(kGridRowAxis, *old_style, new_style, |
- *child) || |
- SelfAlignmentChangedToStretch(kGridColumnAxis, *old_style, new_style, |
- *child) || |
- SelfAlignmentChangedFromStretch(kGridColumnAxis, *old_style, |
- new_style, *child)) { |
- child->SetNeedsLayout(LayoutInvalidationReason::kGridChanged); |
- } |
- } |
- } |
// FIXME: The following checks could be narrowed down if we kept track of |
// which type of grid items we have: |
@@ -1582,21 +1527,29 @@ |
} |
StyleSelfAlignmentData LayoutGrid::AlignSelfForChild( |
- const LayoutBox& child, |
- const ComputedStyle* style) const { |
- if (!style) |
- style = Style(); |
+ const LayoutBox& child) const { |
+ if (!child.IsAnonymous()) { |
+ return child.StyleRef().ResolvedAlignSelf( |
+ SelfAlignmentNormalBehavior(&child)); |
+ } |
+ // All the 'auto' values has been solved by the StyleAdjuster, but it's |
+ // possible that some grid items generate Anonymous boxes, which need to be |
+ // solved during layout. |
return child.StyleRef().ResolvedAlignSelf(SelfAlignmentNormalBehavior(&child), |
- style); |
+ Style()); |
} |
StyleSelfAlignmentData LayoutGrid::JustifySelfForChild( |
- const LayoutBox& child, |
- const ComputedStyle* style) const { |
- if (!style) |
- style = Style(); |
+ const LayoutBox& child) const { |
+ if (!child.IsAnonymous()) { |
+ return child.StyleRef().ResolvedJustifySelf( |
+ SelfAlignmentNormalBehavior(&child)); |
+ } |
+ // All the 'auto' values has been solved by the StyleAdjuster, but it's |
+ // possible that some grid items generate Anonymous boxes, which need to be |
+ // solved during layout. |
return child.StyleRef().ResolvedJustifySelf( |
- SelfAlignmentNormalBehavior(&child), style); |
+ SelfAlignmentNormalBehavior(&child), Style()); |
} |
GridTrackSizingDirection LayoutGrid::FlowAwareDirectionForChild( |
@@ -1824,9 +1777,11 @@ |
bool LayoutGrid::IsBaselineAlignmentForChild(const LayoutBox& child, |
GridAxis baseline_axis) const { |
- ItemPosition align = |
- SelfAlignmentForChild(baseline_axis, child).GetPosition(); |
- bool has_auto_margins = baseline_axis == kGridColumnAxis |
+ bool is_column_axis_baseline = baseline_axis == kGridColumnAxis; |
+ ItemPosition align = is_column_axis_baseline |
+ ? AlignSelfForChild(child).GetPosition() |
+ : JustifySelfForChild(child).GetPosition(); |
+ bool has_auto_margins = is_column_axis_baseline |
? HasAutoMarginsInColumnAxis(child) |
: HasAutoMarginsInRowAxis(child); |
return IsBaselinePosition(align) && !has_auto_margins; |
@@ -1846,8 +1801,9 @@ |
: col_axis_alignment_context_; |
auto* context = contexts_map.at(span.StartLine()); |
DCHECK(context); |
- ItemPosition align = |
- SelfAlignmentForChild(baseline_axis, child).GetPosition(); |
+ ItemPosition align = is_column_axis_baseline |
+ ? AlignSelfForChild(child).GetPosition() |
+ : JustifySelfForChild(child).GetPosition(); |
return context->GetSharedGroup(child, align); |
} |
@@ -1965,8 +1921,9 @@ |
auto add_result = contexts_map.insert(span.StartLine(), nullptr); |
// Looking for a compatible baseline-sharing group. |
- ItemPosition align = |
- SelfAlignmentForChild(baseline_axis, child).GetPosition(); |
+ ItemPosition align = is_column_axis_baseline |
+ ? AlignSelfForChild(child).GetPosition() |
+ : JustifySelfForChild(child).GetPosition(); |
if (add_result.is_new_entry) { |
add_result.stored_value->value = |
WTF::MakeUnique<BaselineContext>(child, align, ascent, descent); |