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

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

Issue 2270983002: [layoutng] Add an NGFragmentBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove SwapChildren Created 4 years, 4 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_fragment_builder.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ed605303435a4e8c7541a9abbcf2e84323c5497a
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/ng/ng_fragment_builder.h"
+
+namespace blink {
+
+NGFragmentBuilder::NGFragmentBuilder(NGFragmentBase::NGFragmentType type)
+ : type_(type),
+ writing_mode_(HorizontalTopBottom),
+ direction_(LeftToRight) {}
+
+NGFragmentBuilder& NGFragmentBuilder::SetWritingMode(
+ NGWritingMode writing_mode) {
+ writing_mode_ = writing_mode;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::SetDirection(NGDirection direction) {
+ direction_ = direction;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::SetInlineSize(LayoutUnit size) {
+ size_.inlineSize = size;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::SetBlockSize(LayoutUnit size) {
+ size_.blockSize = size;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::SetInlineOverflow(LayoutUnit size) {
+ overflow_.inlineSize = size;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) {
+ overflow_.blockSize = size;
+ return *this;
+}
+
+NGFragmentBuilder& NGFragmentBuilder::AddChild(const NGFragment* child) {
+ DCHECK_EQ(type_, NGFragmentBase::FragmentBox)
+ << "Only box fragments can have children";
+ children_.append(child);
+ return *this;
+}
+
+NGFragment* NGFragmentBuilder::ToFragment() {
+ // TODO(layout-ng): Support text fragments
+ DCHECK_EQ(type_, NGFragmentBase::FragmentBox);
+ NGFragment* fragment =
+ new NGFragment(size_, overflow_, writing_mode_, direction_, children_);
+ return fragment;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698