mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibWeb: Handle fallback values for CSS variables :^)
This commit is contained in:
parent
23dc0dac88
commit
67e1125b4c
2 changed files with 10 additions and 4 deletions
|
@ -452,7 +452,7 @@ struct MatchingDeclarations {
|
||||||
Vector<MatchingRule> author_rules;
|
Vector<MatchingRule> author_rules;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool StyleComputer::expand_unresolved_values(DOM::Element& element, Vector<StyleComponentValueRule> const& source, Vector<StyleComponentValueRule>& dest) const
|
bool StyleComputer::expand_unresolved_values(DOM::Element& element, Vector<StyleComponentValueRule> const& source, Vector<StyleComponentValueRule>& dest, size_t source_start_index) const
|
||||||
{
|
{
|
||||||
// FIXME: Do this better!
|
// FIXME: Do this better!
|
||||||
// We build a copy of the tree of StyleComponentValueRules, with all var()s replaced with their contents.
|
// We build a copy of the tree of StyleComponentValueRules, with all var()s replaced with their contents.
|
||||||
|
@ -468,7 +468,8 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, Vector<Style
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto& value : source) {
|
for (size_t source_index = source_start_index; source_index < source.size(); source_index++) {
|
||||||
|
auto& value = source[source_index];
|
||||||
if (value.is_function()) {
|
if (value.is_function()) {
|
||||||
if (value.function().name().equals_ignoring_case("var"sv)) {
|
if (value.function().name().equals_ignoring_case("var"sv)) {
|
||||||
auto& var_contents = value.function().values();
|
auto& var_contents = value.function().values();
|
||||||
|
@ -489,7 +490,12 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, Vector<Style
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle fallback value
|
// Use the provided fallback value, if any.
|
||||||
|
if (var_contents.size() > 2 && var_contents[1].is(Token::Type::Comma)) {
|
||||||
|
if (!expand_unresolved_values(element, var_contents, dest, 2))
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& source_function = value.function();
|
auto& source_function = value.function();
|
||||||
|
|
|
@ -62,7 +62,7 @@ private:
|
||||||
void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID) const;
|
void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID) const;
|
||||||
|
|
||||||
RefPtr<StyleValue> resolve_unresolved_style_value(DOM::Element&, PropertyID, UnresolvedStyleValue const&) const;
|
RefPtr<StyleValue> resolve_unresolved_style_value(DOM::Element&, PropertyID, UnresolvedStyleValue const&) const;
|
||||||
bool expand_unresolved_values(DOM::Element&, Vector<StyleComponentValueRule> const& source, Vector<StyleComponentValueRule>& dest) const;
|
bool expand_unresolved_values(DOM::Element&, Vector<StyleComponentValueRule> const& source, Vector<StyleComponentValueRule>& dest, size_t source_start_index = 0) const;
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_stylesheet(CascadeOrigin, Callback) const;
|
void for_each_stylesheet(CascadeOrigin, Callback) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue