mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 20:49:41 +00:00
LibWeb/CSS: Make CSSStyleValue.to_string() return ExceptionOr
DOMMatrix.to_string() throws exceptions if any of its values are non-finite. This ends up affecting CSSStyleValue because its subclass CSSTransformValue (which is about to be added) serializes CSSTransformComponents, and one of those is CSSMatrixComponent, which calls DOMMatrix.to_string(). This is all quite unfortunate, and because at the time the spec for DOMMatrix was written, CSS couldn't represent NaN or infinity. That's no longer true, so I'm hoping the spec can be updated and this can be reverted. https://github.com/w3c/fxtf-drafts/issues/611
This commit is contained in:
parent
a1db5e7789
commit
d3d695e9d2
Notes:
github-actions[bot]
2025-09-24 11:28:48 +00:00
Author: https://github.com/AtkinsSJ
Commit: d3d695e9d2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6227
19 changed files with 48 additions and 44 deletions
|
@ -116,7 +116,7 @@ WebIDL::ExceptionOr<void> CSSUnparsedValue::set_value_of_new_indexed_property(u3
|
|||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#serialize-a-cssunparsedvalue
|
||||
String CSSUnparsedValue::to_string() const
|
||||
WebIDL::ExceptionOr<String> CSSUnparsedValue::to_string() const
|
||||
{
|
||||
// To serialize a CSSUnparsedValue this:
|
||||
// 1. Let s initially be the empty string.
|
||||
|
@ -126,15 +126,17 @@ String CSSUnparsedValue::to_string() const
|
|||
for (auto const& item : m_tokens) {
|
||||
// FIXME: In order to match the expected test behaviour, this should insert comments, with the same rules as
|
||||
// serialize_a_series_of_component_values(). See https://github.com/w3c/css-houdini-drafts/issues/1148
|
||||
item.visit(
|
||||
TRY(item.visit(
|
||||
// 1. If item is a USVString, append it to s.
|
||||
[&](String const& string) {
|
||||
[&](String const& string) -> WebIDL::ExceptionOr<void> {
|
||||
s.append(string);
|
||||
return {};
|
||||
},
|
||||
// 2. Otherwise, item is a CSSVariableReferenceValue. Serialize it, then append the result to s.
|
||||
[&](GC::Ref<CSSVariableReferenceValue> const& variable) {
|
||||
s.append(variable->to_string());
|
||||
});
|
||||
[&](GC::Ref<CSSVariableReferenceValue> const& variable) -> WebIDL::ExceptionOr<void> {
|
||||
s.append(TRY(variable->to_string()));
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
||||
// 3. Return s.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue