|
@@ -1478,6 +1478,55 @@ ErrorOr<void> LogCalculationNode::dump(StringBuilder& builder, int indent) const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
+ErrorOr<NonnullOwnPtr<ExpCalculationNode>> ExpCalculationNode::create(NonnullOwnPtr<CalculationNode> value)
|
|
|
+{
|
|
|
+ return adopt_nonnull_own_or_enomem(new (nothrow) ExpCalculationNode(move(value)));
|
|
|
+}
|
|
|
+
|
|
|
+ExpCalculationNode::ExpCalculationNode(NonnullOwnPtr<CalculationNode> value)
|
|
|
+ : CalculationNode(Type::Exp)
|
|
|
+ , m_value(move(value))
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+ExpCalculationNode::~ExpCalculationNode() = default;
|
|
|
+
|
|
|
+ErrorOr<String> ExpCalculationNode::to_string() const
|
|
|
+{
|
|
|
+ StringBuilder builder;
|
|
|
+ builder.append("exp("sv);
|
|
|
+ builder.append(TRY(m_value->to_string()));
|
|
|
+ builder.append(")"sv);
|
|
|
+ return builder.to_string();
|
|
|
+}
|
|
|
+
|
|
|
+Optional<CalculatedStyleValue::ResolvedType> ExpCalculationNode::resolved_type() const
|
|
|
+{
|
|
|
+ return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+}
|
|
|
+
|
|
|
+CalculatedStyleValue::CalculationResult ExpCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+{
|
|
|
+ auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
+ auto node_a_value = resolve_value(node_a.value(), context);
|
|
|
+ auto result = exp(node_a_value);
|
|
|
+
|
|
|
+ return { Number(Number::Type::Number, result) };
|
|
|
+}
|
|
|
+
|
|
|
+ErrorOr<void> ExpCalculationNode::for_each_child_node(Function<ErrorOr<void>(NonnullOwnPtr<CalculationNode>&)> const& callback)
|
|
|
+{
|
|
|
+ TRY(m_value->for_each_child_node(callback));
|
|
|
+ TRY(callback(m_value));
|
|
|
+ return {};
|
|
|
+}
|
|
|
+
|
|
|
+ErrorOr<void> ExpCalculationNode::dump(StringBuilder& builder, int indent) const
|
|
|
+{
|
|
|
+ TRY(builder.try_appendff("{: >{}}EXP: {}\n", "", indent, TRY(to_string())));
|
|
|
+ return {};
|
|
|
+}
|
|
|
+
|
|
|
void CalculatedStyleValue::CalculationResult::add(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
{
|
|
|
add_or_subtract_internal(SumOperation::Add, other, context, percentage_basis);
|