ladybird/Libraries/LibWeb/CSS/StyleValues/PendingSubstitutionStyleValue.h
Callum Law ed2909674f LibWeb: Add computationally independent check for custom properties
Registered custom properties only accept "computationally independent"
values for their initial value
2026-03-26 01:11:39 +00:00

47 lines
1.8 KiB
C++

/*
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
// https://drafts.csswg.org/css-values-5/#pending-substitution-value
class PendingSubstitutionStyleValue final : public StyleValueWithDefaultOperators<PendingSubstitutionStyleValue> {
public:
static ValueComparingNonnullRefPtr<PendingSubstitutionStyleValue> create(StyleValue const& original_shorthand_value)
{
return adopt_ref(*new (nothrow) PendingSubstitutionStyleValue(original_shorthand_value));
}
virtual ~PendingSubstitutionStyleValue() override = default;
virtual void serialize(StringBuilder&, SerializationMode) const override { }
virtual Vector<Parser::ComponentValue> tokenize() const override
{
// Not sure what to do here, but this isn't valid so returning GIV seems the most correct.
return { Parser::ComponentValue { Parser::GuaranteedInvalidValue {} } };
}
StyleValue const& original_shorthand_value() const { return *m_original_shorthand_value; }
// We shouldn't need to compare these, but in case we do: The nature of them is that their value is unknown, so
// consider them all to be unique.
bool properties_equal(PendingSubstitutionStyleValue const&) const { return false; }
// NB: We should never be in a position where we need to check this
virtual bool is_computationally_independent() const override { VERIFY_NOT_REACHED(); }
private:
explicit PendingSubstitutionStyleValue(StyleValue const& original_shorthand_value)
: StyleValueWithDefaultOperators(Type::PendingSubstitution)
, m_original_shorthand_value(original_shorthand_value)
{
}
NonnullRefPtr<StyleValue const> m_original_shorthand_value;
};
}