LibWeb: Make storage of CSS::StyleValues const-correct

Now we consistently use `RefPtr<StyleValue const>` for all StyleValues.
This commit is contained in:
Andrew Kaster 2025-04-15 15:18:27 -06:00
commit a2c5fd5133
113 changed files with 628 additions and 629 deletions

View file

@ -25,7 +25,7 @@ Each property will have some set of these fields on it:
| `affects-stacking-context` | No | `false` | Boolean. Whether this property can cause a new stacking context for the element. | `bool property_affects_stacking_context(PropertyID)` | | `affects-stacking-context` | No | `false` | Boolean. Whether this property can cause a new stacking context for the element. | `bool property_affects_stacking_context(PropertyID)` |
| `animation-type` | Yes | | String. How the property should be animated. Defined by the spec. See below. | `AnimationType animation_type_from_longhand_property(PropertyID)` | | `animation-type` | Yes | | String. How the property should be animated. Defined by the spec. See below. | `AnimationType animation_type_from_longhand_property(PropertyID)` |
| `inherited` | Yes | | Boolean. Whether the property is inherited by its child elements. | `bool is_inherited_property(PropertyID)` | | `inherited` | Yes | | Boolean. Whether the property is inherited by its child elements. | `bool is_inherited_property(PropertyID)` |
| `initial` | Yes | | String. The property's initial value if it is not specified. | `NonnullRefPtr<CSSStyleValue> property_initial_value(PropertyID)` | | `initial` | Yes | | String. The property's initial value if it is not specified. | `NonnullRefPtr<CSSStyleValue const> property_initial_value(PropertyID)` |
| `legacy-alias-for` | No | Nothing | String. The name of a property this is an alias for. See below. | | | `legacy-alias-for` | No | Nothing | String. The name of a property this is an alias for. See below. | |
| `logical-alias-for` | No | Nothing | Array of strings. The name of a property this is an alias for. See below. | | | `logical-alias-for` | No | Nothing | Array of strings. The name of a property this is an alias for. See below. | |
| `longhands` | No | `[]` | Array of strings. If this is a shorthand, these are the property names that it expands out into. | `Vector<PropertyID> longhands_for_shorthand(PropertyID)` | | `longhands` | No | `[]` | Array of strings. If this is a shorthand, these are the property names that it expands out into. | `Vector<PropertyID> longhands_for_shorthand(PropertyID)` |
@ -89,7 +89,7 @@ The generated code provides:
it exists in that at-rule. it exists in that at-rule.
- `FlyString to_string(DescriptorID)` for serializing descriptor names. - `FlyString to_string(DescriptorID)` for serializing descriptor names.
- `bool at_rule_supports_descriptor(AtRuleID, DescriptorID)` to query if the given at-rule allows the descriptor. - `bool at_rule_supports_descriptor(AtRuleID, DescriptorID)` to query if the given at-rule allows the descriptor.
- `RefPtr<CSSStyleValue> descriptor_initial_value(AtRuleID, DescriptorID)` for getting a descriptor's initial value. - `RefPtr<CSSStyleValue const> descriptor_initial_value(AtRuleID, DescriptorID)` for getting a descriptor's initial value.
- `DescriptorMetadata get_descriptor_metadata(AtRuleID, DescriptorID)` returns data used for parsing the descriptor. - `DescriptorMetadata get_descriptor_metadata(AtRuleID, DescriptorID)` returns data used for parsing the descriptor.
### At-rule fields ### At-rule fields

View file

@ -84,7 +84,7 @@ Optional<Angle::Type> Angle::unit_from_name(StringView name)
return {}; return {};
} }
Angle Angle::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, Angle const& reference_value) Angle Angle::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Angle const& reference_value)
{ {
return calculated->resolve_angle( return calculated->resolve_angle(
{ {

View file

@ -52,7 +52,7 @@ public:
return 0; return 0;
} }
static Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Angle const& reference_value); static Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Angle const& reference_value);
private: private:
Type m_type; Type m_type;

View file

@ -100,7 +100,7 @@ WebIDL::ExceptionOr<void> CSSFontFaceDescriptors::set_property(StringView proper
return {}; return {};
// 5. Let component value list be the result of parsing value for property property. // 5. Let component value list be the result of parsing value for property property.
RefPtr<CSSStyleValue> component_value_list = parse_css_descriptor(Parser::ParsingParams {}, AtRuleID::FontFace, *descriptor_id, value); RefPtr<CSSStyleValue const> component_value_list = parse_css_descriptor(Parser::ParsingParams {}, AtRuleID::FontFace, *descriptor_id, value);
// 6. If component value list is null, then return. // 6. If component value list is null, then return.
if (!component_value_list) if (!component_value_list)

View file

@ -13,12 +13,12 @@ namespace Web::CSS {
GC_DEFINE_ALLOCATOR(CSSPropertyRule); GC_DEFINE_ALLOCATOR(CSSPropertyRule);
GC::Ref<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue> initial_value) GC::Ref<CSSPropertyRule> CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value)
{ {
return realm.create<CSSPropertyRule>(realm, move(name), move(syntax), inherits, move(initial_value)); return realm.create<CSSPropertyRule>(realm, move(name), move(syntax), inherits, move(initial_value));
} }
CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue> initial_value) CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value)
: CSSRule(realm, Type::Property) : CSSRule(realm, Type::Property)
, m_name(move(name)) , m_name(move(name))
, m_syntax(move(syntax)) , m_syntax(move(syntax))

View file

@ -21,7 +21,7 @@ class CSSPropertyRule final : public CSSRule {
GC_DECLARE_ALLOCATOR(CSSPropertyRule); GC_DECLARE_ALLOCATOR(CSSPropertyRule);
public: public:
static GC::Ref<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue> initial_value); static GC::Ref<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value);
virtual ~CSSPropertyRule() = default; virtual ~CSSPropertyRule() = default;
@ -31,7 +31,7 @@ public:
Optional<String> initial_value() const; Optional<String> initial_value() const;
private: private:
CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue> initial_value); CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, RefPtr<CSSStyleValue const> initial_value);
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual String serialized() const override; virtual String serialized() const override;
@ -39,7 +39,7 @@ private:
FlyString m_name; FlyString m_name;
FlyString m_syntax; FlyString m_syntax;
bool m_inherits; bool m_inherits;
RefPtr<CSSStyleValue> m_initial_value; RefPtr<CSSStyleValue const> m_initial_value;
}; };
template<> template<>

View file

@ -428,10 +428,10 @@ static Optional<StyleProperty> style_property_for_sided_shorthand(PropertyID pro
if (top->important != right->important || top->important != bottom->important || top->important != left->important) if (top->important != right->important || top->important != bottom->important || top->important != left->important)
return {}; return {};
ValueComparingNonnullRefPtr<CSSStyleValue> const top_value { top->value }; ValueComparingNonnullRefPtr<CSSStyleValue const> const top_value { top->value };
ValueComparingNonnullRefPtr<CSSStyleValue> const right_value { right->value }; ValueComparingNonnullRefPtr<CSSStyleValue const> const right_value { right->value };
ValueComparingNonnullRefPtr<CSSStyleValue> const bottom_value { bottom->value }; ValueComparingNonnullRefPtr<CSSStyleValue const> const bottom_value { bottom->value };
ValueComparingNonnullRefPtr<CSSStyleValue> const left_value { left->value }; ValueComparingNonnullRefPtr<CSSStyleValue const> const left_value { left->value };
bool const top_and_bottom_same = top_value == bottom_value; bool const top_and_bottom_same = top_value == bottom_value;
bool const left_and_right_same = left_value == right_value; bool const left_and_right_same = left_value == right_value;

View file

@ -17,92 +17,92 @@
namespace Web::CSS { namespace Web::CSS {
Optional<Angle> AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Angle> AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_angle(context); return calculated->resolve_angle(context);
} }
NonnullRefPtr<CSSStyleValue> AngleOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> AngleOrCalculated::create_style_value() const
{ {
return AngleStyleValue::create(value()); return AngleStyleValue::create(value());
} }
Optional<Flex> FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Flex> FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_flex(context); return calculated->resolve_flex(context);
} }
NonnullRefPtr<CSSStyleValue> FlexOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> FlexOrCalculated::create_style_value() const
{ {
return FlexStyleValue::create(value()); return FlexStyleValue::create(value());
} }
Optional<Frequency> FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Frequency> FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_frequency(context); return calculated->resolve_frequency(context);
} }
NonnullRefPtr<CSSStyleValue> FrequencyOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> FrequencyOrCalculated::create_style_value() const
{ {
return FrequencyStyleValue::create(value()); return FrequencyStyleValue::create(value());
} }
Optional<i64> IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<i64> IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_integer(context); return calculated->resolve_integer(context);
} }
NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> IntegerOrCalculated::create_style_value() const
{ {
return IntegerStyleValue::create(value()); return IntegerStyleValue::create(value());
} }
Optional<Length> LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Length> LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_length(context); return calculated->resolve_length(context);
} }
NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> LengthOrCalculated::create_style_value() const
{ {
return LengthStyleValue::create(value()); return LengthStyleValue::create(value());
} }
Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_number(context); return calculated->resolve_number(context);
} }
NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> NumberOrCalculated::create_style_value() const
{ {
return NumberStyleValue::create(value()); return NumberStyleValue::create(value());
} }
Optional<Percentage> PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Percentage> PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_percentage(context); return calculated->resolve_percentage(context);
} }
NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> PercentageOrCalculated::create_style_value() const
{ {
return PercentageStyleValue::create(value()); return PercentageStyleValue::create(value());
} }
Optional<Resolution> ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Resolution> ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_resolution(context); return calculated->resolve_resolution(context);
} }
NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> ResolutionOrCalculated::create_style_value() const
{ {
return ResolutionStyleValue::create(value()); return ResolutionStyleValue::create(value());
} }
Optional<Time> TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<Time> TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return calculated->resolve_time(context); return calculated->resolve_time(context);
} }
NonnullRefPtr<CSSStyleValue> TimeOrCalculated::create_style_value() const NonnullRefPtr<CSSStyleValue const> TimeOrCalculated::create_style_value() const
{ {
return TimeStyleValue::create(value()); return TimeStyleValue::create(value());
} }

View file

@ -26,12 +26,12 @@ public:
{ {
} }
CalculatedOr(NonnullRefPtr<CalculatedStyleValue> calculated) CalculatedOr(NonnullRefPtr<CalculatedStyleValue const> calculated)
: m_value(move(calculated)) : m_value(move(calculated))
{ {
} }
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); } bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue const>>(); }
T const& value() const T const& value() const
{ {
@ -39,17 +39,17 @@ public:
return m_value.template get<T>(); return m_value.template get<T>();
} }
NonnullRefPtr<CSSStyleValue> as_style_value() const NonnullRefPtr<CSSStyleValue const> as_style_value() const
{ {
if (is_calculated()) if (is_calculated())
return calculated(); return calculated();
return create_style_value(); return create_style_value();
} }
NonnullRefPtr<CalculatedStyleValue> const& calculated() const NonnullRefPtr<CalculatedStyleValue const> const& calculated() const
{ {
VERIFY(is_calculated()); VERIFY(is_calculated());
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>(); return m_value.template get<NonnullRefPtr<CalculatedStyleValue const>>();
} }
Optional<T> resolved(CalculationResolutionContext const& context) const Optional<T> resolved(CalculationResolutionContext const& context) const
@ -58,7 +58,7 @@ public:
[&](T const& t) -> Optional<T> { [&](T const& t) -> Optional<T> {
return t; return t;
}, },
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) { [&](NonnullRefPtr<CalculatedStyleValue const> const& calculated) {
return resolve_calculated(calculated, context); return resolve_calculated(calculated, context);
}); });
} }
@ -73,7 +73,7 @@ public:
return t.to_string(); return t.to_string();
} }
}, },
[](NonnullRefPtr<CalculatedStyleValue> const& calculated) { [](NonnullRefPtr<CalculatedStyleValue const> const& calculated) {
return calculated->to_string(CSSStyleValue::SerializationMode::Normal); return calculated->to_string(CSSStyleValue::SerializationMode::Normal);
}); });
} }
@ -86,89 +86,89 @@ public:
} }
protected: protected:
Optional<T> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, CalculationResolutionContext const& context) const Optional<T> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{ {
return static_cast<Self const*>(this)->resolve_calculated(calculated, context); return static_cast<Self const*>(this)->resolve_calculated(calculated, context);
} }
NonnullRefPtr<CSSStyleValue> create_style_value() const NonnullRefPtr<CSSStyleValue const> create_style_value() const
{ {
return static_cast<Self const*>(this)->create_style_value(); return static_cast<Self const*>(this)->create_style_value();
} }
private: private:
Variant<T, NonnullRefPtr<CalculatedStyleValue>> m_value; Variant<T, NonnullRefPtr<CalculatedStyleValue const>> m_value;
}; };
class AngleOrCalculated : public CalculatedOr<AngleOrCalculated, Angle> { class AngleOrCalculated : public CalculatedOr<AngleOrCalculated, Angle> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Angle> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Angle> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class FlexOrCalculated : public CalculatedOr<FlexOrCalculated, Flex> { class FlexOrCalculated : public CalculatedOr<FlexOrCalculated, Flex> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Flex> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Flex> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class FrequencyOrCalculated : public CalculatedOr<FrequencyOrCalculated, Frequency> { class FrequencyOrCalculated : public CalculatedOr<FrequencyOrCalculated, Frequency> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Frequency> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Frequency> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class IntegerOrCalculated : public CalculatedOr<IntegerOrCalculated, i64> { class IntegerOrCalculated : public CalculatedOr<IntegerOrCalculated, i64> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<i64> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<i64> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class LengthOrCalculated : public CalculatedOr<LengthOrCalculated, Length> { class LengthOrCalculated : public CalculatedOr<LengthOrCalculated, Length> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Length> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Length> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class NumberOrCalculated : public CalculatedOr<NumberOrCalculated, double> { class NumberOrCalculated : public CalculatedOr<NumberOrCalculated, double> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<double> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<double> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class PercentageOrCalculated : public CalculatedOr<PercentageOrCalculated, Percentage> { class PercentageOrCalculated : public CalculatedOr<PercentageOrCalculated, Percentage> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Percentage> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Percentage> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class ResolutionOrCalculated : public CalculatedOr<ResolutionOrCalculated, Resolution> { class ResolutionOrCalculated : public CalculatedOr<ResolutionOrCalculated, Resolution> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Resolution> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Resolution> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
class TimeOrCalculated : public CalculatedOr<TimeOrCalculated, Time> { class TimeOrCalculated : public CalculatedOr<TimeOrCalculated, Time> {
public: public:
using CalculatedOr::CalculatedOr; using CalculatedOr::CalculatedOr;
Optional<Time> resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, CalculationResolutionContext const&) const; Optional<Time> resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, CalculationResolutionContext const&) const;
NonnullRefPtr<CSSStyleValue> create_style_value() const; NonnullRefPtr<CSSStyleValue const> create_style_value() const;
}; };
} }

View file

@ -80,7 +80,7 @@ struct Containment {
bool is_empty() const { return !(size_containment || inline_size_containment || layout_containment || style_containment || paint_containment); } bool is_empty() const { return !(size_containment || inline_size_containment || layout_containment || style_containment || paint_containment); }
}; };
using CursorData = Variant<NonnullRefPtr<CursorStyleValue>, Cursor>; using CursorData = Variant<NonnullRefPtr<CursorStyleValue const>, Cursor>;
using ListStyleType = Variant<CounterStyleNameKeyword, String>; using ListStyleType = Variant<CounterStyleNameKeyword, String>;
@ -720,7 +720,7 @@ protected:
Optional<MaskReference> mask; Optional<MaskReference> mask;
CSS::MaskType mask_type { InitialValues::mask_type() }; CSS::MaskType mask_type { InitialValues::mask_type() };
Optional<ClipPathReference> clip_path; Optional<ClipPathReference> clip_path;
RefPtr<CSS::AbstractImageStyleValue> mask_image; RefPtr<CSS::AbstractImageStyleValue const> mask_image;
LengthPercentage cx { InitialValues::cx() }; LengthPercentage cx { InitialValues::cx() };
LengthPercentage cy { InitialValues::cy() }; LengthPercentage cy { InitialValues::cy() };

View file

@ -96,7 +96,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
font_face->m_ascent_override = try_parse_descriptor(DescriptorID::AscentOverride, descriptors.ascent_override); font_face->m_ascent_override = try_parse_descriptor(DescriptorID::AscentOverride, descriptors.ascent_override);
font_face->m_descent_override = try_parse_descriptor(DescriptorID::DescentOverride, descriptors.descent_override); font_face->m_descent_override = try_parse_descriptor(DescriptorID::DescentOverride, descriptors.descent_override);
font_face->m_line_gap_override = try_parse_descriptor(DescriptorID::LineGapOverride, descriptors.line_gap_override); font_face->m_line_gap_override = try_parse_descriptor(DescriptorID::LineGapOverride, descriptors.line_gap_override);
RefPtr<CSSStyleValue> parsed_source; RefPtr<CSSStyleValue const> parsed_source;
if (auto* source_string = source.get_pointer<String>()) { if (auto* source_string = source.get_pointer<String>()) {
parsed_source = parse_css_descriptor(parsing_params, AtRuleID::FontFace, DescriptorID::Src, *source_string); parsed_source = parse_css_descriptor(parsing_params, AtRuleID::FontFace, DescriptorID::Src, *source_string);
if (!parsed_source) { if (!parsed_source) {

View file

@ -63,7 +63,7 @@ Optional<Frequency::Type> Frequency::unit_from_name(StringView name)
return {}; return {};
} }
Frequency Frequency::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, Frequency const& reference_value) Frequency Frequency::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Frequency const& reference_value)
{ {
return calculated->resolve_frequency( return calculated->resolve_frequency(
{ {

View file

@ -47,7 +47,7 @@ public:
return 0; return 0;
} }
static Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Frequency const& reference_value); static Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Frequency const& reference_value);
private: private:
Type m_type; Type m_type;

View file

@ -508,7 +508,7 @@ NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, Calc
struct NumericBaseTypeAndDefault { struct NumericBaseTypeAndDefault {
CSSNumericType::BaseType base_type; CSSNumericType::BaseType base_type;
ValueComparingNonnullRefPtr<CSSStyleValue> default_value; ValueComparingNonnullRefPtr<CSSStyleValue const> default_value;
}; };
static constexpr auto numeric_base_type_and_default = [](CSSStyleValue const& value) -> Optional<NumericBaseTypeAndDefault> { static constexpr auto numeric_base_type_and_default = [](CSSStyleValue const& value) -> Optional<NumericBaseTypeAndDefault> {
switch (value.type()) { switch (value.type()) {

View file

@ -410,7 +410,7 @@ Length Length::absolutized(CSSPixelRect const& viewport_rect, FontMetrics const&
return absolutize(viewport_rect, font_metrics, root_font_metrics).value_or(*this); return absolutize(viewport_rect, font_metrics, root_font_metrics).value_or(*this);
} }
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, Length const& reference_value) Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Length const& reference_value)
{ {
return calculated->resolve_length( return calculated->resolve_length(
{ {
@ -420,7 +420,7 @@ Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& cal
.value(); .value();
} }
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value) Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
{ {
return calculated->resolve_length( return calculated->resolve_length(
{ {

View file

@ -232,8 +232,8 @@ public:
Optional<Length> absolutize(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const; Optional<Length> absolutize(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
Length absolutized(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const; Length absolutized(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Length const& reference_value); static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Length const& reference_value);
static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, CSSPixels reference_value); static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, CSSPixels reference_value);
private: private:
[[nodiscard]] CSSPixels to_px_slow_case(Layout::Node const&) const; [[nodiscard]] CSSPixels to_px_slow_case(Layout::Node const&) const;

View file

@ -16,7 +16,7 @@ public:
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left); LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
~LengthBox(); ~LengthBox();
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue> member, but we can't include the header CSSStyleValue.h as it includes // Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue const> member, but we can't include the header CSSStyleValue.h as it includes
// this file already. To break the cyclic dependency, we must initialize these members in the constructor. // this file already. To break the cyclic dependency, we must initialize these members in the constructor.
LengthPercentage& top() { return m_top; } LengthPercentage& top() { return m_top; }
LengthPercentage& right() { return m_right; } LengthPercentage& right() { return m_right; }

View file

@ -15,7 +15,7 @@
namespace Web::CSS::Parser { namespace Web::CSS::Parser {
Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream<ComponentValue>& unprocessed_tokens) Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream<ComponentValue>& unprocessed_tokens)
{ {
if (!at_rule_supports_descriptor(at_rule_id, descriptor_id)) { if (!at_rule_supports_descriptor(at_rule_id, descriptor_id)) {
dbgln_if(CSS_PARSER_DEBUG, "Unsupported descriptor '{}' in '{}'", to_string(descriptor_id), to_string(at_rule_id)); dbgln_if(CSS_PARSER_DEBUG, "Unsupported descriptor '{}' in '{}'", to_string(descriptor_id), to_string(at_rule_id));
@ -45,7 +45,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_descriptor_valu
[&](Keyword keyword) { [&](Keyword keyword) {
return parse_all_as_single_keyword_value(tokens, keyword); return parse_all_as_single_keyword_value(tokens, keyword);
}, },
[&](PropertyID property_id) -> RefPtr<CSSStyleValue> { [&](PropertyID property_id) -> RefPtr<CSSStyleValue const> {
auto value_or_error = parse_css_value(property_id, tokens); auto value_or_error = parse_css_value(property_id, tokens);
if (value_or_error.is_error()) if (value_or_error.is_error())
return nullptr; return nullptr;
@ -58,7 +58,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_descriptor_valu
return nullptr; return nullptr;
return value_for_property; return value_for_property;
}, },
[&](DescriptorMetadata::ValueType value_type) -> RefPtr<CSSStyleValue> { [&](DescriptorMetadata::ValueType value_type) -> RefPtr<CSSStyleValue const> {
switch (value_type) { switch (value_type) {
case DescriptorMetadata::ValueType::FamilyName: case DescriptorMetadata::ValueType::FamilyName:
return parse_family_name_value(tokens); return parse_family_name_value(tokens);
@ -107,7 +107,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_descriptor_valu
case DescriptorMetadata::ValueType::String: case DescriptorMetadata::ValueType::String:
return parse_string_value(tokens); return parse_string_value(tokens);
case DescriptorMetadata::ValueType::UnicodeRangeTokens: case DescriptorMetadata::ValueType::UnicodeRangeTokens:
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<CSSStyleValue> { return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<CSSStyleValue const> {
return parse_unicode_range_value(tokens); return parse_unicode_range_value(tokens);
}); });
} }

View file

@ -32,7 +32,7 @@ Optional<Vector<TElement>> Parser::parse_color_stop_list(TokenStream<ComponentVa
if (!tokens.has_next_token()) if (!tokens.has_next_token())
return ElementType::Garbage; return ElementType::Garbage;
RefPtr<CSSStyleValue> color; RefPtr<CSSStyleValue const> color;
Optional<typename TElement::PositionType> position; Optional<typename TElement::PositionType> position;
Optional<typename TElement::PositionType> second_position; Optional<typename TElement::PositionType> second_position;
if (position = parse_position(tokens); position.has_value()) { if (position = parse_position(tokens); position.has_value()) {
@ -223,7 +223,7 @@ Optional<InterpolationMethod> Parser::parse_interpolation_method(TokenStream<Com
return interpolation_method; return interpolation_method;
} }
RefPtr<LinearGradientStyleValue> Parser::parse_linear_gradient_function(TokenStream<ComponentValue>& outer_tokens) RefPtr<LinearGradientStyleValue const> Parser::parse_linear_gradient_function(TokenStream<ComponentValue>& outer_tokens)
{ {
using GradientType = LinearGradientStyleValue::GradientType; using GradientType = LinearGradientStyleValue::GradientType;
@ -370,7 +370,7 @@ RefPtr<LinearGradientStyleValue> Parser::parse_linear_gradient_function(TokenStr
return LinearGradientStyleValue::create(gradient_direction, move(*color_stops), gradient_type, repeating_gradient, maybe_interpolation_method); return LinearGradientStyleValue::create(gradient_direction, move(*color_stops), gradient_type, repeating_gradient, maybe_interpolation_method);
} }
RefPtr<ConicGradientStyleValue> Parser::parse_conic_gradient_function(TokenStream<ComponentValue>& outer_tokens) RefPtr<ConicGradientStyleValue const> Parser::parse_conic_gradient_function(TokenStream<ComponentValue>& outer_tokens)
{ {
auto transaction = outer_tokens.begin_transaction(); auto transaction = outer_tokens.begin_transaction();
auto& component_value = outer_tokens.consume_a_token(); auto& component_value = outer_tokens.consume_a_token();
@ -397,7 +397,7 @@ RefPtr<ConicGradientStyleValue> Parser::parse_conic_gradient_function(TokenStrea
return nullptr; return nullptr;
Angle from_angle(0, Angle::Type::Deg); Angle from_angle(0, Angle::Type::Deg);
RefPtr<PositionStyleValue> at_position; RefPtr<PositionStyleValue const> at_position;
Optional<InterpolationMethod> maybe_interpolation_method; Optional<InterpolationMethod> maybe_interpolation_method;
// conic-gradient( [ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list> ) // conic-gradient( [ [ [ from [ <angle> | <zero> ] ]? [ at <position> ]? ] || <color-interpolation-method> ]? , <angular-color-stop-list> )
@ -483,7 +483,7 @@ RefPtr<ConicGradientStyleValue> Parser::parse_conic_gradient_function(TokenStrea
return ConicGradientStyleValue::create(from_angle, at_position.release_nonnull(), move(*color_stops), repeating_gradient, maybe_interpolation_method); return ConicGradientStyleValue::create(from_angle, at_position.release_nonnull(), move(*color_stops), repeating_gradient, maybe_interpolation_method);
} }
RefPtr<RadialGradientStyleValue> Parser::parse_radial_gradient_function(TokenStream<ComponentValue>& outer_tokens) RefPtr<RadialGradientStyleValue const> Parser::parse_radial_gradient_function(TokenStream<ComponentValue>& outer_tokens)
{ {
using EndingShape = RadialGradientStyleValue::EndingShape; using EndingShape = RadialGradientStyleValue::EndingShape;
using Extent = RadialGradientStyleValue::Extent; using Extent = RadialGradientStyleValue::Extent;
@ -526,7 +526,7 @@ RefPtr<RadialGradientStyleValue> Parser::parse_radial_gradient_function(TokenStr
Size size = Extent::FarthestCorner; Size size = Extent::FarthestCorner;
EndingShape ending_shape = EndingShape::Circle; EndingShape ending_shape = EndingShape::Circle;
RefPtr<PositionStyleValue> at_position; RefPtr<PositionStyleValue const> at_position;
auto parse_ending_shape = [&]() -> Optional<EndingShape> { auto parse_ending_shape = [&]() -> Optional<EndingShape> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();

View file

@ -71,14 +71,14 @@ Vector<CSS::Descriptor> parse_css_list_of_descriptors(CSS::Parser::ParsingParams
return CSS::Parser::Parser::create(parsing_params, css).parse_as_list_of_descriptors(at_rule_id); return CSS::Parser::Parser::create(parsing_params, css).parse_as_list_of_descriptors(at_rule_id);
} }
RefPtr<CSS::CSSStyleValue> parse_css_value(CSS::Parser::ParsingParams const& context, StringView string, CSS::PropertyID property_id) RefPtr<CSS::CSSStyleValue const> parse_css_value(CSS::Parser::ParsingParams const& context, StringView string, CSS::PropertyID property_id)
{ {
if (string.is_empty()) if (string.is_empty())
return nullptr; return nullptr;
return CSS::Parser::Parser::create(context, string).parse_as_css_value(property_id); return CSS::Parser::Parser::create(context, string).parse_as_css_value(property_id);
} }
RefPtr<CSS::CSSStyleValue> parse_css_descriptor(CSS::Parser::ParsingParams const& parsing_params, CSS::AtRuleID at_rule_id, CSS::DescriptorID descriptor_id, StringView string) RefPtr<CSS::CSSStyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const& parsing_params, CSS::AtRuleID at_rule_id, CSS::DescriptorID descriptor_id, StringView string)
{ {
if (string.is_empty()) if (string.is_empty())
return nullptr; return nullptr;

View file

@ -1622,7 +1622,7 @@ Vector<ComponentValue> Parser::parse_as_list_of_component_values()
return parse_a_list_of_component_values(m_token_stream); return parse_a_list_of_component_values(m_token_stream);
} }
RefPtr<CSSStyleValue> Parser::parse_as_css_value(PropertyID property_id) RefPtr<CSSStyleValue const> Parser::parse_as_css_value(PropertyID property_id)
{ {
auto component_values = parse_a_list_of_component_values(m_token_stream); auto component_values = parse_a_list_of_component_values(m_token_stream);
auto tokens = TokenStream(component_values); auto tokens = TokenStream(component_values);
@ -1632,7 +1632,7 @@ RefPtr<CSSStyleValue> Parser::parse_as_css_value(PropertyID property_id)
return parsed_value.release_value(); return parsed_value.release_value();
} }
RefPtr<CSSStyleValue> Parser::parse_as_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id) RefPtr<CSSStyleValue const> Parser::parse_as_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id)
{ {
auto component_values = parse_a_list_of_component_values(m_token_stream); auto component_values = parse_a_list_of_component_values(m_token_stream);
auto tokens = TokenStream(component_values); auto tokens = TokenStream(component_values);

View file

@ -119,14 +119,14 @@ public:
RefPtr<Supports> parse_as_supports(); RefPtr<Supports> parse_as_supports();
RefPtr<CSSStyleValue> parse_as_css_value(PropertyID); RefPtr<CSSStyleValue const> parse_as_css_value(PropertyID);
RefPtr<CSSStyleValue> parse_as_descriptor_value(AtRuleID, DescriptorID); RefPtr<CSSStyleValue const> parse_as_descriptor_value(AtRuleID, DescriptorID);
Optional<ComponentValue> parse_as_component_value(); Optional<ComponentValue> parse_as_component_value();
Vector<ComponentValue> parse_as_list_of_component_values(); Vector<ComponentValue> parse_as_list_of_component_values();
static NonnullRefPtr<CSSStyleValue> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyID, UnresolvedStyleValue const&); static NonnullRefPtr<CSSStyleValue const> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyID, UnresolvedStyleValue const&);
[[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr); [[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img = nullptr);
@ -270,7 +270,7 @@ private:
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&); Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
Optional<Gfx::UnicodeRange> parse_unicode_range(StringView); Optional<Gfx::UnicodeRange> parse_unicode_range(StringView);
Vector<Gfx::UnicodeRange> parse_unicode_ranges(TokenStream<ComponentValue>&); Vector<Gfx::UnicodeRange> parse_unicode_ranges(TokenStream<ComponentValue>&);
RefPtr<UnicodeRangeStyleValue> parse_unicode_range_value(TokenStream<ComponentValue>&); RefPtr<UnicodeRangeStyleValue const> parse_unicode_range_value(TokenStream<ComponentValue>&);
Optional<GridSize> parse_grid_size(ComponentValue const&); Optional<GridSize> parse_grid_size(ComponentValue const&);
Optional<GridFitContent> parse_grid_fit_content(Vector<ComponentValue> const&); Optional<GridFitContent> parse_grid_fit_content(Vector<ComponentValue> const&);
Optional<GridMinMax> parse_min_max(Vector<ComponentValue> const&); Optional<GridMinMax> parse_min_max(Vector<ComponentValue> const&);
@ -278,12 +278,12 @@ private:
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&); Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
Optional<URL> parse_url_function(TokenStream<ComponentValue>&); Optional<URL> parse_url_function(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_url_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_url_value(TokenStream<ComponentValue>&);
Optional<ShapeRadius> parse_shape_radius(TokenStream<ComponentValue>&); Optional<ShapeRadius> parse_shape_radius(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_basic_shape_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_basic_shape_value(TokenStream<ComponentValue>&);
RefPtr<FitContentStyleValue> parse_fit_content_value(TokenStream<ComponentValue>&); RefPtr<FitContentStyleValue const> parse_fit_content_value(TokenStream<ComponentValue>&);
template<typename TElement> template<typename TElement>
Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto parse_position); Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto parse_position);
@ -291,144 +291,144 @@ private:
Optional<Vector<AngularColorStopListElement>> parse_angular_color_stop_list(TokenStream<ComponentValue>&); Optional<Vector<AngularColorStopListElement>> parse_angular_color_stop_list(TokenStream<ComponentValue>&);
Optional<InterpolationMethod> parse_interpolation_method(TokenStream<ComponentValue>&); Optional<InterpolationMethod> parse_interpolation_method(TokenStream<ComponentValue>&);
RefPtr<LinearGradientStyleValue> parse_linear_gradient_function(TokenStream<ComponentValue>&); RefPtr<LinearGradientStyleValue const> parse_linear_gradient_function(TokenStream<ComponentValue>&);
RefPtr<ConicGradientStyleValue> parse_conic_gradient_function(TokenStream<ComponentValue>&); RefPtr<ConicGradientStyleValue const> parse_conic_gradient_function(TokenStream<ComponentValue>&);
RefPtr<RadialGradientStyleValue> parse_radial_gradient_function(TokenStream<ComponentValue>&); RefPtr<RadialGradientStyleValue const> parse_radial_gradient_function(TokenStream<ComponentValue>&);
ParseErrorOr<NonnullRefPtr<CSSStyleValue>> parse_css_value(PropertyID, TokenStream<ComponentValue>&, Optional<String> original_source_text = {}); ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> parse_css_value(PropertyID, TokenStream<ComponentValue>&, Optional<String> original_source_text = {});
ParseErrorOr<NonnullRefPtr<CSSStyleValue>> parse_descriptor_value(AtRuleID, DescriptorID, TokenStream<ComponentValue>&); ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> parse_descriptor_value(AtRuleID, DescriptorID, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_css_value_for_property(PropertyID, TokenStream<ComponentValue>&);
struct PropertyAndValue { struct PropertyAndValue {
PropertyID property; PropertyID property;
RefPtr<CSSStyleValue> style_value; RefPtr<CSSStyleValue const> style_value;
}; };
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&); Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_builtin_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_builtin_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_calculated_value(ComponentValue const&); RefPtr<CSSStyleValue const> parse_calculated_value(ComponentValue const&);
Optional<FlyString> parse_custom_ident(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist); Optional<FlyString> parse_custom_ident(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist);
RefPtr<CustomIdentStyleValue> parse_custom_ident_value(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist); RefPtr<CustomIdentStyleValue const> parse_custom_ident_value(TokenStream<ComponentValue>&, ReadonlySpan<StringView> blacklist);
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp) // NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
RefPtr<CalculationNode> parse_math_function(Function const&, CalculationContext const&); RefPtr<CalculationNode> parse_math_function(Function const&, CalculationContext const&);
RefPtr<CalculationNode> parse_a_calc_function_node(Function const&, CalculationContext const&); RefPtr<CalculationNode> parse_a_calc_function_node(Function const&, CalculationContext const&);
RefPtr<CSSStyleValue> parse_keyword_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_keyword_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_hue_none_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_hue_none_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_solidus_and_alpha_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_solidus_and_alpha_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_rgb_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_rgb_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_hsl_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_hsl_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_hwb_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_hwb_color_value(TokenStream<ComponentValue>&);
Optional<Array<RefPtr<CSSStyleValue>, 4>> parse_lab_like_color_value(TokenStream<ComponentValue>&, StringView); Optional<Array<RefPtr<CSSStyleValue const>, 4>> parse_lab_like_color_value(TokenStream<ComponentValue>&, StringView);
RefPtr<CSSStyleValue> parse_lab_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_lab_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_oklab_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_oklab_color_value(TokenStream<ComponentValue>&);
Optional<Array<RefPtr<CSSStyleValue>, 4>> parse_lch_like_color_value(TokenStream<ComponentValue>&, StringView); Optional<Array<RefPtr<CSSStyleValue const>, 4>> parse_lch_like_color_value(TokenStream<ComponentValue>&, StringView);
RefPtr<CSSStyleValue> parse_lch_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_lch_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_oklch_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_oklch_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_color_function(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_color_function(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_light_dark_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_light_dark_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_color_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_color_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_color_scheme_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_color_scheme_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_counter_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_counter_value(TokenStream<ComponentValue>&);
enum class AllowReversed { enum class AllowReversed {
No, No,
Yes, Yes,
}; };
RefPtr<CSSStyleValue> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed); RefPtr<CSSStyleValue const> parse_counter_definitions_value(TokenStream<ComponentValue>&, AllowReversed, i32 default_value_if_not_reversed);
RefPtr<CSSStyleValue> parse_rect_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_rect_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_ratio_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_ratio_value(TokenStream<ComponentValue>&);
RefPtr<StringStyleValue> parse_string_value(TokenStream<ComponentValue>&); RefPtr<StringStyleValue const> parse_string_value(TokenStream<ComponentValue>&);
RefPtr<AbstractImageStyleValue> parse_image_value(TokenStream<ComponentValue>&); RefPtr<AbstractImageStyleValue const> parse_image_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_paint_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_paint_value(TokenStream<ComponentValue>&);
enum class PositionParsingMode { enum class PositionParsingMode {
Normal, Normal,
BackgroundPosition, BackgroundPosition,
}; };
RefPtr<PositionStyleValue> parse_position_value(TokenStream<ComponentValue>&, PositionParsingMode = PositionParsingMode::Normal); RefPtr<PositionStyleValue const> parse_position_value(TokenStream<ComponentValue>&, PositionParsingMode = PositionParsingMode::Normal);
RefPtr<CSSStyleValue> parse_filter_value_list_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_filter_value_list_value(TokenStream<ComponentValue>&);
RefPtr<StringStyleValue> parse_opentype_tag_value(TokenStream<ComponentValue>&); RefPtr<StringStyleValue const> parse_opentype_tag_value(TokenStream<ComponentValue>&);
RefPtr<FontSourceStyleValue> parse_font_source_value(TokenStream<ComponentValue>&); RefPtr<FontSourceStyleValue const> parse_font_source_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_angle_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_angle_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_angle_percentage_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_angle_percentage_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_flex_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_flex_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_frequency_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_frequency_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_frequency_percentage_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_frequency_percentage_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_integer_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_integer_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_length_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_length_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_length_percentage_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_length_percentage_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_number_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_number_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_number_percentage_value(TokenStream<ComponentValue>& tokens); RefPtr<CSSStyleValue const> parse_number_percentage_value(TokenStream<ComponentValue>& tokens);
RefPtr<CSSStyleValue> parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens); RefPtr<CSSStyleValue const> parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens);
RefPtr<CSSStyleValue> parse_percentage_value(TokenStream<ComponentValue>& tokens); RefPtr<CSSStyleValue const> parse_percentage_value(TokenStream<ComponentValue>& tokens);
RefPtr<CSSStyleValue> parse_resolution_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_resolution_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_time_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_time_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_time_percentage_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_time_percentage_value(TokenStream<ComponentValue>&);
using ParseFunction = AK::Function<RefPtr<CSSStyleValue>(TokenStream<ComponentValue>&)>; using ParseFunction = AK::Function<RefPtr<CSSStyleValue const>(TokenStream<ComponentValue>&)>;
RefPtr<CSSStyleValue> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction); RefPtr<CSSStyleValue const> parse_comma_separated_value_list(TokenStream<ComponentValue>&, ParseFunction);
RefPtr<CSSStyleValue> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_simple_comma_separated_value_list(PropertyID, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_all_as_single_keyword_value(TokenStream<ComponentValue>&, Keyword); RefPtr<CSSStyleValue const> parse_all_as_single_keyword_value(TokenStream<ComponentValue>&, Keyword);
RefPtr<CSSStyleValue> parse_aspect_ratio_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_aspect_ratio_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_background_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_background_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID); RefPtr<CSSStyleValue const> parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>&, PropertyID);
RefPtr<CSSStyleValue> parse_single_background_repeat_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_single_background_repeat_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_single_background_size_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_single_background_size_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_border_value(PropertyID, TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_border_value(PropertyID, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_border_radius_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_border_radius_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_border_radius_shorthand_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_columns_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_columns_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_content_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_content_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_counter_increment_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_counter_increment_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_counter_reset_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_counter_reset_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_counter_set_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_counter_set_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_cursor_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_cursor_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_display_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_display_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_flex_shorthand_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_flex_shorthand_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_flex_flow_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_family_name_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_family_name_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_family_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_family_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_language_override_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_language_override_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_feature_settings_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_feature_settings_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variation_settings_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variation_settings_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant_alternates_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant_alternates_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant_east_asian_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant_east_asian_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant_emoji(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant_emoji(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant_ligatures_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant_ligatures_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_font_variant_numeric_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_font_variant_numeric_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_list_style_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_list_style_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_math_depth_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_math_depth_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_overflow_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_overflow_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_place_content_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_place_content_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_place_items_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_place_items_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_place_self_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_place_self_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_quotes_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_quotes_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_scrollbar_gutter_value(TokenStream<ComponentValue>&);
enum class AllowInsetKeyword { enum class AllowInsetKeyword {
No, No,
Yes, Yes,
}; };
RefPtr<CSSStyleValue> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword); RefPtr<CSSStyleValue const> parse_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
RefPtr<CSSStyleValue> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword); RefPtr<CSSStyleValue const> parse_single_shadow_value(TokenStream<ComponentValue>&, AllowInsetKeyword);
RefPtr<CSSStyleValue> parse_text_decoration_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_text_decoration_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_text_decoration_line_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_text_decoration_line_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_rotate_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_rotate_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_stroke_dasharray_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_stroke_dasharray_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_easing_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_easing_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_transform_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_transform_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_transform_origin_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_transform_origin_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_transition_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_transition_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_translate_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_translate_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_scale_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_scale_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_track_size_list(TokenStream<ComponentValue>&, bool allow_separate_line_name_blocks = false); RefPtr<CSSStyleValue const> parse_grid_track_size_list(TokenStream<ComponentValue>&, bool allow_separate_line_name_blocks = false);
RefPtr<CSSStyleValue> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_auto_track_sizes(TokenStream<ComponentValue>&);
RefPtr<GridAutoFlowStyleValue> parse_grid_auto_flow_value(TokenStream<ComponentValue>&); RefPtr<GridAutoFlowStyleValue const> parse_grid_auto_flow_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_track_size_list_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
RefPtr<GridTrackPlacementStyleValue> parse_grid_track_placement(TokenStream<ComponentValue>&); RefPtr<GridTrackPlacementStyleValue const> parse_grid_track_placement(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_track_placement_shorthand_value(PropertyID, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_template_areas_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_template_areas_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_area_shorthand_value(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_grid_shorthand_value(TokenStream<ComponentValue>&); RefPtr<CSSStyleValue const> parse_grid_shorthand_value(TokenStream<ComponentValue>&);
RefPtr<CalculationNode> convert_to_calculation_node(CalcParsing::Node const&, CalculationContext const&); RefPtr<CalculationNode> convert_to_calculation_node(CalcParsing::Node const&, CalculationContext const&);
RefPtr<CalculationNode> parse_a_calculation(Vector<ComponentValue> const&, CalculationContext const&); RefPtr<CalculationNode> parse_a_calculation(Vector<ComponentValue> const&, CalculationContext const&);
@ -457,7 +457,7 @@ private:
OwnPtr<BooleanExpression> parse_supports_feature(TokenStream<ComponentValue>&); OwnPtr<BooleanExpression> parse_supports_feature(TokenStream<ComponentValue>&);
NonnullRefPtr<CSSStyleValue> resolve_unresolved_style_value(DOM::Element&, Optional<PseudoElement>, PropertyID, UnresolvedStyleValue const&); NonnullRefPtr<CSSStyleValue const> resolve_unresolved_style_value(DOM::Element&, Optional<PseudoElement>, PropertyID, UnresolvedStyleValue const&);
bool expand_variables(DOM::Element&, Optional<PseudoElement>, FlyString const& property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest); bool expand_variables(DOM::Element&, Optional<PseudoElement>, FlyString const& property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
bool expand_unresolved_values(DOM::Element&, FlyString const& property_name, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest); bool expand_unresolved_values(DOM::Element&, FlyString const& property_name, TokenStream<ComponentValue>& source, Vector<ComponentValue>& dest);
bool substitute_attr_function(DOM::Element& element, FlyString const& property_name, Function const& attr_function, Vector<ComponentValue>& dest); bool substitute_attr_function(DOM::Element& element, FlyString const& property_name, Function const& attr_function, Vector<ComponentValue>& dest);
@ -523,8 +523,8 @@ namespace Web {
GC::Ref<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::Parser::ParsingParams const&, StringView, Optional<::URL::URL> location = {}, Vector<NonnullRefPtr<CSS::MediaQuery>> = {}); GC::Ref<CSS::CSSStyleSheet> parse_css_stylesheet(CSS::Parser::ParsingParams const&, StringView, Optional<::URL::URL> location = {}, Vector<NonnullRefPtr<CSS::MediaQuery>> = {});
CSS::Parser::Parser::PropertiesAndCustomProperties parse_css_style_attribute(CSS::Parser::ParsingParams const&, StringView); CSS::Parser::Parser::PropertiesAndCustomProperties parse_css_style_attribute(CSS::Parser::ParsingParams const&, StringView);
Vector<CSS::Descriptor> parse_css_list_of_descriptors(CSS::Parser::ParsingParams const&, CSS::AtRuleID, StringView); Vector<CSS::Descriptor> parse_css_list_of_descriptors(CSS::Parser::ParsingParams const&, CSS::AtRuleID, StringView);
RefPtr<CSS::CSSStyleValue> parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid); RefPtr<CSS::CSSStyleValue const> parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
RefPtr<CSS::CSSStyleValue> parse_css_descriptor(CSS::Parser::ParsingParams const&, CSS::AtRuleID, CSS::DescriptorID, StringView); RefPtr<CSS::CSSStyleValue const> parse_css_descriptor(CSS::Parser::ParsingParams const&, CSS::AtRuleID, CSS::DescriptorID, StringView);
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingParams const&, StringView); Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingParams const&, StringView);
Optional<CSS::SelectorList> parse_selector_for_nested_style_rule(CSS::Parser::ParsingParams const&, StringView); Optional<CSS::SelectorList> parse_selector_for_nested_style_rule(CSS::Parser::ParsingParams const&, StringView);
Optional<CSS::Selector::PseudoElementSelector> parse_pseudo_element_selector(CSS::Parser::ParsingParams const&, StringView); Optional<CSS::Selector::PseudoElementSelector> parse_pseudo_element_selector(CSS::Parser::ParsingParams const&, StringView);

View file

@ -66,7 +66,7 @@ static void remove_property(Vector<PropertyID>& properties, PropertyID property_
properties.remove_first_matching([&](auto it) { return it == property_to_remove; }); properties.remove_first_matching([&](auto it) { return it == property_to_remove; });
} }
RefPtr<CSSStyleValue> Parser::parse_all_as_single_keyword_value(TokenStream<ComponentValue>& tokens, Keyword keyword) RefPtr<CSSStyleValue const> Parser::parse_all_as_single_keyword_value(TokenStream<ComponentValue>& tokens, Keyword keyword)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
tokens.discard_whitespace(); tokens.discard_whitespace();
@ -80,9 +80,9 @@ RefPtr<CSSStyleValue> Parser::parse_all_as_single_keyword_value(TokenStream<Comp
return keyword_value; return keyword_value;
} }
RefPtr<CSSStyleValue> Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream<ComponentValue>& tokens)
{ {
return parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) -> RefPtr<CSSStyleValue> { return parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) -> RefPtr<CSSStyleValue const> {
if (auto value = parse_css_value_for_property(property_id, tokens)) if (auto value = parse_css_value_for_property(property_id, tokens))
return value; return value;
tokens.reconsume_current_input_token(); tokens.reconsume_current_input_token();
@ -90,7 +90,7 @@ RefPtr<CSSStyleValue> Parser::parse_simple_comma_separated_value_list(PropertyID
}); });
} }
RefPtr<CSSStyleValue> Parser::parse_css_value_for_property(PropertyID property_id, TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_css_value_for_property(PropertyID property_id, TokenStream<ComponentValue>& tokens)
{ {
return parse_css_value_for_properties({ &property_id, 1 }, tokens) return parse_css_value_for_properties({ &property_id, 1 }, tokens)
.map([](auto& it) { return it.style_value; }) .map([](auto& it) { return it.style_value; })
@ -355,7 +355,7 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
return OptionalNone {}; return OptionalNone {};
} }
Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& unprocessed_tokens, Optional<String> original_source_text) Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_css_value(PropertyID property_id, TokenStream<ComponentValue>& unprocessed_tokens, Optional<String> original_source_text)
{ {
auto context_guard = push_temporary_value_parsing_context(property_id); auto context_guard = push_temporary_value_parsing_context(property_id);
@ -763,7 +763,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_css_value(Prope
return { ShorthandStyleValue::create(property_id, move(longhand_properties), move(longhand_values)) }; return { ShorthandStyleValue::create(property_id, move(longhand_properties), move(longhand_values)) };
} }
RefPtr<CSSStyleValue> Parser::parse_color_scheme_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_color_scheme_value(TokenStream<ComponentValue>& tokens)
{ {
// normal | [ light | dark | <custom-ident> ]+ && only? // normal | [ light | dark | <custom-ident> ]+ && only?
@ -828,7 +828,7 @@ RefPtr<CSSStyleValue> Parser::parse_color_scheme_value(TokenStream<ComponentValu
return ColorSchemeStyleValue::create(schemes, only); return ColorSchemeStyleValue::create(schemes, only);
} }
RefPtr<CSSStyleValue> Parser::parse_counter_definitions_value(TokenStream<ComponentValue>& tokens, AllowReversed allow_reversed, i32 default_value_if_not_reversed) RefPtr<CSSStyleValue const> Parser::parse_counter_definitions_value(TokenStream<ComponentValue>& tokens, AllowReversed allow_reversed, i32 default_value_if_not_reversed)
{ {
// If AllowReversed is Yes, parses: // If AllowReversed is Yes, parses:
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ // [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+
@ -889,7 +889,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_definitions_value(TokenStream<Compon
} }
// https://drafts.csswg.org/css-lists-3/#propdef-counter-increment // https://drafts.csswg.org/css-lists-3/#propdef-counter-increment
RefPtr<CSSStyleValue> Parser::parse_counter_increment_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_counter_increment_value(TokenStream<ComponentValue>& tokens)
{ {
// [ <counter-name> <integer>? ]+ | none // [ <counter-name> <integer>? ]+ | none
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
@ -899,7 +899,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_increment_value(TokenStream<Componen
} }
// https://drafts.csswg.org/css-lists-3/#propdef-counter-reset // https://drafts.csswg.org/css-lists-3/#propdef-counter-reset
RefPtr<CSSStyleValue> Parser::parse_counter_reset_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_counter_reset_value(TokenStream<ComponentValue>& tokens)
{ {
// [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ | none // [ <counter-name> <integer>? | <reversed-counter-name> <integer>? ]+ | none
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
@ -909,7 +909,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_reset_value(TokenStream<ComponentVal
} }
// https://drafts.csswg.org/css-lists-3/#propdef-counter-set // https://drafts.csswg.org/css-lists-3/#propdef-counter-set
RefPtr<CSSStyleValue> Parser::parse_counter_set_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_counter_set_value(TokenStream<ComponentValue>& tokens)
{ {
// [ <counter-name> <integer>? ]+ | none // [ <counter-name> <integer>? ]+ | none
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
@ -919,7 +919,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_set_value(TokenStream<ComponentValue
} }
// https://drafts.csswg.org/css-ui-3/#cursor // https://drafts.csswg.org/css-ui-3/#cursor
RefPtr<CSSStyleValue> Parser::parse_cursor_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_cursor_value(TokenStream<ComponentValue>& tokens)
{ {
// [ [<url> [<x> <y>]?,]* <built-in-cursor> ] // [ [<url> [<x> <y>]?,]* <built-in-cursor> ]
// So, any number of custom cursor definitions, and then a mandatory cursor name keyword, all comma-separated. // So, any number of custom cursor definitions, and then a mandatory cursor name keyword, all comma-separated.
@ -985,11 +985,11 @@ RefPtr<CSSStyleValue> Parser::parse_cursor_value(TokenStream<ComponentValue>& to
} }
// https://www.w3.org/TR/css-sizing-4/#aspect-ratio // https://www.w3.org/TR/css-sizing-4/#aspect-ratio
RefPtr<CSSStyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_aspect_ratio_value(TokenStream<ComponentValue>& tokens)
{ {
// `auto || <ratio>` // `auto || <ratio>`
RefPtr<CSSStyleValue> auto_value; RefPtr<CSSStyleValue const> auto_value;
RefPtr<CSSStyleValue> ratio_value; RefPtr<CSSStyleValue const> ratio_value;
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
while (tokens.has_next_token()) { while (tokens.has_next_token()) {
@ -1034,7 +1034,7 @@ RefPtr<CSSStyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValu
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_background_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_background_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -1052,7 +1052,7 @@ RefPtr<CSSStyleValue> Parser::parse_background_value(TokenStream<ComponentValue>
StyleValueVector background_attachments; StyleValueVector background_attachments;
StyleValueVector background_clips; StyleValueVector background_clips;
StyleValueVector background_origins; StyleValueVector background_origins;
RefPtr<CSSStyleValue> background_color; RefPtr<CSSStyleValue const> background_color;
auto initial_background_image = property_initial_value(PropertyID::BackgroundImage); auto initial_background_image = property_initial_value(PropertyID::BackgroundImage);
auto initial_background_position_x = property_initial_value(PropertyID::BackgroundPositionX); auto initial_background_position_x = property_initial_value(PropertyID::BackgroundPositionX);
@ -1065,14 +1065,14 @@ RefPtr<CSSStyleValue> Parser::parse_background_value(TokenStream<ComponentValue>
auto initial_background_color = property_initial_value(PropertyID::BackgroundColor); auto initial_background_color = property_initial_value(PropertyID::BackgroundColor);
// Per-layer values // Per-layer values
RefPtr<CSSStyleValue> background_image; RefPtr<CSSStyleValue const> background_image;
RefPtr<CSSStyleValue> background_position_x; RefPtr<CSSStyleValue const> background_position_x;
RefPtr<CSSStyleValue> background_position_y; RefPtr<CSSStyleValue const> background_position_y;
RefPtr<CSSStyleValue> background_size; RefPtr<CSSStyleValue const> background_size;
RefPtr<CSSStyleValue> background_repeat; RefPtr<CSSStyleValue const> background_repeat;
RefPtr<CSSStyleValue> background_attachment; RefPtr<CSSStyleValue const> background_attachment;
RefPtr<CSSStyleValue> background_clip; RefPtr<CSSStyleValue const> background_clip;
RefPtr<CSSStyleValue> background_origin; RefPtr<CSSStyleValue const> background_origin;
bool has_multiple_layers = false; bool has_multiple_layers = false;
// BackgroundSize is always parsed as part of BackgroundPosition, so we don't include it here. // BackgroundSize is always parsed as part of BackgroundPosition, so we don't include it here.
@ -1286,7 +1286,7 @@ static Optional<LengthPercentage> style_value_to_length_percentage(auto value)
return {}; return {};
} }
RefPtr<CSSStyleValue> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property) RefPtr<CSSStyleValue const> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property)
{ {
Optional<PositionEdge> relative_edge {}; Optional<PositionEdge> relative_edge {};
@ -1343,7 +1343,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_position_x_or_y_value(Toke
return EdgeStyleValue::create(relative_edge, {}); return EdgeStyleValue::create(relative_edge, {});
} }
RefPtr<CSSStyleValue> Parser::parse_single_background_repeat_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_single_background_repeat_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -1403,11 +1403,11 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_repeat_value(TokenStream<C
return BackgroundRepeatStyleValue::create(x_repeat.value(), y_repeat.value()); return BackgroundRepeatStyleValue::create(x_repeat.value(), y_repeat.value());
} }
RefPtr<CSSStyleValue> Parser::parse_single_background_size_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_single_background_size_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto get_length_percentage = [](CSSStyleValue& style_value) -> Optional<LengthPercentage> { auto get_length_percentage = [](CSSStyleValue const& style_value) -> Optional<LengthPercentage> {
if (style_value.has_auto()) if (style_value.has_auto())
return LengthPercentage { Length::make_auto() }; return LengthPercentage { Length::make_auto() };
if (style_value.is_percentage()) if (style_value.is_percentage())
@ -1451,11 +1451,11 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_size_value(TokenStream<Com
return BackgroundSizeStyleValue::create(x_size.release_value(), y_size.release_value()); return BackgroundSizeStyleValue::create(x_size.release_value(), y_size.release_value());
} }
RefPtr<CSSStyleValue> Parser::parse_border_value(PropertyID property_id, TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_border_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
{ {
RefPtr<CSSStyleValue> border_width; RefPtr<CSSStyleValue const> border_width;
RefPtr<CSSStyleValue> border_color; RefPtr<CSSStyleValue const> border_color;
RefPtr<CSSStyleValue> border_style; RefPtr<CSSStyleValue const> border_style;
auto color_property = PropertyID::Invalid; auto color_property = PropertyID::Invalid;
auto style_property = PropertyID::Invalid; auto style_property = PropertyID::Invalid;
@ -1528,7 +1528,7 @@ RefPtr<CSSStyleValue> Parser::parse_border_value(PropertyID property_id, TokenSt
{ border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull() }); { border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_border_radius_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_border_radius_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.remaining_token_count() == 2) { if (tokens.remaining_token_count() == 2) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -1552,7 +1552,7 @@ RefPtr<CSSStyleValue> Parser::parse_border_radius_value(TokenStream<ComponentVal
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_border_radius_shorthand_value(TokenStream<ComponentValue>& tokens)
{ {
auto top_left = [&](Vector<LengthPercentage>& radii) { return radii[0]; }; auto top_left = [&](Vector<LengthPercentage>& radii) { return radii[0]; };
auto top_right = [&](Vector<LengthPercentage>& radii) { auto top_right = [&](Vector<LengthPercentage>& radii) {
@ -1642,13 +1642,13 @@ RefPtr<CSSStyleValue> Parser::parse_border_radius_shorthand_value(TokenStream<Co
{ move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius) }); { move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius) });
} }
RefPtr<CSSStyleValue> Parser::parse_columns_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_columns_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.remaining_token_count() > 2) if (tokens.remaining_token_count() > 2)
return nullptr; return nullptr;
RefPtr<CSSStyleValue> column_count; RefPtr<CSSStyleValue const> column_count;
RefPtr<CSSStyleValue> column_width; RefPtr<CSSStyleValue const> column_width;
Vector<PropertyID> remaining_longhands { PropertyID::ColumnCount, PropertyID::ColumnWidth }; Vector<PropertyID> remaining_longhands { PropertyID::ColumnCount, PropertyID::ColumnWidth };
int found_autos = 0; int found_autos = 0;
@ -1710,7 +1710,7 @@ RefPtr<CSSStyleValue> Parser::parse_columns_value(TokenStream<ComponentValue>& t
{ column_count.release_nonnull(), column_width.release_nonnull() }); { column_count.release_nonnull(), column_width.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword) RefPtr<CSSStyleValue const> Parser::parse_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
{ {
// "none" // "none"
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
@ -1721,18 +1721,18 @@ RefPtr<CSSStyleValue> Parser::parse_shadow_value(TokenStream<ComponentValue>& to
}); });
} }
RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword) RefPtr<CSSStyleValue const> Parser::parse_single_shadow_value(TokenStream<ComponentValue>& tokens, AllowInsetKeyword allow_inset_keyword)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
RefPtr<CSSStyleValue> color; RefPtr<CSSStyleValue const> color;
RefPtr<CSSStyleValue> offset_x; RefPtr<CSSStyleValue const> offset_x;
RefPtr<CSSStyleValue> offset_y; RefPtr<CSSStyleValue const> offset_y;
RefPtr<CSSStyleValue> blur_radius; RefPtr<CSSStyleValue const> blur_radius;
RefPtr<CSSStyleValue> spread_distance; RefPtr<CSSStyleValue const> spread_distance;
Optional<ShadowPlacement> placement; Optional<ShadowPlacement> placement;
auto possibly_dynamic_length = [&](ComponentValue const& token) -> RefPtr<CSSStyleValue> { auto possibly_dynamic_length = [&](ComponentValue const& token) -> RefPtr<CSSStyleValue const> {
auto tokens = TokenStream<ComponentValue>::of_single_token(token); auto tokens = TokenStream<ComponentValue>::of_single_token(token);
auto maybe_length = parse_length(tokens); auto maybe_length = parse_length(tokens);
if (!maybe_length.has_value()) if (!maybe_length.has_value())
@ -1826,7 +1826,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentVal
return ShadowStyleValue::create(color.release_nonnull(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value()); return ShadowStyleValue::create(color.release_nonnull(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value());
} }
RefPtr<CSSStyleValue> Parser::parse_rotate_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_rotate_value(TokenStream<ComponentValue>& tokens)
{ {
// Value: none | <angle> | [ x | y | z | <number>{3} ] && <angle> // Value: none | <angle> | [ x | y | z | <number>{3} ] && <angle>
@ -1915,7 +1915,7 @@ RefPtr<CSSStyleValue> Parser::parse_rotate_value(TokenStream<ComponentValue>& to
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_stroke_dasharray_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_stroke_dasharray_value(TokenStream<ComponentValue>& tokens)
{ {
// https://svgwg.org/svg2-draft/painting.html#StrokeDashing // https://svgwg.org/svg2-draft/painting.html#StrokeDashing
// Value: none | <dasharray> // Value: none | <dasharray>
@ -1947,7 +1947,7 @@ RefPtr<CSSStyleValue> Parser::parse_stroke_dasharray_value(TokenStream<Component
return StyleValueList::create(move(dashes), StyleValueList::Separator::Comma); return StyleValueList::create(move(dashes), StyleValueList::Separator::Comma);
} }
RefPtr<CSSStyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_content_value(TokenStream<ComponentValue>& tokens)
{ {
// FIXME: `content` accepts several kinds of function() type, which we don't handle in property_accepts_value() yet. // FIXME: `content` accepts several kinds of function() type, which we don't handle in property_accepts_value() yet.
@ -2016,7 +2016,7 @@ RefPtr<CSSStyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& t
} }
// https://www.w3.org/TR/css-display-3/#the-display-properties // https://www.w3.org/TR/css-display-3/#the-display-properties
RefPtr<CSSStyleValue> Parser::parse_display_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_display_value(TokenStream<ComponentValue>& tokens)
{ {
auto parse_single_component_display = [this](TokenStream<ComponentValue>& tokens) -> Optional<Display> { auto parse_single_component_display = [this](TokenStream<ComponentValue>& tokens) -> Optional<Display> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -2146,11 +2146,11 @@ RefPtr<CSSStyleValue> Parser::parse_display_value(TokenStream<ComponentValue>& t
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_flex_shorthand_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_flex_shorthand_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto make_flex_shorthand = [&](NonnullRefPtr<CSSStyleValue> flex_grow, NonnullRefPtr<CSSStyleValue> flex_shrink, NonnullRefPtr<CSSStyleValue> flex_basis) { auto make_flex_shorthand = [&](NonnullRefPtr<CSSStyleValue const> flex_grow, NonnullRefPtr<CSSStyleValue const> flex_shrink, NonnullRefPtr<CSSStyleValue const> flex_basis) {
transaction.commit(); transaction.commit();
return ShorthandStyleValue::create(PropertyID::Flex, return ShorthandStyleValue::create(PropertyID::Flex,
{ PropertyID::FlexGrow, PropertyID::FlexShrink, PropertyID::FlexBasis }, { PropertyID::FlexGrow, PropertyID::FlexShrink, PropertyID::FlexBasis },
@ -2191,9 +2191,9 @@ RefPtr<CSSStyleValue> Parser::parse_flex_shorthand_value(TokenStream<ComponentVa
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> flex_grow; RefPtr<CSSStyleValue const> flex_grow;
RefPtr<CSSStyleValue> flex_shrink; RefPtr<CSSStyleValue const> flex_shrink;
RefPtr<CSSStyleValue> flex_basis; RefPtr<CSSStyleValue const> flex_basis;
// NOTE: FlexGrow has to be before FlexBasis. `0` is a valid FlexBasis, but only // NOTE: FlexGrow has to be before FlexBasis. `0` is a valid FlexBasis, but only
// if FlexGrow (along with optional FlexShrink) have already been specified. // if FlexGrow (along with optional FlexShrink) have already been specified.
@ -2240,10 +2240,10 @@ RefPtr<CSSStyleValue> Parser::parse_flex_shorthand_value(TokenStream<ComponentVa
return make_flex_shorthand(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull()); return make_flex_shorthand(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
} }
RefPtr<CSSStyleValue> Parser::parse_flex_flow_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_flex_flow_value(TokenStream<ComponentValue>& tokens)
{ {
RefPtr<CSSStyleValue> flex_direction; RefPtr<CSSStyleValue const> flex_direction;
RefPtr<CSSStyleValue> flex_wrap; RefPtr<CSSStyleValue const> flex_wrap;
auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap }; auto remaining_longhands = Vector { PropertyID::FlexDirection, PropertyID::FlexWrap };
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -2280,15 +2280,15 @@ RefPtr<CSSStyleValue> Parser::parse_flex_flow_value(TokenStream<ComponentValue>&
{ flex_direction.release_nonnull(), flex_wrap.release_nonnull() }); { flex_direction.release_nonnull(), flex_wrap.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_value(TokenStream<ComponentValue>& tokens)
{ {
RefPtr<CSSStyleValue> font_width; RefPtr<CSSStyleValue const> font_width;
RefPtr<CSSStyleValue> font_style; RefPtr<CSSStyleValue const> font_style;
RefPtr<CSSStyleValue> font_weight; RefPtr<CSSStyleValue const> font_weight;
RefPtr<CSSStyleValue> font_size; RefPtr<CSSStyleValue const> font_size;
RefPtr<CSSStyleValue> line_height; RefPtr<CSSStyleValue const> line_height;
RefPtr<CSSStyleValue> font_families; RefPtr<CSSStyleValue const> font_families;
RefPtr<CSSStyleValue> font_variant; RefPtr<CSSStyleValue const> font_variant;
// FIXME: Handle system fonts. (caption, icon, menu, message-box, small-caption, status-bar) // FIXME: Handle system fonts. (caption, icon, menu, message-box, small-caption, status-bar)
@ -2443,12 +2443,12 @@ RefPtr<CSSStyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& toke
} }
// https://drafts.csswg.org/css-fonts-4/#font-family-prop // https://drafts.csswg.org/css-fonts-4/#font-family-prop
RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_family_value(TokenStream<ComponentValue>& tokens)
{ {
// [ <family-name> | <generic-family> ]# // [ <family-name> | <generic-family> ]#
// FIXME: We currently require font-family to always be a list, even with one item. // FIXME: We currently require font-family to always be a list, even with one item.
// Maybe change that? // Maybe change that?
auto result = parse_comma_separated_value_list(tokens, [this](auto& inner_tokens) -> RefPtr<CSSStyleValue> { auto result = parse_comma_separated_value_list(tokens, [this](auto& inner_tokens) -> RefPtr<CSSStyleValue const> {
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
// <generic-family> // <generic-family>
@ -2475,7 +2475,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue
return StyleValueList::create(StyleValueVector { result.release_nonnull() }, StyleValueList::Separator::Comma); return StyleValueList::create(StyleValueVector { result.release_nonnull() }, StyleValueList::Separator::Comma);
} }
RefPtr<CSSStyleValue> Parser::parse_font_language_override_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_language_override_value(TokenStream<ComponentValue>& tokens)
{ {
// https://drafts.csswg.org/css-fonts/#propdef-font-language-override // https://drafts.csswg.org/css-fonts/#propdef-font-language-override
// This is `normal | <string>` but with the constraint that the string has to be 4 characters long: // This is `normal | <string>` but with the constraint that the string has to be 4 characters long:
@ -2507,7 +2507,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_language_override_value(TokenStream<Com
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_font_feature_settings_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_feature_settings_value(TokenStream<ComponentValue>& tokens)
{ {
// https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings // https://drafts.csswg.org/css-fonts/#propdef-font-feature-settings
// normal | <feature-tag-value># // normal | <feature-tag-value>#
@ -2525,14 +2525,14 @@ RefPtr<CSSStyleValue> Parser::parse_font_feature_settings_value(TokenStream<Comp
// value for that axis." // value for that axis."
// So, we deduplicate them here using a HashSet. // So, we deduplicate them here using a HashSet.
OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue>> feature_tags_map; OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue const>> feature_tags_map;
for (auto const& values : tag_values) { for (auto const& values : tag_values) {
// <feature-tag-value> = <opentype-tag> [ <integer [0,∞]> | on | off ]? // <feature-tag-value> = <opentype-tag> [ <integer [0,∞]> | on | off ]?
TokenStream tag_tokens { values }; TokenStream tag_tokens { values };
tag_tokens.discard_whitespace(); tag_tokens.discard_whitespace();
auto opentype_tag = parse_opentype_tag_value(tag_tokens); auto opentype_tag = parse_opentype_tag_value(tag_tokens);
tag_tokens.discard_whitespace(); tag_tokens.discard_whitespace();
RefPtr<CSSStyleValue> value; RefPtr<CSSStyleValue const> value;
if (tag_tokens.has_next_token()) { if (tag_tokens.has_next_token()) {
if (auto integer = parse_integer_value(tag_tokens)) { if (auto integer = parse_integer_value(tag_tokens)) {
if (integer->is_integer() && integer->as_integer().value() < 0) if (integer->is_integer() && integer->as_integer().value() < 0)
@ -2580,7 +2580,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_feature_settings_value(TokenStream<Comp
return StyleValueList::create(move(feature_tags), StyleValueList::Separator::Comma); return StyleValueList::create(move(feature_tags), StyleValueList::Separator::Comma);
} }
RefPtr<CSSStyleValue> Parser::parse_font_variation_settings_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variation_settings_value(TokenStream<ComponentValue>& tokens)
{ {
// https://drafts.csswg.org/css-fonts/#propdef-font-variation-settings // https://drafts.csswg.org/css-fonts/#propdef-font-variation-settings
// normal | [ <opentype-tag> <number>]# // normal | [ <opentype-tag> <number>]#
@ -2597,7 +2597,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variation_settings_value(TokenStream<Co
// previous value for that axis. This deduplication is observable by accessing the computed value of this property." // previous value for that axis. This deduplication is observable by accessing the computed value of this property."
// So, we deduplicate them here using a HashSet. // So, we deduplicate them here using a HashSet.
OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue>> axis_tags_map; OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue const>> axis_tags_map;
for (auto const& values : tag_values) { for (auto const& values : tag_values) {
TokenStream tag_tokens { values }; TokenStream tag_tokens { values };
tag_tokens.discard_whitespace(); tag_tokens.discard_whitespace();
@ -2626,7 +2626,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variation_settings_value(TokenStream<Co
return StyleValueList::create(move(axis_tags), StyleValueList::Separator::Comma); return StyleValueList::create(move(axis_tags), StyleValueList::Separator::Comma);
} }
RefPtr<CSSStyleValue> Parser::parse_font_variant(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variant(TokenStream<ComponentValue>& tokens)
{ {
// 6.11 https://drafts.csswg.org/css-fonts/#propdef-font-variant // 6.11 https://drafts.csswg.org/css-fonts/#propdef-font-variant
// normal | none | // normal | none |
@ -2655,10 +2655,10 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant(TokenStream<ComponentValue>& to
bool has_east_asian_variant = false; bool has_east_asian_variant = false;
bool has_east_asian_width = false; bool has_east_asian_width = false;
bool has_east_asian_ruby = false; bool has_east_asian_ruby = false;
RefPtr<CSSStyleValue> alternates_value {}; RefPtr<CSSStyleValue const> alternates_value {};
RefPtr<CSSStyleValue> caps_value {}; RefPtr<CSSStyleValue const> caps_value {};
RefPtr<CSSStyleValue> emoji_value {}; RefPtr<CSSStyleValue const> emoji_value {};
RefPtr<CSSStyleValue> position_value {}; RefPtr<CSSStyleValue const> position_value {};
StyleValueVector east_asian_values; StyleValueVector east_asian_values;
StyleValueVector ligatures_values; StyleValueVector ligatures_values;
StyleValueVector numeric_values; StyleValueVector numeric_values;
@ -2817,7 +2817,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant(TokenStream<ComponentValue>& to
} }
auto normal_value = CSSKeywordValue::create(Keyword::Normal); auto normal_value = CSSKeywordValue::create(Keyword::Normal);
auto resolve_list = [&normal_value](StyleValueVector values) -> NonnullRefPtr<CSSStyleValue> { auto resolve_list = [&normal_value](StyleValueVector values) -> NonnullRefPtr<CSSStyleValue const> {
if (values.is_empty()) if (values.is_empty())
return normal_value; return normal_value;
if (values.size() == 1) if (values.size() == 1)
@ -2862,7 +2862,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant(TokenStream<ComponentValue>& to
}); });
} }
RefPtr<CSSStyleValue> Parser::parse_font_variant_alternates_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variant_alternates_value(TokenStream<ComponentValue>& tokens)
{ {
// 6.8 https://drafts.csswg.org/css-fonts/#font-variant-alternates-prop // 6.8 https://drafts.csswg.org/css-fonts/#font-variant-alternates-prop
// normal | // normal |
@ -2887,7 +2887,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_alternates_value(TokenStream<Co
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_font_variant_east_asian_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variant_east_asian_value(TokenStream<ComponentValue>& tokens)
{ {
// 6.10 https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian // 6.10 https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian
// normal | [ <east-asian-variant-values> || <east-asian-width-values> || ruby ] // normal | [ <east-asian-variant-values> || <east-asian-width-values> || ruby ]
@ -2899,9 +2899,9 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_east_asian_value(TokenStream<Co
return normal.release_nonnull(); return normal.release_nonnull();
// [ <east-asian-variant-values> || <east-asian-width-values> || ruby ] // [ <east-asian-variant-values> || <east-asian-width-values> || ruby ]
RefPtr<CSSStyleValue> ruby_value; RefPtr<CSSStyleValue const> ruby_value;
RefPtr<CSSStyleValue> variant_value; RefPtr<CSSStyleValue const> variant_value;
RefPtr<CSSStyleValue> width_value; RefPtr<CSSStyleValue const> width_value;
while (tokens.has_next_token()) { while (tokens.has_next_token()) {
auto maybe_value = parse_keyword_value(tokens); auto maybe_value = parse_keyword_value(tokens);
@ -2954,7 +2954,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_east_asian_value(TokenStream<Co
return StyleValueList::create(move(values), StyleValueList::Separator::Space); return StyleValueList::create(move(values), StyleValueList::Separator::Space);
} }
RefPtr<CSSStyleValue> Parser::parse_font_variant_ligatures_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variant_ligatures_value(TokenStream<ComponentValue>& tokens)
{ {
// 6.4 https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures // 6.4 https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures
// normal | none | [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ] // normal | none | [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ]
@ -2972,10 +2972,10 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_ligatures_value(TokenStream<Com
return none.release_nonnull(); return none.release_nonnull();
// [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ] // [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ]
RefPtr<CSSStyleValue> common_ligatures_value; RefPtr<CSSStyleValue const> common_ligatures_value;
RefPtr<CSSStyleValue> discretionary_ligatures_value; RefPtr<CSSStyleValue const> discretionary_ligatures_value;
RefPtr<CSSStyleValue> historical_ligatures_value; RefPtr<CSSStyleValue const> historical_ligatures_value;
RefPtr<CSSStyleValue> contextual_value; RefPtr<CSSStyleValue const> contextual_value;
while (tokens.has_next_token()) { while (tokens.has_next_token()) {
auto maybe_value = parse_keyword_value(tokens); auto maybe_value = parse_keyword_value(tokens);
@ -3038,7 +3038,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_ligatures_value(TokenStream<Com
return StyleValueList::create(move(values), StyleValueList::Separator::Space); return StyleValueList::create(move(values), StyleValueList::Separator::Space);
} }
RefPtr<CSSStyleValue> Parser::parse_font_variant_numeric_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_font_variant_numeric_value(TokenStream<ComponentValue>& tokens)
{ {
// 6.7 https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric // 6.7 https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric
// normal | [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero] // normal | [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero]
@ -3050,11 +3050,11 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_numeric_value(TokenStream<Compo
if (auto normal = parse_all_as_single_keyword_value(tokens, Keyword::Normal)) if (auto normal = parse_all_as_single_keyword_value(tokens, Keyword::Normal))
return normal.release_nonnull(); return normal.release_nonnull();
RefPtr<CSSStyleValue> figures_value; RefPtr<CSSStyleValue const> figures_value;
RefPtr<CSSStyleValue> spacing_value; RefPtr<CSSStyleValue const> spacing_value;
RefPtr<CSSStyleValue> fractions_value; RefPtr<CSSStyleValue const> fractions_value;
RefPtr<CSSStyleValue> ordinals_value; RefPtr<CSSStyleValue const> ordinals_value;
RefPtr<CSSStyleValue> slashed_zero_value; RefPtr<CSSStyleValue const> slashed_zero_value;
// [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero] // [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero]
while (tokens.has_next_token()) { while (tokens.has_next_token()) {
@ -3123,11 +3123,11 @@ RefPtr<CSSStyleValue> Parser::parse_font_variant_numeric_value(TokenStream<Compo
return StyleValueList::create(move(values), StyleValueList::Separator::Space); return StyleValueList::create(move(values), StyleValueList::Separator::Space);
} }
RefPtr<CSSStyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_list_style_value(TokenStream<ComponentValue>& tokens)
{ {
RefPtr<CSSStyleValue> list_position; RefPtr<CSSStyleValue const> list_position;
RefPtr<CSSStyleValue> list_image; RefPtr<CSSStyleValue const> list_image;
RefPtr<CSSStyleValue> list_type; RefPtr<CSSStyleValue const> list_type;
int found_nones = 0; int found_nones = 0;
Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType }; Vector<PropertyID> remaining_longhands { PropertyID::ListStyleImage, PropertyID::ListStylePosition, PropertyID::ListStyleType };
@ -3200,7 +3200,7 @@ RefPtr<CSSStyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>
{ list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull() }); { list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_math_depth_value(TokenStream<ComponentValue>& tokens)
{ {
// https://w3c.github.io/mathml-core/#propdef-math-depth // https://w3c.github.io/mathml-core/#propdef-math-depth
// auto-add | add(<integer>) | <integer> // auto-add | add(<integer>) | <integer>
@ -3240,7 +3240,7 @@ RefPtr<CSSStyleValue> Parser::parse_math_depth_value(TokenStream<ComponentValue>
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto maybe_x_value = parse_css_value_for_property(PropertyID::OverflowX, tokens); auto maybe_x_value = parse_css_value_for_property(PropertyID::OverflowX, tokens);
@ -3258,7 +3258,7 @@ RefPtr<CSSStyleValue> Parser::parse_overflow_value(TokenStream<ComponentValue>&
{ *maybe_x_value, *maybe_x_value }); { *maybe_x_value, *maybe_x_value });
} }
RefPtr<CSSStyleValue> Parser::parse_place_content_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_place_content_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens); auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens);
@ -3283,7 +3283,7 @@ RefPtr<CSSStyleValue> Parser::parse_place_content_value(TokenStream<ComponentVal
{ maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() }); { maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_place_items_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens); auto maybe_align_items_value = parse_css_value_for_property(PropertyID::AlignItems, tokens);
@ -3308,7 +3308,7 @@ RefPtr<CSSStyleValue> Parser::parse_place_items_value(TokenStream<ComponentValue
{ *maybe_align_items_value, *maybe_justify_items_value }); { *maybe_align_items_value, *maybe_justify_items_value });
} }
RefPtr<CSSStyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_place_self_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens); auto maybe_align_self_value = parse_css_value_for_property(PropertyID::AlignSelf, tokens);
@ -3333,7 +3333,7 @@ RefPtr<CSSStyleValue> Parser::parse_place_self_value(TokenStream<ComponentValue>
{ *maybe_align_self_value, *maybe_justify_self_value }); { *maybe_align_self_value, *maybe_justify_self_value });
} }
RefPtr<CSSStyleValue> Parser::parse_quotes_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_quotes_value(TokenStream<ComponentValue>& tokens)
{ {
// https://www.w3.org/TR/css-content-3/#quotes-property // https://www.w3.org/TR/css-content-3/#quotes-property
// auto | none | [ <string> <string> ]+ // auto | none | [ <string> <string> ]+
@ -3365,12 +3365,12 @@ RefPtr<CSSStyleValue> Parser::parse_quotes_value(TokenStream<ComponentValue>& to
return StyleValueList::create(move(string_values), StyleValueList::Separator::Space); return StyleValueList::create(move(string_values), StyleValueList::Separator::Space);
} }
RefPtr<CSSStyleValue> Parser::parse_text_decoration_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_text_decoration_value(TokenStream<ComponentValue>& tokens)
{ {
RefPtr<CSSStyleValue> decoration_line; RefPtr<CSSStyleValue const> decoration_line;
RefPtr<CSSStyleValue> decoration_thickness; RefPtr<CSSStyleValue const> decoration_thickness;
RefPtr<CSSStyleValue> decoration_style; RefPtr<CSSStyleValue const> decoration_style;
RefPtr<CSSStyleValue> decoration_color; RefPtr<CSSStyleValue const> decoration_color;
auto remaining_longhands = Vector { PropertyID::TextDecorationColor, PropertyID::TextDecorationLine, PropertyID::TextDecorationStyle, PropertyID::TextDecorationThickness }; auto remaining_longhands = Vector { PropertyID::TextDecorationColor, PropertyID::TextDecorationLine, PropertyID::TextDecorationStyle, PropertyID::TextDecorationThickness };
@ -3427,7 +3427,7 @@ RefPtr<CSSStyleValue> Parser::parse_text_decoration_value(TokenStream<ComponentV
{ decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull() }); { decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_text_decoration_line_value(TokenStream<ComponentValue>& tokens)
{ {
StyleValueVector style_values; StyleValueVector style_values;
@ -3475,7 +3475,7 @@ RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<Compo
} }
// https://www.w3.org/TR/css-transforms-1/#transform-property // https://www.w3.org/TR/css-transforms-1/#transform-property
RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_transform_value(TokenStream<ComponentValue>& tokens)
{ {
// <transform> = none | <transform-list> // <transform> = none | <transform-list>
// <transform-list> = <transform-function>+ // <transform-list> = <transform-function>+
@ -3581,7 +3581,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>&
// https://www.w3.org/TR/css-transforms-1/#propdef-transform-origin // https://www.w3.org/TR/css-transforms-1/#propdef-transform-origin
// FIXME: This only supports a 2D position // FIXME: This only supports a 2D position
RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_transform_origin_value(TokenStream<ComponentValue>& tokens)
{ {
enum class Axis { enum class Axis {
None, None,
@ -3591,10 +3591,10 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
struct AxisOffset { struct AxisOffset {
Axis axis; Axis axis;
NonnullRefPtr<CSSStyleValue> offset; NonnullRefPtr<CSSStyleValue const> offset;
}; };
auto to_axis_offset = [](RefPtr<CSSStyleValue> value) -> Optional<AxisOffset> { auto to_axis_offset = [](RefPtr<CSSStyleValue const> value) -> Optional<AxisOffset> {
if (!value) if (!value)
return OptionalNone {}; return OptionalNone {};
if (value->is_percentage()) if (value->is_percentage())
@ -3625,7 +3625,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto make_list = [&transaction](NonnullRefPtr<CSSStyleValue> const& x_value, NonnullRefPtr<CSSStyleValue> const& y_value) -> NonnullRefPtr<StyleValueList> { auto make_list = [&transaction](NonnullRefPtr<CSSStyleValue const> const& x_value, NonnullRefPtr<CSSStyleValue const> const& y_value) -> NonnullRefPtr<StyleValueList> {
transaction.commit(); transaction.commit();
return StyleValueList::create(StyleValueVector { x_value, y_value }, StyleValueList::Separator::Space); return StyleValueList::create(StyleValueVector { x_value, y_value }, StyleValueList::Separator::Space);
}; };
@ -3652,8 +3652,8 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
if (!first_value.has_value() || !second_value.has_value()) if (!first_value.has_value() || !second_value.has_value())
return nullptr; return nullptr;
RefPtr<CSSStyleValue> x_value; RefPtr<CSSStyleValue const> x_value;
RefPtr<CSSStyleValue> y_value; RefPtr<CSSStyleValue const> y_value;
if (first_value->axis == Axis::X) { if (first_value->axis == Axis::X) {
x_value = first_value->offset; x_value = first_value->offset;
@ -3696,7 +3696,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_transition_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_transition_value(TokenStream<ComponentValue>& tokens)
{ {
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
return none; return none;
@ -3775,7 +3775,7 @@ RefPtr<CSSStyleValue> Parser::parse_transition_value(TokenStream<ComponentValue>
return TransitionStyleValue::create(move(transitions)); return TransitionStyleValue::create(move(transitions));
} }
RefPtr<CSSStyleValue> Parser::parse_translate_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_translate_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.remaining_token_count() == 1) { if (tokens.remaining_token_count() == 1) {
// "none" // "none"
@ -3802,7 +3802,7 @@ RefPtr<CSSStyleValue> Parser::parse_translate_value(TokenStream<ComponentValue>&
return TransformationStyleValue::create(PropertyID::Translate, TransformFunction::Translate, { maybe_x.release_nonnull(), maybe_y.release_nonnull() }); return TransformationStyleValue::create(PropertyID::Translate, TransformFunction::Translate, { maybe_x.release_nonnull(), maybe_y.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_scale_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_scale_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.remaining_token_count() == 1) { if (tokens.remaining_token_count() == 1) {
// "none" // "none"
@ -3830,7 +3830,7 @@ RefPtr<CSSStyleValue> Parser::parse_scale_value(TokenStream<ComponentValue>& tok
} }
// https://drafts.csswg.org/css-overflow/#propdef-scrollbar-gutter // https://drafts.csswg.org/css-overflow/#propdef-scrollbar-gutter
RefPtr<CSSStyleValue> Parser::parse_scrollbar_gutter_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_scrollbar_gutter_value(TokenStream<ComponentValue>& tokens)
{ {
// auto | stable && both-edges? // auto | stable && both-edges?
if (!tokens.has_next_token()) if (!tokens.has_next_token())
@ -3893,7 +3893,7 @@ RefPtr<CSSStyleValue> Parser::parse_scrollbar_gutter_value(TokenStream<Component
return ScrollbarGutterStyleValue::create(gutter_value); return ScrollbarGutterStyleValue::create(gutter_value);
} }
RefPtr<CSSStyleValue> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_track_placement_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
{ {
auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart; auto start_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnStart : PropertyID::GridRowStart;
auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd; auto end_property = (property_id == PropertyID::GridColumn) ? PropertyID::GridColumnEnd : PropertyID::GridRowEnd;
@ -3952,7 +3952,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_track_placement_shorthand_value(Propert
// https://www.w3.org/TR/css-grid-2/#explicit-grid-shorthand // https://www.w3.org/TR/css-grid-2/#explicit-grid-shorthand
// 7.4. Explicit Grid Shorthand: the grid-template property // 7.4. Explicit Grid Shorthand: the grid-template property
RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_track_size_list_shorthand_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
{ {
// The grid-template property is a shorthand for setting grid-template-columns, grid-template-rows, // The grid-template property is a shorthand for setting grid-template-columns, grid-template-rows,
// and grid-template-areas in a single declaration. It has several distinct syntax forms: // and grid-template-areas in a single declaration. It has several distinct syntax forms:
@ -4010,7 +4010,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list_shorthand_value(Propert
{ parsed_template_areas_values.release_nonnull(), parsed_template_rows_values.release_nonnull(), parsed_template_columns_values.release_nonnull() }); { parsed_template_areas_values.release_nonnull(), parsed_template_rows_values.release_nonnull(), parsed_template_columns_values.release_nonnull() });
} }
RefPtr<CSSStyleValue> Parser::parse_grid_area_shorthand_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_area_shorthand_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -4099,7 +4099,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_area_shorthand_value(TokenStream<Compon
{ GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end) }); { GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end) });
} }
RefPtr<CSSStyleValue> Parser::parse_grid_shorthand_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_shorthand_value(TokenStream<ComponentValue>& tokens)
{ {
// <'grid-template'> | // <'grid-template'> |
// FIXME: <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? | // FIXME: <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? |
@ -4108,7 +4108,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_shorthand_value(TokenStream<ComponentVa
} }
// https://www.w3.org/TR/css-grid-1/#grid-template-areas-property // https://www.w3.org/TR/css-grid-1/#grid-template-areas-property
RefPtr<CSSStyleValue> Parser::parse_grid_template_areas_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_template_areas_value(TokenStream<ComponentValue>& tokens)
{ {
// none | <string>+ // none | <string>+
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
@ -4169,7 +4169,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_template_areas_value(TokenStream<Compon
return GridTemplateAreaStyleValue::create(grid_area_rows); return GridTemplateAreaStyleValue::create(grid_area_rows);
} }
RefPtr<CSSStyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentValue>& tokens)
{ {
// https://www.w3.org/TR/css-grid-2/#auto-tracks // https://www.w3.org/TR/css-grid-2/#auto-tracks
// <track-size>+ // <track-size>+
@ -4191,7 +4191,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_auto_track_sizes(TokenStream<ComponentV
} }
// https://www.w3.org/TR/css-grid-1/#grid-auto-flow-property // https://www.w3.org/TR/css-grid-1/#grid-auto-flow-property
RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(TokenStream<ComponentValue>& tokens) RefPtr<GridAutoFlowStyleValue const> Parser::parse_grid_auto_flow_value(TokenStream<ComponentValue>& tokens)
{ {
// [ row | column ] || dense // [ row | column ] || dense
if (!tokens.has_next_token()) if (!tokens.has_next_token())
@ -4243,7 +4243,7 @@ RefPtr<GridAutoFlowStyleValue> Parser::parse_grid_auto_flow_value(TokenStream<Co
return GridAutoFlowStyleValue::create(axis.value_or(GridAutoFlowStyleValue::Axis::Row), dense.value_or(GridAutoFlowStyleValue::Dense::No)); return GridAutoFlowStyleValue::create(axis.value_or(GridAutoFlowStyleValue::Axis::Row), dense.value_or(GridAutoFlowStyleValue::Dense::No));
} }
RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list(TokenStream<ComponentValue>& tokens, bool allow_separate_line_name_blocks) RefPtr<CSSStyleValue const> Parser::parse_grid_track_size_list(TokenStream<ComponentValue>& tokens, bool allow_separate_line_name_blocks)
{ {
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
return GridTrackSizeListStyleValue::make_none(); return GridTrackSizeListStyleValue::make_none();
@ -4290,7 +4290,7 @@ RefPtr<CSSStyleValue> Parser::parse_grid_track_size_list(TokenStream<ComponentVa
return GridTrackSizeListStyleValue::create(GridTrackSizeList(move(track_list))); return GridTrackSizeListStyleValue::create(GridTrackSizeList(move(track_list)));
} }
RefPtr<CSSStyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_filter_value_list_value(TokenStream<ComponentValue>& tokens)
{ {
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
return none; return none;

View file

@ -538,7 +538,7 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
Optional<FlyString> syntax_maybe; Optional<FlyString> syntax_maybe;
Optional<bool> inherits_maybe; Optional<bool> inherits_maybe;
RefPtr<CSSStyleValue> initial_value_maybe; RefPtr<CSSStyleValue const> initial_value_maybe;
rule.for_each_as_declaration_list([&](auto& declaration) { rule.for_each_as_declaration_list([&](auto& declaration) {
if (auto descriptor = convert_to_descriptor(AtRuleID::Property, declaration); descriptor.has_value()) { if (auto descriptor = convert_to_descriptor(AtRuleID::Property, declaration); descriptor.has_value()) {

View file

@ -66,7 +66,7 @@
namespace Web::CSS::Parser { namespace Web::CSS::Parser {
RefPtr<CSSStyleValue> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value) RefPtr<CSSStyleValue const> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
{ {
auto first = parse_one_value(tokens); auto first = parse_one_value(tokens);
if (!first || !tokens.has_next_token()) if (!first || !tokens.has_next_token())
@ -338,7 +338,7 @@ Optional<Ratio> Parser::parse_ratio(TokenStream<ComponentValue>& tokens)
} }
// https://drafts.csswg.org/css-fonts-4/#family-name-syntax // https://drafts.csswg.org/css-fonts-4/#family-name-syntax
RefPtr<CSSStyleValue> Parser::parse_family_name_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_family_name_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
tokens.discard_whitespace(); tokens.discard_whitespace();
@ -647,14 +647,14 @@ Vector<Gfx::UnicodeRange> Parser::parse_unicode_ranges(TokenStream<ComponentValu
return unicode_ranges; return unicode_ranges;
} }
RefPtr<UnicodeRangeStyleValue> Parser::parse_unicode_range_value(TokenStream<ComponentValue>& tokens) RefPtr<UnicodeRangeStyleValue const> Parser::parse_unicode_range_value(TokenStream<ComponentValue>& tokens)
{ {
if (auto range = parse_unicode_range(tokens); range.has_value()) if (auto range = parse_unicode_range(tokens); range.has_value())
return UnicodeRangeStyleValue::create(range.release_value()); return UnicodeRangeStyleValue::create(range.release_value());
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_integer_value(TokenStream<ComponentValue>& tokens)
{ {
auto const& peek_token = tokens.next_token(); auto const& peek_token = tokens.next_token();
if (peek_token.is(Token::Type::Number) && peek_token.token().number().is_integer()) { if (peek_token.is(Token::Type::Number) && peek_token.token().number().is_integer()) {
@ -671,7 +671,7 @@ RefPtr<CSSStyleValue> Parser::parse_integer_value(TokenStream<ComponentValue>& t
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_number_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_number_value(TokenStream<ComponentValue>& tokens)
{ {
auto const& peek_token = tokens.next_token(); auto const& peek_token = tokens.next_token();
if (peek_token.is(Token::Type::Number)) { if (peek_token.is(Token::Type::Number)) {
@ -688,7 +688,7 @@ RefPtr<CSSStyleValue> Parser::parse_number_value(TokenStream<ComponentValue>& to
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_number_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_number_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
// Parses [<percentage> | <number>] (which is equivalent to [<alpha-value>]) // Parses [<percentage> | <number>] (which is equivalent to [<alpha-value>])
if (auto value = parse_number_value(tokens)) if (auto value = parse_number_value(tokens))
@ -698,7 +698,7 @@ RefPtr<CSSStyleValue> Parser::parse_number_percentage_value(TokenStream<Componen
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_number_percentage_none_value(TokenStream<ComponentValue>& tokens)
{ {
// Parses [<percentage> | <number> | none] (which is equivalent to [<alpha-value> | none]) // Parses [<percentage> | <number> | none] (which is equivalent to [<alpha-value> | none])
if (auto value = parse_number_value(tokens)) if (auto value = parse_number_value(tokens))
@ -714,7 +714,7 @@ RefPtr<CSSStyleValue> Parser::parse_number_percentage_none_value(TokenStream<Com
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
auto const& peek_token = tokens.next_token(); auto const& peek_token = tokens.next_token();
if (peek_token.is(Token::Type::Percentage)) { if (peek_token.is(Token::Type::Percentage)) {
@ -731,7 +731,7 @@ RefPtr<CSSStyleValue> Parser::parse_percentage_value(TokenStream<ComponentValue>
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_angle_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_angle_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -762,7 +762,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_value(TokenStream<ComponentValue>& tok
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_angle_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_angle_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -796,7 +796,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_percentage_value(TokenStream<Component
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_flex_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -818,7 +818,7 @@ RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& toke
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_frequency_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_frequency_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -840,7 +840,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_value(TokenStream<ComponentValue>&
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_frequency_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_frequency_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -865,7 +865,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_percentage_value(TokenStream<Compo
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_length_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_length_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -909,7 +909,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_value(TokenStream<ComponentValue>& to
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_length_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_length_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -956,7 +956,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_percentage_value(TokenStream<Componen
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_resolution_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_resolution_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -978,7 +978,7 @@ RefPtr<CSSStyleValue> Parser::parse_resolution_value(TokenStream<ComponentValue>
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_time_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_time_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -1000,7 +1000,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_value(TokenStream<ComponentValue>& toke
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_time_percentage_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_time_percentage_value(TokenStream<ComponentValue>& tokens)
{ {
if (tokens.next_token().is(Token::Type::Dimension)) { if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -1025,7 +1025,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_percentage_value(TokenStream<ComponentV
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_keyword_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_keyword_value(TokenStream<ComponentValue>& tokens)
{ {
auto const& peek_token = tokens.next_token(); auto const& peek_token = tokens.next_token();
if (peek_token.is(Token::Type::Ident)) { if (peek_token.is(Token::Type::Ident)) {
@ -1040,7 +1040,7 @@ RefPtr<CSSStyleValue> Parser::parse_keyword_value(TokenStream<ComponentValue>& t
} }
// https://www.w3.org/TR/CSS2/visufx.html#value-def-shape // https://www.w3.org/TR/CSS2/visufx.html#value-def-shape
RefPtr<CSSStyleValue> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_rect_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto const& function_token = tokens.consume_a_token(); auto const& function_token = tokens.consume_a_token();
@ -1123,7 +1123,7 @@ RefPtr<CSSStyleValue> Parser::parse_rect_value(TokenStream<ComponentValue>& toke
} }
// https://www.w3.org/TR/css-color-4/#typedef-hue // https://www.w3.org/TR/css-color-4/#typedef-hue
RefPtr<CSSStyleValue> Parser::parse_hue_none_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_hue_none_value(TokenStream<ComponentValue>& tokens)
{ {
// Parses [<hue> | none] // Parses [<hue> | none]
// <hue> = <number> | <angle> // <hue> = <number> | <angle>
@ -1141,7 +1141,7 @@ RefPtr<CSSStyleValue> Parser::parse_hue_none_value(TokenStream<ComponentValue>&
} }
// https://www.w3.org/TR/css-color-4/#typedef-color-alpha-value // https://www.w3.org/TR/css-color-4/#typedef-color-alpha-value
RefPtr<CSSStyleValue> Parser::parse_solidus_and_alpha_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_solidus_and_alpha_value(TokenStream<ComponentValue>& tokens)
{ {
// [ / [<alpha-value> | none] ]? // [ / [<alpha-value> | none] ]?
// <alpha-value> = <number> | <percentage> // <alpha-value> = <number> | <percentage>
@ -1162,7 +1162,7 @@ RefPtr<CSSStyleValue> Parser::parse_solidus_and_alpha_value(TokenStream<Componen
} }
// https://www.w3.org/TR/css-color-4/#funcdef-rgb // https://www.w3.org/TR/css-color-4/#funcdef-rgb
RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_rgb_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// rgb() = [ <legacy-rgb-syntax> | <modern-rgb-syntax> ] // rgb() = [ <legacy-rgb-syntax> | <modern-rgb-syntax> ]
// rgba() = [ <legacy-rgba-syntax> | <modern-rgba-syntax> ] // rgba() = [ <legacy-rgba-syntax> | <modern-rgba-syntax> ]
@ -1186,10 +1186,10 @@ RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>&
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name }); auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
RefPtr<CSSStyleValue> red; RefPtr<CSSStyleValue const> red;
RefPtr<CSSStyleValue> green; RefPtr<CSSStyleValue const> green;
RefPtr<CSSStyleValue> blue; RefPtr<CSSStyleValue const> blue;
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
auto inner_tokens = TokenStream { function_token.function().value }; auto inner_tokens = TokenStream { function_token.function().value };
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
@ -1284,7 +1284,7 @@ RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>&
} }
// https://www.w3.org/TR/css-color-4/#funcdef-hsl // https://www.w3.org/TR/css-color-4/#funcdef-hsl
RefPtr<CSSStyleValue> Parser::parse_hsl_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_hsl_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// hsl() = [ <legacy-hsl-syntax> | <modern-hsl-syntax> ] // hsl() = [ <legacy-hsl-syntax> | <modern-hsl-syntax> ]
// hsla() = [ <legacy-hsla-syntax> | <modern-hsla-syntax> ] // hsla() = [ <legacy-hsla-syntax> | <modern-hsla-syntax> ]
@ -1310,10 +1310,10 @@ RefPtr<CSSStyleValue> Parser::parse_hsl_color_value(TokenStream<ComponentValue>&
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name }); auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
RefPtr<CSSStyleValue> h; RefPtr<CSSStyleValue const> h;
RefPtr<CSSStyleValue> s; RefPtr<CSSStyleValue const> s;
RefPtr<CSSStyleValue> l; RefPtr<CSSStyleValue const> l;
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
auto inner_tokens = TokenStream { function_token.function().value }; auto inner_tokens = TokenStream { function_token.function().value };
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
@ -1396,7 +1396,7 @@ RefPtr<CSSStyleValue> Parser::parse_hsl_color_value(TokenStream<ComponentValue>&
} }
// https://www.w3.org/TR/css-color-4/#funcdef-hwb // https://www.w3.org/TR/css-color-4/#funcdef-hwb
RefPtr<CSSStyleValue> Parser::parse_hwb_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_hwb_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// hwb() = hwb( // hwb() = hwb(
// [<hue> | none] // [<hue> | none]
@ -1413,10 +1413,10 @@ RefPtr<CSSStyleValue> Parser::parse_hwb_color_value(TokenStream<ComponentValue>&
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name }); auto context_guard = push_temporary_value_parsing_context(FunctionContext { function_token.function().name });
RefPtr<CSSStyleValue> h; RefPtr<CSSStyleValue const> h;
RefPtr<CSSStyleValue> w; RefPtr<CSSStyleValue const> w;
RefPtr<CSSStyleValue> b; RefPtr<CSSStyleValue const> b;
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
auto inner_tokens = TokenStream { function_token.function().value }; auto inner_tokens = TokenStream { function_token.function().value };
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
@ -1449,7 +1449,7 @@ RefPtr<CSSStyleValue> Parser::parse_hwb_color_value(TokenStream<ComponentValue>&
return CSSHWB::create(h.release_nonnull(), w.release_nonnull(), b.release_nonnull(), alpha.release_nonnull()); return CSSHWB::create(h.release_nonnull(), w.release_nonnull(), b.release_nonnull(), alpha.release_nonnull());
} }
Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lab_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name) Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lab_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
{ {
// This helper is designed to be compatible with lab and oklab and parses a function with a form like: // This helper is designed to be compatible with lab and oklab and parses a function with a form like:
// f() = f( [ <percentage> | <number> | none] // f() = f( [ <percentage> | <number> | none]
@ -1464,10 +1464,10 @@ Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lab_like_color_value(Tok
if (!function_token.is_function(function_name)) if (!function_token.is_function(function_name))
return OptionalNone {}; return OptionalNone {};
RefPtr<CSSStyleValue> l; RefPtr<CSSStyleValue const> l;
RefPtr<CSSStyleValue> a; RefPtr<CSSStyleValue const> a;
RefPtr<CSSStyleValue> b; RefPtr<CSSStyleValue const> b;
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
auto inner_tokens = TokenStream { function_token.function().value }; auto inner_tokens = TokenStream { function_token.function().value };
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
@ -1502,7 +1502,7 @@ Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lab_like_color_value(Tok
} }
// https://www.w3.org/TR/css-color-4/#funcdef-lab // https://www.w3.org/TR/css-color-4/#funcdef-lab
RefPtr<CSSStyleValue> Parser::parse_lab_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_lab_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// lab() = lab( [<percentage> | <number> | none] // lab() = lab( [<percentage> | <number> | none]
// [ <percentage> | <number> | none] // [ <percentage> | <number> | none]
@ -1522,7 +1522,7 @@ RefPtr<CSSStyleValue> Parser::parse_lab_color_value(TokenStream<ComponentValue>&
} }
// https://www.w3.org/TR/css-color-4/#funcdef-oklab // https://www.w3.org/TR/css-color-4/#funcdef-oklab
RefPtr<CSSStyleValue> Parser::parse_oklab_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_oklab_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// oklab() = oklab( [ <percentage> | <number> | none] // oklab() = oklab( [ <percentage> | <number> | none]
// [ <percentage> | <number> | none] // [ <percentage> | <number> | none]
@ -1541,7 +1541,7 @@ RefPtr<CSSStyleValue> Parser::parse_oklab_color_value(TokenStream<ComponentValue
color_values[3].release_nonnull()); color_values[3].release_nonnull());
} }
Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lch_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name) Optional<Array<RefPtr<CSSStyleValue const>, 4>> Parser::parse_lch_like_color_value(TokenStream<ComponentValue>& outer_tokens, StringView function_name)
{ {
// This helper is designed to be compatible with lch and oklch and parses a function with a form like: // This helper is designed to be compatible with lch and oklch and parses a function with a form like:
// f() = f( [<percentage> | <number> | none] // f() = f( [<percentage> | <number> | none]
@ -1574,7 +1574,7 @@ Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lch_like_color_value(Tok
return OptionalNone {}; return OptionalNone {};
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
if (inner_tokens.has_next_token()) { if (inner_tokens.has_next_token()) {
alpha = parse_solidus_and_alpha_value(inner_tokens); alpha = parse_solidus_and_alpha_value(inner_tokens);
if (!alpha || inner_tokens.has_next_token()) if (!alpha || inner_tokens.has_next_token())
@ -1590,7 +1590,7 @@ Optional<Array<RefPtr<CSSStyleValue>, 4>> Parser::parse_lch_like_color_value(Tok
} }
// https://www.w3.org/TR/css-color-4/#funcdef-lch // https://www.w3.org/TR/css-color-4/#funcdef-lch
RefPtr<CSSStyleValue> Parser::parse_lch_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_lch_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// lch() = lch( [<percentage> | <number> | none] // lch() = lch( [<percentage> | <number> | none]
// [ <percentage> | <number> | none] // [ <percentage> | <number> | none]
@ -1610,7 +1610,7 @@ RefPtr<CSSStyleValue> Parser::parse_lch_color_value(TokenStream<ComponentValue>&
} }
// https://www.w3.org/TR/css-color-4/#funcdef-oklch // https://www.w3.org/TR/css-color-4/#funcdef-oklch
RefPtr<CSSStyleValue> Parser::parse_oklch_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_oklch_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
// oklch() = oklch( [ <percentage> | <number> | none] // oklch() = oklch( [ <percentage> | <number> | none]
// [ <percentage> | <number> | none] // [ <percentage> | <number> | none]
@ -1630,7 +1630,7 @@ RefPtr<CSSStyleValue> Parser::parse_oklch_color_value(TokenStream<ComponentValue
} }
// https://www.w3.org/TR/css-color-4/#funcdef-color // https://www.w3.org/TR/css-color-4/#funcdef-color
RefPtr<CSSStyleValue> Parser::parse_color_function(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_color_function(TokenStream<ComponentValue>& outer_tokens)
{ {
// color() = color( <colorspace-params> [ / [ <alpha-value> | none ] ]? ) // color() = color( <colorspace-params> [ / [ <alpha-value> | none ] ]? )
// <colorspace-params> = [ <predefined-rgb-params> | <xyz-params>] // <colorspace-params> = [ <predefined-rgb-params> | <xyz-params>]
@ -1673,7 +1673,7 @@ RefPtr<CSSStyleValue> Parser::parse_color_function(TokenStream<ComponentValue>&
return {}; return {};
inner_tokens.discard_whitespace(); inner_tokens.discard_whitespace();
RefPtr<CSSStyleValue> alpha; RefPtr<CSSStyleValue const> alpha;
if (inner_tokens.has_next_token()) { if (inner_tokens.has_next_token()) {
alpha = parse_solidus_and_alpha_value(inner_tokens); alpha = parse_solidus_and_alpha_value(inner_tokens);
if (!alpha || inner_tokens.has_next_token()) if (!alpha || inner_tokens.has_next_token())
@ -1692,7 +1692,7 @@ RefPtr<CSSStyleValue> Parser::parse_color_function(TokenStream<ComponentValue>&
} }
// https://drafts.csswg.org/css-color-5/#funcdef-light-dark // https://drafts.csswg.org/css-color-5/#funcdef-light-dark
RefPtr<CSSStyleValue> Parser::parse_light_dark_color_value(TokenStream<ComponentValue>& outer_tokens) RefPtr<CSSStyleValue const> Parser::parse_light_dark_color_value(TokenStream<ComponentValue>& outer_tokens)
{ {
auto transaction = outer_tokens.begin_transaction(); auto transaction = outer_tokens.begin_transaction();
@ -1726,7 +1726,7 @@ RefPtr<CSSStyleValue> Parser::parse_light_dark_color_value(TokenStream<Component
} }
// https://www.w3.org/TR/css-color-4/#color-syntax // https://www.w3.org/TR/css-color-4/#color-syntax
RefPtr<CSSStyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>& tokens)
{ {
// Keywords: <system-color> | <deprecated-color> | currentColor // Keywords: <system-color> | <deprecated-color> | currentColor
@ -1873,7 +1873,7 @@ RefPtr<CSSStyleValue> Parser::parse_color_value(TokenStream<ComponentValue>& tok
} }
// https://drafts.csswg.org/css-lists-3/#counter-functions // https://drafts.csswg.org/css-lists-3/#counter-functions
RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_counter_value(TokenStream<ComponentValue>& tokens)
{ {
auto parse_counter_name = [this](TokenStream<ComponentValue>& tokens) -> Optional<FlyString> { auto parse_counter_name = [this](TokenStream<ComponentValue>& tokens) -> Optional<FlyString> {
// https://drafts.csswg.org/css-lists-3/#typedef-counter-name // https://drafts.csswg.org/css-lists-3/#typedef-counter-name
@ -1895,7 +1895,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& t
return counter_name->custom_ident(); return counter_name->custom_ident();
}; };
auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<CSSStyleValue> { auto parse_counter_style = [this](TokenStream<ComponentValue>& tokens) -> RefPtr<CSSStyleValue const> {
// https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style // https://drafts.csswg.org/css-counter-styles-3/#typedef-counter-style
// <counter-style> = <counter-style-name> | <symbols()> // <counter-style> = <counter-style-name> | <symbols()>
// For now we just support <counter-style-name>, found here: // For now we just support <counter-style-name>, found here:
@ -1933,7 +1933,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& t
if (!counter_name.has_value()) if (!counter_name.has_value())
return nullptr; return nullptr;
RefPtr<CSSStyleValue> counter_style; RefPtr<CSSStyleValue const> counter_style;
if (function_values.size() > 1) { if (function_values.size() > 1) {
TokenStream counter_style_tokens { function_values[1] }; TokenStream counter_style_tokens { function_values[1] };
counter_style = parse_counter_style(counter_style_tokens); counter_style = parse_counter_style(counter_style_tokens);
@ -1970,7 +1970,7 @@ RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& t
if (!join_string || string_tokens.has_next_token()) if (!join_string || string_tokens.has_next_token())
return nullptr; return nullptr;
RefPtr<CSSStyleValue> counter_style; RefPtr<CSSStyleValue const> counter_style;
if (function_values.size() > 2) { if (function_values.size() > 2) {
TokenStream counter_style_tokens { function_values[2] }; TokenStream counter_style_tokens { function_values[2] };
counter_style = parse_counter_style(counter_style_tokens); counter_style = parse_counter_style(counter_style_tokens);
@ -1988,14 +1988,14 @@ RefPtr<CSSStyleValue> Parser::parse_counter_value(TokenStream<ComponentValue>& t
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_ratio_value(TokenStream<ComponentValue>& tokens)
{ {
if (auto ratio = parse_ratio(tokens); ratio.has_value()) if (auto ratio = parse_ratio(tokens); ratio.has_value())
return RatioStyleValue::create(ratio.release_value()); return RatioStyleValue::create(ratio.release_value());
return nullptr; return nullptr;
} }
RefPtr<StringStyleValue> Parser::parse_string_value(TokenStream<ComponentValue>& tokens) RefPtr<StringStyleValue const> Parser::parse_string_value(TokenStream<ComponentValue>& tokens)
{ {
auto const& peek = tokens.next_token(); auto const& peek = tokens.next_token();
if (peek.is(Token::Type::String)) { if (peek.is(Token::Type::String)) {
@ -2006,7 +2006,7 @@ RefPtr<StringStyleValue> Parser::parse_string_value(TokenStream<ComponentValue>&
return nullptr; return nullptr;
} }
RefPtr<AbstractImageStyleValue> Parser::parse_image_value(TokenStream<ComponentValue>& tokens) RefPtr<AbstractImageStyleValue const> Parser::parse_image_value(TokenStream<ComponentValue>& tokens)
{ {
tokens.mark(); tokens.mark();
auto url = parse_url_function(tokens); auto url = parse_url_function(tokens);
@ -2036,11 +2036,11 @@ RefPtr<AbstractImageStyleValue> Parser::parse_image_value(TokenStream<ComponentV
} }
// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint // https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
RefPtr<CSSStyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens)
{ {
// `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke` // `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
auto parse_color_or_none = [&]() -> Optional<RefPtr<CSSStyleValue>> { auto parse_color_or_none = [&]() -> Optional<RefPtr<CSSStyleValue const>> {
if (auto color = parse_color_value(tokens)) if (auto color = parse_color_value(tokens))
return color; return color;
@ -2080,7 +2080,7 @@ RefPtr<CSSStyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tok
} }
// https://www.w3.org/TR/css-values-4/#position // https://www.w3.org/TR/css-values-4/#position
RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentValue>& tokens, PositionParsingMode position_parsing_mode) RefPtr<PositionStyleValue const> Parser::parse_position_value(TokenStream<ComponentValue>& tokens, PositionParsingMode position_parsing_mode)
{ {
auto parse_position_edge = [](TokenStream<ComponentValue>& tokens) -> Optional<PositionEdge> { auto parse_position_edge = [](TokenStream<ComponentValue>& tokens) -> Optional<PositionEdge> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -2131,7 +2131,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
// ] // ]
// [ left | center | right | top | bottom | <length-percentage> ] // [ left | center | right | top | bottom | <length-percentage> ]
auto alternative_1 = [&]() -> RefPtr<PositionStyleValue> { auto alternative_1 = [&]() -> RefPtr<PositionStyleValue const> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
tokens.discard_whitespace(); tokens.discard_whitespace();
@ -2164,7 +2164,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
}; };
// [ left | center | right ] && [ top | center | bottom ] // [ left | center | right ] && [ top | center | bottom ]
auto alternative_2 = [&]() -> RefPtr<PositionStyleValue> { auto alternative_2 = [&]() -> RefPtr<PositionStyleValue const> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
tokens.discard_whitespace(); tokens.discard_whitespace();
@ -2200,10 +2200,10 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
// [ left | center | right | <length-percentage> ] // [ left | center | right | <length-percentage> ]
// [ top | center | bottom | <length-percentage> ] // [ top | center | bottom | <length-percentage> ]
auto alternative_3 = [&]() -> RefPtr<PositionStyleValue> { auto alternative_3 = [&]() -> RefPtr<PositionStyleValue const> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto parse_position_or_length = [&](bool as_horizontal) -> RefPtr<EdgeStyleValue> { auto parse_position_or_length = [&](bool as_horizontal) -> RefPtr<EdgeStyleValue const> {
tokens.discard_whitespace(); tokens.discard_whitespace();
if (auto maybe_position = parse_position_edge(tokens); maybe_position.has_value()) { if (auto maybe_position = parse_position_edge(tokens); maybe_position.has_value()) {
@ -2237,7 +2237,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
// [ [ left | right ] <length-percentage> ] && // [ [ left | right ] <length-percentage> ] &&
// [ [ top | bottom ] <length-percentage> ] // [ [ top | bottom ] <length-percentage> ]
auto alternative_4 = [&]() -> RefPtr<PositionStyleValue> { auto alternative_4 = [&]() -> RefPtr<PositionStyleValue const> {
struct PositionAndLength { struct PositionAndLength {
PositionEdge position; PositionEdge position;
LengthPercentage length; LengthPercentage length;
@ -2293,7 +2293,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
// The extra 3-value syntax that's allowed for background-position: // The extra 3-value syntax that's allowed for background-position:
// [ center | [ left | right ] <length-percentage>? ] && // [ center | [ left | right ] <length-percentage>? ] &&
// [ center | [ top | bottom ] <length-percentage>? ] // [ center | [ top | bottom ] <length-percentage>? ]
auto alternative_5_for_background_position = [&]() -> RefPtr<PositionStyleValue> { auto alternative_5_for_background_position = [&]() -> RefPtr<PositionStyleValue const> {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
struct PositionAndMaybeLength { struct PositionAndMaybeLength {
@ -2355,7 +2355,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
if (!is_vertical(group2.position, true)) if (!is_vertical(group2.position, true))
return nullptr; return nullptr;
auto to_style_value = [&](PositionAndMaybeLength const& group) -> NonnullRefPtr<EdgeStyleValue> { auto to_style_value = [&](PositionAndMaybeLength const& group) -> NonnullRefPtr<EdgeStyleValue const> {
if (group.position == PositionEdge::Center) if (group.position == PositionEdge::Center)
return EdgeStyleValue::create(PositionEdge::Center, {}); return EdgeStyleValue::create(PositionEdge::Center, {});
@ -2382,7 +2382,7 @@ RefPtr<PositionStyleValue> Parser::parse_position_value(TokenStream<ComponentVal
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_easing_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -2392,7 +2392,7 @@ RefPtr<CSSStyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& to
if (part.is(Token::Type::Ident)) { if (part.is(Token::Type::Ident)) {
auto name = part.token().ident(); auto name = part.token().ident();
auto maybe_simple_easing = [&] -> RefPtr<EasingStyleValue> { auto maybe_simple_easing = [&] -> RefPtr<EasingStyleValue const> {
if (name.equals_ignoring_ascii_case("linear"sv)) if (name.equals_ignoring_ascii_case("linear"sv))
return EasingStyleValue::create(EasingStyleValue::Linear::identity()); return EasingStyleValue::create(EasingStyleValue::Linear::identity());
if (name.equals_ignoring_ascii_case("ease"sv)) if (name.equals_ignoring_ascii_case("ease"sv))
@ -2590,7 +2590,7 @@ Optional<URL> Parser::parse_url_function(TokenStream<ComponentValue>& tokens)
return {}; return {};
} }
RefPtr<CSSStyleValue> Parser::parse_url_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_url_value(TokenStream<ComponentValue>& tokens)
{ {
auto url = parse_url_function(tokens); auto url = parse_url_function(tokens);
if (!url.has_value()) if (!url.has_value())
@ -2633,7 +2633,7 @@ Optional<ShapeRadius> Parser::parse_shape_radius(TokenStream<ComponentValue>& to
return {}; return {};
} }
RefPtr<FitContentStyleValue> Parser::parse_fit_content_value(TokenStream<ComponentValue>& tokens) RefPtr<FitContentStyleValue const> Parser::parse_fit_content_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto& component_value = tokens.consume_a_token(); auto& component_value = tokens.consume_a_token();
@ -2663,7 +2663,7 @@ RefPtr<FitContentStyleValue> Parser::parse_fit_content_value(TokenStream<Compone
return FitContentStyleValue::create(maybe_length.release_value()); return FitContentStyleValue::create(maybe_length.release_value());
} }
RefPtr<CSSStyleValue> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_basic_shape_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto& component_value = tokens.consume_a_token(); auto& component_value = tokens.consume_a_token();
@ -2905,7 +2905,7 @@ RefPtr<CSSStyleValue> Parser::parse_basic_shape_value(TokenStream<ComponentValue
return nullptr; return nullptr;
} }
RefPtr<CSSStyleValue> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens) RefPtr<CSSStyleValue const> Parser::parse_builtin_value(TokenStream<ComponentValue>& tokens)
{ {
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
auto& component_value = tokens.consume_a_token(); auto& component_value = tokens.consume_a_token();
@ -2967,7 +2967,7 @@ Optional<FlyString> Parser::parse_custom_ident(TokenStream<ComponentValue>& toke
return custom_ident; return custom_ident;
} }
RefPtr<CustomIdentStyleValue> Parser::parse_custom_ident_value(TokenStream<ComponentValue>& tokens, ReadonlySpan<StringView> blacklist) RefPtr<CustomIdentStyleValue const> Parser::parse_custom_ident_value(TokenStream<ComponentValue>& tokens, ReadonlySpan<StringView> blacklist)
{ {
if (auto custom_ident = parse_custom_ident(tokens, blacklist); custom_ident.has_value()) if (auto custom_ident = parse_custom_ident(tokens, blacklist); custom_ident.has_value())
return CustomIdentStyleValue::create(custom_ident.release_value()); return CustomIdentStyleValue::create(custom_ident.release_value());
@ -3213,7 +3213,7 @@ Optional<CSS::ExplicitGridTrack> Parser::parse_track_sizing_function(ComponentVa
} }
} }
RefPtr<GridTrackPlacementStyleValue> Parser::parse_grid_track_placement(TokenStream<ComponentValue>& tokens) RefPtr<GridTrackPlacementStyleValue const> Parser::parse_grid_track_placement(TokenStream<ComponentValue>& tokens)
{ {
// FIXME: This shouldn't be needed. Right now, the below code returns a CSSStyleValue even if no tokens are consumed! // FIXME: This shouldn't be needed. Right now, the below code returns a CSSStyleValue even if no tokens are consumed!
if (!tokens.has_next_token()) if (!tokens.has_next_token())
@ -3319,7 +3319,7 @@ RefPtr<GridTrackPlacementStyleValue> Parser::parse_grid_track_placement(TokenStr
return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value)); return GridTrackPlacementStyleValue::create(GridTrackPlacement::make_span(span_or_position_value));
} }
RefPtr<CSSStyleValue> Parser::parse_calculated_value(ComponentValue const& component_value) RefPtr<CSSStyleValue const> Parser::parse_calculated_value(ComponentValue const& component_value)
{ {
if (!component_value.is_function()) if (!component_value.is_function())
return nullptr; return nullptr;
@ -3633,7 +3633,7 @@ RefPtr<CalculationNode> Parser::parse_a_calculation(Vector<ComponentValue> const
} }
// https://drafts.csswg.org/css-fonts/#typedef-opentype-tag // https://drafts.csswg.org/css-fonts/#typedef-opentype-tag
RefPtr<StringStyleValue> Parser::parse_opentype_tag_value(TokenStream<ComponentValue>& tokens) RefPtr<StringStyleValue const> Parser::parse_opentype_tag_value(TokenStream<ComponentValue>& tokens)
{ {
// <opentype-tag> = <string> // <opentype-tag> = <string>
// The <opentype-tag> is a case-sensitive OpenType feature tag. // The <opentype-tag> is a case-sensitive OpenType feature tag.
@ -3657,7 +3657,7 @@ RefPtr<StringStyleValue> Parser::parse_opentype_tag_value(TokenStream<ComponentV
return string_value; return string_value;
} }
RefPtr<FontSourceStyleValue> Parser::parse_font_source_value(TokenStream<ComponentValue>& tokens) RefPtr<FontSourceStyleValue const> Parser::parse_font_source_value(TokenStream<ComponentValue>& tokens)
{ {
// <font-src> = <url> [ format(<font-format>)]? [ tech( <font-tech>#)]? | local(<family-name>) // <font-src> = <url> [ format(<font-format>)]? [ tech( <font-tech>#)]? | local(<family-name>)
auto transaction = tokens.begin_transaction(); auto transaction = tokens.begin_transaction();
@ -3728,7 +3728,7 @@ RefPtr<FontSourceStyleValue> Parser::parse_font_source_value(TokenStream<Compone
return FontSourceStyleValue::create(completed_url.release_value(), move(format)); return FontSourceStyleValue::create(completed_url.release_value(), move(format));
} }
NonnullRefPtr<CSSStyleValue> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(ParsingParams const& context, DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
{ {
// Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying // Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying
// to produce a different CSSStyleValue from it. // to produce a different CSSStyleValue from it.
@ -3783,7 +3783,7 @@ private:
bool m_marked { false }; bool m_marked { false };
}; };
NonnullRefPtr<CSSStyleValue> Parser::resolve_unresolved_style_value(DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved) NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(DOM::Element& element, Optional<PseudoElement> pseudo_element, PropertyID property_id, UnresolvedStyleValue const& unresolved)
{ {
TokenStream unresolved_values_without_variables_expanded { unresolved.values() }; TokenStream unresolved_values_without_variables_expanded { unresolved.values() };
Vector<ComponentValue> values_with_variables_expanded; Vector<ComponentValue> values_with_variables_expanded;

View file

@ -31,7 +31,7 @@ public:
{ {
} }
PercentageOr(NonnullRefPtr<CalculatedStyleValue> calculated) PercentageOr(NonnullRefPtr<CalculatedStyleValue const> calculated)
: m_value(move(calculated)) : m_value(move(calculated))
{ {
} }
@ -51,7 +51,7 @@ public:
} }
bool is_percentage() const { return m_value.template has<Percentage>(); } bool is_percentage() const { return m_value.template has<Percentage>(); }
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); } bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue const>>(); }
bool contains_percentage() const bool contains_percentage() const
{ {
@ -62,7 +62,7 @@ public:
[&](Percentage const&) { [&](Percentage const&) {
return true; return true;
}, },
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) { [&](NonnullRefPtr<CalculatedStyleValue const> const& calculated) {
return calculated->contains_percentage(); return calculated->contains_percentage();
}); });
} }
@ -73,10 +73,10 @@ public:
return m_value.template get<Percentage>(); return m_value.template get<Percentage>();
} }
NonnullRefPtr<CalculatedStyleValue> const& calculated() const NonnullRefPtr<CalculatedStyleValue const> const& calculated() const
{ {
VERIFY(is_calculated()); VERIFY(is_calculated());
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>(); return m_value.template get<NonnullRefPtr<CalculatedStyleValue const>>();
} }
CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const
@ -100,7 +100,7 @@ public:
[&](Percentage const& percentage) { [&](Percentage const& percentage) {
return reference_value.percentage_of(percentage); return reference_value.percentage_of(percentage);
}, },
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) { [&](NonnullRefPtr<CalculatedStyleValue const> const& calculated) {
return T::resolve_calculated(calculated, layout_node, reference_value); return T::resolve_calculated(calculated, layout_node, reference_value);
}); });
} }
@ -114,7 +114,7 @@ public:
[&](Percentage const& percentage) { [&](Percentage const& percentage) {
return Length::make_px(CSSPixels(percentage.value() * reference_value) / 100); return Length::make_px(CSSPixels(percentage.value() * reference_value) / 100);
}, },
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) { [&](NonnullRefPtr<CalculatedStyleValue const> const& calculated) {
return T::resolve_calculated(calculated, layout_node, reference_value); return T::resolve_calculated(calculated, layout_node, reference_value);
}); });
} }
@ -122,7 +122,7 @@ public:
String to_string() const String to_string() const
{ {
if (is_calculated()) if (is_calculated())
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string(CSSStyleValue::SerializationMode::Normal); return m_value.template get<NonnullRefPtr<CalculatedStyleValue const>>()->to_string(CSSStyleValue::SerializationMode::Normal);
if (is_percentage()) if (is_percentage())
return m_value.template get<Percentage>().to_string(); return m_value.template get<Percentage>().to_string();
return m_value.template get<T>().to_string(); return m_value.template get<T>().to_string();
@ -135,7 +135,7 @@ public:
if (is_percentage() != other.is_percentage()) if (is_percentage() != other.is_percentage())
return false; return false;
if (is_calculated()) if (is_calculated())
return (*m_value.template get<NonnullRefPtr<CalculatedStyleValue>>() == *other.m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()); return (*m_value.template get<NonnullRefPtr<CalculatedStyleValue const>>() == *other.m_value.template get<NonnullRefPtr<CalculatedStyleValue const>>());
if (is_percentage()) if (is_percentage())
return (m_value.template get<Percentage>() == other.m_value.template get<Percentage>()); return (m_value.template get<Percentage>() == other.m_value.template get<Percentage>());
return (m_value.template get<T>() == other.m_value.template get<T>()); return (m_value.template get<T>() == other.m_value.template get<T>());
@ -146,7 +146,7 @@ protected:
T const& get_t() const { return m_value.template get<T>(); } T const& get_t() const { return m_value.template get<T>(); }
private: private:
Variant<T, Percentage, NonnullRefPtr<CalculatedStyleValue>> m_value; Variant<T, Percentage, NonnullRefPtr<CalculatedStyleValue const>> m_value;
}; };
template<typename T> template<typename T>

View file

@ -39,7 +39,7 @@ Size Size::make_percentage(Percentage percentage)
return Size { Type::Percentage, move(percentage) }; return Size { Type::Percentage, move(percentage) };
} }
Size Size::make_calculated(NonnullRefPtr<Web::CSS::CalculatedStyleValue> calculated) Size Size::make_calculated(NonnullRefPtr<CalculatedStyleValue const> calculated)
{ {
return Size { Type::Calculated, move(calculated) }; return Size { Type::Calculated, move(calculated) };
} }

View file

@ -29,7 +29,7 @@ public:
static Size make_px(CSSPixels); static Size make_px(CSSPixels);
static Size make_length(Length); static Size make_length(Length);
static Size make_percentage(Percentage); static Size make_percentage(Percentage);
static Size make_calculated(NonnullRefPtr<CalculatedStyleValue>); static Size make_calculated(NonnullRefPtr<CalculatedStyleValue const>);
static Size make_min_content(); static Size make_min_content();
static Size make_max_content(); static Size make_max_content();
static Size make_fit_content(LengthPercentage available_space); static Size make_fit_content(LengthPercentage available_space);

View file

@ -1006,7 +1006,7 @@ void StyleComputer::set_all_properties(
continue; continue;
} }
NonnullRefPtr<CSSStyleValue> property_value = value; NonnullRefPtr<CSSStyleValue const> property_value = value;
if (property_value->is_unresolved()) if (property_value->is_unresolved())
property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { document }, element, pseudo_element, property_id, property_value->as_unresolved()); property_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { document }, element, pseudo_element, property_id, property_value->as_unresolved());
if (!property_value->is_unresolved()) if (!property_value->is_unresolved())
@ -2486,7 +2486,7 @@ static bool is_monospace(CSSStyleValue const& value)
// instead of the default font size (16px). // instead of the default font size (16px).
// See this blog post for a lot more details about this weirdness: // See this blog post for a lot more details about this weirdness:
// https://manishearth.github.io/blog/2017/08/10/font-size-an-unexpectedly-complex-css-property/ // https://manishearth.github.io/blog/2017/08/10/font-size-an-unexpectedly-complex-css-property/
RefPtr<CSSStyleValue> StyleComputer::recascade_font_size_if_needed( RefPtr<CSSStyleValue const> StyleComputer::recascade_font_size_if_needed(
DOM::Element& element, DOM::Element& element,
Optional<CSS::PseudoElement> pseudo_element, Optional<CSS::PseudoElement> pseudo_element,
CascadedProperties& cascaded_properties) const CascadedProperties& cascaded_properties) const
@ -2510,7 +2510,7 @@ RefPtr<CSSStyleValue> StyleComputer::recascade_font_size_if_needed(
for (auto* ancestor = element.parent_element(); ancestor; ancestor = ancestor->parent_element()) for (auto* ancestor = element.parent_element(); ancestor; ancestor = ancestor->parent_element())
ancestors.append(*ancestor); ancestors.append(*ancestor);
NonnullRefPtr<CSSStyleValue> new_font_size = CSS::LengthStyleValue::create(CSS::Length::make_px(default_monospace_font_size_in_px)); NonnullRefPtr<CSSStyleValue const> new_font_size = CSS::LengthStyleValue::create(CSS::Length::make_px(default_monospace_font_size_in_px));
CSSPixels current_size_in_px = default_monospace_font_size_in_px; CSSPixels current_size_in_px = default_monospace_font_size_in_px;
for (auto& ancestor : ancestors.in_reverse()) { for (auto& ancestor : ancestors.in_reverse()) {

View file

@ -183,7 +183,7 @@ public:
static CSSPixelFraction absolute_size_mapping(Keyword); static CSSPixelFraction absolute_size_mapping(Keyword);
RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth = 0) const; RefPtr<Gfx::FontCascadeList const> compute_font_for_style_values(DOM::Element const* element, Optional<CSS::PseudoElement> pseudo_element, CSSStyleValue const& font_family, CSSStyleValue const& font_size, CSSStyleValue const& font_style, CSSStyleValue const& font_weight, CSSStyleValue const& font_stretch, int math_depth = 0) const;
[[nodiscard]] RefPtr<CSSStyleValue> recascade_font_size_if_needed(DOM::Element&, Optional<CSS::PseudoElement> pseudo_element, CascadedProperties&) const; [[nodiscard]] RefPtr<CSSStyleValue const> recascade_font_size_if_needed(DOM::Element&, Optional<CSS::PseudoElement> pseudo_element, CascadedProperties&) const;
void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; } void set_viewport_rect(Badge<DOM::Document>, CSSPixelRect const& viewport_rect) { m_viewport_rect = viewport_rect; }

View file

@ -165,7 +165,7 @@ struct ColorStopListElement {
Optional<ColorHint> transition_hint; Optional<ColorHint> transition_hint;
struct ColorStop { struct ColorStop {
RefPtr<CSSStyleValue> color; RefPtr<CSSStyleValue const> color;
Optional<TPosition> position; Optional<TPosition> position;
Optional<TPosition> second_position = {}; Optional<TPosition> second_position = {};
inline bool operator==(ColorStop const&) const = default; inline bool operator==(ColorStop const&) const = default;

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class AngleStyleValue : public CSSUnitValue { class AngleStyleValue : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<AngleStyleValue> create(Angle angle) static ValueComparingNonnullRefPtr<AngleStyleValue const> create(Angle angle)
{ {
return adopt_ref(*new (nothrow) AngleStyleValue(move(angle))); return adopt_ref(*new (nothrow) AngleStyleValue(move(angle)));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators<BackgroundRepeatStyleValue> { class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators<BackgroundRepeatStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue> create(Repeat repeat_x, Repeat repeat_y) static ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue const> create(Repeat repeat_x, Repeat repeat_y)
{ {
return adopt_ref(*new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y)); return adopt_ref(*new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y));
} }

View file

@ -18,7 +18,7 @@ namespace Web::CSS {
// NOTE: This is not used for identifier sizes, like `cover` and `contain`. // NOTE: This is not used for identifier sizes, like `cover` and `contain`.
class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> { class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<BackgroundSizeStyleValue> create(LengthPercentage size_x, LengthPercentage size_y) static ValueComparingNonnullRefPtr<BackgroundSizeStyleValue const> create(LengthPercentage size_x, LengthPercentage size_y)
{ {
return adopt_ref(*new (nothrow) BackgroundSizeStyleValue(size_x, size_y)); return adopt_ref(*new (nothrow) BackgroundSizeStyleValue(size_x, size_y));
} }

View file

@ -59,7 +59,7 @@ struct Circle {
bool operator==(Circle const&) const = default; bool operator==(Circle const&) const = default;
ShapeRadius radius; ShapeRadius radius;
ValueComparingNonnullRefPtr<PositionStyleValue> position; ValueComparingNonnullRefPtr<PositionStyleValue const> position;
}; };
struct Ellipse { struct Ellipse {
@ -70,7 +70,7 @@ struct Ellipse {
ShapeRadius radius_x; ShapeRadius radius_x;
ShapeRadius radius_y; ShapeRadius radius_y;
ValueComparingNonnullRefPtr<PositionStyleValue> position; ValueComparingNonnullRefPtr<PositionStyleValue const> position;
}; };
struct Polygon { struct Polygon {
@ -94,7 +94,7 @@ using BasicShape = Variant<Inset, Xywh, Rect, Circle, Ellipse, Polygon>;
class BasicShapeStyleValue : public StyleValueWithDefaultOperators<BasicShapeStyleValue> { class BasicShapeStyleValue : public StyleValueWithDefaultOperators<BasicShapeStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<BasicShapeStyleValue> create(BasicShape basic_shape) static ValueComparingNonnullRefPtr<BasicShapeStyleValue const> create(BasicShape basic_shape)
{ {
return adopt_ref(*new (nothrow) BasicShapeStyleValue(move(basic_shape))); return adopt_ref(*new (nothrow) BasicShapeStyleValue(move(basic_shape)));
} }

View file

@ -17,7 +17,7 @@ namespace Web::CSS {
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> { class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius) static ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
{ {
return adopt_ref(*new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius)); return adopt_ref(*new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius));
} }

View file

@ -18,7 +18,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<CSSColorValue> CSSColorValue::create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name) ValueComparingNonnullRefPtr<CSSColorValue const> CSSColorValue::create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name)
{ {
return CSSRGB::create( return CSSRGB::create(
NumberStyleValue::create(color.red()), NumberStyleValue::create(color.red()),

View file

@ -23,7 +23,7 @@ enum class ColorSyntax : u8 {
// https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue // https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue
class CSSColorValue : public CSSStyleValue { class CSSColorValue : public CSSStyleValue {
public: public:
static ValueComparingNonnullRefPtr<CSSColorValue> create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name = {}); static ValueComparingNonnullRefPtr<CSSColorValue const> create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name = {});
virtual ~CSSColorValue() override = default; virtual ~CSSColorValue() override = default;
virtual bool has_color() const override { return true; } virtual bool has_color() const override { return true; }

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csshsl // https://drafts.css-houdini.org/css-typed-om-1/#csshsl
class CSSHSL final : public CSSColorValue { class CSSHSL final : public CSSColorValue {
public: public:
static ValueComparingNonnullRefPtr<CSSHSL> create(ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> s, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingRefPtr<CSSStyleValue> alpha, ColorSyntax color_syntax) static ValueComparingNonnullRefPtr<CSSHSL const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> s, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax)
{ {
// alpha defaults to 1 // alpha defaults to 1
if (!alpha) if (!alpha)
@ -36,17 +36,17 @@ public:
virtual bool equals(CSSStyleValue const& other) const override; virtual bool equals(CSSStyleValue const& other) const override;
private: private:
CSSHSL(ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> s, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> alpha, ColorSyntax color_syntax) CSSHSL(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> s, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax)
: CSSColorValue(ColorType::HSL, color_syntax) : CSSColorValue(ColorType::HSL, color_syntax)
, m_properties { .h = move(h), .s = move(s), .l = move(l), .alpha = move(alpha) } , m_properties { .h = move(h), .s = move(s), .l = move(l), .alpha = move(alpha) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> h; ValueComparingNonnullRefPtr<CSSStyleValue const> h;
ValueComparingNonnullRefPtr<CSSStyleValue> s; ValueComparingNonnullRefPtr<CSSStyleValue const> s;
ValueComparingNonnullRefPtr<CSSStyleValue> l; ValueComparingNonnullRefPtr<CSSStyleValue const> l;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csshwb // https://drafts.css-houdini.org/css-typed-om-1/#csshwb
class CSSHWB final : public CSSColorValue { class CSSHWB final : public CSSColorValue {
public: public:
static ValueComparingNonnullRefPtr<CSSHWB> create(ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> w, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingRefPtr<CSSStyleValue> alpha = {}) static ValueComparingNonnullRefPtr<CSSHWB const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> w, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
{ {
// alpha defaults to 1 // alpha defaults to 1
if (!alpha) if (!alpha)
@ -36,17 +36,17 @@ public:
virtual bool equals(CSSStyleValue const& other) const override; virtual bool equals(CSSStyleValue const& other) const override;
private: private:
CSSHWB(ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> w, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSHWB(ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> w, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSColorValue(ColorType::HWB, ColorSyntax::Modern) : CSSColorValue(ColorType::HWB, ColorSyntax::Modern)
, m_properties { .h = move(h), .w = move(w), .b = move(b), .alpha = move(alpha) } , m_properties { .h = move(h), .w = move(w), .b = move(b), .alpha = move(alpha) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> h; ValueComparingNonnullRefPtr<CSSStyleValue const> h;
ValueComparingNonnullRefPtr<CSSStyleValue> w; ValueComparingNonnullRefPtr<CSSStyleValue const> w;
ValueComparingNonnullRefPtr<CSSStyleValue> b; ValueComparingNonnullRefPtr<CSSStyleValue const> b;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };

View file

@ -17,28 +17,28 @@ namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue // https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
class CSSKeywordValue : public StyleValueWithDefaultOperators<CSSKeywordValue> { class CSSKeywordValue : public StyleValueWithDefaultOperators<CSSKeywordValue> {
public: public:
static ValueComparingNonnullRefPtr<CSSKeywordValue> create(Keyword keyword) static ValueComparingNonnullRefPtr<CSSKeywordValue const> create(Keyword keyword)
{ {
// NOTE: We'll have to be much more careful with caching once we expose CSSKeywordValue to JS, as it's mutable. // NOTE: We'll have to be much more careful with caching once we expose CSSKeywordValue to JS, as it's mutable.
switch (keyword) { switch (keyword) {
case Keyword::Inherit: { case Keyword::Inherit: {
static ValueComparingNonnullRefPtr<CSSKeywordValue> const inherit_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Inherit)); static ValueComparingNonnullRefPtr<CSSKeywordValue const> const inherit_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Inherit));
return inherit_instance; return inherit_instance;
} }
case Keyword::Initial: { case Keyword::Initial: {
static ValueComparingNonnullRefPtr<CSSKeywordValue> const initial_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Initial)); static ValueComparingNonnullRefPtr<CSSKeywordValue const> const initial_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Initial));
return initial_instance; return initial_instance;
} }
case Keyword::Revert: { case Keyword::Revert: {
static ValueComparingNonnullRefPtr<CSSKeywordValue> const revert_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Revert)); static ValueComparingNonnullRefPtr<CSSKeywordValue const> const revert_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Revert));
return revert_instance; return revert_instance;
} }
case Keyword::RevertLayer: { case Keyword::RevertLayer: {
static ValueComparingNonnullRefPtr<CSSKeywordValue> const revert_layer_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::RevertLayer)); static ValueComparingNonnullRefPtr<CSSKeywordValue const> const revert_layer_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::RevertLayer));
return revert_layer_instance; return revert_layer_instance;
} }
case Keyword::Unset: { case Keyword::Unset: {
static ValueComparingNonnullRefPtr<CSSKeywordValue> const unset_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Unset)); static ValueComparingNonnullRefPtr<CSSKeywordValue const> const unset_instance = adopt_ref(*new (nothrow) CSSKeywordValue(Keyword::Unset));
return unset_instance; return unset_instance;
} }
default: default:

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
class CSSLCHLike : public CSSColorValue { class CSSLCHLike : public CSSColorValue {
public: public:
template<DerivedFrom<CSSLCHLike> T> template<DerivedFrom<CSSLCHLike> T>
static ValueComparingNonnullRefPtr<T> create(ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> c, ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingRefPtr<CSSStyleValue> alpha = {}) static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
{ {
// alpha defaults to 1 // alpha defaults to 1
if (!alpha) if (!alpha)
@ -32,17 +32,17 @@ public:
virtual bool equals(CSSStyleValue const& other) const override; virtual bool equals(CSSStyleValue const& other) const override;
protected: protected:
CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> c, ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSColorValue(color_type, ColorSyntax::Modern) : CSSColorValue(color_type, ColorSyntax::Modern)
, m_properties { .l = move(l), .c = move(c), .h = move(h), .alpha = move(alpha) } , m_properties { .l = move(l), .c = move(c), .h = move(h), .alpha = move(alpha) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> l; ValueComparingNonnullRefPtr<CSSStyleValue const> l;
ValueComparingNonnullRefPtr<CSSStyleValue> c; ValueComparingNonnullRefPtr<CSSStyleValue const> c;
ValueComparingNonnullRefPtr<CSSStyleValue> h; ValueComparingNonnullRefPtr<CSSStyleValue const> h;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };
@ -50,7 +50,7 @@ protected:
// https://drafts.css-houdini.org/css-typed-om-1/#csslch // https://drafts.css-houdini.org/css-typed-om-1/#csslch
class CSSLCH final : public CSSLCHLike { class CSSLCH final : public CSSLCHLike {
public: public:
CSSLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> c, ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSLCHLike(ColorType::LCH, move(l), move(c), move(h), move(alpha)) : CSSLCHLike(ColorType::LCH, move(l), move(c), move(h), move(alpha))
{ {
} }
@ -64,7 +64,7 @@ public:
// https://drafts.css-houdini.org/css-typed-om-1/#cssoklch // https://drafts.css-houdini.org/css-typed-om-1/#cssoklch
class CSSOKLCH final : public CSSLCHLike { class CSSOKLCH final : public CSSLCHLike {
public: public:
CSSOKLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> c, ValueComparingNonnullRefPtr<CSSStyleValue> h, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSOKLCH(Badge<CSSLCHLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> c, ValueComparingNonnullRefPtr<CSSStyleValue const> h, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSLCHLike(ColorType::OKLCH, move(l), move(c), move(h), move(alpha)) : CSSLCHLike(ColorType::OKLCH, move(l), move(c), move(h), move(alpha))
{ {
} }

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
class CSSLabLike : public CSSColorValue { class CSSLabLike : public CSSColorValue {
public: public:
template<typename T> template<typename T>
static ValueComparingNonnullRefPtr<T> create(ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> a, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingRefPtr<CSSStyleValue> alpha = {}) static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha = {})
{ {
// alpha defaults to 1 // alpha defaults to 1
if (!alpha) if (!alpha)
@ -33,17 +33,17 @@ public:
virtual bool equals(CSSStyleValue const& other) const override; virtual bool equals(CSSStyleValue const& other) const override;
protected: protected:
CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> a, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSColorValue(color_type, ColorSyntax::Modern) : CSSColorValue(color_type, ColorSyntax::Modern)
, m_properties { .l = move(l), .a = move(a), .b = move(b), .alpha = move(alpha) } , m_properties { .l = move(l), .a = move(a), .b = move(b), .alpha = move(alpha) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> l; ValueComparingNonnullRefPtr<CSSStyleValue const> l;
ValueComparingNonnullRefPtr<CSSStyleValue> a; ValueComparingNonnullRefPtr<CSSStyleValue const> a;
ValueComparingNonnullRefPtr<CSSStyleValue> b; ValueComparingNonnullRefPtr<CSSStyleValue const> b;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };
@ -54,7 +54,7 @@ public:
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override; virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override;
virtual String to_string(SerializationMode) const override; virtual String to_string(SerializationMode) const override;
CSSOKLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> a, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSOKLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSLabLike(ColorType::OKLab, move(l), move(a), move(b), move(alpha)) : CSSLabLike(ColorType::OKLab, move(l), move(a), move(b), move(alpha))
{ {
} }
@ -66,7 +66,7 @@ public:
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override; virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override;
virtual String to_string(SerializationMode) const override; virtual String to_string(SerializationMode) const override;
CSSLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue> l, ValueComparingNonnullRefPtr<CSSStyleValue> a, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) CSSLab(Badge<CSSLabLike>, ValueComparingNonnullRefPtr<CSSStyleValue const> l, ValueComparingNonnullRefPtr<CSSStyleValue const> a, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSLabLike(ColorType::Lab, move(l), move(a), move(b), move(alpha)) : CSSLabLike(ColorType::Lab, move(l), move(a), move(b), move(alpha))
{ {
} }

View file

@ -15,7 +15,7 @@ class CSSLightDark final : public CSSColorValue {
public: public:
virtual ~CSSLightDark() override = default; virtual ~CSSLightDark() override = default;
static ValueComparingNonnullRefPtr<CSSLightDark> create(ValueComparingNonnullRefPtr<CSSStyleValue> light, ValueComparingNonnullRefPtr<CSSStyleValue> dark) static ValueComparingNonnullRefPtr<CSSLightDark const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> light, ValueComparingNonnullRefPtr<CSSStyleValue const> dark)
{ {
return AK::adopt_ref(*new (nothrow) CSSLightDark(move(light), move(dark))); return AK::adopt_ref(*new (nothrow) CSSLightDark(move(light), move(dark)));
} }
@ -25,15 +25,15 @@ public:
virtual String to_string(SerializationMode) const override; virtual String to_string(SerializationMode) const override;
private: private:
CSSLightDark(ValueComparingNonnullRefPtr<CSSStyleValue> light, ValueComparingNonnullRefPtr<CSSStyleValue> dark) CSSLightDark(ValueComparingNonnullRefPtr<CSSStyleValue const> light, ValueComparingNonnullRefPtr<CSSStyleValue const> dark)
: CSSColorValue(CSSColorValue::ColorType::LightDark, ColorSyntax::Modern) : CSSColorValue(CSSColorValue::ColorType::LightDark, ColorSyntax::Modern)
, m_properties { .light = move(light), .dark = move(dark) } , m_properties { .light = move(light), .dark = move(dark) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> light; ValueComparingNonnullRefPtr<CSSStyleValue const> light;
ValueComparingNonnullRefPtr<CSSStyleValue> dark; ValueComparingNonnullRefPtr<CSSStyleValue const> dark;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
}; };

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#cssrgb // https://drafts.css-houdini.org/css-typed-om-1/#cssrgb
class CSSRGB final : public CSSColorValue { class CSSRGB final : public CSSColorValue {
public: public:
static ValueComparingNonnullRefPtr<CSSRGB> create(ValueComparingNonnullRefPtr<CSSStyleValue> r, ValueComparingNonnullRefPtr<CSSStyleValue> g, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingRefPtr<CSSStyleValue> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {}) static ValueComparingNonnullRefPtr<CSSRGB const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> r, ValueComparingNonnullRefPtr<CSSStyleValue const> g, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
{ {
// alpha defaults to 1 // alpha defaults to 1
if (!alpha) if (!alpha)
@ -36,17 +36,17 @@ public:
virtual bool equals(CSSStyleValue const& other) const override; virtual bool equals(CSSStyleValue const& other) const override;
private: private:
CSSRGB(ValueComparingNonnullRefPtr<CSSStyleValue> r, ValueComparingNonnullRefPtr<CSSStyleValue> g, ValueComparingNonnullRefPtr<CSSStyleValue> b, ValueComparingNonnullRefPtr<CSSStyleValue> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {}) CSSRGB(ValueComparingNonnullRefPtr<CSSStyleValue const> r, ValueComparingNonnullRefPtr<CSSStyleValue const> g, ValueComparingNonnullRefPtr<CSSStyleValue const> b, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
: CSSColorValue(ColorType::RGB, color_syntax) : CSSColorValue(ColorType::RGB, color_syntax)
, m_properties { .r = move(r), .g = move(g), .b = move(b), .alpha = move(alpha), .name = name } , m_properties { .r = move(r), .g = move(g), .b = move(b), .alpha = move(alpha), .name = name }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<CSSStyleValue> r; ValueComparingNonnullRefPtr<CSSStyleValue const> r;
ValueComparingNonnullRefPtr<CSSStyleValue> g; ValueComparingNonnullRefPtr<CSSStyleValue const> g;
ValueComparingNonnullRefPtr<CSSStyleValue> b; ValueComparingNonnullRefPtr<CSSStyleValue const> b;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
Optional<FlyString> name; Optional<FlyString> name;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;

View file

@ -664,11 +664,11 @@ CalculatedStyleValue::CalculationResult NumericCalculationNode::resolve(Calculat
return CalculatedStyleValue::CalculationResult::from_value(m_value, context, numeric_type()); return CalculatedStyleValue::CalculationResult::from_value(m_value, context, numeric_type());
} }
RefPtr<CSSStyleValue> NumericCalculationNode::to_style_value(CalculationContext const& context) const RefPtr<CSSStyleValue const> NumericCalculationNode::to_style_value(CalculationContext const& context) const
{ {
// TODO: Clamp values to the range allowed by the context. // TODO: Clamp values to the range allowed by the context.
return m_value.visit( return m_value.visit(
[&](Number const& number) -> RefPtr<CSSStyleValue> { [&](Number const& number) -> RefPtr<CSSStyleValue const> {
// FIXME: Returning infinity or NaN as a NumberStyleValue isn't valid. // FIXME: Returning infinity or NaN as a NumberStyleValue isn't valid.
// This is a temporary fix until value-clamping is implemented here. // This is a temporary fix until value-clamping is implemented here.
// In future, we can remove these two lines and return NonnullRefPtr again. // In future, we can remove these two lines and return NonnullRefPtr again.
@ -679,13 +679,13 @@ RefPtr<CSSStyleValue> NumericCalculationNode::to_style_value(CalculationContext
return IntegerStyleValue::create(llround(number.value())); return IntegerStyleValue::create(llround(number.value()));
return NumberStyleValue::create(number.value()); return NumberStyleValue::create(number.value());
}, },
[](Angle const& angle) -> RefPtr<CSSStyleValue> { return AngleStyleValue::create(angle); }, [](Angle const& angle) -> RefPtr<CSSStyleValue const> { return AngleStyleValue::create(angle); },
[](Flex const& flex) -> RefPtr<CSSStyleValue> { return FlexStyleValue::create(flex); }, [](Flex const& flex) -> RefPtr<CSSStyleValue const> { return FlexStyleValue::create(flex); },
[](Frequency const& frequency) -> RefPtr<CSSStyleValue> { return FrequencyStyleValue::create(frequency); }, [](Frequency const& frequency) -> RefPtr<CSSStyleValue const> { return FrequencyStyleValue::create(frequency); },
[](Length const& length) -> RefPtr<CSSStyleValue> { return LengthStyleValue::create(length); }, [](Length const& length) -> RefPtr<CSSStyleValue const> { return LengthStyleValue::create(length); },
[](Percentage const& percentage) -> RefPtr<CSSStyleValue> { return PercentageStyleValue::create(percentage); }, [](Percentage const& percentage) -> RefPtr<CSSStyleValue const> { return PercentageStyleValue::create(percentage); },
[](Resolution const& resolution) -> RefPtr<CSSStyleValue> { return ResolutionStyleValue::create(resolution); }, [](Resolution const& resolution) -> RefPtr<CSSStyleValue const> { return ResolutionStyleValue::create(resolution); },
[](Time const& time) -> RefPtr<CSSStyleValue> { return TimeStyleValue::create(time); }); [](Time const& time) -> RefPtr<CSSStyleValue const> { return TimeStyleValue::create(time); });
} }
Optional<NonFiniteValue> NumericCalculationNode::infinite_or_nan_value() const Optional<NonFiniteValue> NumericCalculationNode::infinite_or_nan_value() const

View file

@ -67,7 +67,7 @@ public:
Optional<CSSNumericType> m_type; Optional<CSSNumericType> m_type;
}; };
static ValueComparingNonnullRefPtr<CalculatedStyleValue> create(NonnullRefPtr<CalculationNode> calculation, CSSNumericType resolved_type, CalculationContext context) static ValueComparingNonnullRefPtr<CalculatedStyleValue const> create(NonnullRefPtr<CalculationNode> calculation, CSSNumericType resolved_type, CalculationContext context)
{ {
return adopt_ref(*new (nothrow) CalculatedStyleValue(move(calculation), move(resolved_type), move(context))); return adopt_ref(*new (nothrow) CalculatedStyleValue(move(calculation), move(resolved_type), move(context)));
} }
@ -262,7 +262,7 @@ public:
virtual CalculatedStyleValue::CalculationResult resolve(CalculationResolutionContext const&) const override; virtual CalculatedStyleValue::CalculationResult resolve(CalculationResolutionContext const&) const override;
virtual NonnullRefPtr<CalculationNode> with_simplified_children(CalculationContext const&, CalculationResolutionContext const&) const override { return *this; } virtual NonnullRefPtr<CalculationNode> with_simplified_children(CalculationContext const&, CalculationResolutionContext const&) const override { return *this; }
RefPtr<CSSStyleValue> to_style_value(CalculationContext const&) const; RefPtr<CSSStyleValue const> to_style_value(CalculationContext const&) const;
virtual Vector<NonnullRefPtr<CalculationNode>> children() const override { return {}; } virtual Vector<NonnullRefPtr<CalculationNode>> children() const override { return {}; }
NumericValue const& value() const { return m_value; } NumericValue const& value() const { return m_value; }

View file

@ -58,7 +58,7 @@ StringView string_view_from_color_type(CSSColorValue::ColorType color_type)
} }
ValueComparingNonnullRefPtr<ColorFunctionStyleValue> ColorFunctionStyleValue::create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue> c1, ValueComparingNonnullRefPtr<CSSStyleValue> c2, ValueComparingNonnullRefPtr<CSSStyleValue> c3, ValueComparingRefPtr<CSSStyleValue> alpha) ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> ColorFunctionStyleValue::create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingRefPtr<CSSStyleValue const> alpha)
{ {
VERIFY(any_of(s_supported_color_space, [=](auto supported) { return color_space == supported; })); VERIFY(any_of(s_supported_color_space, [=](auto supported) { return color_space == supported; }));
@ -93,7 +93,7 @@ ColorFunctionStyleValue::Resolved ColorFunctionStyleValue::resolve_properties()
// https://www.w3.org/TR/css-color-4/#serializing-color-function-values // https://www.w3.org/TR/css-color-4/#serializing-color-function-values
String ColorFunctionStyleValue::to_string(SerializationMode mode) const String ColorFunctionStyleValue::to_string(SerializationMode mode) const
{ {
auto convert_percentage = [](ValueComparingNonnullRefPtr<CSSStyleValue> const& value) -> RemoveReference<decltype(value)> { auto convert_percentage = [](ValueComparingNonnullRefPtr<CSSStyleValue const> const& value) -> RemoveReference<decltype(value)> {
if (value->is_percentage()) if (value->is_percentage())
return NumberStyleValue::create(value->as_percentage().value() / 100); return NumberStyleValue::create(value->as_percentage().value() / 100);
return value; return value;

View file

@ -15,7 +15,7 @@ class ColorFunctionStyleValue final : public CSSColorValue {
public: public:
virtual ~ColorFunctionStyleValue() override = default; virtual ~ColorFunctionStyleValue() override = default;
static ValueComparingNonnullRefPtr<ColorFunctionStyleValue> create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue> c1, ValueComparingNonnullRefPtr<CSSStyleValue> c2, ValueComparingNonnullRefPtr<CSSStyleValue> c3, ValueComparingRefPtr<CSSStyleValue> alpha = {}); static ValueComparingNonnullRefPtr<ColorFunctionStyleValue const> create(StringView color_space, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingRefPtr<CSSStyleValue const> alpha = {});
virtual bool equals(CSSStyleValue const&) const override; virtual bool equals(CSSStyleValue const&) const override;
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override; virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override;
@ -26,15 +26,15 @@ public:
static constexpr Array s_supported_color_space = { "a98-rgb"sv, "display-p3"sv, "srgb"sv, "srgb-linear"sv, "prophoto-rgb"sv, "rec2020"sv, "xyz"sv, "xyz-d50"sv, "xyz-d65"sv }; static constexpr Array s_supported_color_space = { "a98-rgb"sv, "display-p3"sv, "srgb"sv, "srgb-linear"sv, "prophoto-rgb"sv, "rec2020"sv, "xyz"sv, "xyz-d50"sv, "xyz-d65"sv };
private: private:
ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue> c1, ValueComparingNonnullRefPtr<CSSStyleValue> c2, ValueComparingNonnullRefPtr<CSSStyleValue> c3, ValueComparingNonnullRefPtr<CSSStyleValue> alpha) ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<CSSStyleValue const> c1, ValueComparingNonnullRefPtr<CSSStyleValue const> c2, ValueComparingNonnullRefPtr<CSSStyleValue const> c3, ValueComparingNonnullRefPtr<CSSStyleValue const> alpha)
: CSSColorValue(color_type, ColorSyntax::Modern) : CSSColorValue(color_type, ColorSyntax::Modern)
, m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) } , m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) }
{ {
} }
struct Properties { struct Properties {
Array<ValueComparingNonnullRefPtr<CSSStyleValue>, 3> channels; Array<ValueComparingNonnullRefPtr<CSSStyleValue const>, 3> channels;
ValueComparingNonnullRefPtr<CSSStyleValue> alpha; ValueComparingNonnullRefPtr<CSSStyleValue const> alpha;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
}; };

View file

@ -12,11 +12,11 @@ namespace Web::CSS {
class ColorSchemeStyleValue final : public StyleValueWithDefaultOperators<ColorSchemeStyleValue> { class ColorSchemeStyleValue final : public StyleValueWithDefaultOperators<ColorSchemeStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<ColorSchemeStyleValue> create(Vector<String> schemes, bool only) static ValueComparingNonnullRefPtr<ColorSchemeStyleValue const> create(Vector<String> schemes, bool only)
{ {
return adopt_ref(*new (nothrow) ColorSchemeStyleValue(move(schemes), only)); return adopt_ref(*new (nothrow) ColorSchemeStyleValue(move(schemes), only));
} }
static ValueComparingNonnullRefPtr<ColorSchemeStyleValue> normal() static ValueComparingNonnullRefPtr<ColorSchemeStyleValue const> normal()
{ {
return adopt_ref(*new (nothrow) ColorSchemeStyleValue({}, false)); return adopt_ref(*new (nothrow) ColorSchemeStyleValue({}, false));
} }

View file

@ -17,7 +17,7 @@ namespace Web::CSS {
class ConicGradientStyleValue final : public AbstractImageStyleValue { class ConicGradientStyleValue final : public AbstractImageStyleValue {
public: public:
static ValueComparingNonnullRefPtr<ConicGradientStyleValue> create(Angle from_angle, ValueComparingNonnullRefPtr<PositionStyleValue> position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method) static ValueComparingNonnullRefPtr<ConicGradientStyleValue const> create(Angle from_angle, ValueComparingNonnullRefPtr<PositionStyleValue const> position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method)
{ {
VERIFY(!color_stop_list.is_empty()); VERIFY(!color_stop_list.is_empty());
bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value(); bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value();
@ -54,7 +54,7 @@ public:
bool is_repeating() const { return m_properties.repeating == GradientRepeating::Yes; } bool is_repeating() const { return m_properties.repeating == GradientRepeating::Yes; }
private: private:
ConicGradientStyleValue(Angle from_angle, ValueComparingNonnullRefPtr<PositionStyleValue> position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method, ColorSyntax color_syntax) ConicGradientStyleValue(Angle from_angle, ValueComparingNonnullRefPtr<PositionStyleValue const> position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method, ColorSyntax color_syntax)
: AbstractImageStyleValue(Type::ConicGradient) : AbstractImageStyleValue(Type::ConicGradient)
, m_properties { .from_angle = from_angle, .position = move(position), .color_stop_list = move(color_stop_list), .repeating = repeating, .interpolation_method = interpolation_method, .color_syntax = color_syntax } , m_properties { .from_angle = from_angle, .position = move(position), .color_stop_list = move(color_stop_list), .repeating = repeating, .interpolation_method = interpolation_method, .color_syntax = color_syntax }
{ {
@ -62,7 +62,7 @@ private:
struct Properties { struct Properties {
Angle from_angle; Angle from_angle;
ValueComparingNonnullRefPtr<PositionStyleValue> position; ValueComparingNonnullRefPtr<PositionStyleValue const> position;
Vector<AngularColorStopListElement> color_stop_list; Vector<AngularColorStopListElement> color_stop_list;
GradientRepeating repeating; GradientRepeating repeating;
Optional<InterpolationMethod> interpolation_method; Optional<InterpolationMethod> interpolation_method;

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> { class ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<ContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text) static ValueComparingNonnullRefPtr<ContentStyleValue const> create(ValueComparingNonnullRefPtr<StyleValueList const> content, ValueComparingRefPtr<StyleValueList const> alt_text)
{ {
return adopt_ref(*new (nothrow) ContentStyleValue(move(content), move(alt_text))); return adopt_ref(*new (nothrow) ContentStyleValue(move(content), move(alt_text)));
} }
@ -30,15 +30,15 @@ public:
bool properties_equal(ContentStyleValue const& other) const { return m_properties == other.m_properties; } bool properties_equal(ContentStyleValue const& other) const { return m_properties == other.m_properties; }
private: private:
ContentStyleValue(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text) ContentStyleValue(ValueComparingNonnullRefPtr<StyleValueList const> content, ValueComparingRefPtr<StyleValueList const> alt_text)
: StyleValueWithDefaultOperators(Type::Content) : StyleValueWithDefaultOperators(Type::Content)
, m_properties { .content = move(content), .alt_text = move(alt_text) } , m_properties { .content = move(content), .alt_text = move(alt_text) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<StyleValueList> content; ValueComparingNonnullRefPtr<StyleValueList const> content;
ValueComparingRefPtr<StyleValueList> alt_text; ValueComparingRefPtr<StyleValueList const> alt_text;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };

View file

@ -23,7 +23,7 @@ struct CounterDefinition {
*/ */
class CounterDefinitionsStyleValue : public StyleValueWithDefaultOperators<CounterDefinitionsStyleValue> { class CounterDefinitionsStyleValue : public StyleValueWithDefaultOperators<CounterDefinitionsStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<CounterDefinitionsStyleValue> create(Vector<CounterDefinition> counter_definitions) static ValueComparingNonnullRefPtr<CounterDefinitionsStyleValue const> create(Vector<CounterDefinition> counter_definitions)
{ {
return adopt_ref(*new (nothrow) CounterDefinitionsStyleValue(move(counter_definitions))); return adopt_ref(*new (nothrow) CounterDefinitionsStyleValue(move(counter_definitions)));
} }

View file

@ -19,11 +19,11 @@ public:
Counters, Counters,
}; };
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style) static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
{ {
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {})); return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {}));
} }
static ValueComparingNonnullRefPtr<CounterStyleValue> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style) static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<CSSStyleValue const> counter_style)
{ {
return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counters, move(counter_name), move(counter_style), move(join_string))); return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counters, move(counter_name), move(counter_style), move(join_string)));
} }

View file

@ -18,14 +18,14 @@ namespace Web::CSS {
class CursorStyleValue final : public StyleValueWithDefaultOperators<CursorStyleValue> { class CursorStyleValue final : public StyleValueWithDefaultOperators<CursorStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<CursorStyleValue> create(ValueComparingNonnullRefPtr<AbstractImageStyleValue> image, Optional<NumberOrCalculated> x, Optional<NumberOrCalculated> y) static ValueComparingNonnullRefPtr<CursorStyleValue const> create(ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image, Optional<NumberOrCalculated> x, Optional<NumberOrCalculated> y)
{ {
VERIFY(x.has_value() == y.has_value()); VERIFY(x.has_value() == y.has_value());
return adopt_ref(*new (nothrow) CursorStyleValue(move(image), move(x), move(y))); return adopt_ref(*new (nothrow) CursorStyleValue(move(image), move(x), move(y)));
} }
virtual ~CursorStyleValue() override = default; virtual ~CursorStyleValue() override = default;
ValueComparingNonnullRefPtr<AbstractImageStyleValue> image() const { return m_properties.image; } ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image() const { return m_properties.image; }
Optional<NumberOrCalculated> const& x() const { return m_properties.x; } Optional<NumberOrCalculated> const& x() const { return m_properties.x; }
Optional<NumberOrCalculated> const& y() const { return m_properties.y; } Optional<NumberOrCalculated> const& y() const { return m_properties.y; }
@ -36,7 +36,7 @@ public:
bool properties_equal(CursorStyleValue const& other) const { return m_properties == other.m_properties; } bool properties_equal(CursorStyleValue const& other) const { return m_properties == other.m_properties; }
private: private:
CursorStyleValue(ValueComparingNonnullRefPtr<AbstractImageStyleValue> image, CursorStyleValue(ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image,
Optional<NumberOrCalculated> x, Optional<NumberOrCalculated> x,
Optional<NumberOrCalculated> y) Optional<NumberOrCalculated> y)
: StyleValueWithDefaultOperators(Type::Cursor) : StyleValueWithDefaultOperators(Type::Cursor)
@ -45,7 +45,7 @@ private:
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<AbstractImageStyleValue> image; ValueComparingNonnullRefPtr<AbstractImageStyleValue const> image;
Optional<NumberOrCalculated> x; Optional<NumberOrCalculated> x;
Optional<NumberOrCalculated> y; Optional<NumberOrCalculated> y;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
// https://www.w3.org/TR/css-values-4/#custom-idents // https://www.w3.org/TR/css-values-4/#custom-idents
class CustomIdentStyleValue final : public StyleValueWithDefaultOperators<CustomIdentStyleValue> { class CustomIdentStyleValue final : public StyleValueWithDefaultOperators<CustomIdentStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<CustomIdentStyleValue> create(FlyString custom_ident) static ValueComparingNonnullRefPtr<CustomIdentStyleValue const> create(FlyString custom_ident)
{ {
return adopt_ref(*new (nothrow) CustomIdentStyleValue(move(custom_ident))); return adopt_ref(*new (nothrow) CustomIdentStyleValue(move(custom_ident)));
} }

View file

@ -8,7 +8,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<DisplayStyleValue> DisplayStyleValue::create(Display const& display) ValueComparingNonnullRefPtr<DisplayStyleValue const> DisplayStyleValue::create(Display const& display)
{ {
return adopt_ref(*new (nothrow) DisplayStyleValue(display)); return adopt_ref(*new (nothrow) DisplayStyleValue(display));
} }

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class DisplayStyleValue : public StyleValueWithDefaultOperators<DisplayStyleValue> { class DisplayStyleValue : public StyleValueWithDefaultOperators<DisplayStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<DisplayStyleValue> create(Display const&); static ValueComparingNonnullRefPtr<DisplayStyleValue const> create(Display const&);
virtual ~DisplayStyleValue() override = default; virtual ~DisplayStyleValue() override = default;
virtual String to_string(SerializationMode) const override { return m_display.to_string(); } virtual String to_string(SerializationMode) const override { return m_display.to_string(); }

View file

@ -94,7 +94,7 @@ public:
String to_string() const; String to_string() const;
}; };
static ValueComparingNonnullRefPtr<EasingStyleValue> create(Function const& function) static ValueComparingNonnullRefPtr<EasingStyleValue const> create(Function const& function)
{ {
return adopt_ref(*new (nothrow) EasingStyleValue(function)); return adopt_ref(*new (nothrow) EasingStyleValue(function));
} }

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> { class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<EdgeStyleValue> create(Optional<PositionEdge> edge, Optional<LengthPercentage> const& offset) static ValueComparingNonnullRefPtr<EdgeStyleValue const> create(Optional<PositionEdge> edge, Optional<LengthPercentage> const& offset)
{ {
return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset)); return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset));
} }

View file

@ -57,7 +57,7 @@ using FilterFunction = Variant<FilterOperation::Blur, FilterOperation::DropShado
class FilterValueListStyleValue final : public StyleValueWithDefaultOperators<FilterValueListStyleValue> { class FilterValueListStyleValue final : public StyleValueWithDefaultOperators<FilterValueListStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<FilterValueListStyleValue> create( static ValueComparingNonnullRefPtr<FilterValueListStyleValue const> create(
Vector<FilterFunction> filter_value_list) Vector<FilterFunction> filter_value_list)
{ {
VERIFY(filter_value_list.size() >= 1); VERIFY(filter_value_list.size() >= 1);

View file

@ -13,11 +13,11 @@ namespace Web::CSS {
class FitContentStyleValue final : public CSSStyleValue { class FitContentStyleValue final : public CSSStyleValue {
public: public:
static ValueComparingNonnullRefPtr<FitContentStyleValue> create() static ValueComparingNonnullRefPtr<FitContentStyleValue const> create()
{ {
return adopt_ref(*new (nothrow) FitContentStyleValue(LengthPercentage { Length::make_auto() })); return adopt_ref(*new (nothrow) FitContentStyleValue(LengthPercentage { Length::make_auto() }));
} }
static ValueComparingNonnullRefPtr<FitContentStyleValue> create(LengthPercentage length_percentage) static ValueComparingNonnullRefPtr<FitContentStyleValue const> create(LengthPercentage length_percentage)
{ {
return adopt_ref(*new (nothrow) FitContentStyleValue(move(length_percentage))); return adopt_ref(*new (nothrow) FitContentStyleValue(move(length_percentage)));
} }

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class FlexStyleValue final : public CSSUnitValue { class FlexStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<FlexStyleValue> create(Flex flex) static ValueComparingNonnullRefPtr<FlexStyleValue const> create(Flex flex)
{ {
return adopt_ref(*new (nothrow) FlexStyleValue(move(flex))); return adopt_ref(*new (nothrow) FlexStyleValue(move(flex)));
} }

View file

@ -14,11 +14,11 @@ namespace Web::CSS {
class FontSourceStyleValue final : public StyleValueWithDefaultOperators<FontSourceStyleValue> { class FontSourceStyleValue final : public StyleValueWithDefaultOperators<FontSourceStyleValue> {
public: public:
struct Local { struct Local {
NonnullRefPtr<CSSStyleValue> name; NonnullRefPtr<CSSStyleValue const> name;
}; };
using Source = Variant<Local, ::URL::URL>; using Source = Variant<Local, ::URL::URL>;
static ValueComparingNonnullRefPtr<FontSourceStyleValue> create(Source source, Optional<FlyString> format) static ValueComparingNonnullRefPtr<FontSourceStyleValue const> create(Source source, Optional<FlyString> format)
{ {
return adopt_ref(*new (nothrow) FontSourceStyleValue(move(source), move(format))); return adopt_ref(*new (nothrow) FontSourceStyleValue(move(source), move(format)));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class FrequencyStyleValue final : public CSSUnitValue { class FrequencyStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<FrequencyStyleValue> create(Frequency frequency) static ValueComparingNonnullRefPtr<FrequencyStyleValue const> create(Frequency frequency)
{ {
return adopt_ref(*new (nothrow) FrequencyStyleValue(move(frequency))); return adopt_ref(*new (nothrow) FrequencyStyleValue(move(frequency)));
} }

View file

@ -8,7 +8,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<GridAutoFlowStyleValue> GridAutoFlowStyleValue::create(Axis axis, Dense dense) ValueComparingNonnullRefPtr<GridAutoFlowStyleValue const> GridAutoFlowStyleValue::create(Axis axis, Dense dense)
{ {
return adopt_ref(*new GridAutoFlowStyleValue(axis, dense)); return adopt_ref(*new GridAutoFlowStyleValue(axis, dense));
} }

View file

@ -20,7 +20,7 @@ public:
No, No,
Yes, Yes,
}; };
static ValueComparingNonnullRefPtr<GridAutoFlowStyleValue> create(Axis, Dense); static ValueComparingNonnullRefPtr<GridAutoFlowStyleValue const> create(Axis, Dense);
virtual ~GridAutoFlowStyleValue() override = default; virtual ~GridAutoFlowStyleValue() override = default;
[[nodiscard]] bool is_row() const { return m_row; } [[nodiscard]] bool is_row() const { return m_row; }

View file

@ -12,7 +12,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue> GridTemplateAreaStyleValue::create(Vector<Vector<String>> grid_template_area) ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> GridTemplateAreaStyleValue::create(Vector<Vector<String>> grid_template_area)
{ {
return adopt_ref(*new (nothrow) GridTemplateAreaStyleValue(grid_template_area)); return adopt_ref(*new (nothrow) GridTemplateAreaStyleValue(grid_template_area));
} }

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class GridTemplateAreaStyleValue final : public StyleValueWithDefaultOperators<GridTemplateAreaStyleValue> { class GridTemplateAreaStyleValue final : public StyleValueWithDefaultOperators<GridTemplateAreaStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue> create(Vector<Vector<String>> grid_template_area); static ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> create(Vector<Vector<String>> grid_template_area);
virtual ~GridTemplateAreaStyleValue() override = default; virtual ~GridTemplateAreaStyleValue() override = default;
Vector<Vector<String>> const& grid_template_area() const { return m_grid_template_area; } Vector<Vector<String>> const& grid_template_area() const { return m_grid_template_area; }

View file

@ -11,7 +11,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement) ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement)
{ {
return adopt_ref(*new (nothrow) GridTrackPlacementStyleValue(grid_track_placement)); return adopt_ref(*new (nothrow) GridTrackPlacementStyleValue(grid_track_placement));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class GridTrackPlacementStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementStyleValue> { class GridTrackPlacementStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue> create(GridTrackPlacement grid_track_placement); static ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> create(GridTrackPlacement grid_track_placement);
virtual ~GridTrackPlacementStyleValue() override = default; virtual ~GridTrackPlacementStyleValue() override = default;
GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; } GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; }

View file

@ -16,17 +16,17 @@ String GridTrackSizeListStyleValue::to_string(SerializationMode) const
return m_grid_track_size_list.to_string(); return m_grid_track_size_list.to_string();
} }
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> GridTrackSizeListStyleValue::create(CSS::GridTrackSizeList grid_track_size_list)
{ {
return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(grid_track_size_list)); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(grid_track_size_list));
} }
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::make_auto() ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> GridTrackSizeListStyleValue::make_auto()
{ {
return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList())); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList()));
} }
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::make_none() ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> GridTrackSizeListStyleValue::make_none()
{ {
return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList())); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList()));
} }

View file

@ -16,11 +16,11 @@ namespace Web::CSS {
class GridTrackSizeListStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListStyleValue> { class GridTrackSizeListStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> create(CSS::GridTrackSizeList grid_track_size_list); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> create(CSS::GridTrackSizeList grid_track_size_list);
virtual ~GridTrackSizeListStyleValue() override = default; virtual ~GridTrackSizeListStyleValue() override = default;
static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> make_auto(); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> make_auto();
static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> make_none(); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> make_none();
CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; } CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; }

View file

@ -20,12 +20,12 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<ImageStyleValue> ImageStyleValue::create(URL const& url) ValueComparingNonnullRefPtr<ImageStyleValue const> ImageStyleValue::create(URL const& url)
{ {
return adopt_ref(*new (nothrow) ImageStyleValue(url)); return adopt_ref(*new (nothrow) ImageStyleValue(url));
} }
ValueComparingNonnullRefPtr<ImageStyleValue> ImageStyleValue::create(::URL::URL const& url) ValueComparingNonnullRefPtr<ImageStyleValue const> ImageStyleValue::create(::URL::URL const& url)
{ {
return adopt_ref(*new (nothrow) ImageStyleValue(URL { url.to_string() })); return adopt_ref(*new (nothrow) ImageStyleValue(URL { url.to_string() }));
} }

View file

@ -24,9 +24,8 @@ class ImageStyleValue final
using Base = AbstractImageStyleValue; using Base = AbstractImageStyleValue;
public: public:
static ValueComparingNonnullRefPtr<ImageStyleValue> create(URL const&); static ValueComparingNonnullRefPtr<ImageStyleValue const> create(URL const&);
static ValueComparingNonnullRefPtr<ImageStyleValue> create(::URL::URL const&); static ValueComparingNonnullRefPtr<ImageStyleValue const> create(::URL::URL const&);
virtual ~ImageStyleValue() override; virtual ~ImageStyleValue() override;
virtual void visit_edges(JS::Cell::Visitor& visitor) const override; virtual void visit_edges(JS::Cell::Visitor& visitor) const override;
@ -46,7 +45,7 @@ public:
virtual Optional<Gfx::Color> color_if_single_pixel_bitmap() const override; virtual Optional<Gfx::Color> color_if_single_pixel_bitmap() const override;
Gfx::ImmutableBitmap const* current_frame_bitmap(DevicePixelRect const& dest_rect) const; Gfx::ImmutableBitmap const* current_frame_bitmap(DevicePixelRect const& dest_rect) const;
Function<void()> on_animate; mutable Function<void()> on_animate;
GC::Ptr<HTML::DecodedImageData> image_data() const; GC::Ptr<HTML::DecodedImageData> image_data() const;

View file

@ -12,7 +12,7 @@ namespace Web::CSS {
class IntegerStyleValue final : public CSSUnitValue { class IntegerStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<IntegerStyleValue> create(i64 value) static ValueComparingNonnullRefPtr<IntegerStyleValue const> create(i64 value)
{ {
return adopt_ref(*new (nothrow) IntegerStyleValue(value)); return adopt_ref(*new (nothrow) IntegerStyleValue(value));
} }

View file

@ -11,7 +11,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<LengthStyleValue> LengthStyleValue::create(Length const& length) ValueComparingNonnullRefPtr<LengthStyleValue const> LengthStyleValue::create(Length const& length)
{ {
VERIFY(!length.is_auto()); VERIFY(!length.is_auto());
if (length.is_px()) { if (length.is_px()) {

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class LengthStyleValue final : public CSSUnitValue { class LengthStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<LengthStyleValue> create(Length const&); static ValueComparingNonnullRefPtr<LengthStyleValue const> create(Length const&);
virtual ~LengthStyleValue() override = default; virtual ~LengthStyleValue() override = default;
Length const& length() const { return m_length; } Length const& length() const { return m_length; }

View file

@ -39,7 +39,7 @@ public:
WebKit WebKit
}; };
static ValueComparingNonnullRefPtr<LinearGradientStyleValue> create(GradientDirection direction, Vector<LinearColorStopListElement> color_stop_list, GradientType type, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method) static ValueComparingNonnullRefPtr<LinearGradientStyleValue const> create(GradientDirection direction, Vector<LinearColorStopListElement> color_stop_list, GradientType type, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method)
{ {
VERIFY(!color_stop_list.is_empty()); VERIFY(!color_stop_list.is_empty());
bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value(); bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value();

View file

@ -8,17 +8,17 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_auto_add() ValueComparingNonnullRefPtr<MathDepthStyleValue const> MathDepthStyleValue::create_auto_add()
{ {
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::AutoAdd)); return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::AutoAdd));
} }
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value) ValueComparingNonnullRefPtr<MathDepthStyleValue const> MathDepthStyleValue::create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
{ {
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Add, move(integer_value))); return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Add, move(integer_value)));
} }
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value) ValueComparingNonnullRefPtr<MathDepthStyleValue const> MathDepthStyleValue::create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
{ {
return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Integer, move(integer_value))); return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Integer, move(integer_value)));
} }

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> { class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_auto_add(); static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_auto_add();
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value); static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value);
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value); static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value);
virtual ~MathDepthStyleValue() override = default; virtual ~MathDepthStyleValue() override = default;
bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; } bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; }

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class NumberStyleValue final : public CSSUnitValue { class NumberStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<NumberStyleValue> create(double value) static ValueComparingNonnullRefPtr<NumberStyleValue const> create(double value)
{ {
return adopt_ref(*new (nothrow) NumberStyleValue(value)); return adopt_ref(*new (nothrow) NumberStyleValue(value));
} }

View file

@ -20,21 +20,21 @@ public:
FontFeatureSettings, FontFeatureSettings,
FontVariationSettings, FontVariationSettings,
}; };
static ValueComparingNonnullRefPtr<OpenTypeTaggedStyleValue> create(Mode mode, FlyString tag, ValueComparingNonnullRefPtr<CSSStyleValue> value) static ValueComparingNonnullRefPtr<OpenTypeTaggedStyleValue const> create(Mode mode, FlyString tag, ValueComparingNonnullRefPtr<CSSStyleValue const> value)
{ {
return adopt_ref(*new (nothrow) OpenTypeTaggedStyleValue(mode, move(tag), move(value))); return adopt_ref(*new (nothrow) OpenTypeTaggedStyleValue(mode, move(tag), move(value)));
} }
virtual ~OpenTypeTaggedStyleValue() override = default; virtual ~OpenTypeTaggedStyleValue() override = default;
FlyString const& tag() const { return m_tag; } FlyString const& tag() const { return m_tag; }
ValueComparingNonnullRefPtr<CSSStyleValue> const& value() const { return m_value; } ValueComparingNonnullRefPtr<CSSStyleValue const> const& value() const { return m_value; }
virtual String to_string(SerializationMode) const override; virtual String to_string(SerializationMode) const override;
bool properties_equal(OpenTypeTaggedStyleValue const&) const; bool properties_equal(OpenTypeTaggedStyleValue const&) const;
private: private:
explicit OpenTypeTaggedStyleValue(Mode mode, FlyString tag, ValueComparingNonnullRefPtr<CSSStyleValue> value) explicit OpenTypeTaggedStyleValue(Mode mode, FlyString tag, ValueComparingNonnullRefPtr<CSSStyleValue const> value)
: StyleValueWithDefaultOperators(Type::OpenTypeTagged) : StyleValueWithDefaultOperators(Type::OpenTypeTagged)
, m_mode(mode) , m_mode(mode)
, m_tag(move(tag)) , m_tag(move(tag))
@ -44,7 +44,7 @@ private:
Mode m_mode; Mode m_mode;
FlyString m_tag; FlyString m_tag;
ValueComparingNonnullRefPtr<CSSStyleValue> m_value; ValueComparingNonnullRefPtr<CSSStyleValue const> m_value;
}; };
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class PercentageStyleValue final : public CSSUnitValue { class PercentageStyleValue final : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage) static ValueComparingNonnullRefPtr<PercentageStyleValue const> create(Percentage percentage)
{ {
return adopt_ref(*new (nothrow) PercentageStyleValue(move(percentage))); return adopt_ref(*new (nothrow) PercentageStyleValue(move(percentage)));
} }

View file

@ -18,11 +18,11 @@ namespace Web::CSS {
class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> { class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<PositionStyleValue> create(ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y) static ValueComparingNonnullRefPtr<PositionStyleValue const> create(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y)
{ {
return adopt_ref(*new (nothrow) PositionStyleValue(move(edge_x), move(edge_y))); return adopt_ref(*new (nothrow) PositionStyleValue(move(edge_x), move(edge_y)));
} }
static ValueComparingNonnullRefPtr<PositionStyleValue> create_center() static ValueComparingNonnullRefPtr<PositionStyleValue const> create_center()
{ {
return adopt_ref(*new (nothrow) PositionStyleValue( return adopt_ref(*new (nothrow) PositionStyleValue(
EdgeStyleValue::create(PositionEdge::Center, {}), EdgeStyleValue::create(PositionEdge::Center, {}),
@ -30,8 +30,8 @@ public:
} }
virtual ~PositionStyleValue() override = default; virtual ~PositionStyleValue() override = default;
ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x() const { return m_properties.edge_x; } ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x() const { return m_properties.edge_x; }
ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y() const { return m_properties.edge_y; } ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y() const { return m_properties.edge_y; }
bool is_center() const; bool is_center() const;
CSSPixelPoint resolved(Layout::Node const&, CSSPixelRect const&) const; CSSPixelPoint resolved(Layout::Node const&, CSSPixelRect const&) const;
@ -40,15 +40,15 @@ public:
bool properties_equal(PositionStyleValue const& other) const { return m_properties == other.m_properties; } bool properties_equal(PositionStyleValue const& other) const { return m_properties == other.m_properties; }
private: private:
PositionStyleValue(ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y) PositionStyleValue(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y)
: StyleValueWithDefaultOperators(Type::Position) : StyleValueWithDefaultOperators(Type::Position)
, m_properties { .edge_x = edge_x, .edge_y = edge_y } , m_properties { .edge_x = move(edge_x), .edge_y = move(edge_y) }
{ {
} }
struct Properties { struct Properties {
ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x; ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x;
ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y; ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y;
bool operator==(Properties const&) const = default; bool operator==(Properties const&) const = default;
} m_properties; } m_properties;
}; };

View file

@ -43,7 +43,7 @@ public:
using Size = Variant<Extent, CircleSize, EllipseSize>; using Size = Variant<Extent, CircleSize, EllipseSize>;
static ValueComparingNonnullRefPtr<RadialGradientStyleValue> create(EndingShape ending_shape, Size size, ValueComparingNonnullRefPtr<PositionStyleValue> position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method) static ValueComparingNonnullRefPtr<RadialGradientStyleValue const> create(EndingShape ending_shape, Size size, ValueComparingNonnullRefPtr<PositionStyleValue const> position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method)
{ {
VERIFY(!color_stop_list.is_empty()); VERIFY(!color_stop_list.is_empty());
bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value(); bool any_non_legacy = color_stop_list.find_first_index_if([](auto const& stop) { return !stop.color_stop.color->is_keyword() && stop.color_stop.color->as_color().color_syntax() == ColorSyntax::Modern; }).has_value();
@ -80,7 +80,7 @@ public:
virtual ~RadialGradientStyleValue() override = default; virtual ~RadialGradientStyleValue() override = default;
private: private:
RadialGradientStyleValue(EndingShape ending_shape, Size size, ValueComparingNonnullRefPtr<PositionStyleValue> position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method, ColorSyntax color_syntax) RadialGradientStyleValue(EndingShape ending_shape, Size size, ValueComparingNonnullRefPtr<PositionStyleValue const> position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating, Optional<InterpolationMethod> interpolation_method, ColorSyntax color_syntax)
: AbstractImageStyleValue(Type::RadialGradient) : AbstractImageStyleValue(Type::RadialGradient)
, m_properties { .ending_shape = ending_shape, .size = size, .position = move(position), .color_stop_list = move(color_stop_list), .repeating = repeating, .interpolation_method = interpolation_method, .color_syntax = color_syntax } , m_properties { .ending_shape = ending_shape, .size = size, .position = move(position), .color_stop_list = move(color_stop_list), .repeating = repeating, .interpolation_method = interpolation_method, .color_syntax = color_syntax }
{ {
@ -89,7 +89,7 @@ private:
struct Properties { struct Properties {
EndingShape ending_shape; EndingShape ending_shape;
Size size; Size size;
ValueComparingNonnullRefPtr<PositionStyleValue> position; ValueComparingNonnullRefPtr<PositionStyleValue const> position;
Vector<LinearColorStopListElement> color_stop_list; Vector<LinearColorStopListElement> color_stop_list;
GradientRepeating repeating; GradientRepeating repeating;
Optional<InterpolationMethod> interpolation_method; Optional<InterpolationMethod> interpolation_method;

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class RatioStyleValue final : public StyleValueWithDefaultOperators<RatioStyleValue> { class RatioStyleValue final : public StyleValueWithDefaultOperators<RatioStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<RatioStyleValue> create(Ratio ratio) static ValueComparingNonnullRefPtr<RatioStyleValue const> create(Ratio ratio)
{ {
return adopt_ref(*new (nothrow) RatioStyleValue(move(ratio))); return adopt_ref(*new (nothrow) RatioStyleValue(move(ratio)));
} }

View file

@ -11,7 +11,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<RectStyleValue> RectStyleValue::create(EdgeRect rect) ValueComparingNonnullRefPtr<RectStyleValue const> RectStyleValue::create(EdgeRect rect)
{ {
return adopt_ref(*new (nothrow) RectStyleValue(move(rect))); return adopt_ref(*new (nothrow) RectStyleValue(move(rect)));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class RectStyleValue : public StyleValueWithDefaultOperators<RectStyleValue> { class RectStyleValue : public StyleValueWithDefaultOperators<RectStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<RectStyleValue> create(EdgeRect rect); static ValueComparingNonnullRefPtr<RectStyleValue const> create(EdgeRect rect);
virtual ~RectStyleValue() override = default; virtual ~RectStyleValue() override = default;
EdgeRect rect() const { return m_rect; } EdgeRect rect() const { return m_rect; }

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class ResolutionStyleValue : public CSSUnitValue { class ResolutionStyleValue : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<ResolutionStyleValue> create(Resolution resolution) static ValueComparingNonnullRefPtr<ResolutionStyleValue const> create(Resolution resolution)
{ {
return adopt_ref(*new (nothrow) ResolutionStyleValue(move(resolution))); return adopt_ref(*new (nothrow) ResolutionStyleValue(move(resolution)));
} }

View file

@ -12,7 +12,7 @@ namespace Web::CSS {
class ScrollbarGutterStyleValue final : public StyleValueWithDefaultOperators<ScrollbarGutterStyleValue> { class ScrollbarGutterStyleValue final : public StyleValueWithDefaultOperators<ScrollbarGutterStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<ScrollbarGutterStyleValue> create(ScrollbarGutter value) static ValueComparingNonnullRefPtr<ScrollbarGutterStyleValue const> create(ScrollbarGutter value)
{ {
return adopt_ref(*new (nothrow) ScrollbarGutterStyleValue(value)); return adopt_ref(*new (nothrow) ScrollbarGutterStyleValue(value));
} }

View file

@ -22,7 +22,7 @@ enum class ShadowPlacement {
class ShadowStyleValue final : public StyleValueWithDefaultOperators<ShadowStyleValue> { class ShadowStyleValue final : public StyleValueWithDefaultOperators<ShadowStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<ShadowStyleValue> create( static ValueComparingNonnullRefPtr<ShadowStyleValue const> create(
ValueComparingNonnullRefPtr<CSSStyleValue const> color, ValueComparingNonnullRefPtr<CSSStyleValue const> color,
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_x, ValueComparingNonnullRefPtr<CSSStyleValue const> offset_x,
ValueComparingNonnullRefPtr<CSSStyleValue const> offset_y, ValueComparingNonnullRefPtr<CSSStyleValue const> offset_y,

View file

@ -12,7 +12,7 @@ namespace Web::CSS {
class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> { class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values) static ValueComparingNonnullRefPtr<ShorthandStyleValue const> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values)
{ {
return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values))); return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values)));
} }

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
class StringStyleValue : public StyleValueWithDefaultOperators<StringStyleValue> { class StringStyleValue : public StyleValueWithDefaultOperators<StringStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<StringStyleValue> create(FlyString const& string) static ValueComparingNonnullRefPtr<StringStyleValue const> create(FlyString const& string)
{ {
return adopt_ref(*new (nothrow) StringStyleValue(string)); return adopt_ref(*new (nothrow) StringStyleValue(string));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class TimeStyleValue : public CSSUnitValue { class TimeStyleValue : public CSSUnitValue {
public: public:
static ValueComparingNonnullRefPtr<TimeStyleValue> create(Time time) static ValueComparingNonnullRefPtr<TimeStyleValue const> create(Time time)
{ {
return adopt_ref(*new (nothrow) TimeStyleValue(move(time))); return adopt_ref(*new (nothrow) TimeStyleValue(move(time)));
} }

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> { class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<TransformationStyleValue> create(PropertyID property, TransformFunction transform_function, StyleValueVector&& values) static ValueComparingNonnullRefPtr<TransformationStyleValue const> create(PropertyID property, TransformFunction transform_function, StyleValueVector&& values)
{ {
return adopt_ref(*new (nothrow) TransformationStyleValue(property, transform_function, move(values))); return adopt_ref(*new (nothrow) TransformationStyleValue(property, transform_function, move(values)));
} }

View file

@ -17,15 +17,15 @@ namespace Web::CSS {
class TransitionStyleValue final : public StyleValueWithDefaultOperators<TransitionStyleValue> { class TransitionStyleValue final : public StyleValueWithDefaultOperators<TransitionStyleValue> {
public: public:
struct Transition { struct Transition {
ValueComparingRefPtr<CustomIdentStyleValue> property_name; ValueComparingRefPtr<CustomIdentStyleValue const> property_name;
TimeOrCalculated duration { CSS::Time::make_seconds(0.0) }; TimeOrCalculated duration { CSS::Time::make_seconds(0.0) };
TimeOrCalculated delay { CSS::Time::make_seconds(0.0) }; TimeOrCalculated delay { CSS::Time::make_seconds(0.0) };
ValueComparingRefPtr<EasingStyleValue> easing; ValueComparingRefPtr<EasingStyleValue const> easing;
bool operator==(Transition const&) const = default; bool operator==(Transition const&) const = default;
}; };
static ValueComparingNonnullRefPtr<TransitionStyleValue> create(Vector<Transition> transitions) static ValueComparingNonnullRefPtr<TransitionStyleValue const> create(Vector<Transition> transitions)
{ {
return adopt_ref(*new (nothrow) TransitionStyleValue(move(transitions))); return adopt_ref(*new (nothrow) TransitionStyleValue(move(transitions)));
} }

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> { class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<URLStyleValue> create(::URL::URL const& url) static ValueComparingNonnullRefPtr<URLStyleValue const> create(::URL::URL const& url)
{ {
return adopt_ref(*new (nothrow) URLStyleValue(url)); return adopt_ref(*new (nothrow) URLStyleValue(url));
} }

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class UnicodeRangeStyleValue final : public StyleValueWithDefaultOperators<UnicodeRangeStyleValue> { class UnicodeRangeStyleValue final : public StyleValueWithDefaultOperators<UnicodeRangeStyleValue> {
public: public:
static ValueComparingNonnullRefPtr<UnicodeRangeStyleValue> create(Gfx::UnicodeRange unicode_range) static ValueComparingNonnullRefPtr<UnicodeRangeStyleValue const> create(Gfx::UnicodeRange unicode_range)
{ {
return adopt_ref(*new (nothrow) UnicodeRangeStyleValue(unicode_range)); return adopt_ref(*new (nothrow) UnicodeRangeStyleValue(unicode_range));
} }

View file

@ -17,7 +17,7 @@ namespace Web::CSS {
class UnresolvedStyleValue final : public CSSStyleValue { class UnresolvedStyleValue final : public CSSStyleValue {
public: public:
static ValueComparingNonnullRefPtr<UnresolvedStyleValue> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr, Optional<String> original_source_text) static ValueComparingNonnullRefPtr<UnresolvedStyleValue const> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr, Optional<String> original_source_text)
{ {
return adopt_ref(*new (nothrow) UnresolvedStyleValue(move(values), contains_var_or_attr, move(original_source_text))); return adopt_ref(*new (nothrow) UnresolvedStyleValue(move(values), contains_var_or_attr, move(original_source_text)));
} }

Some files were not shown because too many files have changed in this diff Show more