/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, MacDue <macdue@dueutil.tech> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/CSS/CSSStyleValue.h> |
10 | | #include <LibWeb/CSS/Enums.h> |
11 | | #include <LibWeb/CSS/PercentageOr.h> |
12 | | |
13 | | namespace Web::CSS { |
14 | | |
15 | | class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> { |
16 | | public: |
17 | | static ValueComparingNonnullRefPtr<EdgeStyleValue> create(PositionEdge edge, LengthPercentage const& offset) |
18 | 0 | { |
19 | 0 | VERIFY(edge != PositionEdge::Center); |
20 | 0 | return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset)); |
21 | 0 | } |
22 | 0 | virtual ~EdgeStyleValue() override = default; |
23 | | |
24 | | // NOTE: `center` is converted to `left 50%` or `top 50%` in parsing, so is never returned here. |
25 | 0 | PositionEdge edge() const { return m_properties.edge; } |
26 | 0 | LengthPercentage const& offset() const { return m_properties.offset; } |
27 | | |
28 | | virtual String to_string() const override; |
29 | | |
30 | 0 | bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; } |
31 | | |
32 | | private: |
33 | | EdgeStyleValue(PositionEdge edge, LengthPercentage const& offset) |
34 | 0 | : StyleValueWithDefaultOperators(Type::Edge) |
35 | 0 | , m_properties { .edge = edge, .offset = offset } |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | struct Properties { |
40 | | PositionEdge edge; |
41 | | LengthPercentage offset; |
42 | 0 | bool operator==(Properties const&) const = default; |
43 | | } m_properties; |
44 | | }; |
45 | | |
46 | | } |