diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 77e64044ad3..6157a2d06f7 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -295,6 +296,12 @@ OpenTypeTaggedStyleValue const& CSSStyleValue::as_open_type_tagged() const return static_cast(*this); } +PendingSubstitutionStyleValue const& CSSStyleValue::as_pending_substitution() const +{ + VERIFY(is_pending_substitution()); + return static_cast(*this); +} + PercentageStyleValue const& CSSStyleValue::as_percentage() const { VERIFY(is_percentage()); diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.h b/Libraries/LibWeb/CSS/CSSStyleValue.h index edb19d674cf..ac22963ecf7 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -122,6 +122,7 @@ public: MathDepth, Number, OpenTypeTagged, + PendingSubstitution, Percentage, Position, RadialGradient, @@ -295,6 +296,10 @@ public: OpenTypeTaggedStyleValue const& as_open_type_tagged() const; OpenTypeTaggedStyleValue& as_open_type_tagged() { return const_cast(const_cast(*this).as_open_type_tagged()); } + bool is_pending_substitution() const { return type() == Type::PendingSubstitution; } + PendingSubstitutionStyleValue const& as_pending_substitution() const; + PendingSubstitutionStyleValue& as_pending_substitution() { return const_cast(const_cast(*this).as_pending_substitution()); } + bool is_percentage() const { return type() == Type::Percentage; } PercentageStyleValue const& as_percentage() const; PercentageStyleValue& as_percentage() { return const_cast(const_cast(*this).as_percentage()); } diff --git a/Libraries/LibWeb/CSS/StyleValues/PendingSubstitutionStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/PendingSubstitutionStyleValue.h new file mode 100644 index 00000000000..10b43012d60 --- /dev/null +++ b/Libraries/LibWeb/CSS/StyleValues/PendingSubstitutionStyleValue.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::CSS { + +// https://drafts.csswg.org/css-values-5/#pending-substitution-value +class PendingSubstitutionStyleValue final : public StyleValueWithDefaultOperators { +public: + static ValueComparingNonnullRefPtr create() + { + static ValueComparingNonnullRefPtr instance = adopt_ref(*new (nothrow) PendingSubstitutionStyleValue()); + return instance; + } + virtual ~PendingSubstitutionStyleValue() override = default; + virtual String to_string(SerializationMode) const override { return {}; } + + // 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; } + +private: + PendingSubstitutionStyleValue() + : StyleValueWithDefaultOperators(Type::PendingSubstitution) + { + } +}; + +} diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 683cb3e96ef..c962ec6a5ca 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -266,6 +266,7 @@ class NumberOrCalculated; class NumberStyleValue; class OpenTypeTaggedStyleValue; class ParsedFontFace; +class PendingSubstitutionStyleValue; class Percentage; class PercentageOrCalculated; class PercentageStyleValue;