mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-15 12:39:13 +00:00
CSSTransformComponents hold other CSSStyleValues as their parameters. We want to be able to create internal representations from those parameters without them caring if they would be valid when directly assigned to the property. This is a temporary solution to make transform functions work. To be completely correct, we need to know what is allowed in that context, along with value ranges - a combination of the contexts we create when parsing, and when computing calculations. For transform functions, this doesn't matter, as there's no limit to the range of allowed values.
44 lines
1.4 KiB
C++
44 lines
1.4 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;
|
|
virtual WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(PropertyNameAndID const&, PerformTypeCheck) 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&);
|
|
|
|
}
|