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

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: cbiesinger review 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_inline_node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const { 310 NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const {
311 MinAndMaxContentSizes sizes; 311 MinAndMaxContentSizes sizes;
312 312
313 // Size-contained elements don't consider their contents for intrinsic sizing. 313 // Size-contained elements don't consider their contents for intrinsic sizing.
314 if (Style().containsSize()) 314 if (Style().containsSize())
315 return sizes; 315 return sizes;
316 316
317 // TODO: handle floats & orthogonal children. 317 // TODO: handle floats & orthogonal children.
318 for (NGLayoutInputNode* node = node_->FirstChild(); node; 318 for (NGLayoutInputNode* node = node_->FirstChild(); node;
319 node = node->NextSibling()) { 319 node = node->NextSibling()) {
320 Optional<MinAndMaxContentSizes> child_minmax; 320 MinAndMaxContentSizes child_sizes;
321 if (node->Type() == NGLayoutInputNode::kLegacyInline) { 321 if (node->Type() == NGLayoutInputNode::kLegacyInline) {
322 // TODO(kojii): Implement when there are inline children. 322 // From |NGBlockLayoutAlgorithm| perspective, we can handle |NGInlineNode|
323 return child_minmax; 323 // almost the same as |NGBlockNode|, because an |NGInlineNode| includes
324 // all inline nodes following |node| and their descendants, and produces
325 // an anonymous box that contains all line boxes.
326 // |NextSibling| returns the next block sibling, or nullptr, skipping all
327 // following inline siblings and descendants.
328 child_sizes = toNGInlineNode(node)->ComputeMinAndMaxContentSizes();
329 } else {
330 Optional<MinAndMaxContentSizes> child_minmax;
331 NGBlockNode* block_child = toNGBlockNode(node);
332 if (NeedMinAndMaxContentSizesForContentContribution(
333 block_child->Style())) {
334 child_minmax = block_child->ComputeMinAndMaxContentSizes();
335 }
336
337 child_sizes = ComputeMinAndMaxContentContribution(block_child->Style(),
338 child_minmax);
324 } 339 }
325 NGBlockNode* block_child = toNGBlockNode(node);
326 if (NeedMinAndMaxContentSizesForContentContribution(block_child->Style())) {
327 child_minmax = block_child->ComputeMinAndMaxContentSizes();
328 }
329
330 MinAndMaxContentSizes child_sizes =
331 ComputeMinAndMaxContentContribution(block_child->Style(), child_minmax);
332 340
333 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content); 341 sizes.min_content = std::max(sizes.min_content, child_sizes.min_content);
334 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content); 342 sizes.max_content = std::max(sizes.max_content, child_sizes.max_content);
335 } 343 }
336 344
337 sizes.max_content = std::max(sizes.min_content, sizes.max_content); 345 sizes.max_content = std::max(sizes.min_content, sizes.max_content);
338 return sizes; 346 return sizes;
339 } 347 }
340 348
341 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset( 349 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset(
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 FinalizeForFragmentation(); 519 FinalizeForFragmentation();
512 520
513 return builder_->ToBoxFragment(); 521 return builder_->ToBoxFragment();
514 } 522 }
515 523
516 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) { 524 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) {
517 // TODO(kojii): This logic does not handle when children are mix of 525 // TODO(kojii): This logic does not handle when children are mix of
518 // inline/block. We need to detect the case and setup appropriately; e.g., 526 // inline/block. We need to detect the case and setup appropriately; e.g.,
519 // constraint space, margin collapsing, next siblings, etc. 527 // constraint space, margin collapsing, next siblings, etc.
520 NGLineBuilder line_builder(current_child, space_for_current_child_); 528 NGLineBuilder line_builder(current_child, space_for_current_child_);
529 // TODO(kojii): Need to determine when to invalidate PrepareLayout() more
530 // efficiently than "everytime".
531 current_child->InvalidatePrepareLayout();
521 current_child->LayoutInline(space_for_current_child_, &line_builder); 532 current_child->LayoutInline(space_for_current_child_, &line_builder);
522 // TODO(kojii): The wrapper fragment should not be needed. 533 // TODO(kojii): The wrapper fragment should not be needed.
523 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox, 534 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox,
524 current_child); 535 current_child);
525 line_builder.CreateFragments(&wrapper_fragment_builder); 536 line_builder.CreateFragments(&wrapper_fragment_builder);
526 RefPtr<NGLayoutResult> child_result = 537 RefPtr<NGLayoutResult> child_result =
527 wrapper_fragment_builder.ToBoxFragment(); 538 wrapper_fragment_builder.ToBoxFragment();
528 line_builder.CopyFragmentDataToLayoutBlockFlow(); 539 line_builder.CopyFragmentDataToLayoutBlockFlow();
529 FinishCurrentChildLayout(child_result); 540 FinishCurrentChildLayout(child_result);
530 current_child_ = nullptr; 541 current_child_ = nullptr;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 curr_margin_strut_.Append(curr_child_margins_.block_start); 851 curr_margin_strut_.Append(curr_child_margins_.block_start);
841 space_builder_->SetMarginStrut(curr_margin_strut_); 852 space_builder_->SetMarginStrut(curr_margin_strut_);
842 } 853 }
843 854
844 space_builder_->SetBfcOffset(curr_bfc_offset_); 855 space_builder_->SetBfcOffset(curr_bfc_offset_);
845 856
846 return space_builder_->ToConstraintSpace( 857 return space_builder_->ToConstraintSpace(
847 FromPlatformWritingMode(current_child_style.getWritingMode())); 858 FromPlatformWritingMode(current_child_style.getWritingMode()));
848 } 859 }
849 } // namespace blink 860 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_inline_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698