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

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

Issue 2816933003: Use Layout Opportunity Iterator to position new FC blocks. (Closed)
Patch Set: fix block-formatting-contexts-{005|007} 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/inline/ng_physical_text_fragment.h" 7 #include "core/layout/ng/inline/ng_physical_text_fragment.h"
8 #include "core/layout/ng/ng_block_break_token.h" 8 #include "core/layout/ng/ng_block_break_token.h"
9 #include "core/layout/ng/ng_block_node.h" 9 #include "core/layout/ng/ng_block_node.h"
10 #include "core/layout/ng/ng_break_token.h" 10 #include "core/layout/ng/ng_break_token.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 NOTREACHED(); 102 NOTREACHED();
103 break; 103 break;
104 } 104 }
105 105
106 children_.push_back(std::move(child)); 106 children_.push_back(std::move(child));
107 offsets_.push_back(child_offset); 107 offsets_.push_back(child_offset);
108 108
109 return *this; 109 return *this;
110 } 110 }
111 111
112 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject(
113 RefPtr<NGFloatingObject> floating_object,
114 const NGLogicalOffset& floating_object_offset) {
115 positioned_floats_.push_back(floating_object);
116 floating_object_offsets_.push_back(floating_object_offset);
117 return *this;
118 }
119
120 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset( 112 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset(
121 const NGLogicalOffset& offset) { 113 const NGLogicalOffset& offset) {
122 bfc_offset_ = offset; 114 bfc_offset_ = offset;
123 return *this; 115 return *this;
124 } 116 }
125 117
126 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( 118 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate(
127 NGBlockNode* child, 119 NGBlockNode* child,
128 NGLogicalOffset child_offset) { 120 NGLogicalOffset child_offset) {
129 out_of_flow_descendant_candidates_.insert(child); 121 out_of_flow_descendant_candidates_.insert(child);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 child_break_tokens_.push_back(std::move(last_inline_break_token_)); 189 child_break_tokens_.push_back(std::move(last_inline_break_token_));
198 did_break_ = true; 190 did_break_ = true;
199 } 191 }
200 if (did_break_) { 192 if (did_break_) {
201 break_token = NGBlockBreakToken::Create(node_.Get(), used_block_size_, 193 break_token = NGBlockBreakToken::Create(node_.Get(), used_block_size_,
202 child_break_tokens_); 194 child_break_tokens_);
203 } else { 195 } else {
204 break_token = NGBlockBreakToken::Create(node_.Get()); 196 break_token = NGBlockBreakToken::Create(node_.Get());
205 } 197 }
206 198
207 for (size_t i = 0; i < positioned_floats_.size(); ++i) { 199 for (auto& floating_object : positioned_floats_) {
208 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i]; 200 DCHECK(floating_object->logical_offset)
201 << "logical_offset should be set for a positioned float.";
209 NGPhysicalFragment* floating_fragment = floating_object->fragment.Get(); 202 NGPhysicalFragment* floating_fragment = floating_object->fragment.Get();
210 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( 203 floating_fragment->SetOffset(
211 writing_mode_, direction_, physical_size, floating_fragment->Size())); 204 floating_object->logical_offset.value().ConvertToPhysical(
205 writing_mode_, direction_, physical_size,
206 floating_fragment->Size()));
212 } 207 }
213 208
214 RefPtr<NGPhysicalBoxFragment> fragment = AdoptRef(new NGPhysicalBoxFragment( 209 RefPtr<NGPhysicalBoxFragment> fragment = AdoptRef(new NGPhysicalBoxFragment(
215 node_->GetLayoutObject(), physical_size, 210 node_->GetLayoutObject(), physical_size,
216 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, 211 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_,
217 bfc_offset_, end_margin_strut_, std::move(break_token))); 212 bfc_offset_, end_margin_strut_, std::move(break_token)));
218 213
219 return AdoptRef( 214 return AdoptRef(
220 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, 215 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_,
221 out_of_flow_positions_, unpositioned_floats_)); 216 out_of_flow_positions_, unpositioned_floats_));
222 } 217 }
223 218
224 } // namespace blink 219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698