Commit de8d63e5 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

OOF conflict resolution is logical, not physical

Bug: 740993
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I88f2d778c7f0351daf6165fefc0c8654f209dca7
Reviewed-on: https://chromium-review.googlesource.com/663426Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Aleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501590}
parent 55bacf13
...@@ -62,4 +62,14 @@ LayoutUnit NGStaticPosition::TopInset(LayoutUnit container_size, ...@@ -62,4 +62,14 @@ LayoutUnit NGStaticPosition::TopInset(LayoutUnit container_size,
return offset.top - height - margin_bottom - margin_top; return offset.top - height - margin_bottom - margin_top;
} }
LayoutUnit NGStaticPosition::BottomInset(LayoutUnit container_size,
LayoutUnit height,
LayoutUnit margin_top,
LayoutUnit margin_bottom) const {
if (HasTop())
return container_size - offset.top - height - margin_top - margin_bottom;
else
return container_size - offset.top;
}
} // namespace blink } // namespace blink
...@@ -41,6 +41,10 @@ struct CORE_EXPORT NGStaticPosition { ...@@ -41,6 +41,10 @@ struct CORE_EXPORT NGStaticPosition {
LayoutUnit height, LayoutUnit height,
LayoutUnit margin_top, LayoutUnit margin_top,
LayoutUnit margin_bottom) const; LayoutUnit margin_bottom) const;
LayoutUnit BottomInset(LayoutUnit container_size,
LayoutUnit height,
LayoutUnit margin_top,
LayoutUnit margin_bottom) const;
private: private:
bool HasTop() const { return type == kTopLeft || type == kTopRight; } bool HasTop() const { return type == kTopLeft || type == kTopRight; }
......
...@@ -27,6 +27,24 @@ bool AbsoluteVerticalNeedsEstimate(const ComputedStyle& style) { ...@@ -27,6 +27,24 @@ bool AbsoluteVerticalNeedsEstimate(const ComputedStyle& style) {
(height.IsAuto() && (style.Top().IsAuto() || style.Bottom().IsAuto())); (height.IsAuto() && (style.Top().IsAuto() || style.Bottom().IsAuto()));
} }
// Dominant side:
// htb ltr => top left
// htb rtl => top right
// vlr ltr => top left
// vlr rtl => bottom left
// vrl ltr => top right
// vrl rtl => bottom right
bool IsLeftDominant(const NGConstraintSpace& space) {
return (space.WritingMode() != kVerticalRightLeft) &&
!(space.WritingMode() == kHorizontalTopBottom &&
space.Direction() == TextDirection::kRtl);
}
bool IsTopDominant(const NGConstraintSpace& space) {
return (space.WritingMode() == kHorizontalTopBottom) ||
(space.Direction() != TextDirection::kRtl);
}
LayoutUnit ResolveWidth(const Length& width, LayoutUnit ResolveWidth(const Length& width,
const NGConstraintSpace& space, const NGConstraintSpace& space,
const ComputedStyle& style, const ComputedStyle& style,
...@@ -113,7 +131,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space, ...@@ -113,7 +131,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
margin_right = LayoutUnit(); margin_right = LayoutUnit();
DCHECK(child_minmax.has_value()); DCHECK(child_minmax.has_value());
width = child_minmax->ShrinkToFit(container_size.width) + border_padding; width = child_minmax->ShrinkToFit(container_size.width) + border_padding;
if (space.Direction() == TextDirection::kLtr) { if (IsLeftDominant(space)) {
left = static_position.LeftInset(container_size.width, *width, left = static_position.LeftInset(container_size.width, *width,
*margin_left, *margin_right); *margin_left, *margin_right);
} else { } else {
...@@ -131,7 +149,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space, ...@@ -131,7 +149,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
margin_right = margin_space / 2; margin_right = margin_space / 2;
} else { } else {
// Margins are negative. // Margins are negative.
if (space.Direction() == TextDirection::kLtr) { if (IsLeftDominant(space)) {
margin_left = LayoutUnit(); margin_left = LayoutUnit();
margin_right = margin_space; margin_right = margin_space;
} else { } else {
...@@ -148,7 +166,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space, ...@@ -148,7 +166,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
LayoutUnit margin_extra = margin_space - *margin_left - *margin_right; LayoutUnit margin_extra = margin_space - *margin_left - *margin_right;
if (margin_extra) { if (margin_extra) {
// Relax the end. // Relax the end.
if (space.Direction() == TextDirection::kLtr) if (IsLeftDominant(space))
right = *right + margin_extra; right = *right + margin_extra;
else else
left = *left + margin_extra; left = *left + margin_extra;
...@@ -171,7 +189,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space, ...@@ -171,7 +189,7 @@ void ComputeAbsoluteHorizontal(const NGConstraintSpace& space,
} else if (!left && !right) { } else if (!left && !right) {
// Rule 2. // Rule 2.
DCHECK(width.has_value()); DCHECK(width.has_value());
if (space.Direction() == TextDirection::kLtr) if (IsLeftDominant(space))
left = static_position.LeftInset(container_size.width, *width, left = static_position.LeftInset(container_size.width, *width,
*margin_left, *margin_right); *margin_left, *margin_right);
else else
...@@ -269,8 +287,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space, ...@@ -269,8 +287,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
margin_bottom = LayoutUnit(); margin_bottom = LayoutUnit();
DCHECK(child_minmax.has_value()); DCHECK(child_minmax.has_value());
height = child_minmax->ShrinkToFit(container_size.height) + border_padding; height = child_minmax->ShrinkToFit(container_size.height) + border_padding;
top = static_position.TopInset(container_size.height, *height, *margin_top, if (IsTopDominant(space)) {
*margin_bottom); top = static_position.TopInset(container_size.height, *height,
*margin_top, *margin_bottom);
} else {
bottom = static_position.BottomInset(container_size.height, *height,
*margin_top, *margin_bottom);
}
} else if (top && bottom && height) { } else if (top && bottom && height) {
// Standard: "If top, bottom, and height are not auto:" // Standard: "If top, bottom, and height are not auto:"
// Compute margins. // Compute margins.
...@@ -282,8 +305,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space, ...@@ -282,8 +305,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
margin_bottom = margin_space / 2; margin_bottom = margin_space / 2;
} else { } else {
// Margin space is over-constrained. // Margin space is over-constrained.
margin_top = LayoutUnit(); if (IsTopDominant(space)) {
margin_bottom = margin_space; margin_top = LayoutUnit();
margin_bottom = margin_space;
} else {
margin_top = margin_space;
margin_bottom = LayoutUnit();
}
} }
} else if (!margin_top) { } else if (!margin_top) {
margin_top = margin_space - *margin_bottom; margin_top = margin_space - *margin_bottom;
...@@ -291,8 +319,12 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space, ...@@ -291,8 +319,12 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
margin_bottom = margin_space - *margin_top; margin_bottom = margin_space - *margin_top;
} else { } else {
LayoutUnit margin_extra = margin_space - *margin_top - *margin_bottom; LayoutUnit margin_extra = margin_space - *margin_top - *margin_bottom;
if (margin_extra) if (margin_extra) {
bottom = *bottom + margin_extra; if (IsTopDominant(space))
bottom = *bottom + margin_extra;
else
top = *top + margin_extra;
}
} }
} }
...@@ -311,8 +343,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space, ...@@ -311,8 +343,13 @@ void ComputeAbsoluteVertical(const NGConstraintSpace& space,
} else if (!top && !bottom) { } else if (!top && !bottom) {
// Rule 2. // Rule 2.
DCHECK(height.has_value()); DCHECK(height.has_value());
top = static_position.TopInset(container_size.height, *height, *margin_top, if (IsTopDominant(space)) {
*margin_bottom); top = static_position.TopInset(container_size.height, *height,
*margin_top, *margin_bottom);
} else {
bottom = static_position.BottomInset(container_size.height, *height,
*margin_top, *margin_bottom);
}
} else if (!height && !bottom) { } else if (!height && !bottom) {
// Rule 3. // Rule 3.
DCHECK(child_minmax.has_value()); DCHECK(child_minmax.has_value());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment