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

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

Issue 2752123002: [LayoutNG] Move NGFloatingObject off Oilpan (Closed)
Patch Set: 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_block_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_absolute_utils.h" 7 #include "core/layout/ng/ng_absolute_utils.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_child_iterator.h" 9 #include "core/layout/ng/ng_block_child_iterator.h"
10 #include "core/layout/ng/ng_box_fragment.h" 10 #include "core/layout/ng/ng_box_fragment.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 opportunity_candidate = opportunity_iter.Next(); 155 opportunity_candidate = opportunity_iter.Next();
156 } 156 }
157 return opportunity; 157 return opportunity;
158 } 158 }
159 159
160 // Calculates the logical offset for opportunity. 160 // Calculates the logical offset for opportunity.
161 NGLogicalOffset CalculateLogicalOffsetForOpportunity( 161 NGLogicalOffset CalculateLogicalOffsetForOpportunity(
162 const NGLayoutOpportunity& opportunity, 162 const NGLayoutOpportunity& opportunity,
163 const LayoutUnit float_offset, 163 const LayoutUnit float_offset,
164 const NGLogicalOffset& from_offset, 164 const NGLogicalOffset& from_offset,
165 NGFloatingObject* floating_object) { 165 RefPtr<NGFloatingObject> floating_object) {
166 auto margins = floating_object->margins; 166 auto margins = floating_object->margins;
167 // Adjust to child's margin. 167 // Adjust to child's margin.
168 LayoutUnit inline_offset = margins.inline_start; 168 LayoutUnit inline_offset = margins.inline_start;
169 LayoutUnit block_offset = margins.block_start; 169 LayoutUnit block_offset = margins.block_start;
170 170
171 // Offset from the opportunity's block/inline start. 171 // Offset from the opportunity's block/inline start.
172 inline_offset += opportunity.offset.inline_offset; 172 inline_offset += opportunity.offset.inline_offset;
173 block_offset += opportunity.offset.block_offset; 173 block_offset += opportunity.offset.block_offset;
174 174
175 // Adjust to float: right offset if needed. 175 // Adjust to float: right offset if needed.
176 inline_offset += float_offset; 176 inline_offset += float_offset;
177 177
178 block_offset -= from_offset.block_offset; 178 block_offset -= from_offset.block_offset;
179 inline_offset -= from_offset.inline_offset; 179 inline_offset -= from_offset.inline_offset;
180 180
181 return NGLogicalOffset(inline_offset, block_offset); 181 return NGLogicalOffset(inline_offset, block_offset);
182 } 182 }
183 183
184 // Calculates the relative position from {@code from_offset} of the 184 // Calculates the relative position from {@code from_offset} of the
185 // floating object that is requested to be positioned from {@code origin_point}. 185 // floating object that is requested to be positioned from {@code origin_point}.
186 NGLogicalOffset PositionFloat(const NGLogicalOffset& origin_point, 186 NGLogicalOffset PositionFloat(const NGLogicalOffset& origin_point,
187 const NGLogicalOffset& from_offset, 187 const NGLogicalOffset& from_offset,
188 NGFloatingObject* floating_object, 188 RefPtr<NGFloatingObject> floating_object,
189 NGConstraintSpace* new_parent_space) { 189 NGConstraintSpace* new_parent_space) {
190 const auto* float_space = floating_object->space.get(); 190 const auto* float_space = floating_object->space.get();
191 DCHECK(floating_object->fragment) << "Fragment cannot be null here"; 191 DCHECK(floating_object->fragment) << "Fragment cannot be null here";
192 192
193 // TODO(ikilpatrick): The writing mode switching here looks wrong. 193 // TODO(ikilpatrick): The writing mode switching here looks wrong.
194 NGBoxFragment float_fragment( 194 NGBoxFragment float_fragment(
195 float_space->WritingMode(), 195 float_space->WritingMode(),
196 toNGPhysicalBoxFragment(floating_object->fragment.get())); 196 toNGPhysicalBoxFragment(floating_object->fragment.get()));
197 197
198 // Find a layout opportunity that will fit our float. 198 // Find a layout opportunity that will fit our float.
(...skipping 16 matching lines...) Expand all
215 new_parent_space->AddExclusion(exclusion); 215 new_parent_space->AddExclusion(exclusion);
216 216
217 return CalculateLogicalOffsetForOpportunity(opportunity, float_offset, 217 return CalculateLogicalOffsetForOpportunity(opportunity, float_offset,
218 from_offset, floating_object); 218 from_offset, floating_object);
219 } 219 }
220 220
221 // Updates the Floating Object's left offset from the provided parent_space 221 // Updates the Floating Object's left offset from the provided parent_space
222 // and {@code floating_object}'s space and margins. 222 // and {@code floating_object}'s space and margins.
223 void UpdateFloatingObjectLeftOffset( 223 void UpdateFloatingObjectLeftOffset(
224 const NGConstraintSpace& new_parent_space, 224 const NGConstraintSpace& new_parent_space,
225 const Persistent<NGFloatingObject>& floating_object, 225 const RefPtr<NGFloatingObject>& floating_object,
ikilpatrick 2017/03/15 22:45:40 so for all these in the anon namespace its probabl
Gleb Lanbin 2017/03/15 23:24:25 Done.
226 const NGLogicalOffset& float_logical_offset) { 226 const NGLogicalOffset& float_logical_offset) {
227 // TODO(glebl): We should use physical offset here. 227 // TODO(glebl): We should use physical offset here.
228 floating_object->left_offset = 228 floating_object->left_offset =
229 floating_object->original_parent_space->BfcOffset().inline_offset - 229 floating_object->original_parent_space->BfcOffset().inline_offset -
230 new_parent_space.BfcOffset().inline_offset + 230 new_parent_space.BfcOffset().inline_offset +
231 float_logical_offset.inline_offset; 231 float_logical_offset.inline_offset;
232 } 232 }
233 233
234 // Positions pending floats stored on the fragment builder starting from 234 // Positions pending floats stored on the fragment builder starting from
235 // {@code origin_point_block_offset}. 235 // {@code origin_point_block_offset}.
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 DCHECK(builder_.BfcOffset()); 760 DCHECK(builder_.BfcOffset());
761 space_available -= curr_bfc_offset_.block_offset; 761 space_available -= curr_bfc_offset_.block_offset;
762 } 762 }
763 } 763 }
764 space_builder_.SetFragmentainerSpaceAvailable(space_available); 764 space_builder_.SetFragmentainerSpaceAvailable(space_available);
765 765
766 return space_builder_.ToConstraintSpace( 766 return space_builder_.ToConstraintSpace(
767 FromPlatformWritingMode(child_style.getWritingMode())); 767 FromPlatformWritingMode(child_style.getWritingMode()));
768 } 768 }
769 } // namespace blink 769 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698