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

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

Issue 2772503004: [LayoutNG] Add NGInlineBreakToken and back of NGInlineLayoutAlgorithm (Closed)
Patch Set: Rename Created 3 years, 9 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_break_token.h" 7 #include "core/layout/ng/ng_block_break_token.h"
8 #include "core/layout/ng/ng_block_node.h" 8 #include "core/layout/ng/ng_block_node.h"
9 #include "core/layout/ng/ng_break_token.h" 9 #include "core/layout/ng/ng_break_token.h"
10 #include "core/layout/ng/ng_fragment.h" 10 #include "core/layout/ng/ng_fragment.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 return AddChild(child->PhysicalFragment(), child_offset); 74 return AddChild(child->PhysicalFragment(), child_offset);
75 } 75 }
76 76
77 NGFragmentBuilder& NGFragmentBuilder::AddChild( 77 NGFragmentBuilder& NGFragmentBuilder::AddChild(
78 RefPtr<NGPhysicalFragment> child, 78 RefPtr<NGPhysicalFragment> child,
79 const NGLogicalOffset& child_offset) { 79 const NGLogicalOffset& child_offset) {
80 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox) 80 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentBox)
81 << "Only box fragments can have children"; 81 << "Only box fragments can have children";
82 82
83 // Update if we have fragmented in this flow. 83 switch (child->Type()) {
84 did_break_ |= child->IsBox() && !child->BreakToken()->IsFinished(); 84 case NGPhysicalBoxFragment::kFragmentBox:
85 // Update if we have fragmented in this flow.
86 did_break_ |= !child->BreakToken()->IsFinished();
87 child_break_tokens_.push_back(child->BreakToken());
88 break;
89 case NGPhysicalBoxFragment::kFragmentLineBox:
90 // NGInlineNode produces multiple line boxes in an anonymous box. Only
91 // the last break token is needed to be taken to parent.
ikilpatrick 2017/03/24 20:58:05 .nit ... is needed to be reported to the parent. ?
92 DCHECK(child->BreakToken() && child->BreakToken()->InputNode() == node_);
93 last_inline_break_token_ =
94 child->BreakToken()->IsFinished() ? nullptr : child->BreakToken();
95 break;
96 case NGPhysicalBoxFragment::kFragmentText:
97 DCHECK(!child->BreakToken());
98 break;
ikilpatrick 2017/03/24 20:58:05 default: NOTREACHED()?
99 }
85 100
86 child_break_tokens_.push_back(child->BreakToken());
87 children_.push_back(std::move(child)); 101 children_.push_back(std::move(child));
88 offsets_.push_back(child_offset); 102 offsets_.push_back(child_offset);
89 103
90 return *this; 104 return *this;
91 } 105 }
92 106
93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( 107 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject(
94 RefPtr<NGFloatingObject> floating_object, 108 RefPtr<NGFloatingObject> floating_object,
95 const NGLogicalOffset& floating_object_offset) { 109 const NGLogicalOffset& floating_object_offset) {
96 positioned_floats_.push_back(floating_object); 110 positioned_floats_.push_back(floating_object);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 180
167 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 181 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
168 182
169 for (size_t i = 0; i < children_.size(); ++i) { 183 for (size_t i = 0; i < children_.size(); ++i) {
170 NGPhysicalFragment* child = children_[i].get(); 184 NGPhysicalFragment* child = children_[i].get();
171 child->SetOffset(offsets_[i].ConvertToPhysical( 185 child->SetOffset(offsets_[i].ConvertToPhysical(
172 writing_mode_, direction_, physical_size, child->Size())); 186 writing_mode_, direction_, physical_size, child->Size()));
173 } 187 }
174 188
175 RefPtr<NGBreakToken> break_token; 189 RefPtr<NGBreakToken> break_token;
190 if (last_inline_break_token_) {
191 child_break_tokens_.push_back(std::move(last_inline_break_token_));
192 did_break_ = true;
ikilpatrick 2017/03/24 20:58:05 does this need to check if last_inline_break_token
193 }
176 if (did_break_) { 194 if (did_break_) {
177 break_token = NGBlockBreakToken::create( 195 break_token = NGBlockBreakToken::create(node_.get(), used_block_size_,
178 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_); 196 child_break_tokens_);
179 } else { 197 } else {
180 break_token = NGBlockBreakToken::create(node_.get()); 198 break_token = NGBlockBreakToken::create(node_.get());
181 } 199 }
182 200
183 for (size_t i = 0; i < positioned_floats_.size(); ++i) { 201 for (size_t i = 0; i < positioned_floats_.size(); ++i) {
184 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i]; 202 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i];
185 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); 203 NGPhysicalFragment* floating_fragment = floating_object->fragment.get();
186 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( 204 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical(
187 writing_mode_, direction_, physical_size, floating_fragment->Size())); 205 writing_mode_, direction_, physical_size, floating_fragment->Size()));
188 } 206 }
189 207
190 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( 208 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment(
191 node_->GetLayoutObject(), physical_size, 209 node_->GetLayoutObject(), physical_size,
192 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, 210 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_,
193 bfc_offset_, end_margin_strut_, std::move(break_token))); 211 bfc_offset_, end_margin_strut_, std::move(break_token)));
194 212
195 return adoptRef( 213 return adoptRef(
196 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, 214 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_,
197 out_of_flow_positions_, unpositioned_floats_)); 215 out_of_flow_positions_, unpositioned_floats_));
198 } 216 }
199 217
200 } // namespace blink 218 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698