mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-27 21:42:53 +00:00
LibWeb/CSS: Store @property
initial value as a style value
For now, it's the "raw" UnresolvedStyleValue. Later, we'll need to try to parse it into a "real" style value using the property's syntax.
This commit is contained in:
parent
9292b769ef
commit
a80408fea6
Notes:
github-actions[bot]
2025-04-08 09:00:42 +00:00
Author: https://github.com/AtkinsSJ
Commit: a80408fea6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4265
4 changed files with 24 additions and 19 deletions
|
@ -65,13 +65,11 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_descriptor_valu
|
|||
return parse_comma_separated_value_list(tokens, [this](auto& tokens) -> RefPtr<CSSStyleValue> {
|
||||
return parse_font_source_value(tokens);
|
||||
});
|
||||
case DescriptorMetadata::ValueType::OptionalDeclarationValue: {
|
||||
// FIXME: This is for an @property's initial value. Figure out what this should actually do once we need it.
|
||||
StringBuilder initial_value_sb;
|
||||
case DescriptorMetadata::ValueType::OptionalDeclarationValue:
|
||||
// `component_values` already has what we want. Just skip through its tokens so code below knows we consumed them.
|
||||
while (tokens.has_next_token())
|
||||
initial_value_sb.append(tokens.consume_a_token().to_string());
|
||||
return StringStyleValue::create(initial_value_sb.to_fly_string_without_validation());
|
||||
}
|
||||
tokens.discard_a_token();
|
||||
return UnresolvedStyleValue::create(move(component_values), false, {});
|
||||
case DescriptorMetadata::ValueType::PositivePercentage:
|
||||
if (auto percentage_value = parse_percentage_value(tokens)) {
|
||||
if (percentage_value->is_percentage()) {
|
||||
|
|
|
@ -535,7 +535,7 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
|
|||
|
||||
Optional<FlyString> syntax_maybe;
|
||||
Optional<bool> inherits_maybe;
|
||||
Optional<String> initial_value_maybe;
|
||||
RefPtr<CSSStyleValue> initial_value_maybe;
|
||||
|
||||
rule.for_each_as_declaration_list([&](auto& declaration) {
|
||||
if (auto descriptor = convert_to_descriptor(AtRuleID::Property, declaration); descriptor.has_value()) {
|
||||
|
@ -558,15 +558,16 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
|
|||
return;
|
||||
}
|
||||
if (descriptor->descriptor_id == DescriptorID::InitialValue) {
|
||||
if (descriptor->value->is_string())
|
||||
initial_value_maybe = descriptor->value->as_string().string_value().to_string();
|
||||
initial_value_maybe = *descriptor->value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Parse the initial value using the syntax, if it's provided.
|
||||
|
||||
if (syntax_maybe.has_value() && inherits_maybe.has_value()) {
|
||||
return CSSPropertyRule::create(realm(), name, syntax_maybe.value(), inherits_maybe.value(), std::move(initial_value_maybe));
|
||||
return CSSPropertyRule::create(realm(), name, syntax_maybe.value(), inherits_maybe.value(), move(initial_value_maybe));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue