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

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

Issue 2921463004: [LayoutNG] PODify NGLayoutInputNode and sub-classes. (Closed)
Patch Set: new ng-bot expectations Created 3 years, 6 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_layout_input_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
index fb4269a185d92a7bb4fc71e7232d989fd3e3293a..0acff48f33cc2ccf8c9592108859c9e88937a043 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
@@ -3,48 +3,50 @@
// found in the LICENSE file.
#include "core/layout/ng/ng_layout_input_node.h"
+
#include "core/layout/ng/inline/ng_inline_node.h"
+#include "core/layout/ng/layout_ng_block_flow.h"
#include "core/layout/ng/ng_block_node.h"
+#include "core/layout/ng/ng_layout_result.h"
+#include "core/layout/ng/ng_min_max_content_size.h"
#include "platform/wtf/text/StringBuilder.h"
namespace blink {
namespace {
#ifndef NDEBUG
-void AppendNodeToString(const NGLayoutInputNode* node,
+void AppendNodeToString(NGLayoutInputNode node,
StringBuilder* string_builder,
unsigned indent = 2) {
if (!node)
return;
DCHECK(string_builder);
- string_builder->Append(node->ToString());
+ string_builder->Append(node.ToString());
string_builder->Append("\n");
StringBuilder indent_builder;
for (unsigned i = 0; i < indent; i++)
indent_builder.Append(" ");
- if (node->IsBlock()) {
- auto* first_child =
- ToNGBlockNode(const_cast<NGLayoutInputNode*>(node))->FirstChild();
- for (NGLayoutInputNode* node_runner = first_child; node_runner;
- node_runner = node_runner->NextSibling()) {
+ if (node.IsBlock()) {
+ NGLayoutInputNode first_child = ToNGBlockNode(node).FirstChild();
+ for (NGLayoutInputNode node_runner = first_child; node_runner;
+ node_runner = node_runner.NextSibling()) {
string_builder->Append(indent_builder.ToString());
AppendNodeToString(node_runner, string_builder, indent + 2);
}
}
- if (node->IsInline()) {
- for (const NGInlineItem& inline_item : ToNGInlineNode(node)->Items()) {
+ if (node.IsInline()) {
+ for (const NGInlineItem& inline_item : ToNGInlineNode(node).Items()) {
string_builder->Append(indent_builder.ToString());
string_builder->Append(inline_item.ToString());
string_builder->Append("\n");
}
- auto* next_sibling =
- ToNGInlineNode(const_cast<NGLayoutInputNode*>(node))->NextSibling();
- for (NGLayoutInputNode* node_runner = next_sibling; node_runner;
- node_runner = node_runner->NextSibling()) {
+ NGLayoutInputNode next_sibling = ToNGInlineNode(node).NextSibling();
+ for (NGLayoutInputNode node_runner = next_sibling; node_runner;
+ node_runner = node_runner.NextSibling()) {
string_builder->Append(indent_builder.ToString());
AppendNodeToString(node_runner, string_builder, indent + 2);
}
@@ -54,11 +56,56 @@ void AppendNodeToString(const NGLayoutInputNode* node,
} // namespace
+bool NGLayoutInputNode::IsInline() const {
+ return box_->LayoutNGInline();
+}
+
+bool NGLayoutInputNode::IsBlock() const {
+ return !IsInline();
+}
+
+bool NGLayoutInputNode::IsFloating() const {
+ return IsBlock() && Style().IsFloating();
+}
+
+bool NGLayoutInputNode::IsOutOfFlowPositioned() const {
+ return IsBlock() && Style().HasOutOfFlowPosition();
+}
+
+RefPtr<NGLayoutResult> NGLayoutInputNode::Layout(NGConstraintSpace* space,
+ NGBreakToken* break_token) {
+ return IsInline() ? ToNGInlineNode(*this).Layout(space, break_token)
+ : ToNGBlockNode(*this).Layout(space, break_token);
+}
+
+MinMaxContentSize NGLayoutInputNode::ComputeMinMaxContentSize() {
+ return IsInline() ? ToNGInlineNode(*this).ComputeMinMaxContentSize()
+ : ToNGBlockNode(*this).ComputeMinMaxContentSize();
+}
+
+NGLayoutInputNode NGLayoutInputNode::NextSibling() {
+ return IsInline() ? ToNGInlineNode(*this).NextSibling()
+ : ToNGBlockNode(*this).NextSibling();
+}
+
+LayoutObject* NGLayoutInputNode::GetLayoutObject() const {
+ return box_;
+}
+
+const ComputedStyle& NGLayoutInputNode::Style() const {
+ return box_->StyleRef();
+}
+
+String NGLayoutInputNode::ToString() const {
+ return IsInline() ? ToNGInlineNode(*this).ToString()
+ : ToNGBlockNode(*this).ToString();
+}
+
#ifndef NDEBUG
void NGLayoutInputNode::ShowNodeTree() const {
StringBuilder string_builder;
string_builder.Append("\n.:: LayoutNG Node Tree ::.\n\n");
- AppendNodeToString(this, &string_builder);
+ AppendNodeToString(*this, &string_builder);
fprintf(stderr, "%s\n", string_builder.ToString().Utf8().data());
}
#endif

Powered by Google App Engine
This is Rietveld 408576698