mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibWeb: Implement CSS tan()
This commit is contained in:
parent
46a5efe388
commit
64f0349a9e
4 changed files with 100 additions and 0 deletions
|
@ -3642,6 +3642,30 @@ ErrorOr<OwnPtr<CalculationNode>> Parser::parse_cos_function(Function const& func
|
|||
return TRY(CosCalculationNode::create(calculation_node.release_nonnull()));
|
||||
}
|
||||
|
||||
ErrorOr<OwnPtr<CalculationNode>> Parser::parse_tan_function(Function const& function)
|
||||
{
|
||||
auto calculation_node = TRY(parse_a_calculation(function.values()));
|
||||
|
||||
if (!calculation_node) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "tan() parameter must be a valid calculation"sv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto maybe_parameter_type = calculation_node->resolved_type();
|
||||
if (!maybe_parameter_type.has_value()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "Failed to resolve type for tan() parameter"sv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto resolved_type = maybe_parameter_type.value();
|
||||
if (resolved_type != CalculatedStyleValue::ResolvedType::Number && resolved_type != CalculatedStyleValue::ResolvedType::Angle) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "tan() parameter must be a number or angle"sv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return TRY(TanCalculationNode::create(calculation_node.release_nonnull()));
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<StyleValue>> Parser::parse_dynamic_value(ComponentValue const& component_value)
|
||||
{
|
||||
if (component_value.is_function()) {
|
||||
|
@ -3692,6 +3716,9 @@ ErrorOr<OwnPtr<CalculationNode>> Parser::parse_a_calc_function_node(Function con
|
|||
if (function.name().equals_ignoring_ascii_case("cos"sv))
|
||||
return TRY(parse_cos_function(function));
|
||||
|
||||
if (function.name().equals_ignoring_ascii_case("tan"sv))
|
||||
return TRY(parse_tan_function(function));
|
||||
|
||||
dbgln_if(CSS_PARSER_DEBUG, "We didn't implement `{}` function yet", function.name());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue