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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698