Skip to content

Truly independent web browser

1.2 KB
Raw Blame
/*
 * Copyright (c) 2018-2020, Andreas Kling <[email protected]>
 * Copyright (c) 2021, Tobias Christiansen <[email protected]>
 * Copyright (c) 2021-2024, Sam Atkins <[email protected]>
 * Copyright (c) 2022-2023, MacDue <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/CSS/Angle.h>
#include <LibWeb/CSS/StyleValues/DimensionStyleValue.h>

namespace Web::CSS {

class AngleStyleValue : public DimensionStyleValue {
public:
    static ValueComparingNonnullRefPtr<AngleStyleValue const> create(Angle angle)
    {
        return adopt_ref(*new (nothrow) AngleStyleValue(move(angle)));
    }
    virtual ~AngleStyleValue() override;

    Angle angle() const { return Angle(m_value->angle.value, static_cast<AngleUnit>(m_value->angle.unit)); }
    virtual double raw_value() const override { return m_value->angle.value; }
    virtual Utf16FlyString unit_name() const override { return angle().unit_name(); }

private:
    friend class StyleValue;

    explicit AngleStyleValue(StyleValueFFI::StyleValueData const* data)
        : DimensionStyleValue(Type::Angle, data)
    {
    }

    explicit AngleStyleValue(Angle angle);
};

}