Produce JS-visible string results as UTF-16 at their source, including numeric formatting, BigInt and BigFraction formatting, URI encoding, console formatting, parser errors, regular expression errors, Intl and Temporal records, LibUnicode locale boundaries, and LibWeb bindings. Handle fractional radix formatting through the UTF-16 builder view.
49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
/*
|
||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||
*
|
||
* SPDX-License-Identifier: BSD-2-Clause
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||
#include <LibWeb/WebIDL/Types.h>
|
||
|
||
namespace Web::CSS {
|
||
|
||
using CSSUnparsedSegment = Variant<Utf16String, GC::Ref<CSSVariableReferenceValue>>;
|
||
|
||
// https://drafts.css-houdini.org/css-typed-om-1/#cssunparsedvalue
|
||
class CSSUnparsedValue final : public CSSStyleValue {
|
||
WEB_PLATFORM_OBJECT(CSSUnparsedValue, CSSStyleValue);
|
||
GC_DECLARE_ALLOCATOR(CSSUnparsedValue);
|
||
|
||
public:
|
||
[[nodiscard]] static GC::Ref<CSSUnparsedValue> create(JS::Realm&, ReadonlySpan<CSSUnparsedSegment>);
|
||
static WebIDL::ExceptionOr<GC::Ref<CSSUnparsedValue>> construct_impl(JS::Realm&, ReadonlySpan<CSSUnparsedSegment>);
|
||
|
||
virtual ~CSSUnparsedValue() override;
|
||
|
||
WebIDL::UnsignedLong length() const;
|
||
virtual Optional<JS::Value> item_value(size_t index) const override;
|
||
virtual WebIDL::ExceptionOr<void> set_value_of_existing_indexed_property(u32, JS::Value) override;
|
||
virtual WebIDL::ExceptionOr<void> set_value_of_new_indexed_property(u32, JS::Value) override;
|
||
|
||
virtual WebIDL::ExceptionOr<Utf16String> to_string() const override;
|
||
virtual WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(PropertyNameAndID const&, PerformTypeCheck) const override;
|
||
|
||
private:
|
||
explicit CSSUnparsedValue(JS::Realm&, ReadonlySpan<CSSUnparsedSegment>);
|
||
|
||
virtual void initialize(JS::Realm&) override;
|
||
virtual void visit_edges(Visitor&) override;
|
||
|
||
bool contains_unparsed_value(CSSUnparsedValue const&) const;
|
||
|
||
// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssunparsedvalue-tokens-slot
|
||
// They have a [[tokens]] internal slot, which is a list of USVStrings and CSSVariableReferenceValue objects.
|
||
// This list is the object’s values to iterate over.
|
||
Vector<CSSUnparsedSegment> m_tokens;
|
||
};
|
||
|
||
}
|