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_block_layout_algorithm.cc

Issue 2706403008: [LayoutNG] Implement ComputeMinAndMaxContentSizes for inline (Closed)
Patch Set: Change the way to load ahem to make asan bot happy 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_box_fragment.h" 9 #include "core/layout/ng/ng_box_fragment.h"
10 #include "core/layout/ng/ng_column_mapper.h" 10 #include "core/layout/ng/ng_column_mapper.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const { 316 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const {
317 MinAndMaxContentSizes sizes; 317 MinAndMaxContentSizes sizes;
318 318
319 // Size-contained elements don't consider their contents for intrinsic sizing. 319 // Size-contained elements don't consider their contents for intrinsic sizing.
320 if (Style().containsSize()) 320 if (Style().containsSize())
321 return sizes; 321 return sizes;
322 322
323 // TODO: handle floats & orthogonal children. 323 // TODO: handle floats & orthogonal children.
324 for (NGLayoutInputNode* node = node_->FirstChild(); node; 324 for (NGLayoutInputNode* node = node_->FirstChild(); node;
325 node = node->NextSibling()) { 325 node = node->NextSibling()) {
326 Optional<MinAndMaxContentSizes> child_minmax; 326 MinAndMaxContentSizes child_sizes;
327 if (node->Type() == NGLayoutInputNode::kLegacyInline) { 327 if (node->Type() == NGLayoutInputNode::kLegacyInline) {
328 // TODO(kojii): Implement when there are inline children. 328 // From |NGBlockLayoutAlgorithm| perspective, we can handle |NGInlineNode|
329 return child_minmax; 329 // almost the same as |NGBlockNode|, because an |NGInlineNode| includes
330 // all inline nodes following |node| and their descendants, and produces
331 // an anonymous box that contains all line boxes.
332 // |NextSibling| returns the next block sibling, or nullptr, skipping all
333 // following inline siblings and descendants.
cbiesinger 2017/02/27 23:16:16 Thanks for the explanation! That was not obvious t
kojii 2017/02/28 03:30:37 My bad actually, this isn't obvious to anyone, I s
334 child_sizes = toNGInlineNode(node)->ComputeMinAndMaxContentSizes();
335 } else {
336 Optional<MinAndMaxContentSizes> child_minmax;
337 NGBlockNode* block_child = toNGBlockNode(node);
338 if (NeedMinAndMaxContentSizesForContentContribution(
339 block_child->Style())) {
340 child_minmax = block_child->ComputeMinAndMaxContentSizes();
341 }
342
343 child_sizes = ComputeMinAndMaxContentContribution(block_child->Style(),
344 child_minmax);
330 } 345 }
331 NGBlockNode* block_child = toNGBlockNode(node);
332 if (NeedMinAndMaxContentSizesForContentContribution(block_child->Style())) {
333 child_minmax = block_child->ComputeMinAndMaxContentSizes();
334 }
335
336 MinAndMaxContentSizes child_sizes =
337 ComputeMinAndMaxContentContribution(block_child->Style(), child_minmax);
338 346
339 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content); 347 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content);
340 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content); 348 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content);
341 } 349 }
342 350
343 sizes.max_content = std::max(sizes.min_content, sizes.max_content); 351 sizes.max_content = std::max(sizes.min_content, sizes.max_content);
344 return sizes; 352 return sizes;
345 } 353 }
346 354
347 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset( 355 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 FinalizeForFragmentation(); 513 FinalizeForFragmentation();
506 514
507 return builder_->ToBoxFragment(); 515 return builder_->ToBoxFragment();
508 } 516 }
509 517
510 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) { 518 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) {
511 // TODO(kojii): This logic does not handle when children are mix of 519 // TODO(kojii): This logic does not handle when children are mix of
512 // inline/block. We need to detect the case and setup appropriately; e.g., 520 // inline/block. We need to detect the case and setup appropriately; e.g.,
513 // constraint space, margin collapsing, next siblings, etc. 521 // constraint space, margin collapsing, next siblings, etc.
514 NGLineBuilder line_builder(current_child, space_for_current_child_); 522 NGLineBuilder line_builder(current_child, space_for_current_child_);
523 // TODO(kojii): Need to determine when to invalidate PrepareLayout() more
524 // efficiently than "everytime".
525 current_child->InvalidatePrepareLayout();
515 current_child->LayoutInline(space_for_current_child_, &line_builder); 526 current_child->LayoutInline(space_for_current_child_, &line_builder);
516 // TODO(kojii): The wrapper fragment should not be needed. 527 // TODO(kojii): The wrapper fragment should not be needed.
517 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox, 528 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox,
518 current_child); 529 current_child);
519 line_builder.CreateFragments(&wrapper_fragment_builder); 530 line_builder.CreateFragments(&wrapper_fragment_builder);
520 RefPtr<NGLayoutResult> child_result = 531 RefPtr<NGLayoutResult> child_result =
521 wrapper_fragment_builder.ToBoxFragment(); 532 wrapper_fragment_builder.ToBoxFragment();
522 line_builder.CopyFragmentDataToLayoutBlockFlow(); 533 line_builder.CopyFragmentDataToLayoutBlockFlow();
523 FinishCurrentChildLayout(child_result); 534 FinishCurrentChildLayout(child_result);
524 current_child_ = nullptr; 535 current_child_ = nullptr;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 space_builder_->SetMarginStrut(curr_margin_strut_); 847 space_builder_->SetMarginStrut(curr_margin_strut_);
837 } 848 }
838 849
839 space_builder_->SetBfcOffset(curr_bfc_offset_); 850 space_builder_->SetBfcOffset(curr_bfc_offset_);
840 851
841 return space_builder_->ToConstraintSpace( 852 return space_builder_->ToConstraintSpace(
842 FromPlatformWritingMode(current_child_style.getWritingMode())); 853 FromPlatformWritingMode(current_child_style.getWritingMode()));
843 } 854 }
844 855
845 } // namespace blink 856 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698