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

Unified 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, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
index edc7d660a96802fdae0b49e41322fe4dbf32f3fd..18c68a37fa506f62a05a6c4a30726e28099c038f 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
@@ -317,18 +317,26 @@ NGBlockLayoutAlgorithm::ComputeMinAndMaxContentSizes() const {
// TODO: handle floats & orthogonal children.
for (NGLayoutInputNode* node = node_->FirstChild(); node;
node = node->NextSibling()) {
- Optional<MinAndMaxContentSizes> child_minmax;
+ MinAndMaxContentSizes child_sizes;
if (node->Type() == NGLayoutInputNode::kLegacyInline) {
- // TODO(kojii): Implement when there are inline children.
- return child_minmax;
- }
- NGBlockNode* block_child = toNGBlockNode(node);
- if (NeedMinAndMaxContentSizesForContentContribution(block_child->Style())) {
- child_minmax = block_child->ComputeMinAndMaxContentSizes();
- }
+ // From |NGBlockLayoutAlgorithm| perspective, we can handle |NGInlineNode|
+ // almost the same as |NGBlockNode|, because an |NGInlineNode| includes
+ // all inline nodes following |node| and their descendants, and produces
+ // an anonymous box that contains all line boxes.
+ // |NextSibling| returns the next block sibling, or nullptr, skipping all
+ // following inline siblings and descendants.
+ child_sizes = toNGInlineNode(node)->ComputeMinAndMaxContentSizes();
+ } else {
+ Optional<MinAndMaxContentSizes> child_minmax;
+ NGBlockNode* block_child = toNGBlockNode(node);
+ if (NeedMinAndMaxContentSizesForContentContribution(
+ block_child->Style())) {
+ child_minmax = block_child->ComputeMinAndMaxContentSizes();
+ }
- MinAndMaxContentSizes child_sizes =
- ComputeMinAndMaxContentContribution(block_child->Style(), child_minmax);
+ child_sizes = ComputeMinAndMaxContentContribution(block_child->Style(),
+ child_minmax);
+ }
sizes.min_content = std::max(sizes.min_content, child_sizes.min_content);
sizes.max_content = std::max(sizes.max_content, child_sizes.max_content);
@@ -518,6 +526,9 @@ void NGBlockLayoutAlgorithm::LayoutInlineChildren(NGInlineNode* current_child) {
// inline/block. We need to detect the case and setup appropriately; e.g.,
// constraint space, margin collapsing, next siblings, etc.
NGLineBuilder line_builder(current_child, space_for_current_child_);
+ // TODO(kojii): Need to determine when to invalidate PrepareLayout() more
+ // efficiently than "everytime".
+ current_child->InvalidatePrepareLayout();
current_child->LayoutInline(space_for_current_child_, &line_builder);
// TODO(kojii): The wrapper fragment should not be needed.
NGFragmentBuilder wrapper_fragment_builder(NGPhysicalFragment::kFragmentBox,
« 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