Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dd490d605c8f089877ac86a95aa348387e514892
      
https://github.com/WebKit/WebKit/commit/dd490d605c8f089877ac86a95aa348387e514892
  Author: Tim Nguyen <[email protected]>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-longhands-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-longhands.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space.html
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/ShorthandSerializer.cpp
    M Source/WebCore/css/parser/CSSPropertyParserCustom.h
    M Source/WebCore/editing/EditingStyle.cpp
    M Source/WebCore/style/StyleExtractorCustom.h

  Log Message:
  -----------
  [white-space-trim] Add to white-space shorthand syntax
https://bugs.webkit.org/show_bug.cgi?id=319831
rdar://182739052

Reviewed by Antti Koivisto.

(This is based on Tim Nguyen initial PR)

The syntax for the white-space shorthand is:

normal | pre | pre-wrap | pre-line | <'white-space-collapse'> || 
<'text-wrap-mode'> || <'white-space-trim'>

See: https://drafts.csswg.org/css-text-4/#white-space-property

Add 'white-space-trim' as the third longhand of the 'white-space' shorthand. The
legacy single-keyword forms (normal / pre / pre-wrap / pre-line) map to
'white-space-trim: none' per the normative table in the spec, so they never 
combine
with a discard-* keyword. Serialization -- both of a declaration block
(ShorthandSerializer) and of the computed value (Style::Extractor) -- only 
collapses
to those legacy keywords when 'white-space-trim' is 'none'; otherwise it 
appends the
trim value and omits the other two longhands when they hold their initial value.

'white-space-trim' is gated on the CSSWhiteSpaceTrimEnabled setting while
'white-space' is not, so the shorthand parser gates only the consumption of the
discard-* keywords and always sets the 'white-space-trim' longhand. That keeps 
the
shorthand round-tripping when the setting is off, and matches how 'font' and
'font-variant' handle the settings-gated 'font-variant-emoji' longhand.

Editing copies 'white-space-trim' alongside the other two longhands. All three 
have
to travel together: a partial longhand set makes the 'white-space' shorthand
unserializable, so editing would start emitting 'white-space-collapse' /
'text-wrap-mode' where it used to emit 'white-space'. It is therefore listed 
with the
inheritable editing properties even though it is not an inherited property -- 
if only
the context style carries it, the white-space longhands never compare equal to 
the
context and editing wraps content in redundant spans. The context comparison in
removeStyleInContextNotOverridenByMatchedRules also compares values rather than
CSSValue identity, since 'white-space-trim' serializes to a list for any value 
other
than 'none'.

Tests: 
imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-longhands.html
       
imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand.html

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-longhands-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand-longhands.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-shorthand.html:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space.html:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serializeWhiteSpace const):
* Source/WebCore/css/parser/CSSPropertyParserCustom.h:
(WebCore::CSS::PropertyParserCustom::consumeWhiteSpaceShorthand):
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::EditingStyle::init):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
(WebCore::EditingStyle::removeStyleInContextNotOverridenByMatchedRules):
(WebCore::StyleChange::StyleChange):
* Source/WebCore/style/StyleExtractorCustom.h:
(WebCore::Style::PropertyExtractorAdaptor<CSSPropertyWhiteSpace>::computedValue 
const):

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



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

Reply via email to