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:
Sam Atkins 2025-09-16 15:06:38 +01:00
commit d3d695e9d2
Notes: github-actions[bot] 2025-09-24 11:28:48 +00:00
19 changed files with 48 additions and 44 deletions

View file

@ -89,19 +89,19 @@ WebIDL::ExceptionOr<Utf16String> CSSScale::to_string() const
builder.append("scale3d("sv);
// 2. Serialize thiss x internal slot, and append it to s.
builder.append(m_x->to_string());
builder.append(TRY(m_x->to_string()));
// 3. Append ", " to s.
builder.append(", "sv);
// 4. Serialize thiss y internal slot, and append it to s.
builder.append(m_y->to_string());
builder.append(TRY(m_y->to_string()));
// 5. Append ", " to s.
builder.append(", "sv);
// 6. Serialize thiss z internal slot, and append it to s.
builder.append(m_z->to_string());
builder.append(TRY(m_z->to_string()));
// 7. Append ")" to s, and return s.
builder.append(")"sv);
@ -114,7 +114,7 @@ WebIDL::ExceptionOr<Utf16String> CSSScale::to_string() const
builder.append("scale("sv);
// 2. Serialize thiss x internal slot, and append it to s.
builder.append(m_x->to_string());
builder.append(TRY(m_x->to_string()));
// 3. If thiss x and y internal slots are equal numeric values, append ")" to s and return s.
if (m_x->is_equal_numeric_value(m_y)) {
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<Utf16String> CSSScale::to_string() const
builder.append(", "sv);
// 5. Serialize thiss y internal slot, and append it to s.
builder.append(m_y->to_string());
builder.append(TRY(m_y->to_string()));
// 6. Append ")" to s, and return s.
builder.append(")"sv);