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

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

Issue 2536323003: [LayoutNG] Fix enum values to conform to kEnumName in style guide. (Closed)
Patch Set: rebase. Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_fragment_builder.h" 5 #include "core/layout/ng/ng_fragment_builder.h"
6 #include "core/layout/ng/ng_block_node.h" 6 #include "core/layout/ng/ng_block_node.h"
7 #include "core/style/ComputedStyle.h" 7 #include "core/style/ComputedStyle.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 NGFragmentBuilder::NGFragmentBuilder( 11 NGFragmentBuilder::NGFragmentBuilder(
12 NGPhysicalFragmentBase::NGFragmentType type) 12 NGPhysicalFragmentBase::NGFragmentType type)
13 : type_(type), writing_mode_(HorizontalTopBottom), direction_(LTR) {} 13 : type_(type), writing_mode_(kHorizontalTopBottom), direction_(LTR) {}
14 14
15 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( 15 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode(
16 NGWritingMode writing_mode) { 16 NGWritingMode writing_mode) {
17 writing_mode_ = writing_mode; 17 writing_mode_ = writing_mode;
18 return *this; 18 return *this;
19 } 19 }
20 20
21 NGFragmentBuilder& NGFragmentBuilder::SetDirection(TextDirection direction) { 21 NGFragmentBuilder& NGFragmentBuilder::SetDirection(TextDirection direction) {
22 direction_ = direction; 22 direction_ = direction;
23 return *this; 23 return *this;
(...skipping 14 matching lines...) Expand all
38 return *this; 38 return *this;
39 } 39 }
40 40
41 NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) { 41 NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) {
42 overflow_.block_size = size; 42 overflow_.block_size = size;
43 return *this; 43 return *this;
44 } 44 }
45 45
46 NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragmentBase* child, 46 NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragmentBase* child,
47 NGLogicalOffset offset) { 47 NGLogicalOffset offset) {
48 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox) 48 DCHECK_EQ(type_, NGPhysicalFragmentBase::kFragmentBox)
49 << "Only box fragments can have children"; 49 << "Only box fragments can have children";
50 children_.append(child->PhysicalFragment()); 50 children_.append(child->PhysicalFragment());
51 offsets_.append(offset); 51 offsets_.append(offset);
52 return *this; 52 return *this;
53 } 53 }
54 54
55 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockStart( 55 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockStart(
56 const NGMarginStrut& from) { 56 const NGMarginStrut& from) {
57 margin_strut_.margin_block_start = from.margin_block_start; 57 margin_strut_.margin_block_start = from.margin_block_start;
58 margin_strut_.negative_margin_block_start = from.negative_margin_block_start; 58 margin_strut_.negative_margin_block_start = from.negative_margin_block_start;
59 return *this; 59 return *this;
60 } 60 }
61 61
62 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockEnd( 62 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockEnd(
63 const NGMarginStrut& from) { 63 const NGMarginStrut& from) {
64 margin_strut_.margin_block_end = from.margin_block_end; 64 margin_strut_.margin_block_end = from.margin_block_end;
65 margin_strut_.negative_margin_block_end = from.negative_margin_block_end; 65 margin_strut_.negative_margin_block_end = from.negative_margin_block_end;
66 return *this; 66 return *this;
67 } 67 }
68 68
69 NGPhysicalFragment* NGFragmentBuilder::ToFragment() { 69 NGPhysicalFragment* NGFragmentBuilder::ToFragment() {
70 // TODO(layout-ng): Support text fragments 70 // TODO(layout-ng): Support text fragments
71 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox); 71 DCHECK_EQ(type_, NGPhysicalFragmentBase::kFragmentBox);
72 DCHECK_EQ(offsets_.size(), children_.size()); 72 DCHECK_EQ(offsets_.size(), children_.size());
73 73
74 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 74 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
75 HeapVector<Member<const NGPhysicalFragmentBase>> children; 75 HeapVector<Member<const NGPhysicalFragmentBase>> children;
76 children.reserveCapacity(children_.size()); 76 children.reserveCapacity(children_.size());
77 77
78 for (size_t i = 0; i < children_.size(); ++i) { 78 for (size_t i = 0; i < children_.size(); ++i) {
79 NGPhysicalFragmentBase* child = children_[i].get(); 79 NGPhysicalFragmentBase* child = children_[i].get();
80 child->SetOffset(offsets_[i].ConvertToPhysical( 80 child->SetOffset(offsets_[i].ConvertToPhysical(
81 writing_mode_, direction_, physical_size, child->Size())); 81 writing_mode_, direction_, physical_size, child->Size()));
82 children.append(child); 82 children.append(child);
83 } 83 }
84 return new NGPhysicalFragment( 84 return new NGPhysicalFragment(
85 physical_size, overflow_.ConvertToPhysical(writing_mode_), children, 85 physical_size, overflow_.ConvertToPhysical(writing_mode_), children,
86 out_of_flow_descendants_, out_of_flow_offsets_, margin_strut_); 86 out_of_flow_descendants_, out_of_flow_offsets_, margin_strut_);
87 } 87 }
88 88
89 DEFINE_TRACE(NGFragmentBuilder) { 89 DEFINE_TRACE(NGFragmentBuilder) {
90 visitor->trace(children_); 90 visitor->trace(children_);
91 visitor->trace(out_of_flow_descendants_); 91 visitor->trace(out_of_flow_descendants_);
92 } 92 }
93 93
94 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698