|
@@ -1,31 +1,31 @@
|
|
|
/*
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
|
- * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
|
+ * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
*
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
*/
|
|
|
|
|
|
-#include "CalculatedStyleValue.h"
|
|
|
+#include "CSSMathValue.h"
|
|
|
#include <LibWeb/CSS/Percentage.h>
|
|
|
#include <LibWeb/CSS/PropertyID.h>
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
-static bool is_number(CalculatedStyleValue::ResolvedType type)
|
|
|
+static bool is_number(CSSMathValue::ResolvedType type)
|
|
|
{
|
|
|
- return type == CalculatedStyleValue::ResolvedType::Number || type == CalculatedStyleValue::ResolvedType::Integer;
|
|
|
+ return type == CSSMathValue::ResolvedType::Number || type == CSSMathValue::ResolvedType::Integer;
|
|
|
}
|
|
|
|
|
|
-static bool is_dimension(CalculatedStyleValue::ResolvedType type)
|
|
|
+static bool is_dimension(CSSMathValue::ResolvedType type)
|
|
|
{
|
|
|
- return type != CalculatedStyleValue::ResolvedType::Number
|
|
|
- && type != CalculatedStyleValue::ResolvedType::Integer
|
|
|
- && type != CalculatedStyleValue::ResolvedType::Percentage;
|
|
|
+ return type != CSSMathValue::ResolvedType::Number
|
|
|
+ && type != CSSMathValue::ResolvedType::Integer
|
|
|
+ && type != CSSMathValue::ResolvedType::Percentage;
|
|
|
}
|
|
|
|
|
|
-static double resolve_value_radians(CalculatedStyleValue::CalculationResult::Value value)
|
|
|
+static double resolve_value_radians(CSSMathValue::CalculationResult::Value value)
|
|
|
{
|
|
|
return value.visit(
|
|
|
[](Number const& number) { return number.value(); },
|
|
@@ -33,7 +33,7 @@ static double resolve_value_radians(CalculatedStyleValue::CalculationResult::Val
|
|
|
[](auto const&) { VERIFY_NOT_REACHED(); return 0.0; });
|
|
|
}
|
|
|
|
|
|
-static double resolve_value(CalculatedStyleValue::CalculationResult::Value value, Optional<Length::ResolutionContext const&> context)
|
|
|
+static double resolve_value(CSSMathValue::CalculationResult::Value value, Optional<Length::ResolutionContext const&> context)
|
|
|
{
|
|
|
return value.visit(
|
|
|
[](Number const& number) { return number.value(); },
|
|
@@ -67,26 +67,26 @@ static Optional<CSSNumericType> add_the_types(Vector<NonnullOwnPtr<CalculationNo
|
|
|
return left_type;
|
|
|
}
|
|
|
|
|
|
-static CalculatedStyleValue::CalculationResult to_resolved_type(CalculatedStyleValue::ResolvedType type, double value)
|
|
|
+static CSSMathValue::CalculationResult to_resolved_type(CSSMathValue::ResolvedType type, double value)
|
|
|
{
|
|
|
switch (type) {
|
|
|
- case CalculatedStyleValue::ResolvedType::Integer:
|
|
|
+ case CSSMathValue::ResolvedType::Integer:
|
|
|
return { Number(Number::Type::Integer, value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Number:
|
|
|
+ case CSSMathValue::ResolvedType::Number:
|
|
|
return { Number(Number::Type::Number, value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Angle:
|
|
|
+ case CSSMathValue::ResolvedType::Angle:
|
|
|
return { Angle::make_degrees(value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Flex:
|
|
|
+ case CSSMathValue::ResolvedType::Flex:
|
|
|
return { Flex::make_fr(value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Frequency:
|
|
|
+ case CSSMathValue::ResolvedType::Frequency:
|
|
|
return { Frequency::make_hertz(value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Length:
|
|
|
+ case CSSMathValue::ResolvedType::Length:
|
|
|
return { Length::make_px(CSSPixels::nearest_value_for(value)) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Percentage:
|
|
|
+ case CSSMathValue::ResolvedType::Percentage:
|
|
|
return { Percentage(value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Resolution:
|
|
|
+ case CSSMathValue::ResolvedType::Resolution:
|
|
|
return { Resolution::make_dots_per_pixel(value) };
|
|
|
- case CalculatedStyleValue::ResolvedType::Time:
|
|
|
+ case CSSMathValue::ResolvedType::Time:
|
|
|
return { Time::make_seconds(value) };
|
|
|
}
|
|
|
|
|
@@ -138,17 +138,17 @@ String NumericCalculationNode::to_string() const
|
|
|
return m_value.visit([](auto& value) { return value.to_string(); });
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> NumericCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> NumericCalculationNode::resolved_type() const
|
|
|
{
|
|
|
return m_value.visit(
|
|
|
- [](Number const&) { return CalculatedStyleValue::ResolvedType::Number; },
|
|
|
- [](Angle const&) { return CalculatedStyleValue::ResolvedType::Angle; },
|
|
|
- [](Flex const&) { return CalculatedStyleValue::ResolvedType::Flex; },
|
|
|
- [](Frequency const&) { return CalculatedStyleValue::ResolvedType::Frequency; },
|
|
|
- [](Length const&) { return CalculatedStyleValue::ResolvedType::Length; },
|
|
|
- [](Percentage const&) { return CalculatedStyleValue::ResolvedType::Percentage; },
|
|
|
- [](Resolution const&) { return CalculatedStyleValue::ResolvedType::Resolution; },
|
|
|
- [](Time const&) { return CalculatedStyleValue::ResolvedType::Time; });
|
|
|
+ [](Number const&) { return CSSMathValue::ResolvedType::Number; },
|
|
|
+ [](Angle const&) { return CSSMathValue::ResolvedType::Angle; },
|
|
|
+ [](Flex const&) { return CSSMathValue::ResolvedType::Flex; },
|
|
|
+ [](Frequency const&) { return CSSMathValue::ResolvedType::Frequency; },
|
|
|
+ [](Length const&) { return CSSMathValue::ResolvedType::Length; },
|
|
|
+ [](Percentage const&) { return CSSMathValue::ResolvedType::Percentage; },
|
|
|
+ [](Resolution const&) { return CSSMathValue::ResolvedType::Resolution; },
|
|
|
+ [](Time const&) { return CSSMathValue::ResolvedType::Time; });
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -217,17 +217,17 @@ bool NumericCalculationNode::contains_percentage() const
|
|
|
return m_value.has<Percentage>();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult NumericCalculationNode::resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult NumericCalculationNode::resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
if (m_value.has<Percentage>()) {
|
|
|
// NOTE: Depending on whether percentage_basis is set, the caller of resolve() is expecting a raw percentage or
|
|
|
// resolved length.
|
|
|
return percentage_basis.visit(
|
|
|
- [&](Empty const&) -> CalculatedStyleValue::CalculationResult {
|
|
|
+ [&](Empty const&) -> CSSMathValue::CalculationResult {
|
|
|
return m_value;
|
|
|
},
|
|
|
[&](auto const& value) {
|
|
|
- return CalculatedStyleValue::CalculationResult(value.percentage_of(m_value.get<Percentage>()));
|
|
|
+ return CSSMathValue::CalculationResult(value.percentage_of(m_value.get<Percentage>()));
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -275,12 +275,12 @@ String SumCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> SumCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> SumCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// FIXME: Implement https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
|
// For now, this is just ad-hoc, based on the old implementation.
|
|
|
|
|
|
- Optional<CalculatedStyleValue::ResolvedType> type;
|
|
|
+ Optional<CSSMathValue::ResolvedType> type;
|
|
|
for (auto const& value : m_values) {
|
|
|
auto maybe_value_type = value->resolved_type();
|
|
|
if (!maybe_value_type.has_value())
|
|
@@ -299,17 +299,17 @@ Optional<CalculatedStyleValue::ResolvedType> SumCalculationNode::resolved_type()
|
|
|
|
|
|
// If one side is a <number> and the other is an <integer>, resolve to <number>.
|
|
|
if (is_number(*type) && is_number(value_type)) {
|
|
|
- type = CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ type = CSSMathValue::ResolvedType::Number;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// FIXME: calc() handles <percentage> by allowing them to pretend to be whatever <dimension> type is allowed at this location.
|
|
|
// Since we can't easily check what that type is, we just allow <percentage> to combine with any other <dimension> type.
|
|
|
- if (type == CalculatedStyleValue::ResolvedType::Percentage && is_dimension(value_type)) {
|
|
|
+ if (type == CSSMathValue::ResolvedType::Percentage && is_dimension(value_type)) {
|
|
|
type = value_type;
|
|
|
continue;
|
|
|
}
|
|
|
- if (is_dimension(*type) && value_type == CalculatedStyleValue::ResolvedType::Percentage)
|
|
|
+ if (is_dimension(*type) && value_type == CSSMathValue::ResolvedType::Percentage)
|
|
|
continue;
|
|
|
|
|
|
return {};
|
|
@@ -335,9 +335,9 @@ bool SumCalculationNode::contains_percentage() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult SumCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult SumCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
- Optional<CalculatedStyleValue::CalculationResult> total;
|
|
|
+ Optional<CSSMathValue::CalculationResult> total;
|
|
|
|
|
|
for (auto& additional_product : m_values) {
|
|
|
auto additional_value = additional_product->resolve(context, percentage_basis);
|
|
@@ -408,12 +408,12 @@ String ProductCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> ProductCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> ProductCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// FIXME: Implement https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
|
// For now, this is just ad-hoc, based on the old implementation.
|
|
|
|
|
|
- Optional<CalculatedStyleValue::ResolvedType> type;
|
|
|
+ Optional<CSSMathValue::ResolvedType> type;
|
|
|
for (auto const& value : m_values) {
|
|
|
auto maybe_value_type = value->resolved_type();
|
|
|
if (!maybe_value_type.has_value())
|
|
@@ -429,8 +429,8 @@ Optional<CalculatedStyleValue::ResolvedType> ProductCalculationNode::resolved_ty
|
|
|
if (!(is_number(*type) || is_number(value_type)))
|
|
|
return {};
|
|
|
// If both sides are <integer>, resolve to <integer>.
|
|
|
- if (type == CalculatedStyleValue::ResolvedType::Integer && value_type == CalculatedStyleValue::ResolvedType::Integer) {
|
|
|
- type = CalculatedStyleValue::ResolvedType::Integer;
|
|
|
+ if (type == CSSMathValue::ResolvedType::Integer && value_type == CSSMathValue::ResolvedType::Integer) {
|
|
|
+ type = CSSMathValue::ResolvedType::Integer;
|
|
|
} else {
|
|
|
// Otherwise, resolve to the type of the other side.
|
|
|
if (is_number(*type))
|
|
@@ -473,9 +473,9 @@ bool ProductCalculationNode::contains_percentage() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult ProductCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult ProductCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
- Optional<CalculatedStyleValue::CalculationResult> total;
|
|
|
+ Optional<CSSMathValue::CalculationResult> total;
|
|
|
|
|
|
for (auto& additional_product : m_values) {
|
|
|
auto additional_value = additional_product->resolve(context, percentage_basis);
|
|
@@ -537,7 +537,7 @@ String NegateCalculationNode::to_string() const
|
|
|
return MUST(String::formatted("(0 - {})", m_value->to_string()));
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> NegateCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> NegateCalculationNode::resolved_type() const
|
|
|
{
|
|
|
return m_value->resolved_type();
|
|
|
}
|
|
@@ -554,7 +554,7 @@ bool NegateCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult NegateCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult NegateCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto child_value = m_value->resolve(context, percentage_basis);
|
|
|
child_value.negate();
|
|
@@ -600,11 +600,11 @@ String InvertCalculationNode::to_string() const
|
|
|
return MUST(String::formatted("(1 / {})", m_value->to_string()));
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> InvertCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> InvertCalculationNode::resolved_type() const
|
|
|
{
|
|
|
auto type = m_value->resolved_type();
|
|
|
- if (type == CalculatedStyleValue::ResolvedType::Integer)
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ if (type == CSSMathValue::ResolvedType::Integer)
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
return type;
|
|
|
}
|
|
|
|
|
@@ -624,7 +624,7 @@ bool InvertCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult InvertCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult InvertCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto child_value = m_value->resolve(context, percentage_basis);
|
|
|
child_value.invert();
|
|
@@ -678,7 +678,7 @@ String MinCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> MinCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> MinCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// NOTE: We check during parsing that all values have the same type.
|
|
|
return m_values[0]->resolved_type();
|
|
@@ -701,9 +701,9 @@ bool MinCalculationNode::contains_percentage() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult MinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult MinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
- CalculatedStyleValue::CalculationResult smallest_node = m_values.first()->resolve(context, percentage_basis);
|
|
|
+ CSSMathValue::CalculationResult smallest_node = m_values.first()->resolve(context, percentage_basis);
|
|
|
auto smallest_value = resolve_value(smallest_node.value(), context);
|
|
|
|
|
|
for (size_t i = 1; i < m_values.size(); i++) {
|
|
@@ -775,7 +775,7 @@ String MaxCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> MaxCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> MaxCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// NOTE: We check during parsing that all values have the same type.
|
|
|
return m_values[0]->resolved_type();
|
|
@@ -798,9 +798,9 @@ bool MaxCalculationNode::contains_percentage() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult MaxCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult MaxCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
- CalculatedStyleValue::CalculationResult largest_node = m_values.first()->resolve(context, percentage_basis);
|
|
|
+ CSSMathValue::CalculationResult largest_node = m_values.first()->resolve(context, percentage_basis);
|
|
|
auto largest_value = resolve_value(largest_node.value(), context);
|
|
|
|
|
|
for (size_t i = 1; i < m_values.size(); i++) {
|
|
@@ -874,7 +874,7 @@ String ClampCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> ClampCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> ClampCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// NOTE: We check during parsing that all values have the same type.
|
|
|
return m_min_value->resolved_type();
|
|
@@ -902,7 +902,7 @@ bool ClampCalculationNode::contains_percentage() const
|
|
|
return m_min_value->contains_percentage() || m_center_value->contains_percentage() || m_max_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult ClampCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult ClampCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto min_node = m_min_value->resolve(context, percentage_basis);
|
|
|
auto center_node = m_center_value->resolve(context, percentage_basis);
|
|
@@ -975,7 +975,7 @@ String AbsCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> AbsCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> AbsCalculationNode::resolved_type() const
|
|
|
{
|
|
|
return m_value->resolved_type();
|
|
|
}
|
|
@@ -992,7 +992,7 @@ bool AbsCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult AbsCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult AbsCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto resolved_type = m_value->resolved_type().value();
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
@@ -1046,9 +1046,9 @@ String SignCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> SignCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> SignCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Integer;
|
|
|
+ return CSSMathValue::ResolvedType::Integer;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1063,7 +1063,7 @@ bool SignCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult SignCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult SignCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1127,9 +1127,9 @@ String ConstantCalculationNode::to_string() const
|
|
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
}
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> ConstantCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> ConstantCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1141,7 +1141,7 @@ Optional<CSSNumericType> ConstantCalculationNode::determine_type(PropertyID) con
|
|
|
return CSSNumericType {};
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult ConstantCalculationNode::resolve([[maybe_unused]] Optional<Length::ResolutionContext const&> context, [[maybe_unused]] CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult ConstantCalculationNode::resolve([[maybe_unused]] Optional<Length::ResolutionContext const&> context, [[maybe_unused]] CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
switch (m_constant) {
|
|
|
case CalculationNode::ConstantType::E:
|
|
@@ -1196,9 +1196,9 @@ String SinCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> SinCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> SinCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1213,7 +1213,7 @@ bool SinCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult SinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult SinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value_radians(node_a.value());
|
|
@@ -1264,9 +1264,9 @@ String CosCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> CosCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> CosCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1281,7 +1281,7 @@ bool CosCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult CosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult CosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value_radians(node_a.value());
|
|
@@ -1332,9 +1332,9 @@ String TanCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> TanCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> TanCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1349,7 +1349,7 @@ bool TanCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult TanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult TanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value_radians(node_a.value());
|
|
@@ -1400,9 +1400,9 @@ String AsinCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> AsinCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> AsinCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Angle;
|
|
|
+ return CSSMathValue::ResolvedType::Angle;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1417,7 +1417,7 @@ bool AsinCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult AsinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult AsinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1468,9 +1468,9 @@ String AcosCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> AcosCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> AcosCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Angle;
|
|
|
+ return CSSMathValue::ResolvedType::Angle;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1485,7 +1485,7 @@ bool AcosCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult AcosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult AcosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1536,9 +1536,9 @@ String AtanCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> AtanCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> AtanCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Angle;
|
|
|
+ return CSSMathValue::ResolvedType::Angle;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1553,7 +1553,7 @@ bool AtanCalculationNode::contains_percentage() const
|
|
|
return m_value->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult AtanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult AtanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1607,9 +1607,9 @@ String Atan2CalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> Atan2CalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> Atan2CalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Angle;
|
|
|
+ return CSSMathValue::ResolvedType::Angle;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1624,7 +1624,7 @@ bool Atan2CalculationNode::contains_percentage() const
|
|
|
return m_y->contains_percentage() || m_x->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult Atan2CalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult Atan2CalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_y->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1685,9 +1685,9 @@ String PowCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> PowCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> PowCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1697,7 +1697,7 @@ Optional<CSSNumericType> PowCalculationNode::determine_type(PropertyID) const
|
|
|
return CSSNumericType {};
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult PowCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult PowCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_x->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1755,9 +1755,9 @@ String SqrtCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> SqrtCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> SqrtCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1767,7 +1767,7 @@ Optional<CSSNumericType> SqrtCalculationNode::determine_type(PropertyID) const
|
|
|
return CSSNumericType {};
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult SqrtCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult SqrtCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1822,7 +1822,7 @@ String HypotCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> HypotCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> HypotCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// NOTE: We check during parsing that all values have the same type.
|
|
|
return m_values[0]->resolved_type();
|
|
@@ -1845,7 +1845,7 @@ bool HypotCalculationNode::contains_percentage() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult HypotCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult HypotCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
double square_sum = 0.0;
|
|
|
|
|
@@ -1914,9 +1914,9 @@ String LogCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> LogCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> LogCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1926,7 +1926,7 @@ Optional<CSSNumericType> LogCalculationNode::determine_type(PropertyID) const
|
|
|
return CSSNumericType {};
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult LogCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult LogCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_x->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -1984,9 +1984,9 @@ String ExpCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> ExpCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> ExpCalculationNode::resolved_type() const
|
|
|
{
|
|
|
- return CalculatedStyleValue::ResolvedType::Number;
|
|
|
+ return CSSMathValue::ResolvedType::Number;
|
|
|
}
|
|
|
|
|
|
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
|
@@ -1996,7 +1996,7 @@ Optional<CSSNumericType> ExpCalculationNode::determine_type(PropertyID) const
|
|
|
return CSSNumericType {};
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult ExpCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult ExpCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_value->resolve(context, percentage_basis);
|
|
|
auto node_a_value = resolve_value(node_a.value(), context);
|
|
@@ -2053,7 +2053,7 @@ String RoundCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> RoundCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> RoundCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// Note: We check during parsing that all values have the same type
|
|
|
return m_x->resolved_type();
|
|
@@ -2077,7 +2077,7 @@ bool RoundCalculationNode::contains_percentage() const
|
|
|
return m_x->contains_percentage() || m_y->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult RoundCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult RoundCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto node_a = m_x->resolve(context, percentage_basis);
|
|
|
auto node_b = m_y->resolve(context, percentage_basis);
|
|
@@ -2164,7 +2164,7 @@ String ModCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> ModCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> ModCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// Note: We check during parsing that all values have the same type
|
|
|
return m_x->resolved_type();
|
|
@@ -2188,7 +2188,7 @@ bool ModCalculationNode::contains_percentage() const
|
|
|
return m_x->contains_percentage() || m_y->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult ModCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult ModCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto resolved_type = m_x->resolved_type().value();
|
|
|
auto node_a = m_x->resolve(context, percentage_basis);
|
|
@@ -2250,7 +2250,7 @@ String RemCalculationNode::to_string() const
|
|
|
return MUST(builder.to_string());
|
|
|
}
|
|
|
|
|
|
-Optional<CalculatedStyleValue::ResolvedType> RemCalculationNode::resolved_type() const
|
|
|
+Optional<CSSMathValue::ResolvedType> RemCalculationNode::resolved_type() const
|
|
|
{
|
|
|
// Note: We check during parsing that all values have the same type
|
|
|
return m_x->resolved_type();
|
|
@@ -2274,7 +2274,7 @@ bool RemCalculationNode::contains_percentage() const
|
|
|
return m_x->contains_percentage() || m_y->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::CalculationResult RemCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
|
|
+CSSMathValue::CalculationResult RemCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
|
|
{
|
|
|
auto resolved_type = m_x->resolved_type().value();
|
|
|
auto node_a = m_x->resolve(context, percentage_basis);
|
|
@@ -2310,17 +2310,17 @@ bool RemCalculationNode::equals(CalculationNode const& other) const
|
|
|
&& m_y->equals(*static_cast<RemCalculationNode const&>(other).m_y);
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::add(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
+void CSSMathValue::CalculationResult::add(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
{
|
|
|
add_or_subtract_internal(SumOperation::Add, other, context, percentage_basis);
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::subtract(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
+void CSSMathValue::CalculationResult::subtract(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
{
|
|
|
add_or_subtract_internal(SumOperation::Subtract, other, context, percentage_basis);
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::add_or_subtract_internal(SumOperation op, CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
+void CSSMathValue::CalculationResult::add_or_subtract_internal(SumOperation op, CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
|
|
{
|
|
|
// We know from validation when resolving the type, that "both sides have the same type, or that one side is a <number> and the other is an <integer>".
|
|
|
// Though, having the same type may mean that one side is a <dimension> and the other a <percentage>.
|
|
@@ -2457,7 +2457,7 @@ void CalculatedStyleValue::CalculationResult::add_or_subtract_internal(SumOperat
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::multiply_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
|
|
+void CSSMathValue::CalculationResult::multiply_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
|
|
{
|
|
|
// We know from validation when resolving the type, that at least one side must be a <number> or <integer>.
|
|
|
// Both of these are represented as a double.
|
|
@@ -2498,7 +2498,7 @@ void CalculatedStyleValue::CalculationResult::multiply_by(CalculationResult cons
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::divide_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
|
|
+void CSSMathValue::CalculationResult::divide_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
|
|
{
|
|
|
// We know from validation when resolving the type, that `other` must be a <number> or <integer>.
|
|
|
// Both of these are represented as a Number.
|
|
@@ -2536,7 +2536,7 @@ void CalculatedStyleValue::CalculationResult::divide_by(CalculationResult const&
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::negate()
|
|
|
+void CSSMathValue::CalculationResult::negate()
|
|
|
{
|
|
|
m_value.visit(
|
|
|
[&](Number const& number) {
|
|
@@ -2565,7 +2565,7 @@ void CalculatedStyleValue::CalculationResult::negate()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void CalculatedStyleValue::CalculationResult::invert()
|
|
|
+void CSSMathValue::CalculationResult::invert()
|
|
|
{
|
|
|
// FIXME: Correctly handle division by zero.
|
|
|
m_value.visit(
|
|
@@ -2595,7 +2595,7 @@ void CalculatedStyleValue::CalculationResult::invert()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-CalculatedStyleValue::ResolvedType CalculatedStyleValue::CalculationResult::resolved_type() const
|
|
|
+CSSMathValue::ResolvedType CSSMathValue::CalculationResult::resolved_type() const
|
|
|
{
|
|
|
return m_value.visit(
|
|
|
[](Number const&) { return ResolvedType::Number; },
|
|
@@ -2608,21 +2608,21 @@ CalculatedStyleValue::ResolvedType CalculatedStyleValue::CalculationResult::reso
|
|
|
[](Time const&) { return ResolvedType::Time; });
|
|
|
}
|
|
|
|
|
|
-String CalculatedStyleValue::to_string() const
|
|
|
+String CSSMathValue::to_string() const
|
|
|
{
|
|
|
// FIXME: Implement this according to https://www.w3.org/TR/css-values-4/#calc-serialize once that stabilizes.
|
|
|
return MUST(String::formatted("calc({})", m_calculation->to_string()));
|
|
|
}
|
|
|
|
|
|
-bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
|
|
+bool CSSMathValue::equals(CSSStyleValue const& other) const
|
|
|
{
|
|
|
if (type() != other.type())
|
|
|
return false;
|
|
|
|
|
|
- return m_calculation->equals(*static_cast<CalculatedStyleValue const&>(other).m_calculation);
|
|
|
+ return m_calculation->equals(*static_cast<CSSMathValue const&>(other).m_calculation);
|
|
|
}
|
|
|
|
|
|
-Optional<Angle> CalculatedStyleValue::resolve_angle() const
|
|
|
+Optional<Angle> CSSMathValue::resolve_angle() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
|
|
@@ -2631,7 +2631,7 @@ Optional<Angle> CalculatedStyleValue::resolve_angle() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Angle> CalculatedStyleValue::resolve_angle_percentage(Angle const& percentage_basis) const
|
|
|
+Optional<Angle> CSSMathValue::resolve_angle_percentage(Angle const& percentage_basis) const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, percentage_basis);
|
|
|
|
|
@@ -2647,7 +2647,7 @@ Optional<Angle> CalculatedStyleValue::resolve_angle_percentage(Angle const& perc
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-Optional<Flex> CalculatedStyleValue::resolve_flex() const
|
|
|
+Optional<Flex> CSSMathValue::resolve_flex() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
|
|
@@ -2656,7 +2656,7 @@ Optional<Flex> CalculatedStyleValue::resolve_flex() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Frequency> CalculatedStyleValue::resolve_frequency() const
|
|
|
+Optional<Frequency> CSSMathValue::resolve_frequency() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
|
|
@@ -2665,7 +2665,7 @@ Optional<Frequency> CalculatedStyleValue::resolve_frequency() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Frequency> CalculatedStyleValue::resolve_frequency_percentage(Frequency const& percentage_basis) const
|
|
|
+Optional<Frequency> CSSMathValue::resolve_frequency_percentage(Frequency const& percentage_basis) const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, percentage_basis);
|
|
|
|
|
@@ -2681,7 +2681,7 @@ Optional<Frequency> CalculatedStyleValue::resolve_frequency_percentage(Frequency
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-Optional<Length> CalculatedStyleValue::resolve_length(Length::ResolutionContext const& context) const
|
|
|
+Optional<Length> CSSMathValue::resolve_length(Length::ResolutionContext const& context) const
|
|
|
{
|
|
|
auto result = m_calculation->resolve(context, {});
|
|
|
|
|
@@ -2690,22 +2690,22 @@ Optional<Length> CalculatedStyleValue::resolve_length(Length::ResolutionContext
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Length> CalculatedStyleValue::resolve_length(Layout::Node const& layout_node) const
|
|
|
+Optional<Length> CSSMathValue::resolve_length(Layout::Node const& layout_node) const
|
|
|
{
|
|
|
return resolve_length(Length::ResolutionContext::for_layout_node(layout_node));
|
|
|
}
|
|
|
|
|
|
-Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node const& layout_node, Length const& percentage_basis) const
|
|
|
+Optional<Length> CSSMathValue::resolve_length_percentage(Layout::Node const& layout_node, Length const& percentage_basis) const
|
|
|
{
|
|
|
return resolve_length_percentage(Length::ResolutionContext::for_layout_node(layout_node), percentage_basis);
|
|
|
}
|
|
|
|
|
|
-Optional<Length> CalculatedStyleValue::resolve_length_percentage(Layout::Node const& layout_node, CSSPixels percentage_basis) const
|
|
|
+Optional<Length> CSSMathValue::resolve_length_percentage(Layout::Node const& layout_node, CSSPixels percentage_basis) const
|
|
|
{
|
|
|
return resolve_length_percentage(Length::ResolutionContext::for_layout_node(layout_node), Length::make_px(percentage_basis));
|
|
|
}
|
|
|
|
|
|
-Optional<Length> CalculatedStyleValue::resolve_length_percentage(Length::ResolutionContext const& resolution_context, Length const& percentage_basis) const
|
|
|
+Optional<Length> CSSMathValue::resolve_length_percentage(Length::ResolutionContext const& resolution_context, Length const& percentage_basis) const
|
|
|
{
|
|
|
auto result = m_calculation->resolve(resolution_context, percentage_basis);
|
|
|
|
|
@@ -2721,7 +2721,7 @@ Optional<Length> CalculatedStyleValue::resolve_length_percentage(Length::Resolut
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-Optional<Percentage> CalculatedStyleValue::resolve_percentage() const
|
|
|
+Optional<Percentage> CSSMathValue::resolve_percentage() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
if (result.value().has<Percentage>())
|
|
@@ -2729,7 +2729,7 @@ Optional<Percentage> CalculatedStyleValue::resolve_percentage() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Resolution> CalculatedStyleValue::resolve_resolution() const
|
|
|
+Optional<Resolution> CSSMathValue::resolve_resolution() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
if (result.value().has<Resolution>())
|
|
@@ -2737,7 +2737,7 @@ Optional<Resolution> CalculatedStyleValue::resolve_resolution() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Time> CalculatedStyleValue::resolve_time() const
|
|
|
+Optional<Time> CSSMathValue::resolve_time() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
|
|
@@ -2746,7 +2746,7 @@ Optional<Time> CalculatedStyleValue::resolve_time() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<Time> CalculatedStyleValue::resolve_time_percentage(Time const& percentage_basis) const
|
|
|
+Optional<Time> CSSMathValue::resolve_time_percentage(Time const& percentage_basis) const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, percentage_basis);
|
|
|
|
|
@@ -2759,7 +2759,7 @@ Optional<Time> CalculatedStyleValue::resolve_time_percentage(Time const& percent
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-Optional<double> CalculatedStyleValue::resolve_number() const
|
|
|
+Optional<double> CSSMathValue::resolve_number() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
if (result.value().has<Number>())
|
|
@@ -2767,7 +2767,7 @@ Optional<double> CalculatedStyleValue::resolve_number() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-Optional<i64> CalculatedStyleValue::resolve_integer() const
|
|
|
+Optional<i64> CSSMathValue::resolve_integer() const
|
|
|
{
|
|
|
auto result = m_calculation->resolve({}, {});
|
|
|
if (result.value().has<Number>())
|
|
@@ -2775,12 +2775,12 @@ Optional<i64> CalculatedStyleValue::resolve_integer() const
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-bool CalculatedStyleValue::contains_percentage() const
|
|
|
+bool CSSMathValue::contains_percentage() const
|
|
|
{
|
|
|
return m_calculation->contains_percentage();
|
|
|
}
|
|
|
|
|
|
-String CalculatedStyleValue::dump() const
|
|
|
+String CSSMathValue::dump() const
|
|
|
{
|
|
|
StringBuilder builder;
|
|
|
m_calculation->dump(builder, 0);
|