mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 07:39:16 +00:00
LibWeb: Improve support for CalculatedStyleValue in translate
- Omit calcs that are resolved to `0px` from the serialized value - Allow CSV to be the 'Z' component in interpolated value. - Allow calcs with mixed percentages in the first two arguments. To achieve the third item above the concept of a "special" value parsing context has been added - this will also be useful for instance for different arguments of color functions having different contexts. Gains us 23 WPT tests
This commit is contained in:
parent
18d65b014f
commit
39fdcbc526
Notes:
github-actions[bot]
2025-08-08 08:46:24 +00:00
Author: https://github.com/Calme1709
Commit: 39fdcbc526
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5773
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
10 changed files with 57 additions and 43 deletions
|
@ -2231,14 +2231,12 @@ RefPtr<CSSStyleValue const> Parser::parse_color_value(TokenStream<ComponentValue
|
|||
if (!m_value_context.is_empty()) {
|
||||
quirky_color_allowed = m_value_context.first().visit(
|
||||
[](PropertyID const& property_id) { return property_has_quirk(property_id, Quirk::HashlessHexColor); },
|
||||
[](FunctionContext const&) { return false; },
|
||||
[](DescriptorContext const&) { return false; });
|
||||
[](auto const&) { return false; });
|
||||
}
|
||||
for (auto i = 1u; i < m_value_context.size() && quirky_color_allowed; i++) {
|
||||
quirky_color_allowed = m_value_context[i].visit(
|
||||
[](PropertyID const& property_id) { return property_has_quirk(property_id, Quirk::HashlessHexColor); },
|
||||
[](FunctionContext const&) { return false; },
|
||||
[](DescriptorContext const&) { return false; });
|
||||
[](auto const&) { return false; });
|
||||
}
|
||||
if (quirky_color_allowed) {
|
||||
// NOTE: This algorithm is no longer in the spec, since the concept got moved and renamed. However, it works,
|
||||
|
@ -4108,6 +4106,14 @@ RefPtr<CSSStyleValue const> Parser::parse_calculated_value(ComponentValue const&
|
|||
[](DescriptorContext const&) -> Optional<CalculationContext> {
|
||||
// FIXME: If any descriptors have `<*-percentage>` or `<integer>` types, add them here.
|
||||
return CalculationContext {};
|
||||
},
|
||||
[](SpecialContext special_context) -> Optional<CalculationContext> {
|
||||
switch (special_context) {
|
||||
case SpecialContext::TranslateZArgument:
|
||||
// Percentages are disallowed for the Z axis
|
||||
return CalculationContext {};
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
});
|
||||
if (maybe_context.has_value()) {
|
||||
context = maybe_context.release_value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue