Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 348f90db48a564e65253e5801cc8cbf8d86437d7
https://github.com/WebKit/WebKit/commit/348f90db48a564e65253e5801cc8cbf8d86437d7
Author: Alan Baradlay <[email protected]>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-computed-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-computed.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-invalid-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-invalid.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-valid-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-valid.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-atomic-inline-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-block-in-inline-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-break-spaces-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-content-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-after-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-before-after-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-before-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-dynamic-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-generated-content-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-inline-block-dynamic-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-inline-block-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-interaction-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-nested-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-rtl-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-white-space-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-wrap-ref.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-atomic-inline-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-atomic-inline.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-block-in-inline-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-block-in-inline.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-break-spaces-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-break-spaces.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-content-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-content.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-after-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-after.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-after-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-after.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-dynamic-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-dynamic.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-generated-content-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-generated-content.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-dynamic-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-dynamic.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-interaction-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-interaction.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-intrinsic-width-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-intrinsic-width.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-nested-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-nested.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-rtl-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-rtl.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-wrap-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-wrap.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/white-space-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/shadow-dom-expected.txt
M
LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
M Source/WebCore/Headers.cmake
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/css/CSSProperties.json
M Source/WebCore/css/CSSValueKeywords.in
M Source/WebCore/layout/formattingContexts/inline/InlineContentCache.h
M
Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp
M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h
M Source/WebCore/layout/formattingContexts/inline/IntrinsicWidthHandler.cpp
M
Source/WebCore/layout/formattingContexts/inline/TextOnlySimpleLineBuilder.cpp
M
Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp
M Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp
M Source/WebCore/style/StyleDifference.cpp
M Source/WebCore/style/computed/StyleComputedStyleBase.h
M Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp
M Source/WebCore/style/computed/data/StyleNonInheritedRareData.h
M Source/WebCore/style/values/primitives/StyleKeyword+Mappings.h
A Source/WebCore/style/values/text/StyleWhiteSpaceTrim.cpp
A Source/WebCore/style/values/text/StyleWhiteSpaceTrim.h
Log Message:
-----------
[CSS] Support the white-space-trim property (discard-before / discard-after)
https://bugs.webkit.org/show_bug.cgi?id=319169
rdar://182007943
Reviewed by Antti Koivisto.
Implement the 'discard-before' and 'discard-after' values of the CSS Text 4
'white-space-trim' property
(https://drafts.csswg.org/css-text-4/#white-space-trim)
in the modern inline layout path, behind the CSSWhiteSpaceTrimEnabled setting
(off by default).
'discard-before' / 'discard-after' remove the collapsible white space
immediately before the start / after the end of an element. We do this at
inline-item building time:
InlineItemsBuilder::adjustInlineItemsForWhiteSpaceTrim
discards the corresponding InlineTextItems in a single forward pass before line
building, bidi resolution and intrinsic sizing run, so the removed white space
is kept out of every downstream computation (rendering, soft-wrap opportunities
and min/max-content) at once. The property applies to inline boxes and block
containers, so an inline box or a non-replaced inline-block carries it. Inline
box boundaries -- and floats / out-of-flow boxes -- are transparent to this
adjacency, matching white space collapsing, while other atomic inlines, replaced
content, iframes and block-in-inline boxes are real content that ends it.
Because the property changes which inline items are generated, a value change
invalidates the cached inline item list (InlineInvalidation) and requires layout
(StyleDifference). Since the discard depends on cross-box adjacency that a
partial rebuild starting mid-content cannot resolve, the inline formatting
context re-collects all inline items whenever the content carries
white-space-trim rather than doing an incremental rebuild.
'discard-inner' parses and computes to a value but has no layout effect yet.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-computed-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-computed.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-invalid-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-invalid.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-valid-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/parsing/white-space-trim-valid.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-atomic-inline-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-block-in-inline-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-break-spaces-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-content-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-after-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-before-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-discard-before-after-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-dynamic-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-generated-content-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-inline-block-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-inline-block-dynamic-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-interaction-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-nested-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-rtl-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-white-space-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/reference/white-space-trim-wrap-ref.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-atomic-inline-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-atomic-inline.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-block-in-inline-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-block-in-inline.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-break-spaces-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-break-spaces.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-content-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-content.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-after-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-after.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-after-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-discard-before-after.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-dynamic-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-dynamic.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-generated-content-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-generated-content.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-dynamic-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-inline-block-dynamic.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-interaction-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-interaction.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-intrinsic-width-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-intrinsic-width.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-nested-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-nested.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-rtl-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-rtl.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-white-space.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-wrap-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/white-space-trim-wrap.html:
Added.
(each with its reference/*-ref.html and byte-copy *-expected.html;
intrinsic-width is a
testharness test with *-expected.txt. inline-block, inline-block-dynamic and
block-in-inline
cover the inline-block carrier, its dynamic invalidation and the
block-in-inline construct.)
*
LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/white-space-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/shadow-dom-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Add the
CSSWhiteSpaceTrimEnabled
setting (testable, off by default).
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Build the new files.
* Source/WebCore/css/CSSProperties.json: Add the white-space-trim longhand.
* Source/WebCore/css/CSSValueKeywords.in: Add discard-before / discard-after /
discard-inner.
* Source/WebCore/layout/formattingContexts/inline/InlineContentCache.h: Carry a
hasWhiteSpaceTrim
content attribute.
(WebCore::Layout::InlineContentCache::InlineItems::hasWhiteSpaceTrim const):
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::rebuildInlineItemListIfNeeded):
Force a full inline-item
re-collection when the content has white-space-trim.
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::isNonReplacedInlineBlock): The inline-level block container
that white-space-trim
can carry; excludes replaced content and iframes.
(WebCore::Layout::InlineItemsBuilder::build):
(WebCore::Layout::InlineItemsBuilder::adjustInlineItemsForWhiteSpaceTrim):
Discard the collapsible
white space items before/after the boxes that carry white-space-trim (inline
boxes and non-replaced
inline-blocks) in a single forward pass; treat inline box boundaries, floats
and out-of-flow boxes as
transparent, and other atomic and block-in-inline boxes as real content. Record
hasWhiteSpaceTrim on
the content cache attributes.
(WebCore::Layout::InlineItemsBuilder::handleInlineBoxStart): Track whether any
inline box carries
white-space-trim.
(WebCore::Layout::InlineItemsBuilder::handleInlineLevelBox): Track whether any
inline-block carries
white-space-trim.
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h:
* Source/WebCore/layout/formattingContexts/inline/IntrinsicWidthHandler.cpp:
(WebCore::Layout::isBoxEligibleForNonLineBuilderMinimumWidth):
*
Source/WebCore/layout/formattingContexts/inline/TextOnlySimpleLineBuilder.cpp:
Disqualify the
simplified min-content / text-only fast paths when white-space-trim is present.
(WebCore::Layout::TextOnlySimpleLineBuilder::isEligibleForSimplifiedInlineLayoutByStyle):
*
Source/WebCore/layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp:
(WebCore::Layout::InlineInvalidation::rootStyleWillChange):
(WebCore::Layout::InlineInvalidation::styleWillChange): Mark the inline item
list dirty when
white-space-trim changes on the root, an inline box or an inline-block.
* Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::mayBreakInBetween): Use the next item's own leading
content when it does
not start at the beginning of its text box (its leading white space may have
been discarded), while
avoiding a substring allocation on the common path.
* Source/WebCore/style/StyleDifference.cpp:
* Source/WebCore/style/computed/StyleComputedStyleBase.h:
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.cpp: Store
white-space-trim in
non-inherited rare data.
(WebCore::Style::whiteSpaceTrim):
(WebCore::Style::NonInheritedRareData::NonInheritedRareData):
(WebCore::Style::NonInheritedRareData::operator== const):
(WebCore::Style::NonInheritedRareData::dumpDifferences const):
(WebCore::Style::scrollSnapStop): Deleted.
* Source/WebCore/style/computed/data/StyleNonInheritedRareData.h:
* Source/WebCore/style/values/primitives/StyleKeyword+Mappings.h: Map the new
keywords.
* Source/WebCore/style/values/text/StyleWhiteSpaceTrim.cpp: Added.
(WebCore::Style::CSSValueConversion<WhiteSpaceTrim>::operator):
* Source/WebCore/style/values/text/StyleWhiteSpaceTrim.h: Added.
(WebCore::Style::WhiteSpaceTrim::WhiteSpaceTrim):
(WebCore::Style::WhiteSpaceTrim::fromRaw):
(WebCore::Style::WhiteSpaceTrim::toRaw const):
(WebCore::Style::WhiteSpaceTrim::contains const):
(WebCore::Style::WhiteSpaceTrim::containsAny const):
(WebCore::Style::WhiteSpaceTrim::containsAll const):
(WebCore::Style::WhiteSpaceTrim::containsOnly const):
(WebCore::Style::WhiteSpaceTrim::isNone const):
(WebCore::Style::WhiteSpaceTrim::switchOn const):
Canonical link: https://commits.webkit.org/317172@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications