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

Unified 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, 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
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 9a7fda32cb16d0d61cead49b2d3a0d93e6de72c5..f0c86faa3c2b4df9b861e0dcec28b603106fcb66 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
@@ -323,18 +323,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.
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
+ 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);
@@ -512,6 +520,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,

Powered by Google App Engine
This is Rietveld 408576698