1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

LibWeb: Remove CalculatedStyleValue from Time

Time also isn't used anywhere yet, hooray!
This commit is contained in:
Sam Atkins 2023-03-30 15:55:02 +01:00 committed by Andreas Kling
parent bf915fdfd7
commit ac4350748e
2 changed files with 3 additions and 33 deletions

View file

@ -1,11 +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
*/
#include "Time.h"
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/CSS/Percentage.h>
namespace Web::CSS {
@ -21,13 +21,6 @@ Time::Time(float value, Type type)
{
}
Time Time::make_calculated(NonnullRefPtr<CalculatedStyleValue> calculated_style_value)
{
Time frequency { 0, Type::Calculated };
frequency.m_calculated_style = move(calculated_style_value);
return frequency;
}
Time Time::make_seconds(float value)
{
return { value, Type::S };
@ -35,23 +28,17 @@ Time Time::make_seconds(float value)
Time Time::percentage_of(Percentage const& percentage) const
{
VERIFY(!is_calculated());
return Time { percentage.as_fraction() * m_value, m_type };
}
ErrorOr<String> Time::to_string() const
{
if (is_calculated())
return m_calculated_style->to_string();
return String::formatted("{}{}", m_value, unit_name());
}
float Time::to_seconds() const
{
switch (m_type) {
case Type::Calculated:
return m_calculated_style->resolve_time()->to_seconds();
case Type::S:
return m_value;
case Type::Ms:
@ -63,8 +50,6 @@ float Time::to_seconds() const
StringView Time::unit_name() const
{
switch (m_type) {
case Type::Calculated:
return "calculated"sv;
case Type::S:
return "s"sv;
case Type::Ms:
@ -83,10 +68,4 @@ Optional<Time::Type> Time::unit_from_name(StringView name)
return {};
}
NonnullRefPtr<CalculatedStyleValue> Time::calculated_style_value() const
{
VERIFY(!m_calculated_style.is_null());
return *m_calculated_style;
}
}