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

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

Issue 2632523002: [LayoutNG] Initial support for multicol, introducing NGBlockBreakToken. (Closed)
Patch Set: Add TODO. Created 3 years, 11 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
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 6
7 #include "core/layout/ng/ng_block_node.h" 7 #include "core/layout/ng/ng_block_node.h"
8 #include "core/layout/ng/ng_break_token.h"
8 #include "core/layout/ng/ng_fragment.h" 9 #include "core/layout/ng/ng_fragment.h"
9 #include "core/layout/ng/ng_physical_box_fragment.h" 10 #include "core/layout/ng/ng_physical_box_fragment.h"
10 #include "core/layout/ng/ng_physical_text_fragment.h" 11 #include "core/layout/ng/ng_physical_text_fragment.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 NGFragmentBuilder::NGFragmentBuilder(NGPhysicalFragment::NGFragmentType type) 15 NGFragmentBuilder::NGFragmentBuilder(NGPhysicalFragment::NGFragmentType type)
15 : type_(type), 16 : type_(type),
16 writing_mode_(kHorizontalTopBottom), 17 writing_mode_(kHorizontalTopBottom),
17 direction_(TextDirection::kLtr) {} 18 direction_(TextDirection::kLtr) {}
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 margin_strut_.margin_block_end = from.margin_block_end; 130 margin_strut_.margin_block_end = from.margin_block_end;
130 margin_strut_.negative_margin_block_end = from.negative_margin_block_end; 131 margin_strut_.negative_margin_block_end = from.negative_margin_block_end;
131 return *this; 132 return *this;
132 } 133 }
133 134
134 NGPhysicalBoxFragment* NGFragmentBuilder::ToBoxFragment() { 135 NGPhysicalBoxFragment* NGFragmentBuilder::ToBoxFragment() {
135 // TODO(layout-ng): Support text fragments 136 // TODO(layout-ng): Support text fragments
136 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox); 137 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox);
137 DCHECK_EQ(offsets_.size(), children_.size()); 138 DCHECK_EQ(offsets_.size(), children_.size());
138 139
140 auto* break_token = break_token_.get();
141 break_token_ = nullptr;
142
139 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 143 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
140 HeapVector<Member<const NGPhysicalFragment>> children; 144 HeapVector<Member<const NGPhysicalFragment>> children;
141 children.reserveCapacity(children_.size()); 145 children.reserveCapacity(children_.size());
142 146
143 for (size_t i = 0; i < children_.size(); ++i) { 147 for (size_t i = 0; i < children_.size(); ++i) {
144 NGPhysicalFragment* child = children_[i].get(); 148 NGPhysicalFragment* child = children_[i].get();
145 child->SetOffset(offsets_[i].ConvertToPhysical( 149 child->SetOffset(offsets_[i].ConvertToPhysical(
146 writing_mode_, direction_, physical_size, child->Size())); 150 writing_mode_, direction_, physical_size, child->Size()));
147 children.push_back(child); 151 children.push_back(child);
148 } 152 }
149 return new NGPhysicalBoxFragment( 153 return new NGPhysicalBoxFragment(
150 physical_size, overflow_.ConvertToPhysical(writing_mode_), children, 154 physical_size, overflow_.ConvertToPhysical(writing_mode_), children,
151 out_of_flow_descendants_, out_of_flow_positions_, margin_strut_); 155 out_of_flow_descendants_, out_of_flow_positions_, margin_strut_,
156 break_token);
152 } 157 }
153 158
154 NGPhysicalTextFragment* NGFragmentBuilder::ToTextFragment(NGInlineNode* node, 159 NGPhysicalTextFragment* NGFragmentBuilder::ToTextFragment(NGInlineNode* node,
155 unsigned start_index, 160 unsigned start_index,
156 unsigned end_index) { 161 unsigned end_index) {
157 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); 162 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText);
158 DCHECK(children_.isEmpty()); 163 DCHECK(children_.isEmpty());
159 DCHECK(offsets_.isEmpty()); 164 DCHECK(offsets_.isEmpty());
160 return new NGPhysicalTextFragment( 165 return new NGPhysicalTextFragment(
161 node, start_index, end_index, size_.ConvertToPhysical(writing_mode_), 166 node, start_index, end_index, size_.ConvertToPhysical(writing_mode_),
162 overflow_.ConvertToPhysical(writing_mode_), out_of_flow_descendants_, 167 overflow_.ConvertToPhysical(writing_mode_), out_of_flow_descendants_,
163 out_of_flow_positions_); 168 out_of_flow_positions_);
164 } 169 }
165 170
166 DEFINE_TRACE(NGFragmentBuilder) { 171 DEFINE_TRACE(NGFragmentBuilder) {
167 visitor->trace(children_); 172 visitor->trace(children_);
168 visitor->trace(out_of_flow_descendant_candidates_); 173 visitor->trace(out_of_flow_descendant_candidates_);
169 visitor->trace(out_of_flow_descendants_); 174 visitor->trace(out_of_flow_descendants_);
175 visitor->trace(break_token_);
170 } 176 }
171 177
172 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698