summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-24 17:52:37 +0000
committerLinus Groh <mail@linusgroh.de>2023-03-25 16:56:04 +0000
commit66cb7edffbd128be461e2618243054a27d0d3ed3 (patch)
treef01b67537344c80713ea19d36146a49179163c0a /Userland/Libraries/LibWeb/CSS
parent9b834058ee0ce315c6697cc2f0b73b29740316fe (diff)
downloadserenity-66cb7edffbd128be461e2618243054a27d0d3ed3.zip
LibWeb: Split TextDecorationStyleValue out of StyleValue.{h,cpp}
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp1
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp1
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValue.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValue.h41
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp19
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h57
6 files changed, 79 insertions, 46 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 557dfdf69a..466178e169 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -64,6 +64,7 @@
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
+#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Infra/Strings.h>
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 906320f753..24afe8e3fa 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -43,6 +43,7 @@
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
#include <LibWeb/CSS/StyleValues/OverflowStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
+#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/FontCache.h>
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
index 9354b1ba17..82017b1ce4 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp
@@ -47,6 +47,7 @@
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
+#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Loader/LoadRequest.h>
@@ -1148,11 +1149,6 @@ ErrorOr<String> RectStyleValue::to_string() const
return String::formatted("rect({} {} {} {})", m_rect.top_edge, m_rect.right_edge, m_rect.bottom_edge, m_rect.left_edge);
}
-ErrorOr<String> TextDecorationStyleValue::to_string() const
-{
- return String::formatted("{} {} {} {}", TRY(m_properties.line->to_string()), TRY(m_properties.thickness->to_string()), TRY(m_properties.style->to_string()), TRY(m_properties.color->to_string()));
-}
-
ErrorOr<String> TransformationStyleValue::to_string() const
{
StringBuilder builder;
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h
index 11eab4ea40..eab2ce6fe0 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleValue.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h
@@ -622,47 +622,6 @@ private:
NonnullOwnPtr<CalcSum> m_expression;
};
-class TextDecorationStyleValue final : public StyleValueWithDefaultOperators<TextDecorationStyleValue> {
-public:
- static ValueComparingNonnullRefPtr<TextDecorationStyleValue> create(
- ValueComparingNonnullRefPtr<StyleValue> line,
- ValueComparingNonnullRefPtr<StyleValue> thickness,
- ValueComparingNonnullRefPtr<StyleValue> style,
- ValueComparingNonnullRefPtr<StyleValue> color)
- {
- return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color)));
- }
- virtual ~TextDecorationStyleValue() override = default;
-
- ValueComparingNonnullRefPtr<StyleValue> line() const { return m_properties.line; }
- ValueComparingNonnullRefPtr<StyleValue> thickness() const { return m_properties.thickness; }
- ValueComparingNonnullRefPtr<StyleValue> style() const { return m_properties.style; }
- ValueComparingNonnullRefPtr<StyleValue> color() const { return m_properties.color; }
-
- virtual ErrorOr<String> to_string() const override;
-
- bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; }
-
-private:
- TextDecorationStyleValue(
- ValueComparingNonnullRefPtr<StyleValue> line,
- ValueComparingNonnullRefPtr<StyleValue> thickness,
- ValueComparingNonnullRefPtr<StyleValue> style,
- ValueComparingNonnullRefPtr<StyleValue> color)
- : StyleValueWithDefaultOperators(Type::TextDecoration)
- , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) }
- {
- }
-
- struct Properties {
- ValueComparingNonnullRefPtr<StyleValue> line;
- ValueComparingNonnullRefPtr<StyleValue> thickness;
- ValueComparingNonnullRefPtr<StyleValue> style;
- ValueComparingNonnullRefPtr<StyleValue> color;
- bool operator==(Properties const&) const = default;
- } m_properties;
-};
-
class TimeStyleValue : public StyleValueWithDefaultOperators<TimeStyleValue> {
public:
static ValueComparingNonnullRefPtr<TimeStyleValue> create(Time time)
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp
new file mode 100644
index 0000000000..722ab84629
--- /dev/null
+++ b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
+ * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include "TextDecorationStyleValue.h"
+
+namespace Web::CSS {
+
+ErrorOr<String> TextDecorationStyleValue::to_string() const
+{
+ return String::formatted("{} {} {} {}", TRY(m_properties.line->to_string()), TRY(m_properties.thickness->to_string()), TRY(m_properties.style->to_string()), TRY(m_properties.color->to_string()));
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h
new file mode 100644
index 0000000000..b3a6ace4bc
--- /dev/null
+++ b/Userland/Libraries/LibWeb/CSS/StyleValues/TextDecorationStyleValue.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
+ * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/CSS/StyleValue.h>
+
+namespace Web::CSS {
+
+class TextDecorationStyleValue final : public StyleValueWithDefaultOperators<TextDecorationStyleValue> {
+public:
+ static ValueComparingNonnullRefPtr<TextDecorationStyleValue> create(
+ ValueComparingNonnullRefPtr<StyleValue> line,
+ ValueComparingNonnullRefPtr<StyleValue> thickness,
+ ValueComparingNonnullRefPtr<StyleValue> style,
+ ValueComparingNonnullRefPtr<StyleValue> color)
+ {
+ return adopt_ref(*new TextDecorationStyleValue(move(line), move(thickness), move(style), move(color)));
+ }
+ virtual ~TextDecorationStyleValue() override = default;
+
+ ValueComparingNonnullRefPtr<StyleValue> line() const { return m_properties.line; }
+ ValueComparingNonnullRefPtr<StyleValue> thickness() const { return m_properties.thickness; }
+ ValueComparingNonnullRefPtr<StyleValue> style() const { return m_properties.style; }
+ ValueComparingNonnullRefPtr<StyleValue> color() const { return m_properties.color; }
+
+ virtual ErrorOr<String> to_string() const override;
+
+ bool properties_equal(TextDecorationStyleValue const& other) const { return m_properties == other.m_properties; }
+
+private:
+ TextDecorationStyleValue(
+ ValueComparingNonnullRefPtr<StyleValue> line,
+ ValueComparingNonnullRefPtr<StyleValue> thickness,
+ ValueComparingNonnullRefPtr<StyleValue> style,
+ ValueComparingNonnullRefPtr<StyleValue> color)
+ : StyleValueWithDefaultOperators(Type::TextDecoration)
+ , m_properties { .line = move(line), .thickness = move(thickness), .style = move(style), .color = move(color) }
+ {
+ }
+
+ struct Properties {
+ ValueComparingNonnullRefPtr<StyleValue> line;
+ ValueComparingNonnullRefPtr<StyleValue> thickness;
+ ValueComparingNonnullRefPtr<StyleValue> style;
+ ValueComparingNonnullRefPtr<StyleValue> color;
+ bool operator==(Properties const&) const = default;
+ } m_properties;
+};
+
+}