ladybird/Libraries/LibWeb/CSS/StyleValues/OpacityValueStyleValue.h
Andreas Kling d641bfd7e2 LibWeb: Store custom property names as UTF-16
Move PropertyNameAndID, custom property data, registered custom
properties, and Typed OM associated property names to Utf16FlyString.

This removes the FlyString storage boundary from CSS property-name
handling and lets CSSStyleProperties keep the name it receives from
CSSOM instead of converting it back to UTF-8.
2026-06-09 11:48:02 +02:00

45 lines
1.4 KiB
C++

/*
* Copyright (c) 2026, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
class OpacityValueStyleValue final : public StyleValueWithDefaultOperators<OpacityValueStyleValue> {
public:
static ValueComparingNonnullRefPtr<OpacityValueStyleValue const> create(NonnullRefPtr<StyleValue const>&& value)
{
return adopt_ref(*new (nothrow) OpacityValueStyleValue(move(value)));
}
virtual ~OpacityValueStyleValue() override = default;
virtual void serialize(StringBuilder&, SerializationMode) const override;
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
double resolved() const { return m_value->as_number().number(); }
virtual GC::Ref<CSSStyleValue> reify(JS::Realm& realm, Utf16FlyString const& associated_property) const override;
bool properties_equal(OpacityValueStyleValue const& other) const { return m_value == other.m_value; }
virtual bool is_computationally_independent() const override { return m_value->is_computationally_independent(); }
private:
OpacityValueStyleValue(NonnullRefPtr<StyleValue const>&& value)
: StyleValueWithDefaultOperators(Type::OpacityValue)
, m_value(move(value))
{
}
ValueComparingNonnullRefPtr<StyleValue const> m_value;
};
}