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

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: Cleanup and add a test 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 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 child_sizes = toNGInlineNode(node)->ComputeMinAndMaxContentSizes();
329 return child_minmax; 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);
330 } 339 }
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 340
339 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);
cbiesinger 2017/02/23 19:07:01 This assumes you can linebreak between two inlines
kojii 2017/02/24 01:55:49 At this point, |child_sizes| contains values from
340 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);
cbiesinger 2017/02/23 19:07:01 This is not correct for inline. For inline, you ba
kojii 2017/02/24 01:55:49 Yeah, the code in |NGInlineNode::ComputeMinAndMaxC
341 } 343 }
342 344
343 sizes.max_content = std::max(sizes.min_content, sizes.max_content); 345 sizes.max_content = std::max(sizes.min_content, sizes.max_content);
344 return sizes; 346 return sizes;
345 } 347 }
346 348
347 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset( 349 NGLogicalOffset NGBlockLayoutAlgorithm::CalculateLogicalOffset(
348 const WTF::Optional<NGLogicalOffset>& known_fragment_offset) { 350 const WTF::Optional<NGLogicalOffset>& known_fragment_offset) {
349 LayoutUnit inline_offset = 351 LayoutUnit inline_offset =
350 border_and_padding_.inline_start + curr_child_margins_.inline_start; 352 border_and_padding_.inline_start + curr_child_margins_.inline_start;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 FinalizeForFragmentation(); 507 FinalizeForFragmentation();
506 508
507 return builder_->ToBoxFragment(); 509 return builder_->ToBoxFragment();
508 } 510 }
509 511
510 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) { 512 void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) {
511 // TODO(kojii): This logic does not handle when children are mix of 513 // 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., 514 // inline/block. We need to detect the case and setup appropriately; e.g.,
513 // constraint space, margin collapsing, next siblings, etc. 515 // constraint space, margin collapsing, next siblings, etc.
514 NGLineBuilder line_builder(current_child, space_for_current_child_); 516 NGLineBuilder line_builder(current_child, space_for_current_child_);
517 // TODO(kojii): Need to determine when to invalidate PrepareLayout() more
518 // efficiently than "everytime".
519 current_child->InvalidatePrepareLayout();
515 current_child->LayoutInline(space_for_current_child_, &line_builder); 520 current_child->LayoutInline(space_for_current_child_, &line_builder);
516 // TODO(kojii): The wrapper fragment should not be needed. 521 // TODO(kojii): The wrapper fragment should not be needed.
517 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox, 522 NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox,
518 current_child); 523 current_child);
519 line_builder.CreateFragments(&wrapper_fragment_builder); 524 line_builder.CreateFragments(&wrapper_fragment_builder);
520 RefPtr<NGLayoutResult> child_result = 525 RefPtr<NGLayoutResult> child_result =
521 wrapper_fragment_builder.ToBoxFragment(); 526 wrapper_fragment_builder.ToBoxFragment();
522 line_builder.CopyFragmentDataToLayoutBlockFlow(); 527 line_builder.CopyFragmentDataToLayoutBlockFlow();
523 FinishCurrentChildLayout(child_result); 528 FinishCurrentChildLayout(child_result);
524 current_child_ = nullptr; 529 current_child_ = nullptr;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 space_builder_->SetMarginStrut(curr_margin_strut_); 841 space_builder_->SetMarginStrut(curr_margin_strut_);
837 } 842 }
838 843
839 space_builder_->SetBfcOffset(curr_bfc_offset_); 844 space_builder_->SetBfcOffset(curr_bfc_offset_);
840 845
841 return space_builder_->ToConstraintSpace( 846 return space_builder_->ToConstraintSpace(
842 FromPlatformWritingMode(current_child_style.getWritingMode())); 847 FromPlatformWritingMode(current_child_style.getWritingMode()));
843 } 848 }
844 849
845 } // namespace blink 850 } // 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