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

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

Issue 2719373002: [LayoutNG] Move NGConstraintSpaceBuilder off Oilpan and DISALLOW_NEW. (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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } // namespace 304 } // namespace
305 305
306 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm( 306 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
307 NGBlockNode* node, 307 NGBlockNode* node,
308 NGConstraintSpace* constraint_space, 308 NGConstraintSpace* constraint_space,
309 NGBlockBreakToken* break_token) 309 NGBlockBreakToken* break_token)
310 : node_(node), 310 : node_(node),
311 constraint_space_(constraint_space), 311 constraint_space_(constraint_space),
312 break_token_(break_token), 312 break_token_(break_token),
313 builder_(WTF::wrapUnique( 313 builder_(WTF::wrapUnique(
314 new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox, node))) {} 314 new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox, node))),
315 space_builder_(
ikilpatrick 2017/02/28 18:28:05 We could also do: class NGConstraintSpaceBuilder
cbiesinger 2017/02/28 22:09:16 Hm... I guess we never reset it / we never need to
ikilpatrick 2017/02/28 22:59:26 I changed NGFragmentBuilder as well, and updated t
316 WTF::wrapUnique(new NGConstraintSpaceBuilder(constraint_space_))) {}
315 317
316 Optional<MinAndMaxContentSizes> 318 Optional<MinAndMaxContentSizes>
317 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const { 319 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const {
318 MinAndMaxContentSizes sizes; 320 MinAndMaxContentSizes sizes;
319 321
320 // Size-contained elements don't consider their contents for intrinsic sizing. 322 // Size-contained elements don't consider their contents for intrinsic sizing.
321 if (Style().containsSize()) 323 if (Style().containsSize())
322 return sizes; 324 return sizes;
323 325
324 // TODO: handle floats & orthogonal children. 326 // TODO: handle floats & orthogonal children.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // -1? 395 // -1?
394 LayoutUnit block_size = 396 LayoutUnit block_size =
395 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), NGSizeIndefinite); 397 ComputeBlockSizeForFragment(ConstraintSpace(), Style(), NGSizeIndefinite);
396 LayoutUnit adjusted_block_size(block_size); 398 LayoutUnit adjusted_block_size(block_size);
397 // Our calculated block-axis size may be indefinite at this point. 399 // Our calculated block-axis size may be indefinite at this point.
398 // If so, just leave the size as NGSizeIndefinite instead of subtracting 400 // If so, just leave the size as NGSizeIndefinite instead of subtracting
399 // borders and padding. 401 // borders and padding.
400 if (adjusted_block_size != NGSizeIndefinite) 402 if (adjusted_block_size != NGSizeIndefinite)
401 adjusted_block_size -= border_and_padding_.BlockSum(); 403 adjusted_block_size -= border_and_padding_.BlockSum();
402 404
403 space_builder_ = new NGConstraintSpaceBuilder(constraint_space_);
404 space_builder_ 405 space_builder_
405 ->SetAvailableSize( 406 ->SetAvailableSize(
406 NGLogicalSize(adjusted_inline_size, adjusted_block_size)) 407 NGLogicalSize(adjusted_inline_size, adjusted_block_size))
407 .SetPercentageResolutionSize( 408 .SetPercentageResolutionSize(
408 NGLogicalSize(adjusted_inline_size, adjusted_block_size)); 409 NGLogicalSize(adjusted_inline_size, adjusted_block_size));
409 410
410 builder_->SetDirection(constraint_space_->Direction()); 411 builder_->SetDirection(constraint_space_->Direction());
411 builder_->SetWritingMode(constraint_space_->WritingMode()); 412 builder_->SetWritingMode(constraint_space_->WritingMode());
412 builder_->SetInlineSize(inline_size).SetBlockSize(block_size); 413 builder_->SetInlineSize(inline_size).SetBlockSize(block_size);
413 414
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 DCHECK(builder_->BfcOffset()); 764 DCHECK(builder_->BfcOffset());
764 space_available -= curr_bfc_offset_.block_offset; 765 space_available -= curr_bfc_offset_.block_offset;
765 } 766 }
766 } 767 }
767 space_builder_->SetFragmentainerSpaceAvailable(space_available); 768 space_builder_->SetFragmentainerSpaceAvailable(space_available);
768 769
769 return space_builder_->ToConstraintSpace( 770 return space_builder_->ToConstraintSpace(
770 FromPlatformWritingMode(current_child_style.getWritingMode())); 771 FromPlatformWritingMode(current_child_style.getWritingMode()));
771 } 772 }
772 } // namespace blink 773 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698