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

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

Issue 2519263002: [layout-ng] Convert ng_block_layout_algorithm to yield to the coordinator (Closed)
Patch Set: sync to head Created 4 years 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
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 d8fae61c705351f28a53f08da44b29cd15bcb792..43699720ab09f939075c57415ba8b68a01c2b2be 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
@@ -180,7 +180,8 @@ NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
NGBlockNode* first_child,
NGConstraintSpace* constraint_space,
NGBreakToken* break_token)
- : state_(kStateInit),
+ : NGLayoutAlgorithm(kBlockLayoutAlgorithm),
+ state_(kStateInit),
style_(style),
first_child_(first_child),
constraint_space_(constraint_space),
@@ -190,9 +191,9 @@ NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
}
NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
- NGFragmentBase*,
+ NGPhysicalFragmentBase* child_fragment,
NGPhysicalFragmentBase** fragment_out,
- NGLayoutAlgorithm**) {
+ NGLayoutAlgorithm** algorithm_out) {
switch (state_) {
case kStateInit: {
border_and_padding_ =
@@ -235,14 +236,12 @@ NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
builder_->SetDirection(constraint_space_->Direction());
builder_->SetWritingMode(constraint_space_->WritingMode());
builder_->SetInlineSize(inline_size).SetBlockSize(block_size);
- current_child_ = first_child_;
- if (current_child_)
- space_for_current_child_ = CreateConstraintSpaceForCurrentChild();
- state_ = kStateChildLayout;
+ current_child_ = first_child_;
+ state_ = kStatePrepareForChildLayout;
return kNotFinished;
}
- case kStateChildLayout: {
+ case kStatePrepareForChildLayout: {
if (current_child_) {
// TODO(atotic): uncomment this code when implementing oof layout.
// This code cannot be turned on because it prevents layout of
@@ -253,17 +252,32 @@ NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
// GetChildSpaceOffset());
// }
// else
- if (!LayoutCurrentChild())
- return kNotFinished;
- current_child_ = current_child_->NextSibling();
- if (current_child_) {
- space_for_current_child_ = CreateConstraintSpaceForCurrentChild();
- return kNotFinished;
- }
+ space_for_current_child_ = CreateConstraintSpaceForCurrentChild();
+ *algorithm_out = NGLayoutInputNode::AlgorithmForInputNode(
+ current_child_, space_for_current_child_);
+ state_ = kStateChildLayout;
+ return kChildAlgorithmRequired;
}
+
state_ = kStateFinalize;
return kNotFinished;
}
+ case kStateChildLayout: {
+ DCHECK(current_child_);
+ DCHECK(child_fragment);
+
+ // TODO(layout_ng): Seems like a giant hack to call this here.
+ current_child_->UpdateLayoutBox(toNGPhysicalFragment(child_fragment),
+ space_for_current_child_);
+
+ FinishCurrentChildLayout(
+ new NGFragment(space_for_current_child_->WritingMode(),
+ current_child_->Style()->direction(),
+ toNGPhysicalFragment(child_fragment)));
+ current_child_ = current_child_->NextSibling();
+ state_ = kStatePrepareForChildLayout;
+ return kNotFinished;
+ }
case kStateFinalize: {
content_size_ += border_and_padding_.block_end;
@@ -284,11 +298,8 @@ NGLayoutStatus NGBlockLayoutAlgorithm::Layout(
return kNewFragment;
}
-bool NGBlockLayoutAlgorithm::LayoutCurrentChild() {
- NGFragmentBase* fragment;
- if (!current_child_->Layout(space_for_current_child_, &fragment))
- return false;
-
+void NGBlockLayoutAlgorithm::FinishCurrentChildLayout(
+ NGFragmentBase* fragment) {
NGBoxStrut child_margins = ComputeMargins(
*space_for_current_child_, CurrentChildStyle(),
constraint_space_->WritingMode(), constraint_space_->Direction());
@@ -302,7 +313,6 @@ bool NGBlockLayoutAlgorithm::LayoutCurrentChild() {
fragment_offset = PositionFragment(*fragment, child_margins);
}
builder_->AddChild(fragment, fragment_offset);
- return true;
}
NGBoxStrut NGBlockLayoutAlgorithm::CollapseMargins(

Powered by Google App Engine
This is Rietveld 408576698