ladybird/Libraries/LibWeb/CSS/CalculatedOr.cpp
Sam Atkins c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00

110 lines
3.8 KiB
C++

/*
* Copyright (c) 2023-2025, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "CalculatedOr.h"
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
namespace Web::CSS {
Optional<Angle> AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_angle_deprecated(context);
}
NonnullRefPtr<StyleValue const> AngleOrCalculated::create_style_value() const
{
return AngleStyleValue::create(value());
}
Optional<Flex> FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_flex_deprecated(context);
}
NonnullRefPtr<StyleValue const> FlexOrCalculated::create_style_value() const
{
return FlexStyleValue::create(value());
}
Optional<Frequency> FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_frequency_deprecated(context);
}
NonnullRefPtr<StyleValue const> FrequencyOrCalculated::create_style_value() const
{
return FrequencyStyleValue::create(value());
}
Optional<i64> IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_integer_deprecated(context);
}
NonnullRefPtr<StyleValue const> IntegerOrCalculated::create_style_value() const
{
return IntegerStyleValue::create(value());
}
Optional<Length> LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_length_deprecated(context);
}
NonnullRefPtr<StyleValue const> LengthOrCalculated::create_style_value() const
{
return LengthStyleValue::create(value());
}
Optional<double> NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_number_deprecated(context);
}
NonnullRefPtr<StyleValue const> NumberOrCalculated::create_style_value() const
{
return NumberStyleValue::create(value());
}
Optional<Percentage> PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_percentage_deprecated(context);
}
NonnullRefPtr<StyleValue const> PercentageOrCalculated::create_style_value() const
{
return PercentageStyleValue::create(value());
}
Optional<Resolution> ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_resolution_deprecated(context);
}
NonnullRefPtr<StyleValue const> ResolutionOrCalculated::create_style_value() const
{
return ResolutionStyleValue::create(value());
}
Optional<Time> TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, CalculationResolutionContext const& context) const
{
return calculated->resolve_time_deprecated(context);
}
NonnullRefPtr<StyleValue const> TimeOrCalculated::create_style_value() const
{
return TimeStyleValue::create(value());
}
}