LibWeb: Add CSS view-transition-name

This commit is contained in:
Psychpsyo 2025-02-21 17:56:24 +01:00 committed by Sam Atkins
parent b833168b74
commit c0eb072645
Notes: github-actions[bot] 2025-02-22 14:53:16 +00:00
10 changed files with 78 additions and 5 deletions

View file

@ -55,6 +55,7 @@
#include <LibWeb/CSS/StyleValues/TransitionStyleValue.h>
#include <LibWeb/CSS/StyleValues/UnresolvedStyleValue.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Infra/Strings.h>
namespace Web::CSS::Parser {
@ -713,6 +714,10 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_css_value(Prope
if (auto parsed_value = parse_scale_value(tokens); parsed_value && !tokens.has_next_token())
return parsed_value.release_nonnull();
return ParseError::SyntaxError;
case PropertyID::ViewTransitionName:
if (auto parsed_value = parse_view_transition_name_value(tokens); parsed_value && !tokens.has_next_token())
return parsed_value.release_nonnull();
return ParseError::SyntaxError;
default:
break;
}
@ -4438,4 +4443,29 @@ RefPtr<CSSStyleValue> Parser::parse_filter_value_list_value(TokenStream<Componen
return FilterValueListStyleValue::create(move(filter_value_list));
}
RefPtr<CSSStyleValue> Parser::parse_view_transition_name_value(TokenStream<ComponentValue>& tokens)
{
// none | <custom-ident>
tokens.discard_whitespace();
{
auto transaction = tokens.begin_transaction();
// The values 'none' and 'auto' are excluded from <custom-ident> here.
// Note: Only auto is excluded here since none isn't parsed differently.
auto ident = parse_custom_ident_value(tokens, { "auto"sv });
if (!ident)
return {};
tokens.discard_whitespace();
transaction.commit();
if (Infra::is_ascii_case_insensitive_match(ident->custom_ident().to_string(), "none"sv)) {
return CustomIdentStyleValue::create("none"_fly_string);
} else {
return ident;
}
}
return {};
}
}