OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/layout/ng/ng_fragment_builder.h" |
| 6 |
| 7 namespace blink { |
| 8 |
| 9 NGFragmentBuilder::NGFragmentBuilder(NGFragmentBase::NGFragmentType type) |
| 10 : type_(type), |
| 11 writing_mode_(HorizontalTopBottom), |
| 12 direction_(LeftToRight) {} |
| 13 |
| 14 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( |
| 15 NGWritingMode writing_mode) { |
| 16 writing_mode_ = writing_mode; |
| 17 return *this; |
| 18 } |
| 19 |
| 20 NGFragmentBuilder& NGFragmentBuilder::SetDirection(NGDirection direction) { |
| 21 direction_ = direction; |
| 22 return *this; |
| 23 } |
| 24 |
| 25 NGFragmentBuilder& NGFragmentBuilder::SetInlineSize(LayoutUnit size) { |
| 26 size_.inlineSize = size; |
| 27 return *this; |
| 28 } |
| 29 |
| 30 NGFragmentBuilder& NGFragmentBuilder::SetBlockSize(LayoutUnit size) { |
| 31 size_.blockSize = size; |
| 32 return *this; |
| 33 } |
| 34 |
| 35 NGFragmentBuilder& NGFragmentBuilder::SetInlineOverflow(LayoutUnit size) { |
| 36 overflow_.inlineSize = size; |
| 37 return *this; |
| 38 } |
| 39 |
| 40 NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) { |
| 41 overflow_.blockSize = size; |
| 42 return *this; |
| 43 } |
| 44 |
| 45 NGFragmentBuilder& NGFragmentBuilder::AddChild(const NGFragment* child) { |
| 46 DCHECK_EQ(type_, NGFragmentBase::FragmentBox) |
| 47 << "Only box fragments can have children"; |
| 48 children_.append(child); |
| 49 return *this; |
| 50 } |
| 51 |
| 52 NGFragment* NGFragmentBuilder::ToFragment() { |
| 53 // TODO(layout-ng): Support text fragments |
| 54 DCHECK_EQ(type_, NGFragmentBase::FragmentBox); |
| 55 NGFragment* fragment = |
| 56 new NGFragment(size_, overflow_, writing_mode_, direction_, children_); |
| 57 return fragment; |
| 58 } |
| 59 |
| 60 } // namespace blink |
OLD | NEW |