Diff
Modified: trunk/LayoutTests/ChangeLog (284439 => 284440)
--- trunk/LayoutTests/ChangeLog 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/ChangeLog 2021-10-19 10:14:40 UTC (rev 284440)
@@ -1,3 +1,12 @@
+2021-10-18 Sergio Villar Senin <svil...@igalia.com>
+
+ [css-flexbox] Add flex-basis: content support
+ https://bugs.webkit.org/show_bug.cgi?id=221479
+
+ Reviewed by Javier Fernandez.
+
+ * TestExpectations: Unskipped 6 tests that are now passing.
+
2021-10-19 Cameron McCormack <hey...@apple.com>
Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
Modified: trunk/LayoutTests/TestExpectations (284439 => 284440)
--- trunk/LayoutTests/TestExpectations 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/TestExpectations 2021-10-19 10:14:40 UTC (rev 284440)
@@ -4210,14 +4210,6 @@
webkit.org/b/221478 imported/w3c/web-platform-tests/css/css-flexbox/dynamic-baseline-change.html [ ImageOnlyFailure ]
webkit.org/b/221478 imported/w3c/web-platform-tests/css/css-flexbox/synthesize-vrl-baseline.html [ ImageOnlyFailure ]
-# flex-basis:content.
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-001a.html [ ImageOnlyFailure ]
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-001b.html [ ImageOnlyFailure ]
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-002a.html [ ImageOnlyFailure ]
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-002b.html [ ImageOnlyFailure ]
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-003a.html [ ImageOnlyFailure ]
-webkit.org/b/221479 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-basis-content-004a.html [ ImageOnlyFailure ]
-
# Flex item's min|max content contributions
webkit.org/b/230747 imported/w3c/web-platform-tests/css/css-flexbox/flex-container-max-content-001.html [ ImageOnlyFailure ]
webkit.org/b/230747 imported/w3c/web-platform-tests/css/css-flexbox/flex-container-min-content-001.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (284439 => 284440)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-10-19 10:14:40 UTC (rev 284440)
@@ -1,3 +1,16 @@
+2021-10-18 Sergio Villar Senin <svil...@igalia.com>
+
+ [css-flexbox] Add flex-basis: content support
+ https://bugs.webkit.org/show_bug.cgi?id=221479
+
+ Reviewed by Javier Fernandez.
+
+ Fixed 6 subtest expectations. All of them working fine now.
+
+ * web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt:
+ * web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt:
+ * web-platform-tests/css/css-flexbox/parsing/flex-shorthand-expected.txt:
+
2021-10-19 Cameron McCormack <hey...@apple.com>
Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt (284439 => 284440)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-computed-expected.txt 2021-10-19 10:14:40 UTC (rev 284440)
@@ -2,7 +2,7 @@
PASS Property flex-basis value '1px'
PASS Property flex-basis value '400%'
PASS Property flex-basis value 'auto'
-FAIL Property flex-basis value 'content' assert_true: 'content' is a supported value for flex-basis. expected true got false
+PASS Property flex-basis value 'content'
FAIL Property flex-basis value 'fit-content' assert_true: 'fit-content' is a supported value for flex-basis. expected true got false
FAIL Property flex-basis value 'min-content' assert_true: 'min-content' is a supported value for flex-basis. expected true got false
FAIL Property flex-basis value 'max-content' assert_true: 'max-content' is a supported value for flex-basis. expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt (284439 => 284440)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-basis-valid-expected.txt 2021-10-19 10:14:40 UTC (rev 284440)
@@ -6,5 +6,5 @@
FAIL e.style['flex-basis'] = "fit-content" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['flex-basis'] = "min-content" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['flex-basis'] = "max-content" should set the property value assert_not_equals: property should be set got disallowed value ""
-FAIL e.style['flex-basis'] = "content" should set the property value assert_not_equals: property should be set got disallowed value ""
+PASS e.style['flex-basis'] = "content" should set the property value
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-shorthand-expected.txt (284439 => 284440)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-shorthand-expected.txt 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/parsing/flex-shorthand-expected.txt 2021-10-19 10:14:40 UTC (rev 284440)
@@ -23,10 +23,10 @@
PASS e.style['flex'] = "8 auto" should set flex-grow
PASS e.style['flex'] = "8 auto" should set flex-shrink
PASS e.style['flex'] = "8 auto" should not set unrelated longhands
-FAIL e.style['flex'] = "content" should set flex-basis assert_equals: flex-basis should be canonical expected "content" but got ""
-FAIL e.style['flex'] = "content" should set flex-grow assert_equals: flex-grow should be canonical expected "1" but got ""
-FAIL e.style['flex'] = "content" should set flex-shrink assert_equals: flex-shrink should be canonical expected "1" but got ""
-FAIL e.style['flex'] = "content" should not set unrelated longhands assert_true: expected true got false
+PASS e.style['flex'] = "content" should set flex-basis
+PASS e.style['flex'] = "content" should set flex-grow
+PASS e.style['flex'] = "content" should set flex-shrink
+PASS e.style['flex'] = "content" should not set unrelated longhands
FAIL e.style['flex'] = "0 fit-content" should set flex-basis assert_equals: flex-basis should be canonical expected "fit-content" but got ""
FAIL e.style['flex'] = "0 fit-content" should set flex-grow assert_equals: flex-grow should be canonical expected "0" but got ""
FAIL e.style['flex'] = "0 fit-content" should set flex-shrink assert_equals: flex-shrink should be canonical expected "1" but got ""
Modified: trunk/Source/WebCore/ChangeLog (284439 => 284440)
--- trunk/Source/WebCore/ChangeLog 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/ChangeLog 2021-10-19 10:14:40 UTC (rev 284440)
@@ -1,3 +1,51 @@
+2021-10-18 Sergio Villar Senin <svil...@igalia.com>
+
+ [css-flexbox] Add flex-basis: content support
+ https://bugs.webkit.org/show_bug.cgi?id=221479
+
+ Reviewed by Javier Fernandez.
+
+ Add support for the content keyword as a valid value for the flex-basis property.
+ It indicates an automated size based on the contents of the flex item. It's typically
+ equivalent to the max-content size but it has some adjustments for aspect ratios,
+ orthogonal flows and intrinsic sizing constraints.
+
+ Apart from adding the parsing support, it required very little adjustments in the
+ flexbox code after the refactoring in r284359.
+
+ This makes WebKit pass all of the flex-basis:content tests in WPT. We're talking
+ about 6 tests testing the feature and 6 subtests related to parsing.
+
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Handle Content in switch.
+ (WebCore::CSSPrimitiveValue::init): Initialization for content CSS value.
+ * css/CSSProperties.json:
+ * css/LengthFunctions.cpp: Replaced LengthOrAuto by LengthSizing.
+ (WebCore::valueForLength): Handle Content in switch.
+ (WebCore::floatValueForLength): Ditto.
+ * css/LengthFunctions.h:
+ (WebCore::minimumValueForLength): Ditto.
+ * css/calc/CSSCalcValue.cpp:
+ (WebCore::createCSS): Ditto.
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeFlexBasis): Consume CSSValueContent.
+ (WebCore::CSSPropertyParser::consumeFlex): Ditto.
+ * platform/Length.cpp:
+ (WebCore::operator<<): Added printing support for content.
+ * platform/Length.h:
+ (WebCore::Length::initialize): Added enum for content.
+ (WebCore::Length::isContent const): New method.
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::computeReplacedLogicalWidthUsing const): Handle content in switch.
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::childMainSizeIsDefinite): Treat content as indefinite lenght.
+ (WebCore::RenderFlexibleBox::childHasComputableAspectRatioAndCrossSizeIsConsideredDefinite):
+ Flex basis must be either auto or content.
+ (WebCore::RenderFlexibleBox::computeFlexBaseSizeForChild): Compute flex-basis using max-content
+ if flex-basis:content is specified.
+ * style/StyleBuilderConverter.h:
+ (WebCore::Style::BuilderConverter::convertLengthSizing): Handle content in switch.
+
2021-10-19 Cameron McCormack <hey...@apple.com>
Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (284439 => 284440)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -37,6 +37,7 @@
#include "Counter.h"
#include "DeprecatedCSSOMPrimitiveValue.h"
#include "FontCascade.h"
+#include "Length.h"
#include "Node.h"
#include "Pair.h"
#include "Rect.h"
@@ -290,6 +291,7 @@
{
switch (length.type()) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
case LengthType::MinContent:
@@ -345,6 +347,10 @@
setPrimitiveUnitType(CSSUnitType::CSS_VALUE_ID);
m_value.valueID = CSSValueAuto;
return;
+ case LengthType::Content:
+ setPrimitiveUnitType(CSSUnitType::CSS_VALUE_ID);
+ m_value.valueID = CSSValueContent;
+ return;
case LengthType::Fixed:
setPrimitiveUnitType(CSSUnitType::CSS_PX);
m_value.num = length.value();
Modified: trunk/Source/WebCore/css/CSSProperties.json (284439 => 284440)
--- trunk/Source/WebCore/css/CSSProperties.json 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/CSSProperties.json 2021-10-19 10:14:40 UTC (rev 284440)
@@ -5671,7 +5671,7 @@
"aliases": [
"-webkit-flex-basis"
],
- "converter": "LengthOrAuto"
+ "converter": "LengthSizing"
},
"specification": {
"category": "css-flexbox",
Modified: trunk/Source/WebCore/css/LengthFunctions.cpp (284439 => 284440)
--- trunk/Source/WebCore/css/LengthFunctions.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/LengthFunctions.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -49,6 +49,7 @@
case LengthType::Relative:
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
+ case LengthType::Content:
case LengthType::MinContent:
case LengthType::MaxContent:
case LengthType::FitContent:
@@ -76,6 +77,7 @@
case LengthType::Relative:
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
+ case LengthType::Content:
case LengthType::MinContent:
case LengthType::MaxContent:
case LengthType::FitContent:
@@ -102,6 +104,7 @@
case LengthType::Relative:
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
+ case LengthType::Content:
case LengthType::MinContent:
case LengthType::MaxContent:
case LengthType::FitContent:
Modified: trunk/Source/WebCore/css/LengthFunctions.h (284439 => 284440)
--- trunk/Source/WebCore/css/LengthFunctions.h 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/LengthFunctions.h 2021-10-19 10:14:40 UTC (rev 284440)
@@ -59,6 +59,7 @@
return LayoutUnit(length.nonNanCalculatedValue(maximumValue));
case LengthType::FillAvailable:
case LengthType::Auto:
+ case LengthType::Content:
return 0;
case LengthType::Relative:
case LengthType::Intrinsic:
Modified: trunk/Source/WebCore/css/calc/CSSCalcValue.cpp (284439 => 284440)
--- trunk/Source/WebCore/css/calc/CSSCalcValue.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/calc/CSSCalcValue.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -264,6 +264,7 @@
case LengthType::Calculated:
return createCSS(length.calculationValue()._expression_(), style);
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
case LengthType::MinContent:
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (284439 => 284440)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -2241,7 +2241,7 @@
static RefPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode)
{
// FIXME: Support intrinsic dimensions too.
- if (range.peek().id() == CSSValueAuto)
+ if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueContent)
return consumeIdent(range);
return consumeLengthOrPercent(range, cssParserMode, ValueRange::NonNegative);
}
@@ -5227,7 +5227,7 @@
else
return false;
} else if (!flexBasis) {
- if (m_range.peek().id() == CSSValueAuto)
+ if (m_range.peek().id() == CSSValueAuto || m_range.peek().id() == CSSValueContent)
flexBasis = consumeIdent(m_range);
if (!flexBasis)
flexBasis = consumeLengthOrPercent(m_range, m_context.mode, ValueRange::NonNegative);
Modified: trunk/Source/WebCore/platform/Length.cpp (284439 => 284440)
--- trunk/Source/WebCore/platform/Length.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/platform/Length.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -370,6 +370,7 @@
case LengthType::FillAvailable: ts << "fill-available"; break;
case LengthType::FitContent: ts << "fit-content"; break;
case LengthType::Calculated: ts << "calc"; break;
+ case LengthType::Content: ts << "content"; break;
case LengthType::Undefined: ts << "undefined"; break;
}
return ts;
@@ -379,6 +380,7 @@
{
switch (length.type()) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Undefined:
ts << length.type();
break;
Modified: trunk/Source/WebCore/platform/Length.h (284439 => 284440)
--- trunk/Source/WebCore/platform/Length.h 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/platform/Length.h 2021-10-19 10:14:40 UTC (rev 284440)
@@ -47,6 +47,7 @@
FillAvailable,
FitContent,
Calculated,
+ Content,
Undefined
};
@@ -103,6 +104,7 @@
bool isFillAvailable() const;
bool isFitContent() const;
bool isMinIntrinsic() const;
+ bool isContent() const;
bool hasQuirk() const;
void setHasQuirk(bool);
@@ -236,6 +238,7 @@
switch (m_type) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Undefined:
m_intValue = 0;
break;
@@ -268,6 +271,7 @@
switch (m_type) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Undefined:
m_intValue = 0;
break;
@@ -511,6 +515,11 @@
return type() == LengthType::MinIntrinsic;
}
+inline bool Length::isContent() const
+{
+ return type() == LengthType::Content;
+}
+
Length convertTo100PercentMinusLength(const Length&);
WTF::TextStream& operator<<(WTF::TextStream&, Length);
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (284439 => 284440)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -3341,6 +3341,7 @@
case LengthType::Intrinsic:
case LengthType::MinIntrinsic:
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Relative:
case LengthType::Undefined:
return intrinsicLogicalWidth();
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (284439 => 284440)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -34,6 +34,7 @@
#include "FlexibleBoxAlgorithm.h"
#include "HitTestResult.h"
#include "LayoutRepainter.h"
+#include "Length.h"
#include "RenderBox.h"
#include "RenderChildIterator.h"
#include "RenderLayer.h"
@@ -917,7 +918,7 @@
bool RenderFlexibleBox::childMainSizeIsDefinite(const RenderBox& child, const Length& flexBasis)
{
- if (flexBasis.isAuto())
+ if (flexBasis.isAuto() || flexBasis.isContent())
return false;
if (isColumnFlow() && (flexBasis.isIntrinsic() || flexBasis.type() == LengthType::Intrinsic))
return false;
@@ -935,7 +936,8 @@
bool RenderFlexibleBox::childHasComputableAspectRatioAndCrossSizeIsConsideredDefinite(const RenderBox& child)
{
- return childHasComputableAspectRatio(child)
+ auto flexBasis = flexBasisForChild(child);
+ return childHasComputableAspectRatio(child) && (flexBasis.isContent() || flexBasis.isAuto())
&& (childCrossSizeIsDefinite(child, crossSizeLengthForChild(MainOrPreferredSize, child)) || childCrossSizeShouldUseContainerCrossSize(child));
}
@@ -1069,7 +1071,7 @@
// 9.3.2 E. Otherwise, size the item into the available space using its used flex basis in place of its main size.
{
- ScopedUnboundedBoxWithFlexBasisAsChildMainSize flexBasisScope(child, flexBasis, mainAxisIsChildInlineAxis(child));
+ ScopedUnboundedBoxWithFlexBasisAsChildMainSize flexBasisScope(child, flexBasis.isContent() ? Length(LengthType::MaxContent) : flexBasis, mainAxisIsChildInlineAxis(child));
if (mainAxisIsChildInlineAxis(child))
return child.maxPreferredLogicalWidth() - mainAxisBorderAndPadding;
Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (284439 => 284440)
--- trunk/Source/WebCore/style/StyleBuilderConverter.h 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h 2021-10-19 10:14:40 UTC (rev 284440)
@@ -68,6 +68,7 @@
public:
static Length convertLength(const BuilderState&, const CSSValue&);
static Length convertLengthOrAuto(const BuilderState&, const CSSValue&);
+ static Length convertLengthOrAutoOrContent(const BuilderState&, const CSSValue&);
static Length convertLengthSizing(const BuilderState&, const CSSValue&);
static Length convertLengthMaxSizing(const BuilderState&, const CSSValue&);
static TabSize convertTabSize(const BuilderState&, const CSSValue&);
@@ -244,6 +245,8 @@
return Length(LengthType::FitContent);
case CSSValueAuto:
return Length(LengthType::Auto);
+ case CSSValueContent:
+ return Length(LengthType::Content);
default:
ASSERT_NOT_REACHED();
return Length();
Modified: trunk/Source/WebKit/ChangeLog (284439 => 284440)
--- trunk/Source/WebKit/ChangeLog 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebKit/ChangeLog 2021-10-19 10:14:40 UTC (rev 284440)
@@ -1,3 +1,17 @@
+2021-10-18 Sergio Villar Senin <svil...@igalia.com>
+
+ [css-flexbox] Add flex-basis: content support
+ https://bugs.webkit.org/show_bug.cgi?id=221479
+ <rdar://problem/74279369>
+
+ Reviewed by Javier Fernandez.
+
+ Handle LengthType::Content in encode/decode functions.
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (IPC::ArgumentCoder<Length>::encode):
+ (IPC::ArgumentCoder<Length>::decode):
+
2021-10-19 Cameron McCormack <hey...@apple.com>
Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (284439 => 284440)
--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2021-10-19 08:35:40 UTC (rev 284439)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp 2021-10-19 10:14:40 UTC (rev 284440)
@@ -717,6 +717,7 @@
switch (length.type()) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Undefined:
break;
case LengthType::Fixed:
@@ -752,6 +753,7 @@
switch (type) {
case LengthType::Auto:
+ case LengthType::Content:
case LengthType::Undefined:
length = Length(type);
return true;