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

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

Issue 2668183003: [LayoutNG] Make NG algorithms non-oilpan. (Closed)
Patch Set: fix win compile 2? Created 3 years, 11 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
Index: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
index e531bfda916614aa07dd1e94a992e07d3005f607..2e0d816c343efef56243d82fb22f993eeaf08818 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
@@ -13,6 +13,7 @@
#include "core/layout/ng/ng_constraint_space.h"
#include "core/layout/ng/ng_constraint_space_builder.h"
#include "core/layout/ng/ng_fragment_builder.h"
+#include "core/layout/ng/ng_inline_layout_algorithm.h"
#include "core/layout/ng/ng_inline_node.h"
#include "core/layout/ng/ng_length_utils.h"
#include "core/layout/ng/ng_writing_mode.h"
@@ -79,19 +80,29 @@ NGBlockNode::NGBlockNode(ComputedStyle* style)
NGBlockNode::~NGBlockNode() {}
NGPhysicalFragment* NGBlockNode::Layout(NGConstraintSpace* constraint_space) {
- // We can either use the new layout code to do the layout and then copy the
- // resulting size to the LayoutObject, or use the old layout code and
- // synthesize a fragment.
- if (CanUseNewLayout()) {
- NGLayoutAlgorithm* algorithm =
- NGLayoutInputNode::AlgorithmForInputNode(this, constraint_space);
- fragment_ = toNGPhysicalBoxFragment(algorithm->Layout());
- CopyFragmentDataToLayoutBox(*constraint_space);
- } else {
+ // Use the old layout code and synthesize a fragment.
+ if (!CanUseNewLayout()) {
DCHECK(layout_box_);
fragment_ = RunOldLayout(*constraint_space);
+ return fragment_;
+ }
+
+ NGPhysicalFragment* fragment;
+
+ if (HasInlineChildren()) {
+ fragment =
+ NGInlineLayoutAlgorithm(GetLayoutObject(), &Style(),
+ toNGInlineNode(FirstChild()), constraint_space)
+ .Layout();
+ } else {
+ fragment = NGBlockLayoutAlgorithm(GetLayoutObject(), &Style(),
+ toNGBlockNode(FirstChild()),
+ constraint_space, CurrentBreakToken())
+ .Layout();
}
+ fragment_ = toNGPhysicalBoxFragment(fragment);
+ CopyFragmentDataToLayoutBox(*constraint_space);
return fragment_;
}

Powered by Google App Engine
This is Rietveld 408576698