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 |