1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

LibWeb: Move ComponentValue to CSS::Parser namespace

This commit is contained in:
Sam Atkins 2022-04-12 12:13:10 +01:00 committed by Andreas Kling
parent c449cabae3
commit fff2c35f51
11 changed files with 26 additions and 23 deletions

View file

@ -526,10 +526,10 @@ static RefPtr<StyleValue> get_custom_property(DOM::Element const& element, FlySt
return nullptr;
}
bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<ComponentValue> const& source, Vector<ComponentValue>& dest, size_t source_start_index) const
bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<Parser::ComponentValue> const& source, Vector<Parser::ComponentValue>& dest, size_t source_start_index) const
{
// FIXME: Do this better!
// We build a copy of the tree of StyleComponentValueRules, with all var()s and attr()s replaced with their contents.
// We build a copy of the tree of ComponentValues, with all var()s and attr()s replaced with their contents.
// This is a very naive solution, and we could do better if the CSS Parser could accept tokens one at a time.
// Arbitrary large value chosen to avoid the billion-laughs attack.
@ -619,7 +619,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
}
auto const& source_function = value.function();
Vector<ComponentValue> function_values;
Vector<Parser::ComponentValue> function_values;
if (!expand_unresolved_values(element, property_name, dependencies, source_function.values(), function_values, 0))
return false;
NonnullRefPtr<StyleFunctionRule> function = adopt_ref(*new StyleFunctionRule(source_function.name(), move(function_values)));
@ -628,7 +628,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
}
if (value.is_block()) {
auto const& source_block = value.block();
Vector<ComponentValue> block_values;
Vector<Parser::ComponentValue> block_values;
if (!expand_unresolved_values(element, property_name, dependencies, source_block.values(), block_values, 0))
return false;
NonnullRefPtr<StyleBlockRule> block = adopt_ref(*new StyleBlockRule(source_block.token(), move(block_values)));
@ -647,7 +647,7 @@ RefPtr<StyleValue> StyleComputer::resolve_unresolved_style_value(DOM::Element& e
// to produce a different StyleValue from it.
VERIFY(unresolved.contains_var_or_attr());
Vector<ComponentValue> expanded_values;
Vector<Parser::ComponentValue> expanded_values;
HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>> dependencies;
if (!expand_unresolved_values(element, string_from_property_id(property_id), dependencies, unresolved.values(), expanded_values, 0))
return {};