Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
index f9d1fa9804d88f916d6569abbfc44f3e9e196369..5c5e3abd26dc5442483cc6209f055267098b0acf 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc |
@@ -185,30 +185,8 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space, |
} |
case kStateChildLayout: { |
if (current_child_) { |
- constraint_space_for_children_->SetIsNewFormattingContext( |
- IsNewFormattingContextForInFlowBlockLevelChild( |
- *constraint_space, *current_child_->Style())); |
- |
- NGFragment* fragment; |
- if (!current_child_->Layout(constraint_space_for_children_, &fragment)) |
+ if (!LayoutCurrentChild(constraint_space)) |
return false; |
- |
- NGBoxStrut child_margins = ComputeMargins( |
- *constraint_space_for_children_, *current_child_->Style(), |
- constraint_space_for_children_->WritingMode(), |
- constraint_space_for_children_->Direction()); |
- |
- NGLogicalOffset fragment_offset; |
- if (current_child_->Style()->isFloating()) { |
- fragment_offset = PositionFloatFragment(*fragment, child_margins); |
- } else { |
- ApplyAutoMargins(*constraint_space_for_children_, |
- *current_child_->Style(), *fragment, &child_margins); |
- fragment_offset = |
- PositionFragment(*fragment, child_margins, *constraint_space); |
- } |
- builder_->AddChild(fragment, fragment_offset); |
- |
current_child_ = current_child_->NextSibling(); |
if (current_child_) |
return false; |
@@ -236,6 +214,35 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space, |
return true; |
} |
+bool NGBlockLayoutAlgorithm::LayoutCurrentChild( |
+ const NGConstraintSpace* constraint_space) { |
+ constraint_space_for_children_->SetIsNewFormattingContext( |
+ IsNewFormattingContextForInFlowBlockLevelChild(*constraint_space, |
+ *current_child_->Style())); |
+ |
+ NGFragment* fragment; |
+ if (!current_child_->Layout(constraint_space_for_children_, &fragment)) |
+ return false; |
+ |
+ NGBoxStrut child_margins = |
+ ComputeMargins(*constraint_space_for_children_, *current_child_->Style(), |
+ constraint_space_for_children_->WritingMode(), |
+ constraint_space_for_children_->Direction()); |
+ |
+ NGLogicalOffset fragment_offset; |
+ if (current_child_->Style()->isFloating()) { |
+ fragment_offset = PositionFloatFragment(*fragment, child_margins); |
+ } else { |
+ // TODO(layout-ng): move ApplyAutoMargins to PositionFragment |
+ ApplyAutoMargins(*constraint_space_for_children_, *current_child_->Style(), |
+ *fragment, &child_margins); |
+ fragment_offset = |
+ PositionFragment(*fragment, child_margins, *constraint_space); |
+ } |
+ builder_->AddChild(fragment, fragment_offset); |
+ return true; |
+} |
+ |
NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins( |
const NGConstraintSpace& space, |
const NGBoxStrut& margins, |
@@ -353,4 +360,12 @@ void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { |
builder_->SetMarginStrutBlockEnd(from); |
} |
+DEFINE_TRACE(NGBlockLayoutAlgorithm) { |
+ NGLayoutAlgorithm::trace(visitor); |
+ visitor->trace(first_child_); |
+ visitor->trace(builder_); |
+ visitor->trace(constraint_space_for_children_); |
+ visitor->trace(current_child_); |
+} |
+ |
} // namespace blink |