haikuwebkit/LayoutTests/css-custom-properties-api
Darin Adler 631481f479 CSS parser "consume declaration" algorithm does not handle whitespace correctly
https://bugs.webkit.org/show_bug.cgi?id=227368

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-properties-values-api/at-property-animation-expected.txt:
* web-platform-tests/css/css-properties-values-api/at-property-expected.txt:
* web-platform-tests/css/css-properties-values-api/at-property-shadow-expected.txt:
* web-platform-tests/css/css-properties-values-api/determine-registration-expected.txt:
* web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt:
* web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt:
Regenerated to reflect the whitespace trimming: one new pass, no new failures. Some of
these tests will also need updates to match the newer CSS specification. Not doing those
here right now.

* web-platform-tests/css/css-properties-values-api/at-property.html:
Pulled down a newer version of this test from the WPT repository with expectations in line
with newer CSS specification.

* web-platform-tests/css/css-syntax/declarations-trim-whitespace-expected.txt:
* web-platform-tests/css/css-variables/variable-cssText-expected.txt:
Expect most tests to pass instead of fail. There are still some failures. Given my reading
of the CSS specification I suspect it is the tests that are incorrect.

* web-platform-tests/css/css-variables/variable-definition-expected.txt:
* web-platform-tests/css/css-variables/variable-definition.html:
Pulled down a newer version of this test from the WPT repository with expectations in line
with newer CSS specification. Some tests are still failing because of expectations about
trailing whitespace. Given my reading of the CSS specification I suspect it is the tests
that are incorrect.

* web-platform-tests/css/css-variables/variable-reference-expected.txt:
* web-platform-tests/css/css-variables/variable-reference.html:
* web-platform-tests/css/css-variables/variable-substitution-variable-declaration-expected.txt:
* web-platform-tests/css/css-variables/variable-substitution-variable-declaration.html:
Pulled down a newer version of these tests from the WPT repository with expectations in
line with newer CSS specification.

* web-platform-tests/css/cssom/variable-names-expected.txt: Expect tests to pass, not fail.

Source/WebCore:

Test: imported/w3c/web-platform-tests/css/css-syntax/declarations-trim-whitespace.html

To avoid creating regressions in CSS variable behavior, had to make
changes there to handle whitespace correctly at the same time as the
change to the "consume declaration" algorithm.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::customPropertyValue): Restructured
to not have a case for each variant custom value type. This lets us
support the new Empty value type without extra code here.

* css/CSSCustomPropertyValue.cpp:
(WebCore::CSSCustomPropertyValue::createEmpty): Added. Used for a new
Empty value type for properties that have empty string as their value,
which is a new capability added to the CSS specification.
(WebCore::CSSCustomPropertyValue::equals const): Removed unneeded pointer
comparison optimization. Added support for Empty value.
(WebCore::CSSCustomPropertyValue::customCSSText const): Updated to use
null string for m_stringValue instead of a separate m_serialized flag.
Added support for Empty value.
(WebCore::CSSCustomPropertyValue::tokens const): Added support for
Empty value. Also call directly to customCSSText instead of calling
through cssText.

* css/CSSCustomPropertyValue.h: Updated for the above, adding Empty value.
Removed m_serialized. Greatly simplified the copy constructor since Ref
now has a copy constructor.

* css/CSSVariableReferenceValue.cpp:
(WebCore::resolveVariableFallback): Consume whitespace after the comma,
matching what is now called for in the CSS specification.

* css/calc/CSSCalcExpressionNodeParser.cpp:
(WebCore::CSSCalcExpressionNodeParser::parseCalcFunction): Use
consumeCommaIncludingWhitespace to simplify the code. No behavior change,
just refactoring.

* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeDeclaration): Updated algorithm to match
the CSS specification, trimming whitespace correctly.
(WebCore::CSSParserImpl::consumeCustomPropertyValue): Added support for
a custom property value with no declaration value, as now called for in
the CSS specification, using CSSCustomPropertyValue::createEmpty.

* css/parser/CSSVariableParser.cpp:
(WebCore::isValidVariableReference): Allow empty fallback, as now called
for in the CSS specification.
(WebCore::isValidConstantReference): Ditto.

LayoutTests:

* css-custom-properties-api/inline.html: Update expectations to expect leading
whitespace to be trimmed.

* fast/css/variables/test-suite/011.html: Updated to expect a variable reference
with no fallback tokens to be valid. Change in the CSS specification since this
test was written.
* fast/css/variables/test-suite/013.html: Ditto.
* fast/css/variables/test-suite/041.html: Ditto.
* fast/css/variables/test-suite/043.html: Ditto.

* fast/css/variables/test-suite/061.html: Updated to expect a value with no tokens
to be valid. Change in the CSS specification since this test was written.

* fast/css/variables/test-suite/100.html: Updated to expect a variable reference
with no fallback tokens to be valid. Change in the CSS specification since this
test was written.
* fast/css/variables/test-suite/105.html: Ditto.
* fast/css/variables/test-suite/136.html: Ditto.

* fast/css/variables/test-suite/170.html: Updated to expect a value with no tokens
to be valid. Change in the CSS specification since this test was written.
* fast/css/variables/test-suite/171.html: Ditto.

* platform/mac/TestExpectations: Removed a line for a test that no longer exists
(not changed in this patch).

Canonical link: https://commits.webkit.org/239225@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-29 01:34:20 +00:00
..
border-variable-parsing-expected.html
border-variable-parsing.html CSS variables don't work for colors in "border" property 2018-12-21 21:33:03 +00:00
crash-expected.txt
crash.html
cycles-expected.txt
cycles.html
inherits-expected.txt
inherits.html
initialValue-expected.html
initialValue.html
initialValueJS-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
initialValueJS.html
inline-expected.txt
inline.html CSS parser "consume declaration" algorithm does not handle whitespace correctly 2021-06-29 01:34:20 +00:00
length-expected.txt
length.html
length2-expected.txt
length2.html
registerProperty-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
registerProperty.html