mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
Revert "LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue"
This reverts commit 76daba3069
.
We're going to need separate types for the JS-exposed style values, so
it doesn't make sense for us to match their names with our internal
types.
This commit is contained in:
parent
34f78ca152
commit
69a0f28d04
Notes:
github-actions[bot]
2024-12-21 17:15:55 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/69a0f28d040 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2966
37 changed files with 391 additions and 391 deletions
|
@ -123,6 +123,7 @@ 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
|
||||
|
@ -134,7 +135,6 @@ set(SOURCES
|
|||
CSS/StyleValues/CSSKeywordValue.cpp
|
||||
CSS/StyleValues/CSSLabLike.cpp
|
||||
CSS/StyleValues/CSSLCHLike.cpp
|
||||
CSS/StyleValues/CSSMathValue.cpp
|
||||
CSS/StyleValues/CSSRGB.cpp
|
||||
CSS/StyleValues/DisplayStyleValue.cpp
|
||||
CSS/StyleValues/EasingStyleValue.cpp
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Angle.h"
|
||||
#include <AK/Math.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -84,7 +84,7 @@ Optional<Angle::Type> Angle::unit_from_name(StringView name)
|
|||
return {};
|
||||
}
|
||||
|
||||
Angle Angle::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Angle const& reference_value)
|
||||
Angle Angle::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Angle const& reference_value)
|
||||
{
|
||||
return calculated->resolve_angle_percentage(reference_value).value();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Angle resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Angle const& reference_value);
|
||||
static Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Angle const& reference_value);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
|
|
|
@ -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/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
|
||||
|
@ -104,10 +104,10 @@ BorderRadiusStyleValue const& CSSStyleValue::as_border_radius() const
|
|||
return static_cast<BorderRadiusStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
CSSMathValue const& CSSStyleValue::as_math() const
|
||||
CalculatedStyleValue const& CSSStyleValue::as_calculated() const
|
||||
{
|
||||
VERIFY(is_math());
|
||||
return static_cast<CSSMathValue const&>(*this);
|
||||
VERIFY(is_calculated());
|
||||
return static_cast<CalculatedStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
CSSColorValue const& CSSStyleValue::as_color() const
|
||||
|
@ -406,8 +406,8 @@ int CSSStyleValue::to_font_weight() const
|
|||
if (is_number()) {
|
||||
return round_to<int>(as_number().number());
|
||||
}
|
||||
if (is_math()) {
|
||||
auto maybe_weight = const_cast<CSSMathValue&>(as_math()).resolve_integer();
|
||||
if (is_calculated()) {
|
||||
auto maybe_weight = const_cast<CalculatedStyleValue&>(as_calculated()).resolve_integer();
|
||||
if (maybe_weight.has_value())
|
||||
return maybe_weight.value();
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
BackgroundSize,
|
||||
BasicShape,
|
||||
BorderRadius,
|
||||
Calculated,
|
||||
Color,
|
||||
ConicGradient,
|
||||
Content,
|
||||
|
@ -116,7 +117,6 @@ public:
|
|||
Keyword,
|
||||
Length,
|
||||
LinearGradient,
|
||||
Math,
|
||||
MathDepth,
|
||||
Number,
|
||||
OpenTypeTagged,
|
||||
|
@ -170,6 +170,10 @@ 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()); }
|
||||
|
@ -254,10 +258,6 @@ 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()); }
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const& calculated, Layout::Node const& layout_node) const
|
||||
i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
|
||||
{
|
||||
return calculated->resolve_integer(layout_node).value();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const
|
|||
return IntegerStyleValue::create(value());
|
||||
}
|
||||
|
||||
Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node) const
|
||||
Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
|
||||
{
|
||||
return calculated->resolve_length(layout_node).value();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const
|
|||
return LengthStyleValue::create(value());
|
||||
}
|
||||
|
||||
double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node) const
|
||||
double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
|
||||
{
|
||||
return calculated->resolve_number(layout_node).value();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const
|
|||
return NumberStyleValue::create(value());
|
||||
}
|
||||
|
||||
Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_percentage().value();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const
|
|||
return PercentageStyleValue::create(value());
|
||||
}
|
||||
|
||||
Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_resolution().value();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const
|
|||
return ResolutionStyleValue::create(value());
|
||||
}
|
||||
|
||||
Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const
|
||||
Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
|
||||
{
|
||||
return calculated->resolve_time().value();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/Resolution.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -26,14 +26,14 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
CalculatedOr(NonnullRefPtr<CSSMathValue> calculated)
|
||||
CalculatedOr(NonnullRefPtr<CalculatedStyleValue> calculated)
|
||||
: m_value(move(calculated))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CalculatedOr() = default;
|
||||
|
||||
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CSSMathValue>>(); }
|
||||
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); }
|
||||
|
||||
T const& value() const
|
||||
{
|
||||
|
@ -48,10 +48,10 @@ public:
|
|||
return create_style_value();
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSMathValue> const& calculated() const
|
||||
NonnullRefPtr<CalculatedStyleValue> const& calculated() const
|
||||
{
|
||||
VERIFY(is_calculated());
|
||||
return m_value.template get<NonnullRefPtr<CSSMathValue>>();
|
||||
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>();
|
||||
}
|
||||
|
||||
T resolved(Layout::Node const& layout_node) const
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
[&](T const& t) {
|
||||
return t;
|
||||
},
|
||||
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
|
||||
[&](NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue>>()->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
return m_value.template get<T>().to_string();
|
||||
}
|
||||
|
@ -81,11 +81,11 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
virtual T resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const = 0;
|
||||
virtual T resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const = 0;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const = 0;
|
||||
|
||||
private:
|
||||
Variant<T, NonnullRefPtr<CSSMathValue>> m_value;
|
||||
Variant<T, NonnullRefPtr<CalculatedStyleValue>> m_value;
|
||||
};
|
||||
|
||||
class AngleOrCalculated : public CalculatedOr<Angle> {
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
using CalculatedOr<Angle>::CalculatedOr;
|
||||
|
||||
private:
|
||||
virtual Angle resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Flex resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
[[nodiscard]] i64 resolved(Length::ResolutionContext const&) const;
|
||||
|
||||
private:
|
||||
virtual i64 resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual i64 resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
[[nodiscard]] Length resolved(Length::ResolutionContext const&) const;
|
||||
|
||||
private:
|
||||
virtual Length resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
using CalculatedOr<double>::CalculatedOr;
|
||||
|
||||
private:
|
||||
virtual double resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual double resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
using CalculatedOr<Percentage>::CalculatedOr;
|
||||
|
||||
private:
|
||||
virtual Percentage resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Percentage resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
[[nodiscard]] Resolution resolved() const;
|
||||
|
||||
private:
|
||||
virtual Resolution resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Resolution resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
@ -171,7 +171,7 @@ public:
|
|||
using CalculatedOr<Time>::CalculatedOr;
|
||||
|
||||
private:
|
||||
virtual Time resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&) const override;
|
||||
virtual Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&) const override;
|
||||
virtual NonnullRefPtr<CSSStyleValue> create_style_value() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Frequency.h"
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -63,7 +63,7 @@ Optional<Frequency::Type> Frequency::unit_from_name(StringView name)
|
|||
return {};
|
||||
}
|
||||
|
||||
Frequency Frequency::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Frequency const& reference_value)
|
||||
Frequency Frequency::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Frequency const& reference_value)
|
||||
{
|
||||
return calculated->resolve_frequency_percentage(reference_value).value();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Frequency resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Frequency const& reference_value);
|
||||
static Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Frequency const& reference_value);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
|
|
|
@ -120,8 +120,8 @@ RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyl
|
|||
case CSSStyleValue::Type::Angle:
|
||||
values.append(AngleOrCalculated { value->as_angle().angle() });
|
||||
break;
|
||||
case CSSStyleValue::Type::Math:
|
||||
values.append(LengthPercentage { value->as_math() });
|
||||
case CSSStyleValue::Type::Calculated:
|
||||
values.append(LengthPercentage { value->as_calculated() });
|
||||
break;
|
||||
case CSSStyleValue::Type::Length:
|
||||
values.append(LengthPercentage { value->as_length().length() });
|
||||
|
@ -554,7 +554,7 @@ NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, CSSS
|
|||
values.unchecked_append(to_calculation_node(interpolated_from));
|
||||
values.unchecked_append(to_calculation_node(interpolated_to));
|
||||
auto calc_node = SumCalculationNode::create(move(values));
|
||||
return CSSMathValue::create(move(calc_node), CSSNumericType { to_base_type_and_default->base_type, 1 });
|
||||
return CalculatedStyleValue::create(move(calc_node), CSSNumericType { to_base_type_and_default->base_type, 1 });
|
||||
}
|
||||
|
||||
return delta >= 0.5f ? to : from;
|
||||
|
|
|
@ -404,12 +404,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<CSSMathValue> const& calculated, Layout::Node const& layout_node, Length const& reference_value)
|
||||
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
|
||||
Length Length::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node, CSSPixels reference_value)
|
||||
{
|
||||
return calculated->resolve_length_percentage(layout_node, reference_value).value();
|
||||
}
|
||||
|
|
|
@ -227,8 +227,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<CSSMathValue> const&, Layout::Node const&, Length const& reference_value);
|
||||
static Length resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, CSSPixels reference_value);
|
||||
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);
|
||||
|
||||
private:
|
||||
[[nodiscard]] CSSPixels to_px_slow_case(Layout::Node const&) const;
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
LengthBox(LengthPercentage top, LengthPercentage right, LengthPercentage bottom, LengthPercentage left);
|
||||
~LengthBox();
|
||||
|
||||
// Length (and thus LengthPercentage) includes a RefPtr<CSSMathValue> member, but we can't include the header CSSStyleValue.h as it includes
|
||||
// Length (and thus LengthPercentage) includes a RefPtr<CalculatedStyleValue> 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; }
|
||||
|
|
|
@ -1913,7 +1913,7 @@ RefPtr<CustomIdentStyleValue> Parser::parse_custom_ident_value(TokenStream<Compo
|
|||
return CustomIdentStyleValue::create(custom_ident);
|
||||
}
|
||||
|
||||
RefPtr<CSSMathValue> Parser::parse_calculated_value(ComponentValue const& component_value)
|
||||
RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(ComponentValue const& component_value)
|
||||
{
|
||||
if (!component_value.is_function())
|
||||
return nullptr;
|
||||
|
@ -1928,7 +1928,7 @@ RefPtr<CSSMathValue> Parser::parse_calculated_value(ComponentValue const& compon
|
|||
if (!function_type.has_value())
|
||||
return nullptr;
|
||||
|
||||
return CSSMathValue::create(function_node.release_nonnull(), function_type.release_value());
|
||||
return CalculatedStyleValue::create(function_node.release_nonnull(), function_type.release_value());
|
||||
}
|
||||
|
||||
OwnPtr<CalculationNode> Parser::parse_a_calc_function_node(Function const& function)
|
||||
|
@ -2697,7 +2697,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_math() && dimension_value->as_math().resolves_to_angle())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2710,7 +2710,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_math() && dimension_value->as_math().resolves_to_angle_percentage())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle_percentage())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2723,7 +2723,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_math() && dimension_value->as_math().resolves_to_flex())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_flex())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2736,7 +2736,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_math() && dimension_value->as_math().resolves_to_frequency())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2749,7 +2749,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_math() && dimension_value->as_math().resolves_to_frequency_percentage())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency_percentage())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2762,7 +2762,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_math() && dimension_value->as_math().resolves_to_length())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2775,7 +2775,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_math() && dimension_value->as_math().resolves_to_length_percentage())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length_percentage())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2788,7 +2788,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_math() && dimension_value->as_math().resolves_to_resolution())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_resolution())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2801,7 +2801,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_math() && dimension_value->as_math().resolves_to_time())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -2814,7 +2814,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_math() && dimension_value->as_math().resolves_to_time_percentage())) {
|
||||
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time_percentage())) {
|
||||
transaction.commit();
|
||||
return dimension_value;
|
||||
}
|
||||
|
@ -3052,7 +3052,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_math() && style_value.as_math().resolves_to_percentage());
|
||||
|| (style_value.is_calculated() && style_value.as_calculated().resolves_to_percentage());
|
||||
};
|
||||
bool red_is_percentage = is_percentage(*red);
|
||||
bool green_is_percentage = is_percentage(*green);
|
||||
|
@ -4513,8 +4513,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_math())
|
||||
return LengthPercentage { value->as_math() };
|
||||
if (value->is_calculated())
|
||||
return LengthPercentage { value->as_calculated() };
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -4644,8 +4644,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_math())
|
||||
return LengthPercentage { style_value.as_math() };
|
||||
if (style_value.is_calculated())
|
||||
return LengthPercentage { style_value.as_calculated() };
|
||||
return {};
|
||||
};
|
||||
|
||||
|
@ -7179,7 +7179,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>&
|
|||
argument_tokens.discard_whitespace();
|
||||
|
||||
auto const& value = argument_tokens.consume_a_token();
|
||||
RefPtr<CSSMathValue> maybe_calc_value = parse_calculated_value(value);
|
||||
RefPtr<CalculatedStyleValue> maybe_calc_value = parse_calculated_value(value);
|
||||
|
||||
switch (function_metadata.parameters[argument_index].type) {
|
||||
case TransformFunctionParameterType::Angle: {
|
||||
|
@ -7319,8 +7319,8 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
|
|||
return OptionalNone {};
|
||||
}
|
||||
}
|
||||
if (value->is_math()) {
|
||||
return AxisOffset { Axis::None, value->as_math() };
|
||||
if (value->is_calculated()) {
|
||||
return AxisOffset { Axis::None, value->as_calculated() };
|
||||
}
|
||||
return OptionalNone {};
|
||||
};
|
||||
|
@ -9564,9 +9564,9 @@ bool Parser::expand_unresolved_values(DOM::Element& element, FlyString const& pr
|
|||
}
|
||||
|
||||
if (property.has_value()) {
|
||||
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_math()) {
|
||||
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_calculated()) {
|
||||
// FIXME: Run the actual simplification algorithm
|
||||
auto& calc_value = maybe_calc_value->as_math();
|
||||
auto& calc_value = maybe_calc_value->as_calculated();
|
||||
if (property_accepts_type(*property, ValueType::Angle) && calc_value.resolves_to_angle()) {
|
||||
auto resolved_value = calc_value.resolve_angle();
|
||||
dest.empend(Token::create_dimension(resolved_value->to_degrees(), "deg"_fly_string));
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <LibWeb/CSS/Ratio.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/Supports.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
@ -273,7 +273,7 @@ private:
|
|||
};
|
||||
Optional<PropertyAndValue> parse_css_value_for_properties(ReadonlySpan<PropertyID>, TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSStyleValue> parse_builtin_value(TokenStream<ComponentValue>&);
|
||||
RefPtr<CSSMathValue> parse_calculated_value(ComponentValue const&);
|
||||
RefPtr<CalculatedStyleValue> 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&);
|
||||
|
|
|
@ -619,8 +619,8 @@ GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
|
|||
|
||||
// TODO: Once we implement calc-simplification in the parser, we should no longer see math values here,
|
||||
// unless they're impossible to resolve and thus invalid.
|
||||
if (percentage_value->is_math()) {
|
||||
if (auto result = percentage_value->as_math().resolve_percentage(); result.has_value())
|
||||
if (percentage_value->is_calculated()) {
|
||||
if (auto result = percentage_value->as_calculated().resolve_percentage(); result.has_value())
|
||||
return result.value();
|
||||
}
|
||||
|
||||
|
@ -734,8 +734,8 @@ GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
|
|||
auto const& setting_value = feature_tag->as_open_type_tagged().value();
|
||||
if (setting_value->is_integer()) {
|
||||
settings.set(feature_tag->as_open_type_tagged().tag(), setting_value->as_integer().integer());
|
||||
} else if (setting_value->is_math() && setting_value->as_math().resolves_to_number()) {
|
||||
if (auto integer = setting_value->as_math().resolve_integer(); integer.has_value()) {
|
||||
} else if (setting_value->is_calculated() && setting_value->as_calculated().resolves_to_number()) {
|
||||
if (auto integer = setting_value->as_calculated().resolve_integer(); integer.has_value()) {
|
||||
settings.set(feature_tag->as_open_type_tagged().tag(), *integer);
|
||||
} else {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Calculated value in font-feature-settings descriptor cannot be resolved at parse time; skipping");
|
||||
|
@ -808,8 +808,8 @@ GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
|
|||
auto const& setting_value = variation_tag->as_open_type_tagged().value();
|
||||
if (setting_value->is_number()) {
|
||||
settings.set(variation_tag->as_open_type_tagged().tag(), setting_value->as_number().number());
|
||||
} else if (setting_value->is_math() && setting_value->as_math().resolves_to_number()) {
|
||||
if (auto number = setting_value->as_math().resolve_number(); number.has_value()) {
|
||||
} else if (setting_value->is_calculated() && setting_value->as_calculated().resolves_to_number()) {
|
||||
if (auto number = setting_value->as_calculated().resolve_number(); number.has_value()) {
|
||||
settings.set(variation_tag->as_open_type_tagged().tag(), *number);
|
||||
} else {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Calculated value in font-variation-settings descriptor cannot be resolved at parse time; skipping");
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/Number.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
PercentageOr(NonnullRefPtr<CSSMathValue> calculated)
|
||||
PercentageOr(NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue>>(); }
|
||||
bool is_calculated() const { return m_value.template has<NonnullRefPtr<CalculatedStyleValue>>(); }
|
||||
|
||||
bool contains_percentage() const
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
[&](Percentage const&) {
|
||||
return true;
|
||||
},
|
||||
[&](NonnullRefPtr<CSSMathValue> const& calculated) {
|
||||
[&](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
|
||||
return calculated->contains_percentage();
|
||||
});
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ public:
|
|||
return m_value.template get<Percentage>();
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSMathValue> const& calculated() const
|
||||
NonnullRefPtr<CalculatedStyleValue> const& calculated() const
|
||||
{
|
||||
VERIFY(is_calculated());
|
||||
return m_value.template get<NonnullRefPtr<CSSMathValue>>();
|
||||
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>();
|
||||
}
|
||||
|
||||
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<CSSMathValue> const& calculated) {
|
||||
[&](NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue> const& calculated) {
|
||||
[&](NonnullRefPtr<CalculatedStyleValue> 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<CSSMathValue>>()->to_string(CSSStyleValue::SerializationMode::Normal);
|
||||
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string(CSSStyleValue::SerializationMode::Normal);
|
||||
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<CSSMathValue>>() == *other.m_value.template get<NonnullRefPtr<CSSMathValue>>());
|
||||
return (*m_value.template get<NonnullRefPtr<CalculatedStyleValue>>() == *other.m_value.template get<NonnullRefPtr<CalculatedStyleValue>>());
|
||||
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<CSSMathValue>> m_value;
|
||||
Variant<T, Percentage, NonnullRefPtr<CalculatedStyleValue>> m_value;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -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/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
|
|
|
@ -39,7 +39,7 @@ Size Size::make_percentage(Percentage percentage)
|
|||
return Size { Type::Percentage, move(percentage) };
|
||||
}
|
||||
|
||||
Size Size::make_calculated(NonnullRefPtr<Web::CSS::CSSMathValue> calculated)
|
||||
Size Size::make_calculated(NonnullRefPtr<Web::CSS::CalculatedStyleValue> calculated)
|
||||
{
|
||||
return Size { Type::Calculated, move(calculated) };
|
||||
}
|
||||
|
|
|
@ -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<CSSMathValue>);
|
||||
static Size make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
||||
static Size make_min_content();
|
||||
static Size make_max_content();
|
||||
static Size make_fit_content(Length available_space);
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
bool contains_percentage() const;
|
||||
|
||||
CSSMathValue const& calculated() const
|
||||
CalculatedStyleValue const& calculated() const
|
||||
{
|
||||
VERIFY(is_calculated());
|
||||
return m_length_percentage.calculated();
|
||||
|
|
|
@ -1987,11 +1987,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_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 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 {
|
||||
maybe_length = font_size.as_math().resolve_length(length_resolution_context);
|
||||
maybe_length = font_size.as_calculated().resolve_length(length_resolution_context);
|
||||
}
|
||||
}
|
||||
if (maybe_length.has_value()) {
|
||||
|
@ -2910,8 +2910,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_math())
|
||||
return integer_value.as_math().resolve_integer().value();
|
||||
if (integer_value.is_calculated())
|
||||
return integer_value.as_calculated().resolve_integer().value();
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
|
||||
|
|
|
@ -137,8 +137,8 @@ Variant<LengthPercentage, NormalGap> StyleProperties::gap_value(CSS::PropertyID
|
|||
return NormalGap {};
|
||||
}
|
||||
|
||||
if (value.is_math())
|
||||
return LengthPercentage { const_cast<CSSMathValue&>(value.as_math()) };
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
|
||||
if (value.is_percentage())
|
||||
return LengthPercentage { value.as_percentage().percentage() };
|
||||
|
@ -169,8 +169,8 @@ CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
|
|||
}
|
||||
}
|
||||
|
||||
if (value.is_math())
|
||||
return CSS::Size::make_calculated(const_cast<CSSMathValue&>(value.as_math()));
|
||||
if (value.is_calculated())
|
||||
return CSS::Size::make_calculated(const_cast<CalculatedStyleValue&>(value.as_calculated()));
|
||||
|
||||
if (value.is_percentage())
|
||||
return CSS::Size::make_percentage(value.as_percentage().percentage());
|
||||
|
@ -196,8 +196,8 @@ Optional<LengthPercentage> StyleProperties::length_percentage(CSS::PropertyID id
|
|||
{
|
||||
auto const& value = property(id);
|
||||
|
||||
if (value.is_math())
|
||||
return LengthPercentage { const_cast<CSSMathValue&>(value.as_math()) };
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
|
||||
if (value.is_percentage())
|
||||
return value.as_percentage().percentage();
|
||||
|
@ -265,19 +265,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_math()) {
|
||||
if (line_height.as_math().resolves_to_number()) {
|
||||
auto resolved = line_height.as_math().resolve_number();
|
||||
if (line_height.is_calculated()) {
|
||||
if (line_height.as_calculated().resolves_to_number()) {
|
||||
auto resolved = line_height.as_calculated().resolve_number();
|
||||
if (!resolved.has_value()) {
|
||||
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_math().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
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_math().resolve_length(Length::ResolutionContext { viewport_rect, font_metrics, root_font_metrics });
|
||||
auto resolved = line_height.as_calculated().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_math().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
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);
|
||||
|
@ -309,16 +309,16 @@ float StyleProperties::resolve_opacity_value(CSSStyleValue const& value)
|
|||
|
||||
if (value.is_number()) {
|
||||
unclamped_opacity = value.as_number().number();
|
||||
} else if (value.is_math()) {
|
||||
auto const& calculated = value.as_math();
|
||||
} else if (value.is_calculated()) {
|
||||
auto const& calculated = value.as_calculated();
|
||||
if (calculated.resolves_to_percentage()) {
|
||||
auto maybe_percentage = value.as_math().resolve_percentage();
|
||||
auto maybe_percentage = value.as_calculated().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(CSSStyleValue::SerializationMode::Normal));
|
||||
} else if (calculated.resolves_to_number()) {
|
||||
auto maybe_number = const_cast<CSSMathValue&>(value.as_math()).resolve_number();
|
||||
auto maybe_number = const_cast<CalculatedStyleValue&>(value.as_calculated()).resolve_number();
|
||||
if (maybe_number.has_value())
|
||||
unclamped_opacity = maybe_number.value();
|
||||
else
|
||||
|
@ -359,8 +359,8 @@ NumberOrCalculated StyleProperties::stroke_miterlimit() const
|
|||
{
|
||||
auto const& value = property(CSS::PropertyID::StrokeMiterlimit);
|
||||
|
||||
if (value.is_math()) {
|
||||
auto const& math_value = value.as_math();
|
||||
if (value.is_calculated()) {
|
||||
auto const& math_value = value.as_calculated();
|
||||
VERIFY(math_value.resolves_to_number());
|
||||
return NumberOrCalculated { math_value };
|
||||
}
|
||||
|
@ -449,8 +449,8 @@ CSS::Length StyleProperties::border_spacing_horizontal(Layout::Node const& layou
|
|||
auto const& value = property(CSS::PropertyID::BorderSpacing);
|
||||
if (value.is_length())
|
||||
return value.as_length().length();
|
||||
if (value.is_math())
|
||||
return value.as_math().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||
if (value.is_calculated())
|
||||
return value.as_calculated().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||
auto const& list = value.as_value_list();
|
||||
return list.value_at(0, false)->as_length().length();
|
||||
}
|
||||
|
@ -460,8 +460,8 @@ CSS::Length StyleProperties::border_spacing_vertical(Layout::Node const& layout_
|
|||
auto const& value = property(CSS::PropertyID::BorderSpacing);
|
||||
if (value.is_length())
|
||||
return value.as_length().length();
|
||||
if (value.is_math())
|
||||
return value.as_math().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||
if (value.is_calculated())
|
||||
return value.as_calculated().resolve_length(layout_node).value_or(CSS::Length(0, CSS::Length::Type::Px));
|
||||
auto const& list = value.as_value_list();
|
||||
return list.value_at(1, false)->as_length().length();
|
||||
}
|
||||
|
@ -519,8 +519,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_math()) {
|
||||
auto& calculated = transformation_value->as_math();
|
||||
if (transformation_value->is_calculated()) {
|
||||
auto& calculated = transformation_value->as_calculated();
|
||||
if (calculated.resolves_to_length_percentage()) {
|
||||
values.append(CSS::LengthPercentage { calculated });
|
||||
} else if (calculated.resolves_to_percentage()) {
|
||||
|
@ -574,16 +574,16 @@ Optional<CSS::Transformation> StyleProperties::rotate(Layout::Node const& layout
|
|||
auto resolve_angle = [&layout_node](CSSStyleValue const& value) -> Optional<Angle> {
|
||||
if (value.is_angle())
|
||||
return value.as_angle().angle();
|
||||
if (value.is_math() && value.as_math().resolves_to_angle())
|
||||
return value.as_math().resolve_angle(layout_node);
|
||||
if (value.is_calculated() && value.as_calculated().resolves_to_angle())
|
||||
return value.as_calculated().resolve_angle(layout_node);
|
||||
return {};
|
||||
};
|
||||
|
||||
auto resolve_number = [&](CSSStyleValue const& value) -> Optional<double> {
|
||||
if (value.is_number())
|
||||
return value.as_number().number();
|
||||
if (value.is_math() && value.as_math().resolves_to_number())
|
||||
return value.as_math().resolve_number();
|
||||
if (value.is_calculated() && value.as_calculated().resolves_to_number())
|
||||
return value.as_calculated().resolve_number();
|
||||
return {};
|
||||
};
|
||||
|
||||
|
@ -635,8 +635,8 @@ static Optional<LengthPercentage> length_percentage_for_style_value(CSSStyleValu
|
|||
return value.as_length().length();
|
||||
if (value.is_percentage())
|
||||
return value.as_percentage().percentage();
|
||||
if (value.is_math())
|
||||
return LengthPercentage { const_cast<CSSMathValue&>(value.as_math()) };
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -797,8 +797,8 @@ Optional<CSS::PointerEvents> StyleProperties::pointer_events() const
|
|||
Variant<LengthOrCalculated, NumberOrCalculated> StyleProperties::tab_size() const
|
||||
{
|
||||
auto const& value = property(CSS::PropertyID::TabSize);
|
||||
if (value.is_math()) {
|
||||
auto const& math_value = value.as_math();
|
||||
if (value.is_calculated()) {
|
||||
auto const& math_value = value.as_calculated();
|
||||
if (math_value.resolves_to_length()) {
|
||||
return LengthOrCalculated { math_value };
|
||||
}
|
||||
|
@ -822,8 +822,8 @@ Optional<CSS::WordBreak> StyleProperties::word_break() const
|
|||
Optional<CSS::LengthOrCalculated> StyleProperties::word_spacing() const
|
||||
{
|
||||
auto const& value = property(CSS::PropertyID::WordSpacing);
|
||||
if (value.is_math()) {
|
||||
auto& math_value = value.as_math();
|
||||
if (value.is_calculated()) {
|
||||
auto& math_value = value.as_calculated();
|
||||
if (math_value.resolves_to_length()) {
|
||||
return LengthOrCalculated { math_value };
|
||||
}
|
||||
|
@ -844,8 +844,8 @@ Optional<CSS::WhiteSpace> StyleProperties::white_space() const
|
|||
Optional<LengthOrCalculated> StyleProperties::letter_spacing() const
|
||||
{
|
||||
auto const& value = property(CSS::PropertyID::LetterSpacing);
|
||||
if (value.is_math()) {
|
||||
auto const& math_value = value.as_math();
|
||||
if (value.is_calculated()) {
|
||||
auto const& math_value = value.as_calculated();
|
||||
if (math_value.resolves_to_length()) {
|
||||
return LengthOrCalculated { math_value };
|
||||
}
|
||||
|
@ -1085,8 +1085,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_math())
|
||||
return value->as_math().resolve_length(layout_node);
|
||||
if (value->is_calculated())
|
||||
return value->as_calculated().resolve_length(layout_node);
|
||||
return {};
|
||||
};
|
||||
|
||||
|
@ -1167,8 +1167,8 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
|
|||
if (value.is_percentage())
|
||||
return CSS::LengthPercentage(value.as_percentage().percentage());
|
||||
|
||||
if (value.is_math())
|
||||
return LengthPercentage { const_cast<CSSMathValue&>(value.as_math()) };
|
||||
if (value.is_calculated())
|
||||
return LengthPercentage { const_cast<CalculatedStyleValue&>(value.as_calculated()) };
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -1240,8 +1240,8 @@ Optional<HashMap<FlyString, IntegerOrCalculated>> StyleProperties::font_feature_
|
|||
if (feature_tag.value()->is_integer()) {
|
||||
result.set(feature_tag.tag(), feature_tag.value()->as_integer().value());
|
||||
} else {
|
||||
VERIFY(feature_tag.value()->is_math());
|
||||
result.set(feature_tag.tag(), IntegerOrCalculated { feature_tag.value()->as_math() });
|
||||
VERIFY(feature_tag.value()->is_calculated());
|
||||
result.set(feature_tag.tag(), IntegerOrCalculated { feature_tag.value()->as_calculated() });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1267,8 +1267,8 @@ Optional<HashMap<FlyString, NumberOrCalculated>> StyleProperties::font_variation
|
|||
if (axis_tag.value()->is_number()) {
|
||||
result.set(axis_tag.tag(), axis_tag.value()->as_number().value());
|
||||
} else {
|
||||
VERIFY(axis_tag.value()->is_math());
|
||||
result.set(axis_tag.tag(), NumberOrCalculated { axis_tag.value()->as_math() });
|
||||
VERIFY(axis_tag.value()->is_calculated());
|
||||
result.set(axis_tag.tag(), NumberOrCalculated { axis_tag.value()->as_calculated() });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1470,8 +1470,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_math()) {
|
||||
auto maybe_int = counter.value->as_math().resolve_integer();
|
||||
} else if (counter.value->is_calculated()) {
|
||||
auto maybe_int = counter.value->as_calculated().resolve_integer();
|
||||
if (maybe_int.has_value())
|
||||
data.value = AK::clamp_to<i32>(*maybe_int);
|
||||
} else {
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
@ -40,8 +40,8 @@ Optional<double> 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_math() && style_value.as_math().resolves_to_angle())
|
||||
return normalized(style_value.as_math().resolve_angle().value().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_keyword() && style_value.to_keyword() == Keyword::None)
|
||||
return 0;
|
||||
|
@ -62,8 +62,8 @@ Optional<double> CSSColorValue::resolve_with_reference_value(CSSStyleValue const
|
|||
if (style_value.is_number())
|
||||
return style_value.as_number().number();
|
||||
|
||||
if (style_value.is_math()) {
|
||||
auto const& calculated = style_value.as_math();
|
||||
if (style_value.is_calculated()) {
|
||||
auto const& calculated = style_value.as_calculated();
|
||||
if (calculated.resolves_to_number())
|
||||
return calculated.resolve_number().value();
|
||||
if (calculated.resolves_to_percentage())
|
||||
|
@ -91,8 +91,8 @@ Optional<double> 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_math()) {
|
||||
auto const& calculated = style_value.as_math();
|
||||
if (style_value.is_calculated()) {
|
||||
auto const& calculated = style_value.as_calculated();
|
||||
if (calculated.resolves_to_number())
|
||||
return normalized(calculated.resolve_number().value());
|
||||
if (calculated.resolves_to_percentage())
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <AK/Math.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CSSLabLike.h"
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CSSRGB.h"
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
|
||||
|
@ -29,8 +29,8 @@ Color CSSRGB::to_color(Optional<Layout::NodeWithStyle const&>) const
|
|||
if (style_value.is_percentage())
|
||||
return normalized(style_value.as_percentage().value() * 255 / 100);
|
||||
|
||||
if (style_value.is_math()) {
|
||||
auto const& calculated = style_value.as_math();
|
||||
if (style_value.is_calculated()) {
|
||||
auto const& calculated = style_value.as_calculated();
|
||||
if (calculated.resolves_to_number())
|
||||
return normalized(calculated.resolve_number().value());
|
||||
if (calculated.resolves_to_percentage())
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "CSSMathValue.h"
|
||||
#include "CalculatedStyleValue.h"
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
static bool is_number(CSSMathValue::ResolvedType type)
|
||||
static bool is_number(CalculatedStyleValue::ResolvedType type)
|
||||
{
|
||||
return type == CSSMathValue::ResolvedType::Number || type == CSSMathValue::ResolvedType::Integer;
|
||||
return type == CalculatedStyleValue::ResolvedType::Number || type == CalculatedStyleValue::ResolvedType::Integer;
|
||||
}
|
||||
|
||||
static bool is_dimension(CSSMathValue::ResolvedType type)
|
||||
static bool is_dimension(CalculatedStyleValue::ResolvedType type)
|
||||
{
|
||||
return type != CSSMathValue::ResolvedType::Number
|
||||
&& type != CSSMathValue::ResolvedType::Integer
|
||||
&& type != CSSMathValue::ResolvedType::Percentage;
|
||||
return type != CalculatedStyleValue::ResolvedType::Number
|
||||
&& type != CalculatedStyleValue::ResolvedType::Integer
|
||||
&& type != CalculatedStyleValue::ResolvedType::Percentage;
|
||||
}
|
||||
|
||||
static double resolve_value_radians(CSSMathValue::CalculationResult::Value value)
|
||||
static double resolve_value_radians(CalculatedStyleValue::CalculationResult::Value value)
|
||||
{
|
||||
return value.visit(
|
||||
[](Number const& number) { return number.value(); },
|
||||
|
@ -33,7 +33,7 @@ static double resolve_value_radians(CSSMathValue::CalculationResult::Value value
|
|||
[](auto const&) { VERIFY_NOT_REACHED(); return 0.0; });
|
||||
}
|
||||
|
||||
static double resolve_value(CSSMathValue::CalculationResult::Value value, Optional<Length::ResolutionContext const&> context)
|
||||
static double resolve_value(CalculatedStyleValue::CalculationResult::Value value, Optional<Length::ResolutionContext const&> context)
|
||||
{
|
||||
return value.visit(
|
||||
[](Number const& number) { return number.value(); },
|
||||
|
@ -82,26 +82,26 @@ static Optional<CSSNumericType> add_the_types(Vector<NonnullOwnPtr<CalculationNo
|
|||
return left_type;
|
||||
}
|
||||
|
||||
static CSSMathValue::CalculationResult to_resolved_type(CSSMathValue::ResolvedType type, double value)
|
||||
static CalculatedStyleValue::CalculationResult to_resolved_type(CalculatedStyleValue::ResolvedType type, double value)
|
||||
{
|
||||
switch (type) {
|
||||
case CSSMathValue::ResolvedType::Integer:
|
||||
case CalculatedStyleValue::ResolvedType::Integer:
|
||||
return { Number(Number::Type::Integer, value) };
|
||||
case CSSMathValue::ResolvedType::Number:
|
||||
case CalculatedStyleValue::ResolvedType::Number:
|
||||
return { Number(Number::Type::Number, value) };
|
||||
case CSSMathValue::ResolvedType::Angle:
|
||||
case CalculatedStyleValue::ResolvedType::Angle:
|
||||
return { Angle::make_degrees(value) };
|
||||
case CSSMathValue::ResolvedType::Flex:
|
||||
case CalculatedStyleValue::ResolvedType::Flex:
|
||||
return { Flex::make_fr(value) };
|
||||
case CSSMathValue::ResolvedType::Frequency:
|
||||
case CalculatedStyleValue::ResolvedType::Frequency:
|
||||
return { Frequency::make_hertz(value) };
|
||||
case CSSMathValue::ResolvedType::Length:
|
||||
case CalculatedStyleValue::ResolvedType::Length:
|
||||
return { Length::make_px(CSSPixels::nearest_value_for(value)) };
|
||||
case CSSMathValue::ResolvedType::Percentage:
|
||||
case CalculatedStyleValue::ResolvedType::Percentage:
|
||||
return { Percentage(value) };
|
||||
case CSSMathValue::ResolvedType::Resolution:
|
||||
case CalculatedStyleValue::ResolvedType::Resolution:
|
||||
return { Resolution::make_dots_per_pixel(value) };
|
||||
case CSSMathValue::ResolvedType::Time:
|
||||
case CalculatedStyleValue::ResolvedType::Time:
|
||||
return { Time::make_seconds(value) };
|
||||
}
|
||||
|
||||
|
@ -153,17 +153,17 @@ String NumericCalculationNode::to_string() const
|
|||
return m_value.visit([](auto& value) { return value.to_string(); });
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> NumericCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> NumericCalculationNode::resolved_type() const
|
||||
{
|
||||
return m_value.visit(
|
||||
[](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; });
|
||||
[](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; });
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -232,17 +232,17 @@ bool NumericCalculationNode::contains_percentage() const
|
|||
return m_value.has<Percentage>();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult NumericCalculationNode::resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult NumericCalculationNode::resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::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&) -> CSSMathValue::CalculationResult {
|
||||
[&](Empty const&) -> CalculatedStyleValue::CalculationResult {
|
||||
return m_value;
|
||||
},
|
||||
[&](auto const& value) {
|
||||
return CSSMathValue::CalculationResult(value.percentage_of(m_value.get<Percentage>()));
|
||||
return CalculatedStyleValue::CalculationResult(value.percentage_of(m_value.get<Percentage>()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -290,12 +290,12 @@ String SumCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> SumCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::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<CSSMathValue::ResolvedType> type;
|
||||
Optional<CalculatedStyleValue::ResolvedType> type;
|
||||
for (auto const& value : m_values) {
|
||||
auto maybe_value_type = value->resolved_type();
|
||||
if (!maybe_value_type.has_value())
|
||||
|
@ -314,17 +314,17 @@ Optional<CSSMathValue::ResolvedType> SumCalculationNode::resolved_type() const
|
|||
|
||||
// If one side is a <number> and the other is an <integer>, resolve to <number>.
|
||||
if (is_number(*type) && is_number(value_type)) {
|
||||
type = CSSMathValue::ResolvedType::Number;
|
||||
type = CalculatedStyleValue::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 == CSSMathValue::ResolvedType::Percentage && is_dimension(value_type)) {
|
||||
if (type == CalculatedStyleValue::ResolvedType::Percentage && is_dimension(value_type)) {
|
||||
type = value_type;
|
||||
continue;
|
||||
}
|
||||
if (is_dimension(*type) && value_type == CSSMathValue::ResolvedType::Percentage)
|
||||
if (is_dimension(*type) && value_type == CalculatedStyleValue::ResolvedType::Percentage)
|
||||
continue;
|
||||
|
||||
return {};
|
||||
|
@ -350,9 +350,9 @@ bool SumCalculationNode::contains_percentage() const
|
|||
return false;
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult SumCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult SumCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
Optional<CSSMathValue::CalculationResult> total;
|
||||
Optional<CalculatedStyleValue::CalculationResult> total;
|
||||
|
||||
for (auto& additional_product : m_values) {
|
||||
auto additional_value = additional_product->resolve(context, percentage_basis);
|
||||
|
@ -415,12 +415,12 @@ String ProductCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> ProductCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::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<CSSMathValue::ResolvedType> type;
|
||||
Optional<CalculatedStyleValue::ResolvedType> type;
|
||||
for (auto const& value : m_values) {
|
||||
auto maybe_value_type = value->resolved_type();
|
||||
if (!maybe_value_type.has_value())
|
||||
|
@ -436,8 +436,8 @@ Optional<CSSMathValue::ResolvedType> ProductCalculationNode::resolved_type() con
|
|||
if (!(is_number(*type) || is_number(value_type)))
|
||||
return {};
|
||||
// If both sides are <integer>, resolve to <integer>.
|
||||
if (type == CSSMathValue::ResolvedType::Integer && value_type == CSSMathValue::ResolvedType::Integer) {
|
||||
type = CSSMathValue::ResolvedType::Integer;
|
||||
if (type == CalculatedStyleValue::ResolvedType::Integer && value_type == CalculatedStyleValue::ResolvedType::Integer) {
|
||||
type = CalculatedStyleValue::ResolvedType::Integer;
|
||||
} else {
|
||||
// Otherwise, resolve to the type of the other side.
|
||||
if (is_number(*type))
|
||||
|
@ -480,9 +480,9 @@ bool ProductCalculationNode::contains_percentage() const
|
|||
return false;
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult ProductCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult ProductCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
Optional<CSSMathValue::CalculationResult> total;
|
||||
Optional<CalculatedStyleValue::CalculationResult> total;
|
||||
|
||||
for (auto& additional_product : m_values) {
|
||||
auto additional_value = additional_product->resolve(context, percentage_basis);
|
||||
|
@ -536,7 +536,7 @@ String NegateCalculationNode::to_string() const
|
|||
return MUST(String::formatted("(0 - {})", m_value->to_string()));
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> NegateCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> NegateCalculationNode::resolved_type() const
|
||||
{
|
||||
return m_value->resolved_type();
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ bool NegateCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult NegateCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult NegateCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto child_value = m_value->resolve(context, percentage_basis);
|
||||
child_value.negate();
|
||||
|
@ -593,11 +593,11 @@ String InvertCalculationNode::to_string() const
|
|||
return MUST(String::formatted("(1 / {})", m_value->to_string()));
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> InvertCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> InvertCalculationNode::resolved_type() const
|
||||
{
|
||||
auto type = m_value->resolved_type();
|
||||
if (type == CSSMathValue::ResolvedType::Integer)
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
if (type == CalculatedStyleValue::ResolvedType::Integer)
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ bool InvertCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult InvertCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult InvertCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto child_value = m_value->resolve(context, percentage_basis);
|
||||
child_value.invert();
|
||||
|
@ -665,7 +665,7 @@ String MinCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> MinCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> MinCalculationNode::resolved_type() const
|
||||
{
|
||||
// NOTE: We check during parsing that all values have the same type.
|
||||
return m_values[0]->resolved_type();
|
||||
|
@ -688,9 +688,9 @@ bool MinCalculationNode::contains_percentage() const
|
|||
return false;
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult MinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult MinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
CSSMathValue::CalculationResult smallest_node = m_values.first()->resolve(context, percentage_basis);
|
||||
CalculatedStyleValue::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++) {
|
||||
|
@ -754,7 +754,7 @@ String MaxCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> MaxCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> MaxCalculationNode::resolved_type() const
|
||||
{
|
||||
// NOTE: We check during parsing that all values have the same type.
|
||||
return m_values[0]->resolved_type();
|
||||
|
@ -777,9 +777,9 @@ bool MaxCalculationNode::contains_percentage() const
|
|||
return false;
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult MaxCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult MaxCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
CSSMathValue::CalculationResult largest_node = m_values.first()->resolve(context, percentage_basis);
|
||||
CalculatedStyleValue::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++) {
|
||||
|
@ -845,7 +845,7 @@ String ClampCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> ClampCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> ClampCalculationNode::resolved_type() const
|
||||
{
|
||||
// NOTE: We check during parsing that all values have the same type.
|
||||
return m_min_value->resolved_type();
|
||||
|
@ -873,7 +873,7 @@ bool ClampCalculationNode::contains_percentage() const
|
|||
return m_min_value->contains_percentage() || m_center_value->contains_percentage() || m_max_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult ClampCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult ClampCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::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);
|
||||
|
@ -936,7 +936,7 @@ String AbsCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> AbsCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> AbsCalculationNode::resolved_type() const
|
||||
{
|
||||
return m_value->resolved_type();
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ bool AbsCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult AbsCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult AbsCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto resolved_type = m_value->resolved_type().value();
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
|
@ -1001,9 +1001,9 @@ String SignCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> SignCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> SignCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Integer;
|
||||
return CalculatedStyleValue::ResolvedType::Integer;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1018,7 +1018,7 @@ bool SignCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult SignCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult SignCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1076,9 +1076,9 @@ String ConstantCalculationNode::to_string() const
|
|||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
Optional<CSSMathValue::ResolvedType> ConstantCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> ConstantCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1090,7 +1090,7 @@ Optional<CSSNumericType> ConstantCalculationNode::determine_type(PropertyID) con
|
|||
return CSSNumericType {};
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult ConstantCalculationNode::resolve([[maybe_unused]] Optional<Length::ResolutionContext const&> context, [[maybe_unused]] CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult ConstantCalculationNode::resolve([[maybe_unused]] Optional<Length::ResolutionContext const&> context, [[maybe_unused]] CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
switch (m_constant) {
|
||||
case CalculationNode::ConstantType::E:
|
||||
|
@ -1145,9 +1145,9 @@ String SinCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> SinCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> SinCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1162,7 +1162,7 @@ bool SinCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult SinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult SinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value_radians(node_a.value());
|
||||
|
@ -1207,9 +1207,9 @@ String CosCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> CosCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> CosCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1224,7 +1224,7 @@ bool CosCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult CosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult CosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value_radians(node_a.value());
|
||||
|
@ -1269,9 +1269,9 @@ String TanCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> TanCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> TanCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1286,7 +1286,7 @@ bool TanCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult TanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult TanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value_radians(node_a.value());
|
||||
|
@ -1331,9 +1331,9 @@ String AsinCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> AsinCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> AsinCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Angle;
|
||||
return CalculatedStyleValue::ResolvedType::Angle;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1348,7 +1348,7 @@ bool AsinCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult AsinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult AsinCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1393,9 +1393,9 @@ String AcosCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> AcosCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> AcosCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Angle;
|
||||
return CalculatedStyleValue::ResolvedType::Angle;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1410,7 +1410,7 @@ bool AcosCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult AcosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult AcosCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1455,9 +1455,9 @@ String AtanCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> AtanCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> AtanCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Angle;
|
||||
return CalculatedStyleValue::ResolvedType::Angle;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1472,7 +1472,7 @@ bool AtanCalculationNode::contains_percentage() const
|
|||
return m_value->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult AtanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult AtanCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1520,9 +1520,9 @@ String Atan2CalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> Atan2CalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> Atan2CalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Angle;
|
||||
return CalculatedStyleValue::ResolvedType::Angle;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1537,7 +1537,7 @@ bool Atan2CalculationNode::contains_percentage() const
|
|||
return m_y->contains_percentage() || m_x->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult Atan2CalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult Atan2CalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_y->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1590,9 +1590,9 @@ String PowCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> PowCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> PowCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1602,7 +1602,7 @@ Optional<CSSNumericType> PowCalculationNode::determine_type(PropertyID) const
|
|||
return CSSNumericType {};
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult PowCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult PowCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_x->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1652,9 +1652,9 @@ String SqrtCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> SqrtCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> SqrtCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1664,7 +1664,7 @@ Optional<CSSNumericType> SqrtCalculationNode::determine_type(PropertyID) const
|
|||
return CSSNumericType {};
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult SqrtCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult SqrtCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1713,7 +1713,7 @@ String HypotCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> HypotCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> HypotCalculationNode::resolved_type() const
|
||||
{
|
||||
// NOTE: We check during parsing that all values have the same type.
|
||||
return m_values[0]->resolved_type();
|
||||
|
@ -1736,7 +1736,7 @@ bool HypotCalculationNode::contains_percentage() const
|
|||
return false;
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult HypotCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult HypotCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
double square_sum = 0.0;
|
||||
|
||||
|
@ -1797,9 +1797,9 @@ String LogCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> LogCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> LogCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1809,7 +1809,7 @@ Optional<CSSNumericType> LogCalculationNode::determine_type(PropertyID) const
|
|||
return CSSNumericType {};
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult LogCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult LogCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_x->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1859,9 +1859,9 @@ String ExpCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> ExpCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> ExpCalculationNode::resolved_type() const
|
||||
{
|
||||
return CSSMathValue::ResolvedType::Number;
|
||||
return CalculatedStyleValue::ResolvedType::Number;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
|
||||
|
@ -1871,7 +1871,7 @@ Optional<CSSNumericType> ExpCalculationNode::determine_type(PropertyID) const
|
|||
return CSSNumericType {};
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult ExpCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult ExpCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_value->resolve(context, percentage_basis);
|
||||
auto node_a_value = resolve_value(node_a.value(), context);
|
||||
|
@ -1922,7 +1922,7 @@ String RoundCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> RoundCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> RoundCalculationNode::resolved_type() const
|
||||
{
|
||||
// Note: We check during parsing that all values have the same type
|
||||
return m_x->resolved_type();
|
||||
|
@ -1946,7 +1946,7 @@ bool RoundCalculationNode::contains_percentage() const
|
|||
return m_x->contains_percentage() || m_y->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult RoundCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult RoundCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto node_a = m_x->resolve(context, percentage_basis);
|
||||
auto node_b = m_y->resolve(context, percentage_basis);
|
||||
|
@ -2025,7 +2025,7 @@ String ModCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> ModCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> ModCalculationNode::resolved_type() const
|
||||
{
|
||||
// Note: We check during parsing that all values have the same type
|
||||
return m_x->resolved_type();
|
||||
|
@ -2049,7 +2049,7 @@ bool ModCalculationNode::contains_percentage() const
|
|||
return m_x->contains_percentage() || m_y->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult ModCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult ModCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto resolved_type = m_x->resolved_type().value();
|
||||
auto node_a = m_x->resolve(context, percentage_basis);
|
||||
|
@ -2103,7 +2103,7 @@ String RemCalculationNode::to_string() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<CSSMathValue::ResolvedType> RemCalculationNode::resolved_type() const
|
||||
Optional<CalculatedStyleValue::ResolvedType> RemCalculationNode::resolved_type() const
|
||||
{
|
||||
// Note: We check during parsing that all values have the same type
|
||||
return m_x->resolved_type();
|
||||
|
@ -2127,7 +2127,7 @@ bool RemCalculationNode::contains_percentage() const
|
|||
return m_x->contains_percentage() || m_y->contains_percentage();
|
||||
}
|
||||
|
||||
CSSMathValue::CalculationResult RemCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const& percentage_basis) const
|
||||
CalculatedStyleValue::CalculationResult RemCalculationNode::resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const& percentage_basis) const
|
||||
{
|
||||
auto resolved_type = m_x->resolved_type().value();
|
||||
auto node_a = m_x->resolve(context, percentage_basis);
|
||||
|
@ -2155,17 +2155,17 @@ bool RemCalculationNode::equals(CalculationNode const& other) const
|
|||
&& m_y->equals(*static_cast<RemCalculationNode const&>(other).m_y);
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::add(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
||||
void CalculatedStyleValue::CalculationResult::add(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
||||
{
|
||||
add_or_subtract_internal(SumOperation::Add, other, context, percentage_basis);
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::subtract(CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
||||
void CalculatedStyleValue::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 CSSMathValue::CalculationResult::add_or_subtract_internal(SumOperation op, CalculationResult const& other, Optional<Length::ResolutionContext const&> context, PercentageBasis const& percentage_basis)
|
||||
void CalculatedStyleValue::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>.
|
||||
|
@ -2236,7 +2236,7 @@ void CSSMathValue::CalculationResult::add_or_subtract_internal(SumOperation op,
|
|||
},
|
||||
[&](Length const& length) {
|
||||
if (!context.has_value()) {
|
||||
dbgln("CSSMathValue::CalculationResult::add_or_subtract_internal: Length without context");
|
||||
dbgln("CalculatedStyleValue::CalculationResult::add_or_subtract_internal: Length without context");
|
||||
m_value = Length::make_px(0);
|
||||
return;
|
||||
}
|
||||
|
@ -2308,7 +2308,7 @@ void CSSMathValue::CalculationResult::add_or_subtract_internal(SumOperation op,
|
|||
});
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::multiply_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
||||
void CalculatedStyleValue::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.
|
||||
|
@ -2349,7 +2349,7 @@ void CSSMathValue::CalculationResult::multiply_by(CalculationResult const& other
|
|||
});
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::divide_by(CalculationResult const& other, Optional<Length::ResolutionContext const&> context)
|
||||
void CalculatedStyleValue::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.
|
||||
|
@ -2387,7 +2387,7 @@ void CSSMathValue::CalculationResult::divide_by(CalculationResult const& other,
|
|||
});
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::negate()
|
||||
void CalculatedStyleValue::CalculationResult::negate()
|
||||
{
|
||||
m_value.visit(
|
||||
[&](Number const& number) {
|
||||
|
@ -2416,7 +2416,7 @@ void CSSMathValue::CalculationResult::negate()
|
|||
});
|
||||
}
|
||||
|
||||
void CSSMathValue::CalculationResult::invert()
|
||||
void CalculatedStyleValue::CalculationResult::invert()
|
||||
{
|
||||
// FIXME: Correctly handle division by zero.
|
||||
m_value.visit(
|
||||
|
@ -2446,7 +2446,7 @@ void CSSMathValue::CalculationResult::invert()
|
|||
});
|
||||
}
|
||||
|
||||
CSSMathValue::ResolvedType CSSMathValue::CalculationResult::resolved_type() const
|
||||
CalculatedStyleValue::ResolvedType CalculatedStyleValue::CalculationResult::resolved_type() const
|
||||
{
|
||||
return m_value.visit(
|
||||
[](Number const&) { return ResolvedType::Number; },
|
||||
|
@ -2459,21 +2459,21 @@ CSSMathValue::ResolvedType CSSMathValue::CalculationResult::resolved_type() cons
|
|||
[](Time const&) { return ResolvedType::Time; });
|
||||
}
|
||||
|
||||
String CSSMathValue::to_string(SerializationMode) const
|
||||
String CalculatedStyleValue::to_string(SerializationMode) 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 CSSMathValue::equals(CSSStyleValue const& other) const
|
||||
bool CalculatedStyleValue::equals(CSSStyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
|
||||
return m_calculation->equals(*static_cast<CSSMathValue const&>(other).m_calculation);
|
||||
return m_calculation->equals(*static_cast<CalculatedStyleValue const&>(other).m_calculation);
|
||||
}
|
||||
|
||||
Optional<Angle> CSSMathValue::resolve_angle() const
|
||||
Optional<Angle> CalculatedStyleValue::resolve_angle() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2482,12 +2482,12 @@ Optional<Angle> CSSMathValue::resolve_angle() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Angle> CSSMathValue::resolve_angle(Layout::Node const& layout_node) const
|
||||
Optional<Angle> CalculatedStyleValue::resolve_angle(Layout::Node const& layout_node) const
|
||||
{
|
||||
return resolve_angle(Length::ResolutionContext::for_layout_node(layout_node));
|
||||
}
|
||||
|
||||
Optional<Angle> CSSMathValue::resolve_angle(Length::ResolutionContext const& context) const
|
||||
Optional<Angle> CalculatedStyleValue::resolve_angle(Length::ResolutionContext const& context) const
|
||||
{
|
||||
auto result = m_calculation->resolve(context, {});
|
||||
|
||||
|
@ -2496,7 +2496,7 @@ Optional<Angle> CSSMathValue::resolve_angle(Length::ResolutionContext const& con
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Angle> CSSMathValue::resolve_angle_percentage(Angle const& percentage_basis) const
|
||||
Optional<Angle> CalculatedStyleValue::resolve_angle_percentage(Angle const& percentage_basis) const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, percentage_basis);
|
||||
|
||||
|
@ -2512,7 +2512,7 @@ Optional<Angle> CSSMathValue::resolve_angle_percentage(Angle const& percentage_b
|
|||
});
|
||||
}
|
||||
|
||||
Optional<Flex> CSSMathValue::resolve_flex() const
|
||||
Optional<Flex> CalculatedStyleValue::resolve_flex() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2521,7 +2521,7 @@ Optional<Flex> CSSMathValue::resolve_flex() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Frequency> CSSMathValue::resolve_frequency() const
|
||||
Optional<Frequency> CalculatedStyleValue::resolve_frequency() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ Optional<Frequency> CSSMathValue::resolve_frequency() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Frequency> CSSMathValue::resolve_frequency_percentage(Frequency const& percentage_basis) const
|
||||
Optional<Frequency> CalculatedStyleValue::resolve_frequency_percentage(Frequency const& percentage_basis) const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, percentage_basis);
|
||||
|
||||
|
@ -2546,7 +2546,7 @@ Optional<Frequency> CSSMathValue::resolve_frequency_percentage(Frequency const&
|
|||
});
|
||||
}
|
||||
|
||||
Optional<Length> CSSMathValue::resolve_length(Length::ResolutionContext const& context) const
|
||||
Optional<Length> CalculatedStyleValue::resolve_length(Length::ResolutionContext const& context) const
|
||||
{
|
||||
auto result = m_calculation->resolve(context, {});
|
||||
|
||||
|
@ -2555,22 +2555,22 @@ Optional<Length> CSSMathValue::resolve_length(Length::ResolutionContext const& c
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Length> CSSMathValue::resolve_length(Layout::Node const& layout_node) const
|
||||
Optional<Length> CalculatedStyleValue::resolve_length(Layout::Node const& layout_node) const
|
||||
{
|
||||
return resolve_length(Length::ResolutionContext::for_layout_node(layout_node));
|
||||
}
|
||||
|
||||
Optional<Length> CSSMathValue::resolve_length_percentage(Layout::Node const& layout_node, Length const& percentage_basis) const
|
||||
Optional<Length> CalculatedStyleValue::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> CSSMathValue::resolve_length_percentage(Layout::Node const& layout_node, CSSPixels percentage_basis) const
|
||||
Optional<Length> CalculatedStyleValue::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> CSSMathValue::resolve_length_percentage(Length::ResolutionContext const& resolution_context, Length const& percentage_basis) const
|
||||
Optional<Length> CalculatedStyleValue::resolve_length_percentage(Length::ResolutionContext const& resolution_context, Length const& percentage_basis) const
|
||||
{
|
||||
auto result = m_calculation->resolve(resolution_context, percentage_basis);
|
||||
|
||||
|
@ -2586,7 +2586,7 @@ Optional<Length> CSSMathValue::resolve_length_percentage(Length::ResolutionConte
|
|||
});
|
||||
}
|
||||
|
||||
Optional<Percentage> CSSMathValue::resolve_percentage() const
|
||||
Optional<Percentage> CalculatedStyleValue::resolve_percentage() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
if (result.value().has<Percentage>())
|
||||
|
@ -2594,7 +2594,7 @@ Optional<Percentage> CSSMathValue::resolve_percentage() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Resolution> CSSMathValue::resolve_resolution() const
|
||||
Optional<Resolution> CalculatedStyleValue::resolve_resolution() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
if (result.value().has<Resolution>())
|
||||
|
@ -2602,7 +2602,7 @@ Optional<Resolution> CSSMathValue::resolve_resolution() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Time> CSSMathValue::resolve_time() const
|
||||
Optional<Time> CalculatedStyleValue::resolve_time() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2611,7 +2611,7 @@ Optional<Time> CSSMathValue::resolve_time() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<Time> CSSMathValue::resolve_time_percentage(Time const& percentage_basis) const
|
||||
Optional<Time> CalculatedStyleValue::resolve_time_percentage(Time const& percentage_basis) const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, percentage_basis);
|
||||
|
||||
|
@ -2624,7 +2624,7 @@ Optional<Time> CSSMathValue::resolve_time_percentage(Time const& percentage_basi
|
|||
});
|
||||
}
|
||||
|
||||
Optional<double> CSSMathValue::resolve_number() const
|
||||
Optional<double> CalculatedStyleValue::resolve_number() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2633,7 +2633,7 @@ Optional<double> CSSMathValue::resolve_number() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<double> CSSMathValue::resolve_number(Length::ResolutionContext const& context) const
|
||||
Optional<double> CalculatedStyleValue::resolve_number(Length::ResolutionContext const& context) const
|
||||
{
|
||||
auto result = m_calculation->resolve(context, {});
|
||||
|
||||
|
@ -2642,12 +2642,12 @@ Optional<double> CSSMathValue::resolve_number(Length::ResolutionContext const& c
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<double> CSSMathValue::resolve_number(Layout::Node const& layout_node) const
|
||||
Optional<double> CalculatedStyleValue::resolve_number(Layout::Node const& layout_node) const
|
||||
{
|
||||
return resolve_number(Length::ResolutionContext::for_layout_node(layout_node));
|
||||
}
|
||||
|
||||
Optional<i64> CSSMathValue::resolve_integer() const
|
||||
Optional<i64> CalculatedStyleValue::resolve_integer() const
|
||||
{
|
||||
auto result = m_calculation->resolve({}, {});
|
||||
|
||||
|
@ -2656,7 +2656,7 @@ Optional<i64> CSSMathValue::resolve_integer() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<i64> CSSMathValue::resolve_integer(Length::ResolutionContext const& context) const
|
||||
Optional<i64> CalculatedStyleValue::resolve_integer(Length::ResolutionContext const& context) const
|
||||
{
|
||||
auto result = m_calculation->resolve(context, {});
|
||||
|
||||
|
@ -2665,17 +2665,17 @@ Optional<i64> CSSMathValue::resolve_integer(Length::ResolutionContext const& con
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<i64> CSSMathValue::resolve_integer(Layout::Node const& layout_node) const
|
||||
Optional<i64> CalculatedStyleValue::resolve_integer(Layout::Node const& layout_node) const
|
||||
{
|
||||
return resolve_integer(Length::ResolutionContext::for_layout_node(layout_node));
|
||||
}
|
||||
|
||||
bool CSSMathValue::contains_percentage() const
|
||||
bool CalculatedStyleValue::contains_percentage() const
|
||||
{
|
||||
return m_calculation->contains_percentage();
|
||||
}
|
||||
|
||||
String CSSMathValue::dump() const
|
||||
String CalculatedStyleValue::dump() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
m_calculation->dump(builder, 0);
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.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 CSSMathValue : public CSSStyleValue {
|
||||
class CalculatedStyleValue : public CSSStyleValue {
|
||||
public:
|
||||
enum class ResolvedType {
|
||||
Angle,
|
||||
|
@ -74,9 +74,9 @@ public:
|
|||
Value m_value;
|
||||
};
|
||||
|
||||
static ValueComparingNonnullRefPtr<CSSMathValue> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
||||
static ValueComparingNonnullRefPtr<CalculatedStyleValue> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) CSSMathValue(move(calculation), resolved_type));
|
||||
return adopt_ref(*new (nothrow) CalculatedStyleValue(move(calculation), resolved_type));
|
||||
}
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
@ -132,8 +132,8 @@ public:
|
|||
String dump() const;
|
||||
|
||||
private:
|
||||
explicit CSSMathValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
||||
: CSSStyleValue(Type::Math)
|
||||
explicit CalculatedStyleValue(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
|
||||
: CSSStyleValue(Type::Calculated)
|
||||
, m_resolved_type(resolved_type)
|
||||
, m_calculation(move(calculation))
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ public:
|
|||
// This only exists during parsing.
|
||||
Unparsed,
|
||||
};
|
||||
using NumericValue = CSSMathValue::CalculationResult::Value;
|
||||
using NumericValue = CalculatedStyleValue::CalculationResult::Value;
|
||||
|
||||
virtual ~CalculationNode();
|
||||
|
||||
|
@ -260,11 +260,11 @@ public:
|
|||
}
|
||||
|
||||
virtual String to_string() const = 0;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const = 0;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const = 0;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const = 0;
|
||||
virtual bool contains_percentage() const = 0;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const = 0;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const = 0;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const = 0;
|
||||
virtual bool equals(CalculationNode const&) const = 0;
|
||||
|
||||
|
@ -281,11 +281,11 @@ public:
|
|||
~NumericCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -300,11 +300,11 @@ public:
|
|||
~SumCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -319,11 +319,11 @@ public:
|
|||
~ProductCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -338,11 +338,11 @@ public:
|
|||
~NegateCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -357,11 +357,11 @@ public:
|
|||
~InvertCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -376,10 +376,10 @@ public:
|
|||
~MinCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -395,11 +395,11 @@ public:
|
|||
~MaxCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
||||
|
@ -414,10 +414,10 @@ public:
|
|||
~ClampCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -435,10 +435,10 @@ public:
|
|||
~AbsCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -454,10 +454,10 @@ public:
|
|||
~SignCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -473,10 +473,10 @@ public:
|
|||
~ConstantCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override { return false; }
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&> context, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&> context, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -492,10 +492,10 @@ public:
|
|||
~SinCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -511,10 +511,10 @@ public:
|
|||
~CosCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -530,10 +530,10 @@ public:
|
|||
~TanCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -549,10 +549,10 @@ public:
|
|||
~AsinCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -568,10 +568,10 @@ public:
|
|||
~AcosCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -587,10 +587,10 @@ public:
|
|||
~AtanCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -606,10 +606,10 @@ public:
|
|||
~Atan2CalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -626,10 +626,10 @@ public:
|
|||
~PowCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override { return false; }
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -646,10 +646,10 @@ public:
|
|||
~SqrtCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override { return false; }
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -665,10 +665,10 @@ public:
|
|||
~HypotCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -684,10 +684,10 @@ public:
|
|||
~LogCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override { return false; }
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -704,10 +704,10 @@ public:
|
|||
~ExpCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override { return false; }
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -723,10 +723,10 @@ public:
|
|||
~RoundCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -744,10 +744,10 @@ public:
|
|||
~ModCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
||||
|
@ -764,10 +764,10 @@ public:
|
|||
~RemCalculationNode();
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Optional<CSSMathValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CalculatedStyleValue::ResolvedType> resolved_type() const override;
|
||||
virtual Optional<CSSNumericType> determine_type(PropertyID) const override;
|
||||
virtual bool contains_percentage() const override;
|
||||
virtual CSSMathValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CSSMathValue::PercentageBasis const&) const override;
|
||||
virtual CalculatedStyleValue::CalculationResult resolve(Optional<Length::ResolutionContext const&>, CalculatedStyleValue::PercentageBasis const&) const override;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent) const override;
|
||||
virtual bool equals(CalculationNode const&) const override;
|
|
@ -21,10 +21,10 @@ String EdgeStyleValue::to_string(SerializationMode mode) const
|
|||
if (offset().is_length()) {
|
||||
sum_parts.append(NegateCalculationNode::create(NumericCalculationNode::create(offset().length())));
|
||||
} else {
|
||||
// FIXME: Flip calculated offsets (convert CSSMathValue to CalculationNode, then negate and append)
|
||||
// FIXME: Flip calculated offsets (convert CalculatedStyleValue to CalculationNode, then negate and append)
|
||||
return to_string(CSSStyleValue::SerializationMode::Normal);
|
||||
}
|
||||
auto flipped_absolute = CSSMathValue::create(SumCalculationNode::create(move(sum_parts)), CSSNumericType(CSSNumericType::BaseType::Length, 1));
|
||||
auto flipped_absolute = CalculatedStyleValue::create(SumCalculationNode::create(move(sum_parts)), CSSNumericType(CSSNumericType::BaseType::Length, 1));
|
||||
return flipped_absolute->to_string(mode);
|
||||
}
|
||||
return offset().to_string();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
|
||||
#include "RotationStyleValue.h"
|
||||
|
@ -18,8 +18,8 @@ String RotationStyleValue::to_string(SerializationMode mode) const
|
|||
auto resolve_to_number = [](ValueComparingNonnullRefPtr<CSSStyleValue const> const& value) -> Optional<double> {
|
||||
if (value->is_number())
|
||||
return value->as_number().number();
|
||||
if (value->is_math() && value->as_math().resolves_to_number())
|
||||
return value->as_math().resolve_number();
|
||||
if (value->is_calculated() && value->as_calculated().resolves_to_number())
|
||||
return value->as_calculated().resolve_number();
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "Time.h"
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -74,7 +74,7 @@ Optional<Time::Type> Time::unit_from_name(StringView name)
|
|||
return {};
|
||||
}
|
||||
|
||||
Time Time::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&, Time const& reference_value)
|
||||
Time Time::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&, Time const& reference_value)
|
||||
{
|
||||
return calculated->resolve_time_percentage(reference_value).value();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Time resolve_calculated(NonnullRefPtr<CSSMathValue> const&, Layout::Node const&, Time const& reference_value);
|
||||
static Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Time const& reference_value);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
|
|
|
@ -114,6 +114,7 @@ class BackgroundRepeatStyleValue;
|
|||
class BackgroundSizeStyleValue;
|
||||
class BasicShapeStyleValue;
|
||||
class BorderRadiusStyleValue;
|
||||
class CalculatedStyleValue;
|
||||
class Clip;
|
||||
class ConicGradientStyleValue;
|
||||
class ContentStyleValue;
|
||||
|
@ -132,7 +133,6 @@ class CSSKeyframesRule;
|
|||
class CSSKeywordValue;
|
||||
class CSSLayerBlockRule;
|
||||
class CSSLayerStatementRule;
|
||||
class CSSMathValue;
|
||||
class CSSMediaRule;
|
||||
class CSSNestedDeclarations;
|
||||
class CSSOKLab;
|
||||
|
|
|
@ -754,8 +754,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
if (transition_delay_property.is_time()) {
|
||||
auto const& transition_delay = transition_delay_property.as_time();
|
||||
computed_values.set_transition_delay(transition_delay.time());
|
||||
} else if (transition_delay_property.is_math()) {
|
||||
auto const& transition_delay = transition_delay_property.as_math();
|
||||
} else if (transition_delay_property.is_calculated()) {
|
||||
auto const& transition_delay = transition_delay_property.as_calculated();
|
||||
computed_values.set_transition_delay(transition_delay.resolve_time().value());
|
||||
}
|
||||
|
||||
|
@ -776,8 +776,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
} else {
|
||||
auto resolve_border_width = [&]() -> CSSPixels {
|
||||
auto const& value = computed_style.property(width_property);
|
||||
if (value.is_math())
|
||||
return max(CSSPixels { 0 }, value.as_math().resolve_length(*this)->to_px(*this));
|
||||
if (value.is_calculated())
|
||||
return max(CSSPixels { 0 }, value.as_calculated().resolve_length(*this)->to_px(*this));
|
||||
if (value.is_length())
|
||||
return value.as_length().length().to_px(*this);
|
||||
if (value.is_keyword()) {
|
||||
|
@ -897,8 +897,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
dashes.append(CSS::LengthPercentage { value->as_length().length() });
|
||||
else if (value->is_percentage())
|
||||
dashes.append(CSS::LengthPercentage { value->as_percentage().percentage() });
|
||||
else if (value->is_math())
|
||||
dashes.append(CSS::LengthPercentage { value->as_math() });
|
||||
else if (value->is_calculated())
|
||||
dashes.append(CSS::LengthPercentage { value->as_calculated() });
|
||||
else if (value->is_number())
|
||||
dashes.append(CSS::NumberOrCalculated { value->as_number().number() });
|
||||
}
|
||||
|
|
|
@ -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/CSSMathValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ source_set("StyleValues") {
|
|||
"CSSKeywordValue.cpp",
|
||||
"CSSLCHLike.cpp",
|
||||
"CSSLabLike.cpp",
|
||||
"CSSMathValue.cpp",
|
||||
"CSSRGB.cpp",
|
||||
"CalculatedStyleValue.cpp",
|
||||
"ConicGradientStyleValue.cpp",
|
||||
"ContentStyleValue.cpp",
|
||||
"CounterDefinitionsStyleValue.cpp",
|
||||
|
|
Loading…
Add table
Reference in a new issue