mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb/CSS: Serialize contain
values in canonical order
This commit is contained in:
parent
8534370dbc
commit
96d8bed35b
Notes:
github-actions[bot]
2025-06-17 07:18:54 +00:00
Author: https://github.com/tcl3
Commit: 96d8bed35b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5110
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 32 additions and 24 deletions
|
@ -4839,47 +4839,56 @@ RefPtr<CSSStyleValue const> Parser::parse_contain_value(TokenStream<ComponentVal
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
bool has_size = false;
|
RefPtr<CSSStyleValue const> size_value;
|
||||||
bool has_layout = false;
|
RefPtr<CSSStyleValue const> layout_value;
|
||||||
bool has_style = false;
|
RefPtr<CSSStyleValue const> style_value;
|
||||||
bool has_paint = false;
|
RefPtr<CSSStyleValue const> paint_value;
|
||||||
|
|
||||||
StyleValueVector containments;
|
|
||||||
while (tokens.has_next_token()) {
|
while (tokens.has_next_token()) {
|
||||||
tokens.discard_whitespace();
|
tokens.discard_whitespace();
|
||||||
auto keyword = parse_keyword_value(tokens);
|
auto keyword_value = parse_keyword_value(tokens);
|
||||||
if (!keyword)
|
if (!keyword_value)
|
||||||
return {};
|
return {};
|
||||||
switch (keyword->to_keyword()) {
|
switch (keyword_value->to_keyword()) {
|
||||||
case Keyword::Size:
|
case Keyword::Size:
|
||||||
case Keyword::InlineSize:
|
case Keyword::InlineSize:
|
||||||
if (has_size)
|
if (size_value)
|
||||||
return {};
|
return {};
|
||||||
has_size = true;
|
size_value = move(keyword_value);
|
||||||
break;
|
break;
|
||||||
case Keyword::Layout:
|
case Keyword::Layout:
|
||||||
if (has_layout)
|
if (layout_value)
|
||||||
return {};
|
return {};
|
||||||
has_layout = true;
|
layout_value = move(keyword_value);
|
||||||
break;
|
break;
|
||||||
case Keyword::Style:
|
case Keyword::Style:
|
||||||
if (has_style)
|
if (style_value)
|
||||||
return {};
|
return {};
|
||||||
has_style = true;
|
style_value = move(keyword_value);
|
||||||
break;
|
break;
|
||||||
case Keyword::Paint:
|
case Keyword::Paint:
|
||||||
if (has_paint)
|
if (paint_value)
|
||||||
return {};
|
return {};
|
||||||
has_paint = true;
|
paint_value = move(keyword_value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
containments.append(*keyword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyleValueVector containment_values;
|
||||||
|
if (size_value)
|
||||||
|
containment_values.append(size_value.release_nonnull());
|
||||||
|
if (layout_value)
|
||||||
|
containment_values.append(layout_value.release_nonnull());
|
||||||
|
if (style_value)
|
||||||
|
containment_values.append(style_value.release_nonnull());
|
||||||
|
if (paint_value)
|
||||||
|
containment_values.append(paint_value.release_nonnull());
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
return StyleValueList::create(move(containments), StyleValueList::Separator::Space);
|
return StyleValueList::create(move(containment_values), StyleValueList::Separator::Space);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-text-4/#white-space-trim
|
// https://www.w3.org/TR/css-text-4/#white-space-trim
|
||||||
|
|
|
@ -2,8 +2,7 @@ Harness status: OK
|
||||||
|
|
||||||
Found 13 tests
|
Found 13 tests
|
||||||
|
|
||||||
9 Pass
|
13 Pass
|
||||||
4 Fail
|
|
||||||
Pass e.style['contain'] = "none" should set the property value
|
Pass e.style['contain'] = "none" should set the property value
|
||||||
Pass e.style['contain'] = "strict" should set the property value
|
Pass e.style['contain'] = "strict" should set the property value
|
||||||
Pass e.style['contain'] = "content" should set the property value
|
Pass e.style['contain'] = "content" should set the property value
|
||||||
|
@ -11,9 +10,9 @@ Pass e.style['contain'] = "size" should set the property value
|
||||||
Pass e.style['contain'] = "layout" should set the property value
|
Pass e.style['contain'] = "layout" should set the property value
|
||||||
Pass e.style['contain'] = "style" should set the property value
|
Pass e.style['contain'] = "style" should set the property value
|
||||||
Pass e.style['contain'] = "paint" should set the property value
|
Pass e.style['contain'] = "paint" should set the property value
|
||||||
Fail e.style['contain'] = "layout size" should set the property value
|
Pass e.style['contain'] = "layout size" should set the property value
|
||||||
Fail e.style['contain'] = "paint style" should set the property value
|
Pass e.style['contain'] = "paint style" should set the property value
|
||||||
Pass e.style['contain'] = "layout style paint" should set the property value
|
Pass e.style['contain'] = "layout style paint" should set the property value
|
||||||
Fail e.style['contain'] = "layout paint style size" should set the property value
|
Pass e.style['contain'] = "layout paint style size" should set the property value
|
||||||
Pass e.style['contain'] = "inline-size" should set the property value
|
Pass e.style['contain'] = "inline-size" should set the property value
|
||||||
Fail e.style['contain'] = "layout inline-size" should set the property value
|
Pass e.style['contain'] = "layout inline-size" should set the property value
|
Loading…
Add table
Add a link
Reference in a new issue