Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc

Issue 2449313002: Refactor LayoutCurrentChild (Closed)
Patch Set: Refactor LayoutCurrentChild Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698