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

Unified Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc

Issue 2974823004: [LayoutNG] Fix inline ComputeMinMaxContentSize() (Closed)
Patch Set: Created 3 years, 5 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 | « third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
index 5fa4b4d2524f2a526592aaec8aff9e1d3b3ed241..2cecacc7dc8876491478bc9ffaec6eb23bb840cf 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
@@ -347,10 +347,7 @@ RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space,
return result;
}
-enum class ContentSizeMode { Max, Sum };
-
static LayoutUnit ComputeContentSize(NGInlineNode node,
- ContentSizeMode mode,
LayoutUnit available_inline_size) {
const ComputedStyle& style = node.Style();
NGWritingMode writing_mode = FromPlatformWritingMode(style.GetWritingMode());
@@ -371,11 +368,7 @@ static LayoutUnit ComputeContentSize(NGInlineNode node,
LayoutUnit inline_size = line_info.TextIndent();
for (const NGInlineItemResult item_result : line_info.Results())
inline_size += item_result.inline_size;
- if (mode == ContentSizeMode::Max) {
- result = std::max(inline_size, result);
- } else {
- result += inline_size;
- }
+ result = std::max(inline_size, result);
}
return result;
}
@@ -394,15 +387,16 @@ MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() {
// size. This gives the min-content, the width where lines wrap at every
// break opportunity.
MinMaxContentSize sizes;
- sizes.min_content =
- ComputeContentSize(*this, ContentSizeMode::Max, LayoutUnit());
+ sizes.min_content = ComputeContentSize(*this, LayoutUnit());
// Compute the sum of inline sizes of all inline boxes with no line breaks.
// TODO(kojii): NGConstraintSpaceBuilder does not allow NGSizeIndefinite
// inline available size. We can allow it, or make this more efficient
// without using NGLineBreaker.
- sizes.max_content =
- ComputeContentSize(*this, ContentSizeMode::Sum, LayoutUnit::Max());
+ sizes.max_content = ComputeContentSize(*this, LayoutUnit::Max());
+
+ // Negative text-indent can make min > max. Ensure min is the minimum size.
+ sizes.min_content = std::min(sizes.min_content, sizes.max_content);
return sizes;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698