Commit ab5657b7 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Fix the static position of inline out-of-flow objects to honor text-align

This patch fixes the static position of an out-of-flow objects
to honor the 'text-align' property, when they have inline-type
'display' property, and their siblings are block-level.

Bug: 635619
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I7c83f241984d079f9d3729e3bfbdb8bd428946a4
Reviewed-on: https://chromium-review.googlesource.com/1098750
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566962}
parent 6bc98f91
...@@ -602,7 +602,6 @@ crbug.com/591099 fast/table/percent-height-replaced-content-in-cell.html [ Failu ...@@ -602,7 +602,6 @@ crbug.com/591099 fast/table/percent-height-replaced-content-in-cell.html [ Failu
crbug.com/591099 fast/table/table-display-types-vertical.html [ Failure ] crbug.com/591099 fast/table/table-display-types-vertical.html [ Failure ]
crbug.com/591099 fast/table/unbreakable-images-quirk.html [ Failure ] crbug.com/591099 fast/table/unbreakable-images-quirk.html [ Failure ]
crbug.com/591099 fast/table/vertical-align-baseline-readjust.html [ Failure ] crbug.com/591099 fast/table/vertical-align-baseline-readjust.html [ Failure ]
crbug.com/591099 fast/text/container-align-with-inlines.html [ Failure ]
crbug.com/591099 fast/text/decorations-with-text-combine.html [ Failure ] crbug.com/591099 fast/text/decorations-with-text-combine.html [ Failure ]
crbug.com/591099 fast/text/ellipsis-in-relative-inline-right.html [ Failure ] crbug.com/591099 fast/text/ellipsis-in-relative-inline-right.html [ Failure ]
crbug.com/591099 fast/text/ellipsis-in-relative-inline.html [ Failure ] crbug.com/591099 fast/text/ellipsis-in-relative-inline.html [ Failure ]
......
...@@ -318,12 +318,8 @@ NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset( ...@@ -318,12 +318,8 @@ NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset(
border_scrollbar_padding_.inline_start + child_margins.inline_start; border_scrollbar_padding_.inline_start + child_margins.inline_start;
if (child.IsInline()) { if (child.IsInline()) {
LayoutUnit offset = inline_offset +=
LineOffsetForTextAlign(Style().GetTextAlign(), Style().Direction(), InlineOffsetForTextAlign(Style(), child_available_size_.inline_size);
child_available_size_.inline_size, LayoutUnit());
if (IsRtl(Style().Direction()))
offset = child_available_size_.inline_size - offset;
inline_offset += offset;
} }
// If we've reached here, both the child and the current layout don't have a // If we've reached here, both the child and the current layout don't have a
...@@ -627,9 +623,18 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { ...@@ -627,9 +623,18 @@ scoped_refptr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() {
void NGBlockLayoutAlgorithm::HandleOutOfFlowPositioned( void NGBlockLayoutAlgorithm::HandleOutOfFlowPositioned(
const NGPreviousInflowPosition& previous_inflow_position, const NGPreviousInflowPosition& previous_inflow_position,
NGBlockNode child) { NGBlockNode child) {
const ComputedStyle& child_style = child.Style();
LayoutUnit inline_offset = border_scrollbar_padding_.inline_start;
if (child_style.IsOriginalDisplayInlineType()) {
// If this out-of-flow child is inline type, its static position should
// honor the 'text-align' property.
inline_offset +=
InlineOffsetForTextAlign(Style(), child_available_size_.inline_size);
}
// TODO(ikilpatrick): Determine which of the child's margins need to be // TODO(ikilpatrick): Determine which of the child's margins need to be
// included for the static position. // included for the static position.
NGLogicalOffset offset = {border_scrollbar_padding_.inline_start, NGLogicalOffset offset = {inline_offset,
previous_inflow_position.logical_block_offset}; previous_inflow_position.logical_block_offset};
// We only include the margin strut in the OOF static-position if we know we // We only include the margin strut in the OOF static-position if we know we
......
...@@ -745,6 +745,14 @@ LayoutUnit LineOffsetForTextAlign(ETextAlign text_align, ...@@ -745,6 +745,14 @@ LayoutUnit LineOffsetForTextAlign(ETextAlign text_align,
} }
} }
LayoutUnit InlineOffsetForTextAlign(const ComputedStyle& container_style,
LayoutUnit space_left) {
TextDirection direction = container_style.Direction();
LayoutUnit line_offset = LineOffsetForTextAlign(
container_style.GetTextAlign(), direction, space_left, LayoutUnit());
return IsLtr(direction) ? line_offset : space_left - line_offset;
}
LayoutUnit ConstrainByMinMax(LayoutUnit length, LayoutUnit ConstrainByMinMax(LayoutUnit length,
LayoutUnit min, LayoutUnit min,
LayoutUnit max) { LayoutUnit max) {
......
...@@ -190,6 +190,11 @@ CORE_EXPORT LayoutUnit LineOffsetForTextAlign(ETextAlign, ...@@ -190,6 +190,11 @@ CORE_EXPORT LayoutUnit LineOffsetForTextAlign(ETextAlign,
LayoutUnit space_left, LayoutUnit space_left,
LayoutUnit trailing_spaces_width); LayoutUnit trailing_spaces_width);
// Same as |LineOffsetForTextAlign| but returns the logical inline offset
// instead of line-left offset.
CORE_EXPORT LayoutUnit InlineOffsetForTextAlign(const ComputedStyle&,
LayoutUnit space_left);
CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length, CORE_EXPORT LayoutUnit ConstrainByMinMax(LayoutUnit length,
LayoutUnit min, LayoutUnit min,
LayoutUnit max); LayoutUnit max);
......
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