LibWeb: Replace TextDecorationStyleValue with ShorthandStyleValue
This commit is contained in:
parent
d40b3f2a34
commit
8efac89a16
Notes:
sideshowbarker
2024-07-18 00:54:03 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/8efac89a16 Pull-request: https://github.com/SerenityOS/serenity/pull/21168
11 changed files with 8 additions and 95 deletions
Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues
Userland/Libraries/LibWeb
|
@ -33,7 +33,6 @@ source_set("StyleValues") {
|
|||
"ShadowStyleValue.cpp",
|
||||
"ShorthandStyleValue.cpp",
|
||||
"StyleValueList.cpp",
|
||||
"TextDecorationStyleValue.cpp",
|
||||
"TransformationStyleValue.cpp",
|
||||
"UnresolvedStyleValue.cpp",
|
||||
]
|
||||
|
|
|
@ -110,7 +110,6 @@ set(SOURCES
|
|||
CSS/StyleValues/ShadowStyleValue.cpp
|
||||
CSS/StyleValues/ShorthandStyleValue.cpp
|
||||
CSS/StyleValues/StyleValueList.cpp
|
||||
CSS/StyleValues/TextDecorationStyleValue.cpp
|
||||
CSS/StyleValues/TransformationStyleValue.cpp
|
||||
CSS/StyleValues/UnresolvedStyleValue.cpp
|
||||
CSS/Supports.cpp
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/URLStyleValue.h>
|
||||
|
@ -4722,7 +4721,9 @@ RefPtr<StyleValue> Parser::parse_text_decoration_value(Vector<ComponentValue> co
|
|||
if (!decoration_color)
|
||||
decoration_color = property_initial_value(m_context.realm(), PropertyID::TextDecorationColor);
|
||||
|
||||
return TextDecorationStyleValue::create(decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull());
|
||||
return ShorthandStyleValue::create(PropertyID::TextDecoration,
|
||||
{ PropertyID::TextDecorationLine, PropertyID::TextDecorationThickness, PropertyID::TextDecorationStyle, PropertyID::TextDecorationColor },
|
||||
{ decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull() });
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_text_decoration_line_value(TokenStream<ComponentValue>& tokens)
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/URLStyleValue.h>
|
||||
|
@ -418,7 +417,9 @@ RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(L
|
|||
auto thickness = style_value_for_property(layout_node, PropertyID::TextDecorationThickness);
|
||||
auto style = style_value_for_property(layout_node, PropertyID::TextDecorationStyle);
|
||||
auto color = style_value_for_property(layout_node, PropertyID::TextDecorationColor);
|
||||
return TextDecorationStyleValue::create(*line, *thickness, *style, *color);
|
||||
return ShorthandStyleValue::create(PropertyID::TextDecoration,
|
||||
{ PropertyID::TextDecorationLine, PropertyID::TextDecorationThickness, PropertyID::TextDecorationStyle, PropertyID::TextDecorationColor },
|
||||
{ line.release_nonnull(), thickness.release_nonnull(), style.release_nonnull(), color.release_nonnull() });
|
||||
}
|
||||
case PropertyID::TextDecorationColor:
|
||||
return ColorStyleValue::create(layout_node.computed_values().text_decoration_color());
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/UnresolvedStyleValue.h>
|
||||
|
@ -462,15 +461,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
|||
};
|
||||
|
||||
if (property_id == CSS::PropertyID::TextDecoration) {
|
||||
if (value.is_text_decoration()) {
|
||||
auto const& text_decoration = value.as_text_decoration();
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationLine, text_decoration.line());
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationThickness, text_decoration.thickness());
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationStyle, text_decoration.style());
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationColor, text_decoration.color());
|
||||
return;
|
||||
}
|
||||
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationLine, value);
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationThickness, value);
|
||||
set_longhand_property(CSS::PropertyID::TextDecorationStyle, value);
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/URLStyleValue.h>
|
||||
|
|
|
@ -122,7 +122,6 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
|
|||
__ENUMERATE_STYLE_VALUE_TYPE(Shadow, shadow) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(Shorthand, shorthand) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(String, string) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(TextDecoration, text_decoration) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(Time, time) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(Transformation, transformation) \
|
||||
__ENUMERATE_STYLE_VALUE_TYPE(Unresolved, unresolved) \
|
||||
|
|
|
@ -168,6 +168,8 @@ String ShorthandStyleValue::to_string() const
|
|||
return align_self;
|
||||
return MUST(String::formatted("{} {}", align_self, justify_self));
|
||||
}
|
||||
case PropertyID::TextDecoration:
|
||||
return MUST(String::formatted("{} {} {} {}", longhand(PropertyID::TextDecorationLine)->to_string(), longhand(PropertyID::TextDecorationThickness)->to_string(), longhand(PropertyID::TextDecorationStyle)->to_string(), longhand(PropertyID::TextDecorationColor)->to_string()));
|
||||
default:
|
||||
StringBuilder builder;
|
||||
auto first = true;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* 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 {
|
||||
|
||||
String TextDecorationStyleValue::to_string() const
|
||||
{
|
||||
return MUST(String::formatted("{} {} {} {}", m_properties.line->to_string(), m_properties.thickness->to_string(), m_properties.style->to_string(), m_properties.color->to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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 (nothrow) 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 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;
|
||||
};
|
||||
|
||||
}
|
|
@ -162,7 +162,6 @@ class StyleValue;
|
|||
class StyleValueList;
|
||||
class Supports;
|
||||
class SVGPaint;
|
||||
class TextDecorationStyleValue;
|
||||
class Time;
|
||||
class TimeOrCalculated;
|
||||
class TimePercentage;
|
||||
|
|
Loading…
Add table
Reference in a new issue