summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Angle.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-30 15:33:37 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-30 21:29:50 +0200
commit7a1a97f153c2b005629a3b9643fa45822e237ef4 (patch)
treef1e84b14cf1a522bd203f83cac57d8569d8098f3 /Userland/Libraries/LibWeb/CSS/Angle.cpp
parentfa90a3bb4fc3e4a8a0caa0b80a7ac87765ab67f9 (diff)
downloadserenity-7a1a97f153c2b005629a3b9643fa45822e237ef4.zip
LibWeb: Remove CalculatedStyleValue from Angle
...and replace it with AngleOrCalculated. This has the nice bonus effect of actually handling `calc()` for angles in a transform function. :^) (Previously we just would have asserted.)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Angle.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Angle.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Angle.cpp b/Userland/Libraries/LibWeb/CSS/Angle.cpp
index ea07b52aad..36575de260 100644
--- a/Userland/Libraries/LibWeb/CSS/Angle.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Angle.cpp
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Angle.h"
#include <AK/Math.h>
-#include <LibWeb/CSS/StyleValue.h>
+#include <LibWeb/CSS/Percentage.h>
namespace Web::CSS {
@@ -22,13 +22,6 @@ Angle::Angle(float value, Type type)
{
}
-Angle Angle::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_style_value)
-{
- Angle angle { 0, Type::Calculated };
- angle.m_calculated_style = move(calculated_style_value);
- return angle;
-}
-
Angle Angle::make_degrees(float value)
{
return { value, Type::Deg };
@@ -36,23 +29,17 @@ Angle Angle::make_degrees(float value)
Angle Angle::percentage_of(Percentage const& percentage) const
{
- VERIFY(!is_calculated());
-
return Angle { percentage.as_fraction() * m_value, m_type };
}
ErrorOr<String> Angle::to_string() const
{
- if (is_calculated())
- return m_calculated_style->to_string();
return String::formatted("{}{}", m_value, unit_name());
}
float Angle::to_degrees() const
{
switch (m_type) {
- case Type::Calculated:
- return m_calculated_style->resolve_angle()->to_degrees();
case Type::Deg:
return m_value;
case Type::Grad:
@@ -68,8 +55,6 @@ float Angle::to_degrees() const
StringView Angle::unit_name() const
{
switch (m_type) {
- case Type::Calculated:
- return "calculated"sv;
case Type::Deg:
return "deg"sv;
case Type::Grad:
@@ -99,10 +84,4 @@ Optional<Angle::Type> Angle::unit_from_name(StringView name)
return {};
}
-NonnullRefPtr<CalculatedStyleValue> Angle::calculated_style_value() const
-{
- VERIFY(!m_calculated_style.is_null());
- return *m_calculated_style;
-}
-
}