mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
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.)
This commit is contained in:
parent
fa90a3bb4f
commit
7a1a97f153
6 changed files with 9 additions and 37 deletions
|
@ -1,12 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
@ -15,7 +14,6 @@ namespace Web::CSS {
|
|||
class Angle {
|
||||
public:
|
||||
enum class Type {
|
||||
Calculated,
|
||||
Deg,
|
||||
Grad,
|
||||
Rad,
|
||||
|
@ -26,20 +24,14 @@ public:
|
|||
|
||||
Angle(int value, Type type);
|
||||
Angle(float value, Type type);
|
||||
static Angle make_calculated(NonnullRefPtr<CalculatedStyleValue>);
|
||||
static Angle make_degrees(float);
|
||||
Angle percentage_of(Percentage const&) const;
|
||||
|
||||
bool is_calculated() const { return m_type == Type::Calculated; }
|
||||
NonnullRefPtr<CalculatedStyleValue> calculated_style_value() const;
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
float to_degrees() const;
|
||||
|
||||
bool operator==(Angle const& other) const
|
||||
{
|
||||
if (is_calculated())
|
||||
return m_calculated_style == other.m_calculated_style;
|
||||
return m_type == other.m_type && m_value == other.m_value;
|
||||
}
|
||||
|
||||
|
@ -48,7 +40,6 @@ private:
|
|||
|
||||
Type m_type;
|
||||
float m_value { 0 };
|
||||
RefPtr<CalculatedStyleValue> m_calculated_style;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue