LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue

This matches the name in the CSS Typed OM spec. There's quite a lot
still to do to make it match the spec behavior, but this is the first
step.
This commit is contained in:
Sam Atkins 2024-09-18 17:27:47 +01:00 committed by Sam Atkins
parent 35cb6badc2
commit 76daba3069
Notes: github-actions[bot] 2024-09-18 19:39:35 +00:00
32 changed files with 340 additions and 340 deletions

View file

@ -90,7 +90,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& functions_data, Core::Fil
#include <LibWeb/CSS/MathFunctions.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
namespace Web::CSS::Parser {

View file

@ -11,10 +11,10 @@ source_set("StyleValues") {
"CSSHSL.cpp",
"CSSHWB.cpp",
"CSSKeywordValue.cpp",
"CSSMathValue.cpp",
"CSSOKLCH.cpp",
"CSSOKLab.cpp",
"CSSRGB.cpp",
"CalculatedStyleValue.cpp",
"ConicGradientStyleValue.cpp",
"ContentStyleValue.cpp",
"DisplayStyleValue.cpp",

View file

@ -112,7 +112,6 @@ set(SOURCES
CSS/StyleValues/BackgroundSizeStyleValue.cpp
CSS/StyleValues/BasicShapeStyleValue.cpp
CSS/StyleValues/BorderRadiusStyleValue.cpp
CSS/StyleValues/CalculatedStyleValue.cpp
CSS/StyleValues/ConicGradientStyleValue.cpp
CSS/StyleValues/ContentStyleValue.cpp
CSS/StyleValues/CounterDefinitionsStyleValue.cpp
@ -121,6 +120,7 @@ set(SOURCES
CSS/StyleValues/CSSHSL.cpp
CSS/StyleValues/CSSHWB.cpp
CSS/StyleValues/CSSKeywordValue.cpp
CSS/StyleValues/CSSMathValue.cpp
CSS/StyleValues/CSSOKLab.cpp
CSS/StyleValues/CSSOKLCH.cpp
CSS/StyleValues/CSSRGB.cpp

View file

@ -7,7 +7,7 @@
#include "Angle.h"
#include <AK/Math.h>
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
namespace Web::CSS {
@ -84,7 +84,7 @@ Optional<Angle::Type> Angle::unit_from_name(StringView name)
return {};
}
Angle Angle::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Angle const& reference_value)
Angle Angle::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Angle const& reference_value)
{
return calculated->resolve_angle_percentage(reference_value).value();
}

View file

@ -52,7 +52,7 @@ public:
return 0;
}
static Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Angle const& reference_value);
static Angle resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Angle const& reference_value);
private:
Type m_type;

View file

@ -18,7 +18,7 @@
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
@ -100,10 +100,10 @@ BorderRadiusStyleValue const& CSSStyleValue::as_border_radius() const
return static_cast<BorderRadiusStyleValue const&>(*this);
}
CalculatedStyleValue const& CSSStyleValue::as_calculated() const
CSSMathValue const& CSSStyleValue::as_math() const
{
VERIFY(is_calculated());
return static_cast<CalculatedStyleValue const&>(*this);
VERIFY(is_math());
return static_cast<CSSMathValue const&>(*this);
}
CSSColorValue const& CSSStyleValue::as_color() const
@ -378,8 +378,8 @@ int CSSStyleValue::to_font_weight() const
if (is_number()) {
return round_to<int>(as_number().number());
}
if (is_calculated()) {
auto maybe_weight = const_cast<CalculatedStyleValue&>(as_calculated()).resolve_integer();
if (is_math()) {
auto maybe_weight = const_cast<CSSMathValue&>(as_math()).resolve_integer();
if (maybe_weight.has_value())
return maybe_weight.value();
}

View file

@ -93,7 +93,6 @@ public:
BackgroundSize,
BasicShape,
BorderRadius,
Calculated,
Color,
ConicGradient,
Content,
@ -115,6 +114,7 @@ public:
Keyword,
Length,
LinearGradient,
Math,
MathDepth,
Number,
Percentage,
@ -164,10 +164,6 @@ public:
BorderRadiusStyleValue const& as_border_radius() const;
BorderRadiusStyleValue& as_border_radius() { return const_cast<BorderRadiusStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_border_radius()); }
bool is_calculated() const { return type() == Type::Calculated; }
CalculatedStyleValue const& as_calculated() const;
CalculatedStyleValue& as_calculated() { return const_cast<CalculatedStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_calculated()); }
bool is_color() const { return type() == Type::Color; }
CSSColorValue const& as_color() const;
CSSColorValue& as_color() { return const_cast<CSSColorValue&>(const_cast<CSSStyleValue const&>(*this).as_color()); }
@ -252,6 +248,10 @@ public:
LinearGradientStyleValue const& as_linear_gradient() const;
LinearGradientStyleValue& as_linear_gradient() { return const_cast<LinearGradientStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_linear_gradient()); }
bool is_math() const { return type() == Type::Math; }
CSSMathValue const& as_math() const;
CSSMathValue& as_math() { return const_cast<CSSMathValue&>(const_cast<CSSStyleValue const&>(*this).as_math()); }
bool is_math_depth() const { return type() == Type::MathDepth; }
MathDepthStyleValue const& as_math_depth() const;
MathDepthStyleValue& as_math_depth() { return const_cast<MathDepthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_math_depth()); }

View file

@ -17,7 +17,7 @@
namespace Web::CSS {
Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_angle().value();
}
@ -27,7 +27,7 @@ NonnullRefPtr<CSSStyleValue> AngleOrCalculated::create_style_value() const
return AngleStyleValue::create(value());
}
Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_flex().value();
}
@ -37,7 +37,7 @@ NonnullRefPtr<CSSStyleValue> FlexOrCalculated::create_style_value() const
return FlexStyleValue::create(value());
}
Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_frequency().value();
}
@ -47,7 +47,7 @@ NonnullRefPtr<CSSStyleValue> FrequencyOrCalculated::create_style_value() const
return FrequencyStyleValue::create(value());
}
i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_integer().value();
}
@ -57,7 +57,7 @@ NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const
return IntegerStyleValue::create(value());
}
Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node) const
{
return calculated->resolve_length(layout_node).value();
}
@ -74,7 +74,7 @@ NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const
return LengthStyleValue::create(value());
}
double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_number().value();
}
@ -84,7 +84,7 @@ NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const
return NumberStyleValue::create(value());
}
Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_percentage().value();
}
@ -94,7 +94,7 @@ NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const
return PercentageStyleValue::create(value());
}
Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_resolution().value();
}
@ -104,7 +104,7 @@ NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const
return ResolutionStyleValue::create(value());
}
Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
{
return calculated->resolve_time().value();
}

View file

@ -13,7 +13,7 @@
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/Resolution.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/Time.h>
namespace Web::CSS {
@ -26,14 +26,14 @@ public:
{
}
CalculatedOr(NonnullRefPtr<CalculatedStyleValue> calculated)
CalculatedOr(NonnullRefPtr<CSSMathValue> calculated)
: m_value(move(calculated))
{
}
virtual ~CalculatedOr() = default;
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); }
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CSSMathValue>>(); }
T const& value() const
{
@ -48,10 +48,10 @@ public:
return create_style_value();
}
NonnullRefPtr<CalculatedStyleValue> const& calculated() const
NonnullRefPtr<CSSMathValue> const& calculated() const
{
VERIFY(is_calculated());
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>();
return m_value.template get<NonnullRefPtr<CSSMathValue>>();
}
T resolved(Layout::Node const& layout_node) const
@ -60,7 +60,7 @@ public:
[&](T const& t) {
return t;
},
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
return resolve_calculated(calculated, layout_node);
});
}
@ -68,7 +68,7 @@ public:
String to_string() const
{
if (is_calculated())
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string();
return m_value.template get<NonnullRefPtr<CSSMathValue>>()->to_string();
return m_value.template get<T>().to_string();
}
@ -81,11 +81,11 @@ public:
}
protected:
virtual T resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const = 0;
virtual T resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const = 0;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const = 0;
private:
Variant<T, NonnullRefPtr<CalculatedStyleValue>> m_value;
Variant<T, NonnullRefPtr<CSSMathValue>> m_value;
};
class AngleOrCalculated : public CalculatedOr<Angle> {
@ -93,7 +93,7 @@ public:
using CalculatedOr<Angle>::CalculatedOr;
private:
virtual Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Angle resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -102,7 +102,7 @@ public:
using CalculatedOr<Flex>::CalculatedOr;
private:
virtual Flex resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Flex resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -111,7 +111,7 @@ public:
using CalculatedOr<Frequency>::CalculatedOr;
private:
virtual Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Frequency resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -120,7 +120,7 @@ public:
using CalculatedOr<i64>::CalculatedOr;
private:
virtual i64 resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual i64 resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -131,7 +131,7 @@ public:
[[nodiscard]] Length resolved(Length::ResolutionContext const&) const;
private:
virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Length resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -140,7 +140,7 @@ public:
using CalculatedOr<double>::CalculatedOr;
private:
virtual double resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual double resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -149,7 +149,7 @@ public:
using CalculatedOr<Percentage>::CalculatedOr;
private:
virtual Percentage resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Percentage resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -158,7 +158,7 @@ public:
using CalculatedOr<Resolution>::CalculatedOr;
private:
virtual Resolution resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Resolution resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};
@ -167,7 +167,7 @@ public:
using CalculatedOr<Time>::CalculatedOr;
private:
virtual Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
virtual Time resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
};

View file

@ -6,7 +6,7 @@
#include "Frequency.h"
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
namespace Web::CSS {
@ -63,7 +63,7 @@ Optional<Frequency::Type> Frequency::unit_from_name(StringView name)
return {};
}
Frequency Frequency::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Frequency const& reference_value)
Frequency Frequency::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Frequency const& reference_value)
{
return calculated->resolve_frequency_percentage(reference_value).value();
}

View file

@ -47,7 +47,7 @@ public:
return 0;
}
static Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Frequency const& reference_value);
static Frequency resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Frequency const& reference_value);
private:
Type m_type;

View file

@ -391,12 +391,12 @@ Length Length::absolutized(CSSPixelRect const& viewport_rect, FontMetrics const&
return absolutize(viewport_rect, font_metrics, root_font_metrics).value_or(*this);
}
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, Length const& reference_value)
Length Length::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node, Length const& reference_value)
{
return calculated->resolve_length_percentage(layout_node, reference_value).value();
}
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
Length Length::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
{
return calculated->resolve_length_percentage(layout_node, reference_value).value();
}

View file

@ -223,8 +223,8 @@ public:
Optional<Length> absolutize(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
Length absolutized(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Length const& reference_value);
static Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, CSSPixels reference_value);
static Length resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Length const& reference_value);
static Length resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, CSSPixels reference_value);
private:
[[nodiscard]] CSSPixels to_px_slow_case(Layout::Node const&) const;

View file

@ -16,7 +16,7 @@ public:
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
~LengthBox();
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue> member, but we can't include the header CSSStyleValue.h as it includes
// Length (and thus LengthPercentage) includes a RefPtr<CSSMathValue> member, but we can't include the header CSSStyleValue.h as it includes
// this file already. To break the cyclic dependency, we must initialize these members in the constructor.
LengthPercentage& top() { return m_top; }
LengthPercentage& right() { return m_right; }

View file

@ -1797,7 +1797,7 @@ RefPtr<CustomIdentStyleValue> Parser::parse_custom_ident_value(TokenStream<Compo
return CustomIdentStyleValue::create(custom_ident);
}
RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(ComponentValue const& component_value)
RefPtr<CSSMathValue> Parser::parse_calculated_value(ComponentValue const& component_value)
{
if (!component_value.is_function())
return nullptr;
@ -1812,7 +1812,7 @@ RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(ComponentValue const
if (!function_type.has_value())
return nullptr;
return CalculatedStyleValue::create(function_node.release_nonnull(), function_type.release_value());
return CSSMathValue::create(function_node.release_nonnull(), function_type.release_value());
}
OwnPtr<CalculationNode> Parser::parse_a_calc_function_node(Function const& function)
@ -2529,7 +2529,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_value(TokenStream<ComponentValue>& tok
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_angle()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_angle())) {
transaction.commit();
return dimension_value;
}
@ -2542,7 +2542,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_percentage_value(TokenStream<Component
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_angle() || dimension_value->is_percentage()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle_percentage())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_angle_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2555,7 +2555,7 @@ RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& toke
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_flex()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_flex())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_flex())) {
transaction.commit();
return dimension_value;
}
@ -2568,7 +2568,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_value(TokenStream<ComponentValue>&
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_frequency()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_frequency())) {
transaction.commit();
return dimension_value;
}
@ -2581,7 +2581,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_percentage_value(TokenStream<Compo
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_frequency() || dimension_value->is_percentage()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency_percentage())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_frequency_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2594,7 +2594,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_value(TokenStream<ComponentValue>& to
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_length()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_length())) {
transaction.commit();
return dimension_value;
}
@ -2607,7 +2607,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_percentage_value(TokenStream<Componen
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_length() || dimension_value->is_percentage()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length_percentage())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_length_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2620,7 +2620,7 @@ RefPtr<CSSStyleValue> Parser::parse_resolution_value(TokenStream<ComponentValue>
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_resolution()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_resolution())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_resolution())) {
transaction.commit();
return dimension_value;
}
@ -2633,7 +2633,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_value(TokenStream<ComponentValue>& toke
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_time()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_time())) {
transaction.commit();
return dimension_value;
}
@ -2646,7 +2646,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_percentage_value(TokenStream<ComponentV
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_time() || dimension_value->is_percentage()
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time_percentage())) {
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_time_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2855,7 +2855,7 @@ RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>&
// Verify we're all percentages or all numbers
auto is_percentage = [](CSSStyleValue const& style_value) {
return style_value.is_percentage()
|| (style_value.is_calculated() && style_value.as_calculated().resolves_to_percentage());
|| (style_value.is_math() && style_value.as_math().resolves_to_percentage());
};
bool red_is_percentage = is_percentage(*red);
bool green_is_percentage = is_percentage(*green);
@ -4170,8 +4170,8 @@ static Optional<LengthPercentage> style_value_to_length_percentage(auto value)
return LengthPercentage { value->as_percentage().percentage() };
if (value->is_length())
return LengthPercentage { value->as_length().length() };
if (value->is_calculated())
return LengthPercentage { value->as_calculated() };
if (value->is_math())
return LengthPercentage { value->as_math() };
return {};
}
@ -4298,8 +4298,8 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_size_value(TokenStream<Com
return LengthPercentage { style_value.as_percentage().percentage() };
if (style_value.is_length())
return LengthPercentage { style_value.as_length().length() };
if (style_value.is_calculated())
return LengthPercentage { style_value.as_calculated() };
if (style_value.is_math())
return LengthPercentage { style_value.as_math() };
return {};
};
@ -6207,7 +6207,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>&
argument_tokens.skip_whitespace();
auto const& value = argument_tokens.next_token();
RefPtr<CalculatedStyleValue> maybe_calc_value = parse_calculated_value(value);
RefPtr<CSSMathValue> maybe_calc_value = parse_calculated_value(value);
switch (function_metadata.parameters[argument_index].type) {
case TransformFunctionParameterType::Angle: {
@ -7909,10 +7909,10 @@ public:
ComponentValue& component_value() { return m_component_value; }
virtual String to_string() const override { VERIFY_NOT_REACHED(); }
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override { VERIFY_NOT_REACHED(); }
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override { VERIFY_NOT_REACHED(); }
virtual Optional<CSSNumericType> determine_type(Web::CSS::PropertyID) const override { VERIFY_NOT_REACHED(); }
virtual bool contains_percentage() const override { VERIFY_NOT_REACHED(); }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override { VERIFY_NOT_REACHED(); }
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override { VERIFY_NOT_REACHED(); }
virtual void for_each_child_node(AK::Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override { }
virtual void dump(StringBuilder& builder, int indent) const override
@ -8445,8 +8445,8 @@ bool Parser::expand_unresolved_values(DOM::Element& element, FlyString const& pr
continue;
}
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_calculated()) {
auto& calc_value = maybe_calc_value->as_calculated();
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_math()) {
auto& calc_value = maybe_calc_value->as_math();
if (calc_value.resolves_to_angle()) {
auto resolved_value = calc_value.resolve_angle();
dest.empend(Token::create_dimension(resolved_value->to_degrees(), "deg"_fly_string));

View file

@ -30,7 +30,7 @@
#include <LibWeb/CSS/Ratio.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/Supports.h>
#include <LibWeb/Forward.h>
@ -234,7 +234,7 @@ private:
};
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_builtin_value(TokenStream<ComponentValue>&);
RefPtr<CalculatedStyleValue> parse_calculated_value(ComponentValue const&);
RefPtr<CSSMathValue> parse_calculated_value(ComponentValue const&);
RefPtr<CustomIdentStyleValue> parse_custom_ident_value(TokenStream<ComponentValue>&, std::initializer_list<StringView> blacklist);
// NOTE: Implemented in generated code. (GenerateCSSMathFunctions.cpp)
OwnPtr<CalculationNode> parse_math_function(PropertyID, Function const&);

View file

@ -13,7 +13,7 @@
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/Number.h>
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/Time.h>
namespace Web::CSS {
@ -31,7 +31,7 @@ public:
{
}
PercentageOr(NonnullRefPtr<CalculatedStyleValue> calculated)
PercentageOr(NonnullRefPtr<CSSMathValue> calculated)
: m_value(move(calculated))
{
}
@ -51,7 +51,7 @@ public:
}
bool is_percentage() const { return m_value.template has<Percentage>(); }
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); }
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CSSMathValue>>(); }
bool contains_percentage() const
{
@ -62,7 +62,7 @@ public:
[&](Percentage const&) {
return true;
},
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
return calculated->contains_percentage();
});
}
@ -73,10 +73,10 @@ public:
return m_value.template get<Percentage>();
}
NonnullRefPtr<CalculatedStyleValue> const& calculated() const
NonnullRefPtr<CSSMathValue> const& calculated() const
{
VERIFY(is_calculated());
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>();
return m_value.template get<NonnullRefPtr<CSSMathValue>>();
}
CSSPixels to_px(Layout::Node const& layout_node, CSSPixels reference_value) const
@ -100,7 +100,7 @@ public:
[&](Percentage const& percentage) {
return reference_value.percentage_of(percentage);
},
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
return T::resolve_calculated(calculated, layout_node, reference_value);
});
}
@ -114,7 +114,7 @@ public:
[&](Percentage const& percentage) {
return Length::make_px(CSSPixels(percentage.value() * reference_value) / 100);
},
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
return T::resolve_calculated(calculated, layout_node, reference_value);
});
}
@ -122,7 +122,7 @@ public:
String to_string() const
{
if (is_calculated())
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string();
return m_value.template get<NonnullRefPtr<CSSMathValue>>()->to_string();
if (is_percentage())
return m_value.template get<Percentage>().to_string();
return m_value.template get<T>().to_string();
@ -135,7 +135,7 @@ public:
if (is_percentage() != other.is_percentage())
return false;
if (is_calculated())
return (*m_value.template get<NonnullRefPtr<CalculatedStyleValue>>() == *other.m_value.template get<NonnullRefPtr<CalculatedStyleValue>>());
return (*m_value.template get<NonnullRefPtr<CSSMathValue>>() == *other.m_value.template get<NonnullRefPtr<CSSMathValue>>());
if (is_percentage())
return (m_value.template get<Percentage>() == other.m_value.template get<Percentage>());
return (m_value.template get<T>() == other.m_value.template get<T>());
@ -146,7 +146,7 @@ protected:
T const& get_t() const { return m_value.template get<T>(); }
private:
Variant<T, Percentage, NonnullRefPtr<CalculatedStyleValue>> m_value;
Variant<T, Percentage, NonnullRefPtr<CSSMathValue>> m_value;
};
template<typename T>

View file

@ -17,7 +17,7 @@
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>

View file

@ -44,7 +44,7 @@ Size Size::make_percentage(Percentage percentage)
return Size { Type::Percentage, move(percentage) };
}
Size Size::make_calculated(NonnullRefPtr<Web::CSS::CalculatedStyleValue> calculated)
Size Size::make_calculated(NonnullRefPtr<Web::CSS::CSSMathValue> calculated)
{
return Size { Type::Calculated, move(calculated) };
}

View file

@ -29,7 +29,7 @@ public:
static Size make_px(CSSPixels);
static Size make_length(Length);
static Size make_percentage(Percentage);
static Size make_calculated(NonnullRefPtr<CalculatedStyleValue>);
static Size make_calculated(NonnullRefPtr<CSSMathValue>);
static Size make_min_content();
static Size make_max_content();
static Size make_fit_content(Length available_space);
@ -52,7 +52,7 @@ public:
bool contains_percentage() const;
CalculatedStyleValue const& calculated() const
CSSMathValue const& calculated() const
{
VERIFY(is_calculated());
return m_length_percentage.calculated();

View file

@ -1038,8 +1038,8 @@ static RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element,
case CSSStyleValue::Type::Angle:
values.append(AngleOrCalculated { value->as_angle().angle() });
break;
case CSSStyleValue::Type::Calculated:
values.append(LengthPercentage { value->as_calculated() });
case CSSStyleValue::Type::Math:
values.append(LengthPercentage { value->as_math() });
break;
case CSSStyleValue::Type::Length:
values.append(LengthPercentage { value->as_length().length() });
@ -1472,7 +1472,7 @@ static NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& elemen
values.unchecked_append(to_calculation_node(interpolated_from));
values.unchecked_append(to_calculation_node(interpolated_to));
auto calc_node = SumCalculationNode::create(move(values));
return CalculatedStyleValue::create(move(calc_node), CSSNumericType { to_base_type_and_default->base_type, 1 });
return CSSMathValue::create(move(calc_node), CSSNumericType { to_base_type_and_default->base_type, 1 });
}
return delta >= 0.5f ? to : from;
@ -2240,11 +2240,11 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
} else if (font_size.is_length()) {
maybe_length = font_size.as_length().length();
} else if (font_size.is_calculated()) {
if (font_size.as_calculated().contains_percentage()) {
maybe_length = font_size.as_calculated().resolve_length_percentage(length_resolution_context, Length::make_px(parent_font_size()));
} else if (font_size.is_math()) {
if (font_size.as_math().contains_percentage()) {
maybe_length = font_size.as_math().resolve_length_percentage(length_resolution_context, Length::make_px(parent_font_size()));
} else {
maybe_length = font_size.as_calculated().resolve_length(length_resolution_context);
maybe_length = font_size.as_math().resolve_length(length_resolution_context);
}
}
if (maybe_length.has_value()) {
@ -3097,8 +3097,8 @@ void StyleComputer::compute_math_depth(StyleProperties& style, DOM::Element cons
auto resolve_integer = [&](CSSStyleValue const& integer_value) {
if (integer_value.is_integer())
return integer_value.as_integer().integer();
if (integer_value.is_calculated())
return integer_value.as_calculated().resolve_integer().value();
if (integer_value.is_math())
return integer_value.as_math().resolve_integer().value();
VERIFY_NOT_REACHED();
};

View file

@ -148,8 +148,8 @@ CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
}
}
if (value->is_calculated())
return CSS::Size::make_calculated(const_cast<CalculatedStyleValue&>(value->as_calculated()));
if (value->is_math())
return CSS::Size::make_calculated(const_cast<CSSMathValue&>(value->as_math()));
if (value->is_percentage())
return CSS::Size::make_percentage(value->as_percentage().percentage());
@ -175,8 +175,8 @@ Optional<LengthPercentage> StyleProperties::length_percentage(CSS::PropertyID id
{
auto value = property(id);
if (value->is_calculated())
return LengthPercentage { const_cast<CalculatedStyleValue&>(value->as_calculated()) };
if (value->is_math())
return LengthPercentage { const_cast<CSSMathValue&>(value->as_math()) };
if (value->is_percentage())
return value->as_percentage().percentage();
@ -244,19 +244,19 @@ CSSPixels StyleProperties::compute_line_height(CSSPixelRect const& viewport_rect
return Length(percentage.as_fraction(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics);
}
if (line_height->is_calculated()) {
if (line_height->as_calculated().resolves_to_number()) {
auto resolved = line_height->as_calculated().resolve_number();
if (line_height->is_math()) {
if (line_height->as_math().resolves_to_number()) {
auto resolved = line_height->as_math().resolve_number();
if (!resolved.has_value()) {
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height->as_calculated().to_string());
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height->as_math().to_string());
return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing());
}
return Length(resolved.value(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics);
}
auto resolved = line_height->as_calculated().resolve_length(Length::ResolutionContext { viewport_rect, font_metrics, root_font_metrics });
auto resolved = line_height->as_math().resolve_length(Length::ResolutionContext { viewport_rect, font_metrics, root_font_metrics });
if (!resolved.has_value()) {
dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height->as_calculated().to_string());
dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height->as_math().to_string());
return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing());
}
return resolved->to_px(viewport_rect, font_metrics, root_font_metrics);
@ -288,16 +288,16 @@ float StyleProperties::resolve_opacity_value(CSSStyleValue const& value)
if (value.is_number()) {
unclamped_opacity = value.as_number().number();
} else if (value.is_calculated()) {
auto& calculated = value.as_calculated();
} else if (value.is_math()) {
auto& calculated = value.as_math();
if (calculated.resolves_to_percentage()) {
auto maybe_percentage = value.as_calculated().resolve_percentage();
auto maybe_percentage = value.as_math().resolve_percentage();
if (maybe_percentage.has_value())
unclamped_opacity = maybe_percentage->as_fraction();
else
dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string());
} else if (calculated.resolves_to_number()) {
auto maybe_number = const_cast<CalculatedStyleValue&>(value.as_calculated()).resolve_number();
auto maybe_number = const_cast<CSSMathValue&>(value.as_math()).resolve_number();
if (maybe_number.has_value())
unclamped_opacity = maybe_number.value();
else
@ -469,8 +469,8 @@ Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(CSS
Vector<TransformValue> values;
size_t argument_index = 0;
for (auto& transformation_value : transformation_style_value.values()) {
if (transformation_value->is_calculated()) {
auto& calculated = transformation_value->as_calculated();
if (transformation_value->is_math()) {
auto& calculated = transformation_value->as_math();
if (calculated.resolves_to_length_percentage()) {
values.append(CSS::LengthPercentage { calculated });
} else if (calculated.resolves_to_percentage()) {
@ -903,8 +903,8 @@ Vector<ShadowData> StyleProperties::shadow(PropertyID property_id, Layout::Node
auto resolve_to_length = [&layout_node](NonnullRefPtr<CSSStyleValue const> const& value) -> Optional<Length> {
if (value->is_length())
return value->as_length().length();
if (value->is_calculated())
return value->as_calculated().resolve_length(layout_node);
if (value->is_math())
return value->as_math().resolve_length(layout_node);
return {};
};
@ -985,8 +985,8 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
if (value->is_percentage())
return CSS::LengthPercentage(value->as_percentage().percentage());
if (value->is_calculated())
return LengthPercentage { const_cast<CalculatedStyleValue&>(value->as_calculated()) };
if (value->is_math())
return LengthPercentage { const_cast<CSSMathValue&>(value->as_math()) };
VERIFY_NOT_REACHED();
}
@ -1178,8 +1178,8 @@ Vector<CounterData> StyleProperties::counter_data(PropertyID property_id) const
if (counter.value) {
if (counter.value->is_integer()) {
data.value = AK::clamp_to<i32>(counter.value->as_integer().integer());
} else if (counter.value->is_calculated()) {
auto maybe_int = counter.value->as_calculated().resolve_integer();
} else if (counter.value->is_math()) {
auto maybe_int = counter.value->as_math().resolve_integer();
if (maybe_int.has_value())
data.value = AK::clamp_to<i32>(*maybe_int);
} else {

View file

@ -10,8 +10,8 @@
#include "CSSColorValue.h"
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/CSSRGB.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
@ -58,8 +58,8 @@ Optional<float> CSSColorValue::resolve_hue(CSSStyleValue const& style_value)
if (style_value.is_angle())
return normalized(style_value.as_angle().angle().to_degrees());
if (style_value.is_calculated() && style_value.as_calculated().resolves_to_angle())
return normalized(style_value.as_calculated().resolve_angle().value().to_degrees());
if (style_value.is_math() && style_value.as_math().resolves_to_angle())
return normalized(style_value.as_math().resolve_angle().value().to_degrees());
if (style_value.is_keyword() && style_value.to_keyword() == Keyword::None)
return 0;
@ -80,8 +80,8 @@ Optional<float> CSSColorValue::resolve_with_reference_value(CSSStyleValue const&
if (style_value.is_number())
return style_value.as_number().number();
if (style_value.is_calculated()) {
auto const& calculated = style_value.as_calculated();
if (style_value.is_math()) {
auto const& calculated = style_value.as_math();
if (calculated.resolves_to_number())
return calculated.resolve_number().value();
if (calculated.resolves_to_percentage())
@ -107,8 +107,8 @@ Optional<float> CSSColorValue::resolve_alpha(CSSStyleValue const& style_value)
if (style_value.is_percentage())
return normalized(style_value.as_percentage().percentage().as_fraction());
if (style_value.is_calculated()) {
auto const& calculated = style_value.as_calculated();
if (style_value.is_math()) {
auto const& calculated = style_value.as_math();
if (calculated.resolves_to_number())
return normalized(calculated.resolve_number().value());
if (calculated.resolves_to_percentage())

View file

@ -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);

View file

@ -1,7 +1,7 @@
/*
* 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
@ -24,7 +24,7 @@ namespace Web::CSS {
class CalculationNode;
class CalculatedStyleValue : public CSSStyleValue {
class CSSMathValue : public CSSStyleValue {
public:
enum class ResolvedType {
Angle,
@ -74,9 +74,9 @@ public:
Value m_value;
};
static ValueComparingNonnullRefPtr<CalculatedStyleValue> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
static ValueComparingNonnullRefPtr<CSSMathValue> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
{
return adopt_ref(*new (nothrow) CalculatedStyleValue(move(calculation), resolved_type));
return adopt_ref(*new (nothrow) CSSMathValue(move(calculation), resolved_type));
}
String to_string() const override;
@ -126,8 +126,8 @@ public:
String dump() const;
private:
explicit CalculatedStyleValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
: CSSStyleValue(Type::Calculated)
explicit CSSMathValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
: CSSStyleValue(Type::Math)
, m_resolved_type(resolved_type)
, m_calculation(move(calculation))
{
@ -205,7 +205,7 @@ public:
// This only exists during parsing.
Unparsed,
};
using NumericValue = CalculatedStyleValue::CalculationResult::Value;
using NumericValue = CSSMathValue::CalculationResult::Value;
virtual ~CalculationNode();
@ -254,10 +254,10 @@ public:
}
virtual String to_string() const = 0;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const = 0;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const = 0;
virtual Optional<CSSNumericType> determine_type(PropertyID) const = 0;
virtual bool contains_percentage() const = 0;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const = 0;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const = 0;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) = 0;
virtual void dump(StringBuilder&, int indent) const = 0;
@ -276,10 +276,10 @@ public:
~NumericCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override { }
virtual void dump(StringBuilder&, int indent) const override;
@ -296,10 +296,10 @@ public:
~SumCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -316,10 +316,10 @@ public:
~ProductCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -336,10 +336,10 @@ public:
~NegateCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -356,10 +356,10 @@ public:
~InvertCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -376,10 +376,10 @@ public:
~MinCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -396,10 +396,10 @@ public:
~MaxCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -416,10 +416,10 @@ public:
~ClampCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -438,10 +438,10 @@ public:
~AbsCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -458,10 +458,10 @@ public:
~SignCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -478,10 +478,10 @@ public:
~ConstantCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override { return false; }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override { }
virtual void dump(StringBuilder&, int indent) const override;
@ -498,10 +498,10 @@ public:
~SinCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -518,10 +518,10 @@ public:
~CosCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -538,10 +538,10 @@ public:
~TanCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -558,10 +558,10 @@ public:
~AsinCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -578,10 +578,10 @@ public:
~AcosCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -598,10 +598,10 @@ public:
~AtanCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -618,10 +618,10 @@ public:
~Atan2CalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -639,10 +639,10 @@ public:
~PowCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override { return false; }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -660,10 +660,10 @@ public:
~SqrtCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override { return false; }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -680,10 +680,10 @@ public:
~HypotCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -700,10 +700,10 @@ public:
~LogCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override { return false; }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -721,10 +721,10 @@ public:
~ExpCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override { return false; }
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -741,10 +741,10 @@ public:
~RoundCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -763,10 +763,10 @@ public:
~ModCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;
@ -784,10 +784,10 @@ public:
~RemCalculationNode();
virtual String to_string() const override;
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
virtual bool contains_percentage() const override;
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
virtual void for_each_child_node(Function<void(NonnullOwnPtr<CalculationNode>&)> const&) override;
virtual void dump(StringBuilder&, int indent) const override;

View file

@ -8,7 +8,7 @@
#include <AK/Math.h>
#include <AK/TypeCasts.h>
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>

View file

@ -7,7 +7,7 @@
#include "CSSOKLab.h"
#include <AK/TypeCasts.h>
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>

View file

@ -7,7 +7,7 @@
#include "CSSRGB.h"
#include <AK/TypeCasts.h>
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
@ -27,8 +27,8 @@ Color CSSRGB::to_color(Optional<Layout::NodeWithStyle const&>) const
if (style_value.is_percentage())
return normalized(style_value.as_percentage().value() * 2.55);
if (style_value.is_calculated()) {
auto const& calculated = style_value.as_calculated();
if (style_value.is_math()) {
auto const& calculated = style_value.as_math();
if (calculated.resolves_to_number())
return normalized(calculated.resolve_number().value());
if (calculated.resolves_to_percentage())

View file

@ -6,7 +6,7 @@
#include "Time.h"
#include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
namespace Web::CSS {
@ -74,7 +74,7 @@ Optional<Time::Type> Time::unit_from_name(StringView name)
return {};
}
Time Time::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Time const& reference_value)
Time Time::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Time const& reference_value)
{
return calculated->resolve_time_percentage(reference_value).value();
}

View file

@ -49,7 +49,7 @@ public:
return 0;
}
static Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Time const& reference_value);
static Time resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Time const& reference_value);
private:
Type m_type;

View file

@ -115,6 +115,7 @@ class CSSKeyframesRule;
class CSSKeywordValue;
class CSSLayerBlockRule;
class CSSLayerStatementRule;
class CSSMathValue;
class CSSMediaRule;
class CSSOKLab;
class CSSOKLCH;
@ -127,7 +128,6 @@ class CSSStyleSheet;
struct CSSStyleSheetInit;
class CSSStyleValue;
class CSSSupportsRule;
class CalculatedStyleValue;
class Clip;
class ConicGradientStyleValue;
class ContentStyleValue;

View file

@ -702,8 +702,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
if (transition_delay_property->is_time()) {
auto& transition_delay = transition_delay_property->as_time();
computed_values.set_transition_delay(transition_delay.time());
} else if (transition_delay_property->is_calculated()) {
auto& transition_delay = transition_delay_property->as_calculated();
} else if (transition_delay_property->is_math()) {
auto& transition_delay = transition_delay_property->as_math();
computed_values.set_transition_delay(transition_delay.resolve_time().value());
}
@ -724,8 +724,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
} else {
auto resolve_border_width = [&]() -> CSSPixels {
auto value = computed_style.property(width_property);
if (value->is_calculated())
return max(CSSPixels { 0 }, value->as_calculated().resolve_length(*this)->to_px(*this));
if (value->is_math())
return max(CSSPixels { 0 }, value->as_math().resolve_length(*this)->to_px(*this));
if (value->is_length())
return value->as_length().length().to_px(*this);
if (value->is_keyword()) {