LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}

This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
This commit is contained in:
Sam Atkins 2025-08-08 10:11:51 +01:00 committed by Tim Ledbetter
commit c57975c9fd
Notes: github-actions[bot] 2025-08-08 14:20:54 +00:00
167 changed files with 989 additions and 990 deletions

View file

@ -17,7 +17,7 @@
namespace Web::CSS::Parser {
Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream<ComponentValue>& unprocessed_tokens)
Parser::ParseErrorOr<NonnullRefPtr<StyleValue 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)) {
ErrorReporter::the().report(UnknownPropertyError {
@ -46,7 +46,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
[&](Keyword keyword) {
return parse_all_as_single_keyword_value(tokens, keyword);
},
[&](PropertyID property_id) -> RefPtr<CSSStyleValue const> {
[&](PropertyID property_id) -> RefPtr<StyleValue const> {
auto value_or_error = parse_css_value(property_id, tokens);
if (value_or_error.is_error())
return nullptr;
@ -59,7 +59,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
return nullptr;
return value_for_property;
},
[&](DescriptorMetadata::ValueType value_type) -> RefPtr<CSSStyleValue const> {
[&](DescriptorMetadata::ValueType value_type) -> RefPtr<StyleValue const> {
switch (value_type) {
case DescriptorMetadata::ValueType::CropOrCross: {
// crop || cross
@ -70,8 +70,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
if (!first)
return nullptr;
RefPtr<CSSStyleValue const> crop;
RefPtr<CSSStyleValue const> cross;
RefPtr<StyleValue const> crop;
RefPtr<StyleValue const> cross;
if (first->to_keyword() == Keyword::Crop)
crop = first;
@ -149,8 +149,8 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
}
// [ <page-size> || [ portrait | landscape ] ]
RefPtr<CSSStyleValue const> page_size;
RefPtr<CSSStyleValue const> orientation;
RefPtr<StyleValue const> page_size;
RefPtr<StyleValue const> orientation;
if (auto first_keyword = parse_keyword_value(tokens)) {
if (first_is_one_of(first_keyword->to_keyword(), Keyword::Landscape, Keyword::Portrait)) {
orientation = first_keyword.release_nonnull();
@ -203,7 +203,7 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue const>> Parser::parse_descripto
case DescriptorMetadata::ValueType::String:
return parse_string_value(tokens);
case DescriptorMetadata::ValueType::UnicodeRangeTokens: {
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<CSSStyleValue const> {
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<StyleValue const> {
return parse_unicode_range_value(tokens);
});
}