Commit 1265d024 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Use containing block size correctly for abspos.

UpdateOutOfFlowBlockLayout() needs to deal with both the actual
containing block size, as specified by CSS (i.e. the padding box size),
and the border-box size of the object that is the containing block of an
absolutely positioned descendant.

Some light cleanup. We always need the border sizes, so just calculate
them once, unconditionally. Also, there seems no need for a special path
for grid/flex, so I removed it.

Some tests start to pass. All but one are still expected to fail in legacy.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I85462d76aa9fa3d0105bf079e59f7c2a7a70f117
Reviewed-on: https://chromium-review.googlesource.com/926004Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537918}
parent 58923362
......@@ -1439,12 +1439,16 @@ crbug.com/591099 external/wpt/css/css-ui/text-overflow-027.html [ Failure ]
crbug.com/591099 external/wpt/css/css-ui/text-overflow-029.html [ Failure ]
crbug.com/591099 external/wpt/css/css-values/lh-unit-002.html [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vlr-003.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vlr-005.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vlr-011.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vlr-013.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vlr-033.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-002.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-004.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-006.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-008.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-010.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-012.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-014.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-016.xht [ Pass ]
crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-018.xht [ Pass ]
......@@ -4222,7 +4226,6 @@ crbug.com/591099 fast/pagination/repeating-thead-tfoot-paged-y.html [ Failure ]
crbug.com/591099 fast/pagination/short-pages-tall-content.html [ Timeout ]
crbug.com/591099 fast/pagination/viewport-x-vertical-rl-ltr.html [ Failure ]
crbug.com/591099 fast/pagination/viewport-x-vertical-rl-rtl.html [ Failure ]
crbug.com/591099 fast/pagination/viewport-y-horizontal-tb-rtl.html [ Failure ]
crbug.com/591099 fast/pagination/viewport-y-vertical-rl-ltr.html [ Failure ]
crbug.com/591099 fast/pagination/viewport-y-vertical-rl-rtl.html [ Failure ]
crbug.com/591099 fast/parser/001.html [ Failure ]
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<style>body { overflow:scroll; }</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="width:100px; height:100px; background:green;"></div>
<!DOCTYPE html>
<title>Auto-positioned absolutely positioned in static RTL parent, scrollbars on viewport</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visudet.html#abs-non-replaced-width" title="10.3.7 Absolutely positioned, non-replaced elements">
<link rel="match" href="auto-position-rtl-child-viewport-scrollbar-ref.html">
<style>body { overflow:scroll; }</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="direction:rtl; width:80px; height:80px; border:10px solid green; background:red;">
<div style="position:absolute; width:80px; height:80px; background:green;"></div>
</div>
......@@ -81,34 +81,46 @@ void LayoutNGBlockFlow::UpdateOutOfFlowBlockLayout() {
container_style->GetWritingMode(), container_style->Direction());
// Compute ContainingBlock logical size.
// OverrideContainingBlockLogicalWidth/Height are used by grid layout.
// OverrideContainingBlockLogicalWidth/Height are used by e.g. grid layout.
// Override sizes are padding box size, not border box, so we must add
// borders to compensate.
NGBoxStrut borders;
if (HasOverrideContainingBlockLogicalWidth() ||
HasOverrideContainingBlockLogicalHeight())
borders = ComputeBorders(*constraint_space, *container_style);
LayoutUnit containing_block_logical_width;
LayoutUnit containing_block_logical_height;
NGBoxStrut borders = ComputeBorders(*constraint_space, *container_style);
// Calculate the border-box size of the object that's the containing block of
// this out-of-flow positioned descendant. Note that this is not to be used as
// the containing block size to resolve sizes and positions for the
// descendant, since we're dealing with the border box here (not the padding
// box, which is where the containing block is established). These sizes are
// just used to do a fake/partial NG layout pass of the containing block (that
// object is really managed by legacy layout).
LayoutUnit container_border_box_logical_width;
LayoutUnit container_border_box_logical_height;
if (HasOverrideContainingBlockLogicalWidth()) {
containing_block_logical_width =
container_border_box_logical_width =
OverrideContainingBlockContentLogicalWidth() + borders.InlineSum();
} else {
containing_block_logical_width = container->LogicalWidth();
container_border_box_logical_width = container->LogicalWidth();
}
if (HasOverrideContainingBlockLogicalHeight()) {
containing_block_logical_height =
container_border_box_logical_height =
OverrideContainingBlockContentLogicalHeight() + borders.BlockSum();
} else {
containing_block_logical_height = container->LogicalHeight();
container_border_box_logical_height = container->LogicalHeight();
}
container_builder.SetInlineSize(containing_block_logical_width);
container_builder.SetBlockSize(containing_block_logical_height);
container_builder.SetInlineSize(container_border_box_logical_width);
container_builder.SetBlockSize(container_border_box_logical_height);
container_builder.SetPadding(
ComputePadding(*constraint_space, *container_style));
// Calculate the actual size of the containing block for this out-of-flow
// descendant. This is what's used to size and position us.
LayoutBoxModelObject* css_container = ToLayoutBoxModelObject(Container());
LayoutUnit containing_block_logical_width =
ContainingBlockLogicalWidthForPositioned(css_container);
LayoutUnit containing_block_logical_height =
ContainingBlockLogicalHeightForPositioned(css_container);
// Determine static position.
// static_inline and static_block are inline/block direction offsets
......@@ -116,46 +128,39 @@ void LayoutNGBlockFlow::UpdateOutOfFlowBlockLayout() {
// physical in a single variable.
LayoutUnit static_inline;
LayoutUnit static_block;
LayoutBoxModelObject* css_container = ToLayoutBoxModelObject(Container());
if (container_style->IsDisplayFlexibleOrGridBox()) {
static_inline = Layer()->StaticInlinePosition();
static_block = Layer()->StaticBlockPosition();
Length logical_left;
Length logical_right;
Length logical_top;
Length logical_bottom;
ComputeInlineStaticDistance(logical_left, logical_right, this, css_container,
containing_block_logical_width);
ComputeBlockStaticDistance(logical_top, logical_bottom, this, css_container);
if (parent_style->IsLeftToRightDirection()) {
if (!logical_left.IsAuto()) {
static_inline =
ValueForLength(logical_left, containing_block_logical_width);
}
} else {
Length logical_left;
Length logical_right;
Length logical_top;
Length logical_bottom;
ComputeInlineStaticDistance(
logical_left, logical_right, this, css_container,
ContainingBlockLogicalWidthForPositioned(css_container));
ComputeBlockStaticDistance(logical_top, logical_bottom, this,
css_container);
if (parent_style->IsLeftToRightDirection()) {
if (!logical_left.IsAuto())
static_inline = ValueForLength(logical_left, container->LogicalWidth());
} else {
if (!logical_right.IsAuto()) {
static_inline =
ValueForLength(logical_right, container->LogicalWidth());
}
if (!logical_right.IsAuto()) {
static_inline =
ValueForLength(logical_right, containing_block_logical_width);
}
if (!logical_top.IsAuto())
static_block = ValueForLength(logical_top, container->LogicalHeight());
// Legacy static position is relative to padding box.
// Convert to border box.
NGBoxStrut border_strut =
ComputeBorders(*constraint_space, *container_style);
if (parent_style->IsLeftToRightDirection())
static_inline += border_strut.inline_start;
else
static_inline -= border_strut.inline_end;
static_block += border_strut.block_start;
}
if (!parent_style->IsLeftToRightDirection())
if (!logical_top.IsAuto())
static_block = ValueForLength(logical_top, containing_block_logical_height);
// Legacy static position is relative to padding box. Convert to border
// box. Also flip offsets as necessary to make them relative to to the
// left/top edges.
if (parent_style->IsLeftToRightDirection()) {
static_inline += borders.inline_start;
} else {
static_inline += borders.inline_end;
static_inline = containing_block_logical_width - static_inline;
}
static_block += borders.block_start;
if (parent_style->IsFlippedBlocksWritingMode())
static_block = containing_block_logical_height - static_block;
......@@ -204,7 +209,7 @@ void LayoutNGBlockFlow::UpdateOutOfFlowBlockLayout() {
ToLayoutBox(child_fragment->GetLayoutObject());
NGPhysicalOffset child_offset = child_fragment->Offset();
if (container_style->IsFlippedBlocksWritingMode()) {
child_legacy_box->SetX(containing_block_logical_height -
child_legacy_box->SetX(container_border_box_logical_height -
child_offset.left - child_fragment->Size().width);
} else {
child_legacy_box->SetX(child_offset.left);
......
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