/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/LengthStyleValue.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> |
4 | | * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org> |
5 | | * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> |
6 | | * |
7 | | * SPDX-License-Identifier: BSD-2-Clause |
8 | | */ |
9 | | |
10 | | #pragma once |
11 | | |
12 | | #include <LibWeb/CSS/Length.h> |
13 | | #include <LibWeb/CSS/StyleValues/CSSUnitValue.h> |
14 | | |
15 | | namespace Web::CSS { |
16 | | |
17 | | class LengthStyleValue final : public CSSUnitValue { |
18 | | public: |
19 | | static ValueComparingNonnullRefPtr<LengthStyleValue> create(Length const&); |
20 | 0 | virtual ~LengthStyleValue() override = default; |
21 | | |
22 | 0 | Length const& length() const { return m_length; } |
23 | 0 | virtual double value() const override { return m_length.raw_value(); } |
24 | 0 | virtual StringView unit() const override { return m_length.unit_name(); } |
25 | | |
26 | 0 | virtual String to_string() const override { return m_length.to_string(); } |
27 | | virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; |
28 | | |
29 | | bool equals(CSSStyleValue const& other) const override; |
30 | | |
31 | | private: |
32 | | explicit LengthStyleValue(Length const& length) |
33 | 0 | : CSSUnitValue(Type::Length) |
34 | 0 | , m_length(length) |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | Length m_length; |
39 | | }; |
40 | | |
41 | | } |