mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +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
|
@ -85,7 +85,7 @@ WebIDL::ExceptionOr<GC::Ref<CSSUnitValue>> CSSNumericValue::to(FlyString const&
|
|||
// 2. Let sum be the result of creating a sum value from this. If sum is failure, throw a TypeError.
|
||||
auto sum = create_a_sum_value();
|
||||
if (!sum.has_value())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create a sum from input '{}'", to_string())) };
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create a sum from input '{}'", MUST(to_string()))) };
|
||||
|
||||
// 3. If sum has more than one item, throw a TypeError.
|
||||
// Otherwise, let item be the result of creating a CSSUnitValue from the sole item in sum, then converting it to
|
||||
|
@ -94,11 +94,11 @@ WebIDL::ExceptionOr<GC::Ref<CSSUnitValue>> CSSNumericValue::to(FlyString const&
|
|||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Sum contains more than one item"sv };
|
||||
auto item = CSSUnitValue::create_from_sum_value_item(realm(), sum->first());
|
||||
if (!item)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create CSSUnitValue from input '{}'", to_string())) };
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create CSSUnitValue from input '{}'", MUST(to_string()))) };
|
||||
|
||||
auto converted_item = item->converted_to_unit(unit);
|
||||
if (!converted_item)
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to convert input '{}' to unit '{}'", to_string(), unit)) };
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to convert input '{}' to unit '{}'", MUST(to_string()), unit)) };
|
||||
|
||||
// 4. Return item.
|
||||
return converted_item.as_nonnull();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue