[webkit-changes] [WebKit/WebKit] 262c7e: Preserve whitespace when serializing custom proper...

Antti Koivisto noreply at github.com
Fri Feb 23 05:43:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 262c7e61cab2ef3cdeeab58d28d932aafc4cac39
      https://github.com/WebKit/WebKit/commit/262c7e61cab2ef3cdeeab58d28d932aafc4cac39
  Author: Antti Koivisto <antti at apple.com>
  Date:   2024-02-23 (Fri, 23 Feb 2024)

  Changed paths:
    M LayoutTests/css-custom-properties-api/crash.html
    M LayoutTests/css-custom-properties-api/inline.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/at-container-style-serialization-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-property-style-queries.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/custom-property-rule-ambiguity-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-cssText-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-definition-expected.txt
    M Source/WebCore/css/parser/CSSParserImpl.cpp
    M Source/WebCore/css/parser/CSSParserToken.cpp
    M Source/WebCore/css/parser/CSSParserToken.h
    M Source/WebCore/css/parser/CSSTokenizer.cpp

  Log Message:
  -----------
  Preserve whitespace when serializing custom properties
https://bugs.webkit.org/show_bug.cgi?id=269971
rdar://123491915

Reviewed by Anne van Kesteren.

"Specified values of custom properties must be serialized exactly as specified by the author. Simplifications
that might occur in other properties, such as dropping comments, normalizing whitespace, reserializing numeric
tokens from their value, etc., must not occur."

https://drafts.csswg.org/css-variables-2/#serializing-custom-props

* LayoutTests/css-custom-properties-api/crash.html:
* LayoutTests/css-custom-properties-api/inline.html

Update the tests. Leading and trailing whitespaces should be trimmed also when using CSSStyleDeclaration.setProperty().
This matches other browsers.

* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/at-container-style-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-property-style-queries.html:

Fix a bug in this WPT. It was checking a wrong property and not testing anything.

* LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/custom-property-rule-ambiguity-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-cssText-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-definition-expected.txt:
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::parseCustomPropertyValue):

Also fix trimming of leading and trailing whitespace in CSSStyleDeclaration.setProperty() API.

* Source/WebCore/css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::CSSParserToken):

Remember the number of whitespaces represented by a whitespace token.

(WebCore::CSSParserToken::operator== const):

Also take the space count into account in equality comparison.
This is used for custom properties only.

(WebCore::CSSParserToken::serialize const):

Preserve the spaces in custom property serialization mode.

* Source/WebCore/css/parser/CSSParserToken.h:
* Source/WebCore/css/parser/CSSTokenizer.cpp:
(WebCore::CSSTokenizer::whiteSpace):

Count the spaces.

Canonical link: https://commits.webkit.org/275236@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list