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

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: Resolved merge conflicts Created 3 years, 8 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 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;
99 default:
100 NOTREACHED();
101 break;
102 }
85 103
86 child_break_tokens_.push_back(child->BreakToken());
87 children_.push_back(std::move(child)); 104 children_.push_back(std::move(child));
88 offsets_.push_back(child_offset); 105 offsets_.push_back(child_offset);
89 106
90 return *this; 107 return *this;
91 } 108 }
92 109
93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( 110 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject(
94 RefPtr<NGFloatingObject> floating_object, 111 RefPtr<NGFloatingObject> floating_object,
95 const NGLogicalOffset& floating_object_offset) { 112 const NGLogicalOffset& floating_object_offset) {
96 positioned_floats_.push_back(floating_object); 113 positioned_floats_.push_back(floating_object);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 183
167 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 184 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
168 185
169 for (size_t i = 0; i < children_.size(); ++i) { 186 for (size_t i = 0; i < children_.size(); ++i) {
170 NGPhysicalFragment* child = children_[i].get(); 187 NGPhysicalFragment* child = children_[i].get();
171 child->SetOffset(offsets_[i].ConvertToPhysical( 188 child->SetOffset(offsets_[i].ConvertToPhysical(
172 writing_mode_, direction_, physical_size, child->Size())); 189 writing_mode_, direction_, physical_size, child->Size()));
173 } 190 }
174 191
175 RefPtr<NGBreakToken> break_token; 192 RefPtr<NGBreakToken> break_token;
193 if (last_inline_break_token_) {
194 DCHECK(!last_inline_break_token_->IsFinished());
195 child_break_tokens_.push_back(std::move(last_inline_break_token_));
196 did_break_ = true;
197 }
176 if (did_break_) { 198 if (did_break_) {
177 break_token = NGBlockBreakToken::create( 199 break_token = NGBlockBreakToken::create(node_.get(), used_block_size_,
178 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_); 200 child_break_tokens_);
179 } else { 201 } else {
180 break_token = NGBlockBreakToken::create(node_.get()); 202 break_token = NGBlockBreakToken::create(node_.get());
181 } 203 }
182 204
183 for (size_t i = 0; i < positioned_floats_.size(); ++i) { 205 for (size_t i = 0; i < positioned_floats_.size(); ++i) {
184 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i]; 206 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i];
185 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); 207 NGPhysicalFragment* floating_fragment = floating_object->fragment.get();
186 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( 208 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical(
187 writing_mode_, direction_, physical_size, floating_fragment->Size())); 209 writing_mode_, direction_, physical_size, floating_fragment->Size()));
188 } 210 }
189 211
190 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( 212 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment(
191 node_->GetLayoutObject(), physical_size, 213 node_->GetLayoutObject(), physical_size,
192 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, 214 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_,
193 bfc_offset_, end_margin_strut_, std::move(break_token))); 215 bfc_offset_, end_margin_strut_, std::move(break_token)));
194 216
195 return adoptRef( 217 return adoptRef(
196 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, 218 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_,
197 out_of_flow_positions_, unpositioned_floats_)); 219 out_of_flow_positions_, unpositioned_floats_));
198 } 220 }
199 221
200 } // namespace blink 222 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698