mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb/CSS: Stop inserting whitespace when serializing component values
Now that we don't remove whitespace when parsing, we don't need to artificially insert it back in again when serializing. We do now need to trim leading and trailing whitespace from UnresolvedStyleValues, as this previously was done as part of the whitespace insertion. This makes our serialization of UnresolvedStyleValues more correct and gets us a few WPT passes for each property in the Typed OM tests.
This commit is contained in:
parent
427d7fabd7
commit
61a0898f5f
Notes:
github-actions[bot]
2025-11-03 11:25:01 +00:00
Author: https://github.com/AtkinsSJ
Commit: 61a0898f5f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6646
Reviewed-by: https://github.com/tcl3
13 changed files with 45 additions and 53 deletions
|
|
@ -199,11 +199,9 @@ String serialize_a_css_declaration(StringView property, StringView value, Import
|
|||
}
|
||||
|
||||
// https://drafts.csswg.org/css-syntax/#serialization
|
||||
String serialize_a_series_of_component_values(ReadonlySpan<Parser::ComponentValue> component_values, InsertWhitespace insert_whitespace)
|
||||
String serialize_a_series_of_component_values(ReadonlySpan<Parser::ComponentValue> component_values)
|
||||
{
|
||||
// FIXME: There are special rules here where we should insert a comment between certain tokens. Do that!
|
||||
if (insert_whitespace == InsertWhitespace::Yes)
|
||||
return MUST(Infra::strip_and_collapse_whitespace(MUST(String::join(' ', component_values))));
|
||||
return MUST(String::join(""sv, component_values));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ void serialize_a_comma_separated_list(StringBuilder& builder, Vector<T> const& i
|
|||
|
||||
String serialize_a_css_declaration(StringView property, StringView value, Important = Important::No);
|
||||
|
||||
enum class InsertWhitespace : u8 {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
// FIXME: Remove InsertWhitespace param once style value parsing stops discarding whitespace tokens.
|
||||
String serialize_a_series_of_component_values(ReadonlySpan<Parser::ComponentValue>, InsertWhitespace = InsertWhitespace::No);
|
||||
String serialize_a_series_of_component_values(ReadonlySpan<Parser::ComponentValue>);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ String UnresolvedStyleValue::to_string(SerializationMode) const
|
|||
if (m_original_source_text.has_value())
|
||||
return *m_original_source_text;
|
||||
|
||||
return serialize_a_series_of_component_values(m_values, InsertWhitespace::Yes);
|
||||
return MUST(serialize_a_series_of_component_values(m_values).trim_ascii_whitespace());
|
||||
}
|
||||
|
||||
bool UnresolvedStyleValue::equals(StyleValue const& other) const
|
||||
|
|
@ -145,8 +145,7 @@ private:
|
|||
|
||||
void serialize_unserialized_values()
|
||||
{
|
||||
// FIXME: Stop inserting whitespace once we stop removing it during parsing.
|
||||
m_reified_values.append(serialize_a_series_of_component_values(m_unserialized_values, InsertWhitespace::Yes));
|
||||
m_reified_values.append(serialize_a_series_of_component_values(m_unserialized_values));
|
||||
m_unserialized_values.clear_with_capacity();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ Harness status: OK
|
|||
|
||||
Found 16 tests
|
||||
|
||||
7 Pass
|
||||
9 Fail
|
||||
10 Pass
|
||||
6 Fail
|
||||
Fail var() references work with registered properties
|
||||
Fail References to registered var()-properties work in registered lists
|
||||
Fail References to mixed registered and unregistered var()-properties work in registered lists
|
||||
Fail Registered lists may be concatenated
|
||||
Pass References to registered var()-properties work in registered lists
|
||||
Pass References to mixed registered and unregistered var()-properties work in registered lists
|
||||
Pass Registered lists may be concatenated
|
||||
Fail Font-relative units are absolutized when substituting
|
||||
Fail Calc expressions are resolved when substituting
|
||||
Fail Lists with relative units are absolutized when substituting
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 16 tests
|
||||
|
||||
16 Fail
|
||||
3 Pass
|
||||
13 Fail
|
||||
Fail Normalizing "var(--A)" on a CSS property returns correct CSSUnparsedValue
|
||||
Fail Normalizing "var(--A)" on a shorthand returns correct CSSUnparsedValue
|
||||
Fail Normalizing "var(--A)" on a list-valued property returns correct CSSUnparsedValue
|
||||
|
|
@ -15,7 +16,7 @@ Fail Normalizing "var(--A, var(--B))" on a CSS property returns correct CSSUnpar
|
|||
Fail Normalizing "var(--A, var(--B))" on a shorthand returns correct CSSUnparsedValue
|
||||
Fail Normalizing "var(--A, var(--B))" on a list-valued property returns correct CSSUnparsedValue
|
||||
Fail Normalizing "var(--A, var(--B))" on a custom property returns correct CSSUnparsedValue
|
||||
Fail Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a CSS property returns correct CSSUnparsedValue
|
||||
Pass Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a CSS property returns correct CSSUnparsedValue
|
||||
Fail Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a shorthand returns correct CSSUnparsedValue
|
||||
Fail Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a list-valued property returns correct CSSUnparsedValue
|
||||
Fail Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a custom property returns correct CSSUnparsedValue
|
||||
Pass Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a list-valued property returns correct CSSUnparsedValue
|
||||
Pass Normalizing "calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))" on a custom property returns correct CSSUnparsedValue
|
||||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 37 tests
|
||||
|
||||
35 Pass
|
||||
2 Fail
|
||||
36 Pass
|
||||
1 Fail
|
||||
Pass Can set 'color' to CSS-wide keywords: initial
|
||||
Pass Can set 'color' to CSS-wide keywords: inherit
|
||||
Pass Can set 'color' to CSS-wide keywords: unset
|
||||
Pass Can set 'color' to CSS-wide keywords: revert
|
||||
Fail Can set 'color' to var() references: var(--A)
|
||||
Pass Can set 'color' to var() references: var(--A)
|
||||
Fail Can set 'color' to the 'currentcolor' keyword: currentcolor
|
||||
Pass Setting 'color' to a length: 0px throws TypeError
|
||||
Pass Setting 'color' to a length: -3.14em throws TypeError
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 69 tests
|
||||
|
||||
64 Pass
|
||||
5 Fail
|
||||
65 Pass
|
||||
4 Fail
|
||||
Pass Can set 'cursor' to CSS-wide keywords: initial
|
||||
Pass Can set 'cursor' to CSS-wide keywords: inherit
|
||||
Pass Can set 'cursor' to CSS-wide keywords: unset
|
||||
Pass Can set 'cursor' to CSS-wide keywords: revert
|
||||
Fail Can set 'cursor' to var() references: var(--A)
|
||||
Pass Can set 'cursor' to var() references: var(--A)
|
||||
Pass Can set 'cursor' to the 'auto' keyword: auto
|
||||
Pass Can set 'cursor' to the 'default' keyword: default
|
||||
Pass Can set 'cursor' to the 'none' keyword: none
|
||||
|
|
|
|||
|
|
@ -2,13 +2,12 @@ Harness status: OK
|
|||
|
||||
Found 56 tests
|
||||
|
||||
55 Pass
|
||||
1 Fail
|
||||
56 Pass
|
||||
Pass Can set 'display' to CSS-wide keywords: initial
|
||||
Pass Can set 'display' to CSS-wide keywords: inherit
|
||||
Pass Can set 'display' to CSS-wide keywords: unset
|
||||
Pass Can set 'display' to CSS-wide keywords: revert
|
||||
Fail Can set 'display' to var() references: var(--A)
|
||||
Pass Can set 'display' to var() references: var(--A)
|
||||
Pass Can set 'display' to the 'none' keyword: none
|
||||
Pass Can set 'display' to the 'block' keyword: block
|
||||
Pass Can set 'display' to the 'inline' keyword: inline
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 32 tests
|
||||
|
||||
29 Pass
|
||||
3 Fail
|
||||
30 Pass
|
||||
2 Fail
|
||||
Pass Can set 'line-height' to CSS-wide keywords: initial
|
||||
Pass Can set 'line-height' to CSS-wide keywords: inherit
|
||||
Pass Can set 'line-height' to CSS-wide keywords: unset
|
||||
Pass Can set 'line-height' to CSS-wide keywords: revert
|
||||
Fail Can set 'line-height' to var() references: var(--A)
|
||||
Pass Can set 'line-height' to var() references: var(--A)
|
||||
Pass Can set 'line-height' to the 'normal' keyword: normal
|
||||
Pass Can set 'line-height' to a length: 0px
|
||||
Pass Can set 'line-height' to a length: -3.14em
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 161 tests
|
||||
|
||||
152 Pass
|
||||
9 Fail
|
||||
156 Pass
|
||||
5 Fail
|
||||
Pass Can set 'margin-top' to CSS-wide keywords: initial
|
||||
Pass Can set 'margin-top' to CSS-wide keywords: inherit
|
||||
Pass Can set 'margin-top' to CSS-wide keywords: unset
|
||||
Pass Can set 'margin-top' to CSS-wide keywords: revert
|
||||
Fail Can set 'margin-top' to var() references: var(--A)
|
||||
Pass Can set 'margin-top' to var() references: var(--A)
|
||||
Pass Can set 'margin-top' to the 'auto' keyword: auto
|
||||
Pass Can set 'margin-top' to a percent: 0%
|
||||
Pass Can set 'margin-top' to a percent: -3.14%
|
||||
|
|
@ -40,7 +40,7 @@ Pass Can set 'margin-left' to CSS-wide keywords: initial
|
|||
Pass Can set 'margin-left' to CSS-wide keywords: inherit
|
||||
Pass Can set 'margin-left' to CSS-wide keywords: unset
|
||||
Pass Can set 'margin-left' to CSS-wide keywords: revert
|
||||
Fail Can set 'margin-left' to var() references: var(--A)
|
||||
Pass Can set 'margin-left' to var() references: var(--A)
|
||||
Pass Can set 'margin-left' to the 'auto' keyword: auto
|
||||
Pass Can set 'margin-left' to a percent: 0%
|
||||
Pass Can set 'margin-left' to a percent: -3.14%
|
||||
|
|
@ -72,7 +72,7 @@ Pass Can set 'margin-right' to CSS-wide keywords: initial
|
|||
Pass Can set 'margin-right' to CSS-wide keywords: inherit
|
||||
Pass Can set 'margin-right' to CSS-wide keywords: unset
|
||||
Pass Can set 'margin-right' to CSS-wide keywords: revert
|
||||
Fail Can set 'margin-right' to var() references: var(--A)
|
||||
Pass Can set 'margin-right' to var() references: var(--A)
|
||||
Pass Can set 'margin-right' to the 'auto' keyword: auto
|
||||
Pass Can set 'margin-right' to a percent: 0%
|
||||
Pass Can set 'margin-right' to a percent: -3.14%
|
||||
|
|
@ -104,7 +104,7 @@ Pass Can set 'margin-bottom' to CSS-wide keywords: initial
|
|||
Pass Can set 'margin-bottom' to CSS-wide keywords: inherit
|
||||
Pass Can set 'margin-bottom' to CSS-wide keywords: unset
|
||||
Pass Can set 'margin-bottom' to CSS-wide keywords: revert
|
||||
Fail Can set 'margin-bottom' to var() references: var(--A)
|
||||
Pass Can set 'margin-bottom' to var() references: var(--A)
|
||||
Pass Can set 'margin-bottom' to the 'auto' keyword: auto
|
||||
Pass Can set 'margin-bottom' to a percent: 0%
|
||||
Pass Can set 'margin-bottom' to a percent: -3.14%
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 124 tests
|
||||
|
||||
116 Pass
|
||||
8 Fail
|
||||
120 Pass
|
||||
4 Fail
|
||||
Pass Can set 'padding-top' to CSS-wide keywords: initial
|
||||
Pass Can set 'padding-top' to CSS-wide keywords: inherit
|
||||
Pass Can set 'padding-top' to CSS-wide keywords: unset
|
||||
Pass Can set 'padding-top' to CSS-wide keywords: revert
|
||||
Fail Can set 'padding-top' to var() references: var(--A)
|
||||
Pass Can set 'padding-top' to var() references: var(--A)
|
||||
Pass Can set 'padding-top' to a percent: 0%
|
||||
Fail Can set 'padding-top' to a percent: -3.14%
|
||||
Pass Can set 'padding-top' to a percent: 3.14%
|
||||
|
|
@ -39,7 +39,7 @@ Pass Can set 'padding-left' to CSS-wide keywords: initial
|
|||
Pass Can set 'padding-left' to CSS-wide keywords: inherit
|
||||
Pass Can set 'padding-left' to CSS-wide keywords: unset
|
||||
Pass Can set 'padding-left' to CSS-wide keywords: revert
|
||||
Fail Can set 'padding-left' to var() references: var(--A)
|
||||
Pass Can set 'padding-left' to var() references: var(--A)
|
||||
Pass Can set 'padding-left' to a percent: 0%
|
||||
Fail Can set 'padding-left' to a percent: -3.14%
|
||||
Pass Can set 'padding-left' to a percent: 3.14%
|
||||
|
|
@ -70,7 +70,7 @@ Pass Can set 'padding-right' to CSS-wide keywords: initial
|
|||
Pass Can set 'padding-right' to CSS-wide keywords: inherit
|
||||
Pass Can set 'padding-right' to CSS-wide keywords: unset
|
||||
Pass Can set 'padding-right' to CSS-wide keywords: revert
|
||||
Fail Can set 'padding-right' to var() references: var(--A)
|
||||
Pass Can set 'padding-right' to var() references: var(--A)
|
||||
Pass Can set 'padding-right' to a percent: 0%
|
||||
Fail Can set 'padding-right' to a percent: -3.14%
|
||||
Pass Can set 'padding-right' to a percent: 3.14%
|
||||
|
|
@ -101,7 +101,7 @@ Pass Can set 'padding-bottom' to CSS-wide keywords: initial
|
|||
Pass Can set 'padding-bottom' to CSS-wide keywords: inherit
|
||||
Pass Can set 'padding-bottom' to CSS-wide keywords: unset
|
||||
Pass Can set 'padding-bottom' to CSS-wide keywords: revert
|
||||
Fail Can set 'padding-bottom' to var() references: var(--A)
|
||||
Pass Can set 'padding-bottom' to var() references: var(--A)
|
||||
Pass Can set 'padding-bottom' to a percent: 0%
|
||||
Fail Can set 'padding-bottom' to a percent: -3.14%
|
||||
Pass Can set 'padding-bottom' to a percent: 3.14%
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 33 tests
|
||||
|
||||
31 Pass
|
||||
2 Fail
|
||||
32 Pass
|
||||
1 Fail
|
||||
Pass Can set 'transform' to CSS-wide keywords: initial
|
||||
Pass Can set 'transform' to CSS-wide keywords: inherit
|
||||
Pass Can set 'transform' to CSS-wide keywords: unset
|
||||
Pass Can set 'transform' to CSS-wide keywords: revert
|
||||
Fail Can set 'transform' to var() references: var(--A)
|
||||
Pass Can set 'transform' to var() references: var(--A)
|
||||
Pass Can set 'transform' to the 'none' keyword: none
|
||||
Pass Can set 'transform' to a transform: translate(50%, 50%)
|
||||
Pass Can set 'transform' to a transform: perspective(10em)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
|||
|
||||
Found 95 tests
|
||||
|
||||
89 Pass
|
||||
6 Fail
|
||||
92 Pass
|
||||
3 Fail
|
||||
Pass Can set 'width' to CSS-wide keywords: initial
|
||||
Pass Can set 'width' to CSS-wide keywords: inherit
|
||||
Pass Can set 'width' to CSS-wide keywords: unset
|
||||
Pass Can set 'width' to CSS-wide keywords: revert
|
||||
Fail Can set 'width' to var() references: var(--A)
|
||||
Pass Can set 'width' to var() references: var(--A)
|
||||
Pass Can set 'width' to the 'auto' keyword: auto
|
||||
Pass Can set 'width' to a percent: 0%
|
||||
Fail Can set 'width' to a percent: -3.14%
|
||||
|
|
@ -40,7 +40,7 @@ Pass Can set 'min-width' to CSS-wide keywords: initial
|
|||
Pass Can set 'min-width' to CSS-wide keywords: inherit
|
||||
Pass Can set 'min-width' to CSS-wide keywords: unset
|
||||
Pass Can set 'min-width' to CSS-wide keywords: revert
|
||||
Fail Can set 'min-width' to var() references: var(--A)
|
||||
Pass Can set 'min-width' to var() references: var(--A)
|
||||
Pass Can set 'min-width' to a percent: 0%
|
||||
Fail Can set 'min-width' to a percent: -3.14%
|
||||
Pass Can set 'min-width' to a percent: 3.14%
|
||||
|
|
@ -71,7 +71,7 @@ Pass Can set 'max-width' to CSS-wide keywords: initial
|
|||
Pass Can set 'max-width' to CSS-wide keywords: inherit
|
||||
Pass Can set 'max-width' to CSS-wide keywords: unset
|
||||
Pass Can set 'max-width' to CSS-wide keywords: revert
|
||||
Fail Can set 'max-width' to var() references: var(--A)
|
||||
Pass Can set 'max-width' to var() references: var(--A)
|
||||
Pass Can set 'max-width' to the 'none' keyword: none
|
||||
Pass Can set 'max-width' to a percent: 0%
|
||||
Fail Can set 'max-width' to a percent: -3.14%
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue