/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include "CounterDefinitionsStyleValue.h" |
8 | | #include <LibWeb/CSS/Serialize.h> |
9 | | |
10 | | namespace Web::CSS { |
11 | | |
12 | | String CounterDefinitionsStyleValue::to_string() const |
13 | 0 | { |
14 | 0 | StringBuilder stb; |
15 | |
|
16 | 0 | for (auto const& counter_definition : m_counter_definitions) { |
17 | 0 | if (!stb.is_empty()) |
18 | 0 | stb.append(' '); |
19 | |
|
20 | 0 | if (counter_definition.is_reversed) |
21 | 0 | stb.appendff("reversed({})", counter_definition.name); |
22 | 0 | else |
23 | 0 | stb.append(counter_definition.name); |
24 | |
|
25 | 0 | if (counter_definition.value) |
26 | 0 | stb.appendff(" {}", counter_definition.value->to_string()); |
27 | 0 | } |
28 | |
|
29 | 0 | return stb.to_string_without_validation(); |
30 | 0 | } |
31 | | |
32 | | bool CounterDefinitionsStyleValue::properties_equal(CounterDefinitionsStyleValue const& other) const |
33 | 0 | { |
34 | 0 | if (m_counter_definitions.size() != other.counter_definitions().size()) |
35 | 0 | return false; |
36 | | |
37 | 0 | for (auto i = 0u; i < m_counter_definitions.size(); i++) { |
38 | 0 | auto const& ours = m_counter_definitions[i]; |
39 | 0 | auto const& theirs = other.counter_definitions()[i]; |
40 | 0 | if (ours.name != theirs.name || ours.is_reversed != theirs.is_reversed || ours.value != theirs.value) |
41 | 0 | return false; |
42 | 0 | } |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | } |