Commit 0df88868 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Write resolved auto margins back to LayoutBox.

This fixes some tests that depended on the correct value here when reading out
the margins via getComputedStyle().

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I1f836ea8dc1243f1f2a1b36e69ba8d397417e3a2
Reviewed-on: https://chromium-review.googlesource.com/1127893
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573414}
parent 8e5a085f
...@@ -344,7 +344,6 @@ crbug.com/591099 fast/block/float/nopaint-after-layer-destruction.html [ Failure ...@@ -344,7 +344,6 @@ crbug.com/591099 fast/block/float/nopaint-after-layer-destruction.html [ Failure
crbug.com/591099 fast/block/float/nopaint-after-layer-destruction2.html [ Failure ] crbug.com/591099 fast/block/float/nopaint-after-layer-destruction2.html [ Failure ]
crbug.com/591099 fast/block/float/overlapping-floats-paint-hittest-order-1.html [ Failure ] crbug.com/591099 fast/block/float/overlapping-floats-paint-hittest-order-1.html [ Failure ]
crbug.com/591099 fast/block/line-layout/floats-do-not-fit-on-line.html [ Failure ] crbug.com/591099 fast/block/line-layout/floats-do-not-fit-on-line.html [ Failure ]
crbug.com/591099 fast/block/over-constrained-auto-margin.html [ Failure ]
crbug.com/591099 fast/block/positioning/positioned-child-inside-relative-positioned-anonymous-block.html [ Failure ] crbug.com/591099 fast/block/positioning/positioned-child-inside-relative-positioned-anonymous-block.html [ Failure ]
crbug.com/591099 fast/borders/bidi-002.html [ Failure ] crbug.com/591099 fast/borders/bidi-002.html [ Failure ]
crbug.com/859497 fast/borders/bidi-009a.html [ Failure ] crbug.com/859497 fast/borders/bidi-009a.html [ Failure ]
...@@ -400,8 +399,6 @@ crbug.com/591099 fast/css/focus-ring-continuations.html [ Failure ] ...@@ -400,8 +399,6 @@ crbug.com/591099 fast/css/focus-ring-continuations.html [ Failure ]
crbug.com/714962 fast/css/focus-ring-recursive-continuations.html [ Failure ] crbug.com/714962 fast/css/focus-ring-recursive-continuations.html [ Failure ]
crbug.com/714962 fast/css/focus-ring-recursive-inlines.html [ Failure ] crbug.com/714962 fast/css/focus-ring-recursive-inlines.html [ Failure ]
crbug.com/591099 fast/css/getComputedStyle/computed-style-percentage-top-with-position-inline.html [ Failure ] crbug.com/591099 fast/css/getComputedStyle/computed-style-percentage-top-with-position-inline.html [ Failure ]
crbug.com/591099 fast/css/getComputedStyle/getComputedStyle-margin-auto.html [ Failure ]
crbug.com/591099 fast/css/getComputedStyle/getComputedStyle-margin-percentage.html [ Failure ]
crbug.com/591099 fast/css/opacity-float.html [ Pass ] crbug.com/591099 fast/css/opacity-float.html [ Pass ]
crbug.com/591099 fast/css/outline-narrowLine.html [ Failure ] crbug.com/591099 fast/css/outline-narrowLine.html [ Failure ]
crbug.com/591099 fast/css/transform-inline-style-remove.html [ Failure ] crbug.com/591099 fast/css/transform-inline-style-remove.html [ Failure ]
...@@ -467,7 +464,6 @@ crbug.com/591099 fast/scrolling/jquery-rtl-scroll-type.html [ Failure ] ...@@ -467,7 +464,6 @@ crbug.com/591099 fast/scrolling/jquery-rtl-scroll-type.html [ Failure ]
crbug.com/591099 fast/scrolling/scrollable-area-frame-overflow-hidden.html [ Failure ] crbug.com/591099 fast/scrolling/scrollable-area-frame-overflow-hidden.html [ Failure ]
crbug.com/591099 fast/scrolling/scrollbar-tickmarks-hittest.html [ Pass ] crbug.com/591099 fast/scrolling/scrollbar-tickmarks-hittest.html [ Pass ]
crbug.com/591099 fast/spatial-navigation/snav-fully-aligned-vertically.html [ Failure ] crbug.com/591099 fast/spatial-navigation/snav-fully-aligned-vertically.html [ Failure ]
crbug.com/591099 fast/sub-pixel/computedstylemargin.html [ Failure ]
crbug.com/591099 fast/sub-pixel/inline-block-with-padding.html [ Failure ] crbug.com/591099 fast/sub-pixel/inline-block-with-padding.html [ Failure ]
crbug.com/591099 fast/sub-pixel/sub-pixel-border-2.html [ Failure ] crbug.com/591099 fast/sub-pixel/sub-pixel-border-2.html [ Failure ]
crbug.com/591099 fast/table/border-collapsing/004-vertical.html [ Failure ] crbug.com/591099 fast/table/border-collapsing/004-vertical.html [ Failure ]
......
...@@ -752,6 +752,7 @@ bool NGBlockLayoutAlgorithm::HandleNewFormattingContext( ...@@ -752,6 +752,7 @@ bool NGBlockLayoutAlgorithm::HandleNewFormattingContext(
DCHECK(!child.IsFloating()); DCHECK(!child.IsFloating());
DCHECK(!child.IsOutOfFlowPositioned()); DCHECK(!child.IsOutOfFlowPositioned());
DCHECK(child.CreatesNewFormattingContext()); DCHECK(child.CreatesNewFormattingContext());
DCHECK(child.IsBlock());
const ComputedStyle& child_style = child.Style(); const ComputedStyle& child_style = child.Style();
const TextDirection direction = ConstraintSpace().Direction(); const TextDirection direction = ConstraintSpace().Direction();
...@@ -917,6 +918,13 @@ bool NGBlockLayoutAlgorithm::HandleNewFormattingContext( ...@@ -917,6 +918,13 @@ bool NGBlockLayoutAlgorithm::HandleNewFormattingContext(
container_builder_.AddChild(layout_result, logical_offset); container_builder_.AddChild(layout_result, logical_offset);
container_builder_.PropagateBreak(layout_result); container_builder_.PropagateBreak(layout_result);
// The margins we store will be used by e.g. getComputedStyle().
// When calculating these values, ignore any floats that might have
// affected the child. This is what Edge does.
ResolveInlineMargins(child_style, Style(), child_available_size_.inline_size,
fragment.InlineSize(), &child_data.margins);
ToNGBlockNode(child).StoreMargins(ConstraintSpace(), child_data.margins);
*previous_inflow_position = ComputeInflowPosition( *previous_inflow_position = ComputeInflowPosition(
*previous_inflow_position, child, child_data, child_bfc_offset, *previous_inflow_position, child, child_data, child_bfc_offset,
logical_offset, *layout_result, fragment, logical_offset, *layout_result, fragment,
...@@ -1258,6 +1266,9 @@ bool NGBlockLayoutAlgorithm::HandleInflow( ...@@ -1258,6 +1266,9 @@ bool NGBlockLayoutAlgorithm::HandleInflow(
if (child.IsBlock()) if (child.IsBlock())
container_builder_.PropagateBreak(layout_result); container_builder_.PropagateBreak(layout_result);
if (child.IsBlock())
ToNGBlockNode(child).StoreMargins(ConstraintSpace(), child_data.margins);
*previous_inflow_position = *previous_inflow_position =
ComputeInflowPosition(*previous_inflow_position, child, child_data, ComputeInflowPosition(*previous_inflow_position, child, child_data,
child_bfc_offset, logical_offset, *layout_result, child_bfc_offset, logical_offset, *layout_result,
......
...@@ -416,6 +416,9 @@ void NGBlockNode::CopyFragmentDataToLayoutBox( ...@@ -416,6 +416,9 @@ void NGBlockNode::CopyFragmentDataToLayoutBox(
intrinsic_content_logical_height -= border_scrollbar_padding.BlockSum(); intrinsic_content_logical_height -= border_scrollbar_padding.BlockSum();
box_->SetLogicalHeight(logical_height); box_->SetLogicalHeight(logical_height);
box_->SetIntrinsicContentLogicalHeight(intrinsic_content_logical_height); box_->SetIntrinsicContentLogicalHeight(intrinsic_content_logical_height);
// TODO(mstensho): This should always be done by the parent algorithm, since
// we may have auto margins, which only the parent is able to resolve. Remove
// the following line when all layout modes do this properly.
box_->SetMargin(ComputePhysicalMargins(constraint_space, Style())); box_->SetMargin(ComputePhysicalMargins(constraint_space, Style()));
LayoutMultiColumnFlowThread* flow_thread = GetFlowThread(*box_); LayoutMultiColumnFlowThread* flow_thread = GetFlowThread(*box_);
...@@ -778,4 +781,13 @@ void NGBlockNode::SaveStaticOffsetForLegacy( ...@@ -778,4 +781,13 @@ void NGBlockNode::SaveStaticOffsetForLegacy(
} }
} }
void NGBlockNode::StoreMargins(const NGConstraintSpace& constraint_space,
const NGBoxStrut& margins) {
if (constraint_space.IsIntermediateLayout())
return;
NGPhysicalBoxStrut physical_margins = margins.ConvertToPhysical(
constraint_space.GetWritingMode(), constraint_space.Direction());
box_->SetMargin(physical_margins);
}
} // namespace blink } // namespace blink
...@@ -77,6 +77,9 @@ class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode { ...@@ -77,6 +77,9 @@ class CORE_EXPORT NGBlockNode final : public NGLayoutInputNode {
void SaveStaticOffsetForLegacy(const NGLogicalOffset&, void SaveStaticOffsetForLegacy(const NGLogicalOffset&,
const LayoutObject* offset_container); const LayoutObject* offset_container);
// Write back resolved margins to legacy.
void StoreMargins(const NGConstraintSpace&, const NGBoxStrut& margins);
static bool CanUseNewLayout(const LayoutBox&); static bool CanUseNewLayout(const LayoutBox&);
bool CanUseNewLayout() const; bool CanUseNewLayout() const;
......
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