mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 04:59:23 +00:00
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
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/FlyString.h>
|
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
// https://drafts.css-houdini.org/css-typed-om-1/#typedefdef-csskeywordish
|
|
using CSSKeywordish = Variant<String, GC::Root<CSSKeywordValue>>;
|
|
|
|
// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
|
|
class CSSKeywordValue final : public CSSStyleValue {
|
|
WEB_PLATFORM_OBJECT(CSSKeywordValue, CSSStyleValue);
|
|
GC_DECLARE_ALLOCATOR(CSSKeywordValue);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<CSSKeywordValue> create(JS::Realm&, FlyString value);
|
|
static WebIDL::ExceptionOr<GC::Ref<CSSKeywordValue>> construct_impl(JS::Realm&, FlyString value);
|
|
|
|
virtual ~CSSKeywordValue() override = default;
|
|
|
|
FlyString const& value() const { return m_value; }
|
|
WebIDL::ExceptionOr<void> set_value(FlyString value);
|
|
|
|
virtual WebIDL::ExceptionOr<String> to_string() const override;
|
|
|
|
private:
|
|
explicit CSSKeywordValue(JS::Realm&, FlyString value);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
FlyString m_value;
|
|
};
|
|
|
|
GC::Ref<CSSKeywordValue> rectify_a_keywordish_value(JS::Realm&, CSSKeywordish const&);
|
|
|
|
}
|