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

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

Issue 2752123002: [LayoutNG] Move NGFloatingObject off Oilpan (Closed)
Patch Set: more comments 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 did_break_ |= child->IsBox() && !child->BreakToken()->IsFinished(); 84 did_break_ |= child->IsBox() && !child->BreakToken()->IsFinished();
85 85
86 child_break_tokens_.push_back(child->BreakToken()); 86 child_break_tokens_.push_back(child->BreakToken());
87 children_.push_back(std::move(child)); 87 children_.push_back(std::move(child));
88 offsets_.push_back(child_offset); 88 offsets_.push_back(child_offset);
89 89
90 return *this; 90 return *this;
91 } 91 }
92 92
93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject( 93 NGFragmentBuilder& NGFragmentBuilder::AddFloatingObject(
94 NGFloatingObject* floating_object, 94 RefPtr<NGFloatingObject> floating_object,
95 const NGLogicalOffset& floating_object_offset) { 95 const NGLogicalOffset& floating_object_offset) {
96 positioned_floats_.push_back(floating_object); 96 positioned_floats_.push_back(floating_object);
97 floating_object_offsets_.push_back(floating_object_offset); 97 floating_object_offsets_.push_back(floating_object_offset);
98 return *this; 98 return *this;
99 } 99 }
100 100
101 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset( 101 NGFragmentBuilder& NGFragmentBuilder::SetBfcOffset(
102 const NGLogicalOffset& offset) { 102 const NGLogicalOffset& offset) {
103 bfc_offset_ = offset; 103 bfc_offset_ = offset;
104 return *this; 104 return *this;
105 } 105 }
106 106
107 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate( 107 NGFragmentBuilder& NGFragmentBuilder::AddOutOfFlowChildCandidate(
108 NGBlockNode* child, 108 NGBlockNode* child,
109 NGLogicalOffset child_offset) { 109 NGLogicalOffset child_offset) {
110 out_of_flow_descendant_candidates_.insert(child); 110 out_of_flow_descendant_candidates_.insert(child);
111 NGStaticPosition child_position = 111 NGStaticPosition child_position =
112 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset()); 112 NGStaticPosition::Create(writing_mode_, direction_, NGPhysicalOffset());
113 out_of_flow_candidate_placements_.push_back( 113 out_of_flow_candidate_placements_.push_back(
114 OutOfFlowPlacement{child_offset, child_position}); 114 OutOfFlowPlacement{child_offset, child_position});
115 child->SaveStaticOffsetForLegacy(child_offset); 115 child->SaveStaticOffsetForLegacy(child_offset);
116 return *this; 116 return *this;
117 } 117 }
118 118
119 NGFragmentBuilder& NGFragmentBuilder::AddUnpositionedFloat( 119 NGFragmentBuilder& NGFragmentBuilder::AddUnpositionedFloat(
120 NGFloatingObject* floating_object) { 120 RefPtr<NGFloatingObject> floating_object) {
121 unpositioned_floats_.push_back(floating_object); 121 unpositioned_floats_.push_back(std::move(floating_object));
122 return *this; 122 return *this;
123 } 123 }
124 124
125 void NGFragmentBuilder::GetAndClearOutOfFlowDescendantCandidates( 125 void NGFragmentBuilder::GetAndClearOutOfFlowDescendantCandidates(
126 WeakBoxList* descendants, 126 WeakBoxList* descendants,
127 Vector<NGStaticPosition>* descendant_positions) { 127 Vector<NGStaticPosition>* descendant_positions) {
128 DCHECK(descendants->isEmpty()); 128 DCHECK(descendants->isEmpty());
129 DCHECK(descendant_positions->isEmpty()); 129 DCHECK(descendant_positions->isEmpty());
130 130
131 DCHECK_GE(size_.inline_size, LayoutUnit()); 131 DCHECK_GE(size_.inline_size, LayoutUnit());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 DCHECK_EQ(offsets_.size(), children_.size()); 166 DCHECK_EQ(offsets_.size(), children_.size());
167 167
168 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 168 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
169 169
170 for (size_t i = 0; i < children_.size(); ++i) { 170 for (size_t i = 0; i < children_.size(); ++i) {
171 NGPhysicalFragment* child = children_[i].get(); 171 NGPhysicalFragment* child = children_[i].get();
172 child->SetOffset(offsets_[i].ConvertToPhysical( 172 child->SetOffset(offsets_[i].ConvertToPhysical(
173 writing_mode_, direction_, physical_size, child->Size())); 173 writing_mode_, direction_, physical_size, child->Size()));
174 } 174 }
175 175
176 Vector<Persistent<NGFloatingObject>> positioned_floats;
177 positioned_floats.reserveCapacity(positioned_floats_.size());
178
179 RefPtr<NGBreakToken> break_token; 176 RefPtr<NGBreakToken> break_token;
180 if (did_break_) { 177 if (did_break_) {
181 break_token = NGBlockBreakToken::create( 178 break_token = NGBlockBreakToken::create(
182 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_); 179 toNGBlockNode(node_.get()), used_block_size_, child_break_tokens_);
183 } else { 180 } else {
184 break_token = NGBlockBreakToken::create(node_.get()); 181 break_token = NGBlockBreakToken::create(node_.get());
185 } 182 }
186 183
187 for (size_t i = 0; i < positioned_floats_.size(); ++i) { 184 for (size_t i = 0; i < positioned_floats_.size(); ++i) {
188 Persistent<NGFloatingObject>& floating_object = positioned_floats_[i]; 185 RefPtr<NGFloatingObject>& floating_object = positioned_floats_[i];
189 NGPhysicalFragment* floating_fragment = floating_object->fragment.get(); 186 NGPhysicalFragment* floating_fragment = floating_object->fragment.get();
190 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical( 187 floating_fragment->SetOffset(floating_object_offsets_[i].ConvertToPhysical(
191 writing_mode_, direction_, physical_size, floating_fragment->Size())); 188 writing_mode_, direction_, physical_size, floating_fragment->Size()));
192 positioned_floats.push_back(floating_object);
193 } 189 }
194 190
195 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment( 191 RefPtr<NGPhysicalBoxFragment> fragment = adoptRef(new NGPhysicalBoxFragment(
196 node_->GetLayoutObject(), physical_size, 192 node_->GetLayoutObject(), physical_size,
197 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_, 193 overflow_.ConvertToPhysical(writing_mode_), children_, positioned_floats_,
198 bfc_offset_, end_margin_strut_, std::move(break_token))); 194 bfc_offset_, end_margin_strut_, std::move(break_token)));
199 195
200 return adoptRef( 196 return adoptRef(
201 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_, 197 new NGLayoutResult(std::move(fragment), out_of_flow_descendants_,
202 out_of_flow_positions_, unpositioned_floats_)); 198 out_of_flow_positions_, unpositioned_floats_));
203 } 199 }
204 200
205 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment( 201 RefPtr<NGPhysicalTextFragment> NGFragmentBuilder::ToTextFragment(
206 unsigned index, 202 unsigned index,
207 unsigned start_offset, 203 unsigned start_offset,
208 unsigned end_offset) { 204 unsigned end_offset) {
209 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText); 205 DCHECK_EQ(type_, NGPhysicalFragment::kFragmentText);
210 DCHECK(children_.isEmpty()); 206 DCHECK(children_.isEmpty());
211 DCHECK(offsets_.isEmpty()); 207 DCHECK(offsets_.isEmpty());
212 208
213 Vector<Persistent<NGFloatingObject>> empty_unpositioned_floats;
214 Vector<Persistent<NGFloatingObject>> empty_positioned_floats;
215
216 return adoptRef(new NGPhysicalTextFragment( 209 return adoptRef(new NGPhysicalTextFragment(
217 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset, 210 node_->GetLayoutObject(), toNGInlineNode(node_), index, start_offset,
218 end_offset, size_.ConvertToPhysical(writing_mode_), 211 end_offset, size_.ConvertToPhysical(writing_mode_),
219 overflow_.ConvertToPhysical(writing_mode_))); 212 overflow_.ConvertToPhysical(writing_mode_)));
220 } 213 }
221 214
222 } // namespace blink 215 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698