LibWeb: Handle serialization of invalid border in all contexts
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Previously as we handled this in `get_property_internal` there were some
contexts that we missed, for instance `CSSStyleProperties::serialized`.
This commit is contained in:
Callum Law 2025-07-10 22:45:44 +12:00 committed by Sam Atkins
commit 93f957051a
Notes: github-actions[bot] 2025-07-15 13:27:17 +00:00
4 changed files with 21 additions and 29 deletions

View file

@ -238,6 +238,22 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
return MUST(builder.to_string());
}
case PropertyID::Border: {
auto all_longhands_same_value = [](ValueComparingRefPtr<CSSStyleValue const> const& shorthand) -> bool {
VERIFY(shorthand);
VERIFY(shorthand->is_shorthand());
auto longhands = shorthand->as_shorthand().values();
return all_of(longhands, [&](auto const& longhand) { return longhand == longhands[0]; });
};
// `border` only has a reasonable value if all four sides are the same.
if (!all_longhands_same_value(longhand(PropertyID::BorderWidth)) || !all_longhands_same_value(longhand(PropertyID::BorderStyle)) || !all_longhands_same_value(longhand(PropertyID::BorderColor)))
return ""_string;
return default_to_string();
}
case PropertyID::BorderImage: {
auto source = longhand(PropertyID::BorderImageSource);
auto slice = longhand(PropertyID::BorderImageSlice);