ladybird/Libraries/LibWeb/CSS/CSSVariableReferenceValue.h
Andreas Kling 26b0801a78 LibWeb: Return Utf16String from CSS Typed OM serialization
Make CSS Typed OM to_string() implementations produce Utf16String
instead of building UTF-8 strings and converting at the JS binding
boundary. Use Utf16StringBuilder for numeric, math, and transform
serialization paths that already feed CSS Typed OM stringification.

Keep the older CSSOM StyleValue serializer on StringBuilder for now, and
convert only where Typed OM source values or parser re-entry still need
the existing UTF-8 representation.
2026-06-22 16:10:40 +02:00

43 lines
1.3 KiB
C++

/*
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <AK/Utf16String.h>
#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::CSS {
class CSSVariableReferenceValue : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(CSSVariableReferenceValue, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(CSSVariableReferenceValue);
public:
[[nodiscard]] static GC::Ref<CSSVariableReferenceValue> create(JS::Realm&, FlyString variable, GC::Ptr<CSSUnparsedValue> fallback = nullptr);
static WebIDL::ExceptionOr<GC::Ref<CSSVariableReferenceValue>> construct_impl(JS::Realm&, FlyString variable, GC::Ptr<CSSUnparsedValue> fallback);
virtual ~CSSVariableReferenceValue() override;
String variable() const;
WebIDL::ExceptionOr<void> set_variable(FlyString);
GC::Ptr<CSSUnparsedValue> fallback() const;
WebIDL::ExceptionOr<void> set_fallback(GC::Ptr<CSSUnparsedValue>);
WebIDL::ExceptionOr<Utf16String> to_string() const;
private:
CSSVariableReferenceValue(JS::Realm&, FlyString variable, GC::Ptr<CSSUnparsedValue> fallback);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor&) override;
FlyString m_variable;
GC::Ptr<CSSUnparsedValue> m_fallback;
};
}