LibWeb: Parse and propagate white-space-collapse CSS property

This commit is contained in:
Callum Law 2025-05-16 18:32:31 +12:00 committed by Jelle Raaijmakers
commit ea30356fba
Notes: github-actions[bot] 2025-05-29 10:06:12 +00:00
17 changed files with 321 additions and 180 deletions

View file

@ -830,6 +830,12 @@ WhiteSpace ComputedProperties::white_space() const
return keyword_to_white_space(value.to_keyword()).release_value();
}
WhiteSpaceCollapse ComputedProperties::white_space_collapse() const
{
auto const& value = property(PropertyID::WhiteSpaceCollapse);
return keyword_to_white_space_collapse(value.to_keyword()).release_value();
}
Optional<LengthOrCalculated> ComputedProperties::letter_spacing() const
{
auto const& value = property(PropertyID::LetterSpacing);

View file

@ -101,6 +101,7 @@ public:
Vector<CursorData> cursor() const;
Variant<LengthOrCalculated, NumberOrCalculated> tab_size() const;
WhiteSpace white_space() const;
WhiteSpaceCollapse white_space_collapse() const;
WordBreak word_break() const;
Optional<LengthOrCalculated> word_spacing() const;
Optional<LengthOrCalculated> letter_spacing() const;

View file

@ -101,6 +101,7 @@ public:
static CSS::ContentVisibility content_visibility() { return CSS::ContentVisibility::Visible; }
static CursorData cursor() { return { CSS::Cursor::Auto }; }
static CSS::WhiteSpace white_space() { return CSS::WhiteSpace::Normal; }
static CSS::WhiteSpaceCollapse white_space_collapse() { return CSS::WhiteSpaceCollapse::Collapse; }
static CSS::WordBreak word_break() { return CSS::WordBreak::Normal; }
static CSS::LengthOrCalculated word_spacing() { return CSS::Length::make_px(0); }
static LengthOrCalculated letter_spacing() { return CSS::Length::make_px(0); }
@ -423,6 +424,7 @@ public:
Vector<ShadowData> const& text_shadow() const { return m_inherited.text_shadow; }
CSS::Positioning position() const { return m_noninherited.position; }
CSS::WhiteSpace white_space() const { return m_inherited.white_space; }
CSS::WhiteSpaceCollapse white_space_collapse() const { return m_inherited.white_space_collapse; }
CSS::LengthOrCalculated word_spacing() const { return m_inherited.word_spacing; }
LengthOrCalculated letter_spacing() const { return m_inherited.letter_spacing; }
CSS::FlexDirection flex_direction() const { return m_noninherited.flex_direction; }
@ -616,6 +618,7 @@ protected:
CSS::TextTransform text_transform { InitialValues::text_transform() };
CSS::LengthPercentage text_indent { InitialValues::text_indent() };
CSS::WhiteSpace white_space { InitialValues::white_space() };
CSS::WhiteSpaceCollapse white_space_collapse { InitialValues::white_space_collapse() };
CSS::WordBreak word_break { InitialValues::word_break() };
CSS::LengthOrCalculated word_spacing { InitialValues::word_spacing() };
LengthOrCalculated letter_spacing { InitialValues::letter_spacing() };
@ -819,6 +822,7 @@ public:
void set_webkit_text_fill_color(Color value) { m_inherited.webkit_text_fill_color = value; }
void set_position(CSS::Positioning position) { m_noninherited.position = position; }
void set_white_space(CSS::WhiteSpace value) { m_inherited.white_space = value; }
void set_white_space_collapse(CSS::WhiteSpaceCollapse value) { m_inherited.white_space_collapse = value; }
void set_word_spacing(CSS::LengthOrCalculated value) { m_inherited.word_spacing = move(value); }
void set_word_break(CSS::WordBreak value) { m_inherited.word_break = value; }
void set_letter_spacing(CSS::LengthOrCalculated value) { m_inherited.letter_spacing = value; }

View file

@ -676,6 +676,14 @@
"pre-line",
"pre-wrap"
],
"white-space-collapse": [
"collapse",
"discard",
"preserve",
"preserve-breaks",
"preserve-spaces",
"break-spaces"
],
"word-break": [
"normal",
"keep-all",

View file

@ -102,6 +102,7 @@
"both-edges",
"bottom",
"break-all",
"break-spaces",
"break-word",
"browser",
"butt",
@ -157,6 +158,7 @@
"diagonal-fractions",
"difference",
"disc",
"discard",
"disclosure-closed",
"disclosure-open",
"discretionary-ligatures",
@ -376,6 +378,9 @@
"pre",
"pre-line",
"pre-wrap",
"preserve",
"preserve-breaks",
"preserve-spaces",
"progress",
"progress-bar",
"progressive",

View file

@ -3126,6 +3126,14 @@
"white-space"
]
},
"white-space-collapse": {
"animation-type": "discrete",
"inherited": true,
"initial": "collapse",
"valid-types": [
"white-space-collapse"
]
},
"width": {
"animation-type": "by-computed-value",
"inherited": false,