From 79b640795aacac89e67043a22cb3ceb622bd0864 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Wed, 6 Apr 2022 23:59:01 +0800 Subject: Issue #1370 - Part 3: Implement `content` keyword for `flex-basis` property Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1105111 --- layout/generic/nsFrame.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'layout/generic/nsFrame.cpp') diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 99442e681f..141c148673 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4647,11 +4647,23 @@ nsFrame::SetCoordToFlexBasis(bool aIsInlineFlexItem, return; } + const nsStyleCoord* newCoord = aFlexBasis; + + // Having 'content' as the value of the 'flex-basis' property is + // equivalent to setting both 'flex-basis' and the main size + // properties to 'auto', which is why a dummy 'auto' value will + // be used here for the main size property. + if (aFlexBasis->GetUnit() == eStyleUnit_Enumerated && + aFlexBasis->GetIntValue() == NS_STYLE_FLEX_BASIS_CONTENT) { + static const nsStyleCoord autoStyleCoord(eStyleUnit_Auto); + newCoord = &autoStyleCoord; + } + // Override whichever styleCoord is in the flex container's main axis if (aIsInlineFlexItem) { - *aInlineStyle = aFlexBasis; + *aInlineStyle = newCoord; } else { - *aBlockStyle = aFlexBasis; + *aBlockStyle = newCoord; } } -- cgit v1.2.3