From 6cad3f1921c657bbca59820eb77ffece1d2a99cc Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 8 Aug 2025 11:24:15 +0100 Subject: [PATCH] LibWeb/CSS: Rename CSSColorValue -> ColorStyleValue The typed-om class will be a separate thing. --- Libraries/LibWeb/CMakeLists.txt | 2 +- Libraries/LibWeb/CSS/CSSStyleProperties.cpp | 8 ++--- Libraries/LibWeb/CSS/Interpolation.cpp | 8 ++--- Libraries/LibWeb/CSS/Interpolation.h | 2 +- .../LibWeb/CSS/Parser/PropertyParsing.cpp | 2 +- Libraries/LibWeb/CSS/Parser/ValueParsing.cpp | 8 ++--- Libraries/LibWeb/CSS/StyleComputer.cpp | 2 +- .../CSS/StyleValues/AbstractImageStyleValue.h | 2 +- Libraries/LibWeb/CSS/StyleValues/CSSHSL.h | 6 ++-- Libraries/LibWeb/CSS/StyleValues/CSSHWB.h | 6 ++-- Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.h | 6 ++-- Libraries/LibWeb/CSS/StyleValues/CSSLabLike.h | 6 ++-- .../LibWeb/CSS/StyleValues/CSSLightDark.h | 6 ++-- Libraries/LibWeb/CSS/StyleValues/CSSRGB.h | 6 ++-- .../StyleValues/ColorFunctionStyleValue.cpp | 36 +++++++++---------- .../CSS/StyleValues/ColorFunctionStyleValue.h | 7 ++-- .../CSS/StyleValues/ColorMixStyleValue.cpp | 2 +- .../CSS/StyleValues/ColorMixStyleValue.h | 4 +-- ...{CSSColorValue.cpp => ColorStyleValue.cpp} | 16 ++++----- .../{CSSColorValue.h => ColorStyleValue.h} | 9 +++-- .../StyleValues/LinearGradientStyleValue.h | 2 +- .../StyleValues/ScrollbarColorStyleValue.h | 2 +- .../LibWeb/CSS/StyleValues/StyleValue.cpp | 2 +- Libraries/LibWeb/CSS/StyleValues/StyleValue.h | 2 +- .../LibWeb/Editing/Internal/Algorithms.cpp | 2 +- Libraries/LibWeb/Forward.h | 2 +- Libraries/LibWeb/HTML/HTMLBodyElement.cpp | 6 ++-- Libraries/LibWeb/HTML/HTMLFontElement.cpp | 4 +-- Libraries/LibWeb/HTML/HTMLHRElement.cpp | 4 +-- Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp | 4 +-- Libraries/LibWeb/HTML/HTMLMetaElement.cpp | 2 +- .../LibWeb/HTML/HTMLTableCellElement.cpp | 4 +-- Libraries/LibWeb/HTML/HTMLTableElement.cpp | 8 ++--- Libraries/LibWeb/HTML/HTMLTableRowElement.cpp | 4 +-- .../LibWeb/HTML/HTMLTableSectionElement.cpp | 4 +-- 35 files changed, 97 insertions(+), 99 deletions(-) rename Libraries/LibWeb/CSS/StyleValues/{CSSColorValue.cpp => ColorStyleValue.cpp} (87%) rename Libraries/LibWeb/CSS/StyleValues/{CSSColorValue.h => ColorStyleValue.h} (85%) diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 22a352a8f23..3de71a7a9ee 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -196,11 +196,11 @@ set(SOURCES CSS/StyleValues/ColorFunctionStyleValue.cpp CSS/StyleValues/ColorMixStyleValue.cpp CSS/StyleValues/ColorSchemeStyleValue.cpp + CSS/StyleValues/ColorStyleValue.cpp CSS/StyleValues/ConicGradientStyleValue.cpp CSS/StyleValues/ContentStyleValue.cpp CSS/StyleValues/CounterDefinitionsStyleValue.cpp CSS/StyleValues/CounterStyleValue.cpp - CSS/StyleValues/CSSColorValue.cpp CSS/StyleValues/CSSHSL.cpp CSS/StyleValues/CSSHWB.cpp CSS/StyleValues/CSSLabLike.cpp diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index bbeae4127f4..7b691c410fa 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -364,7 +364,7 @@ static RefPtr style_value_for_shadow(Vector const& auto make_shadow_style_value = [](ShadowData const& shadow) { return ShadowStyleValue::create( - CSSColorValue::create_from_color(shadow.color, ColorSyntax::Modern), + ColorStyleValue::create_from_color(shadow.color, ColorSyntax::Modern), style_value_for_length_percentage(shadow.offset_x), style_value_for_length_percentage(shadow.offset_y), style_value_for_length_percentage(shadow.blur_radius), @@ -474,12 +474,12 @@ static RefPtr resolve_color_style_value(StyleValue const& styl if (style_value.is_color_function()) return style_value; if (style_value.is_color()) { - auto& color_style_value = static_cast(style_value); - if (first_is_one_of(color_style_value.color_type(), CSSColorValue::ColorType::Lab, CSSColorValue::ColorType::OKLab, CSSColorValue::ColorType::LCH, CSSColorValue::ColorType::OKLCH)) + auto& color_style_value = static_cast(style_value); + if (first_is_one_of(color_style_value.color_type(), ColorStyleValue::ColorType::Lab, ColorStyleValue::ColorType::OKLab, ColorStyleValue::ColorType::LCH, ColorStyleValue::ColorType::OKLCH)) return style_value; } - return CSSColorValue::create_from_color(computed_color, ColorSyntax::Modern); + return ColorStyleValue::create_from_color(computed_color, ColorSyntax::Modern); } RefPtr CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index 4945212f8fb..36579237f6b 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -936,7 +936,7 @@ RefPtr interpolate_box_shadow(DOM::Element& element, Calculati values.ensure_capacity(other.size()); for (size_t i = values.size(); i < other.size(); i++) { values.unchecked_append(ShadowStyleValue::create( - CSSColorValue::create_from_color(Color::Transparent, ColorSyntax::Legacy), + ColorStyleValue::create_from_color(Color::Transparent, ColorSyntax::Legacy), LengthStyleValue::create(Length::make_px(0)), LengthStyleValue::create(Length::make_px(0)), LengthStyleValue::create(Length::make_px(0)), @@ -987,7 +987,7 @@ RefPtr interpolate_box_shadow(DOM::Element& element, Calculati interpolated_color = interpolate_color(from_color.value(), to_color.value(), delta, color_syntax); auto result_shadow = ShadowStyleValue::create( - CSSColorValue::create_from_color(interpolated_color, ColorSyntax::Modern), + ColorStyleValue::create_from_color(interpolated_color, ColorSyntax::Modern), *interpolated_offset_x, *interpolated_offset_y, *interpolated_blur_radius, @@ -1119,7 +1119,7 @@ static RefPtr interpolate_value_impl(DOM::Element& element, Ca if (from_color.has_value() && to_color.has_value()) interpolated_color = interpolate_color(from_color.value(), to_color.value(), delta, color_syntax); - return CSSColorValue::create_from_color(interpolated_color, ColorSyntax::Modern); + return ColorStyleValue::create_from_color(interpolated_color, ColorSyntax::Modern); } case StyleValue::Type::Edge: { auto resolved_from = from.as_edge().resolved_value(calculation_context); diff --git a/Libraries/LibWeb/CSS/Interpolation.h b/Libraries/LibWeb/CSS/Interpolation.h index 93e57696d63..d62a01f8c71 100644 --- a/Libraries/LibWeb/CSS/Interpolation.h +++ b/Libraries/LibWeb/CSS/Interpolation.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 26f969e4acc..ab8f9722f73 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -22,8 +22,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index abc737353dd..2a66e281ab2 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -2206,7 +2206,7 @@ RefPtr Parser::parse_color_value(TokenStream& auto color = Color::from_string(ident); if (color.has_value()) { transaction.commit(); - return CSSColorValue::create_from_color(color.release_value(), ColorSyntax::Legacy, ident); + return ColorStyleValue::create_from_color(color.release_value(), ColorSyntax::Legacy, ident); } // Otherwise, fall through to the hashless-hex-color case } @@ -2215,7 +2215,7 @@ RefPtr Parser::parse_color_value(TokenStream& auto color = Color::from_string(MUST(String::formatted("#{}", component_value.token().hash_value()))); if (color.has_value()) { transaction.commit(); - return CSSColorValue::create_from_color(color.release_value(), ColorSyntax::Legacy); + return ColorStyleValue::create_from_color(color.release_value(), ColorSyntax::Legacy); } return {}; } @@ -2299,7 +2299,7 @@ RefPtr Parser::parse_color_value(TokenStream& auto color = Color::from_string(MUST(String::formatted("#{}", serialization))); if (color.has_value()) { transaction.commit(); - return CSSColorValue::create_from_color(color.release_value(), ColorSyntax::Legacy); + return ColorStyleValue::create_from_color(color.release_value(), ColorSyntax::Legacy); } } } diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 6cd1b1f2dca..8104f483aee 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h index 60e80d5738f..d2856e07b87 100644 --- a/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include namespace Web::CSS { diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSHSL.h b/Libraries/LibWeb/CSS/StyleValues/CSSHSL.h index 5b8b2713272..a2362efeb2c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSHSL.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSHSL.h @@ -6,13 +6,13 @@ #pragma once -#include +#include #include namespace Web::CSS { // https://drafts.css-houdini.org/css-typed-om-1/#csshsl -class CSSHSL final : public CSSColorValue { +class CSSHSL final : public ColorStyleValue { public: static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr h, ValueComparingNonnullRefPtr s, ValueComparingNonnullRefPtr l, ValueComparingRefPtr alpha, ColorSyntax color_syntax) { @@ -37,7 +37,7 @@ public: private: CSSHSL(ValueComparingNonnullRefPtr h, ValueComparingNonnullRefPtr s, ValueComparingNonnullRefPtr l, ValueComparingNonnullRefPtr alpha, ColorSyntax color_syntax) - : CSSColorValue(ColorType::HSL, color_syntax) + : ColorStyleValue(ColorType::HSL, color_syntax) , m_properties { .h = move(h), .s = move(s), .l = move(l), .alpha = move(alpha) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSHWB.h b/Libraries/LibWeb/CSS/StyleValues/CSSHWB.h index 0efdf23b3bf..7304a456de8 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSHWB.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSHWB.h @@ -6,13 +6,13 @@ #pragma once -#include +#include #include namespace Web::CSS { // https://drafts.css-houdini.org/css-typed-om-1/#csshwb -class CSSHWB final : public CSSColorValue { +class CSSHWB final : public ColorStyleValue { public: static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr h, ValueComparingNonnullRefPtr w, ValueComparingNonnullRefPtr b, ValueComparingRefPtr alpha = {}) { @@ -37,7 +37,7 @@ public: private: CSSHWB(ValueComparingNonnullRefPtr h, ValueComparingNonnullRefPtr w, ValueComparingNonnullRefPtr b, ValueComparingNonnullRefPtr alpha) - : CSSColorValue(ColorType::HWB, ColorSyntax::Modern) + : ColorStyleValue(ColorType::HWB, ColorSyntax::Modern) , m_properties { .h = move(h), .w = move(w), .b = move(b), .alpha = move(alpha) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.h b/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.h index ce21d99515c..3e919936232 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.h @@ -6,12 +6,12 @@ #pragma once -#include +#include #include namespace Web::CSS { -class CSSLCHLike : public CSSColorValue { +class CSSLCHLike : public ColorStyleValue { public: template T> static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr l, ValueComparingNonnullRefPtr c, ValueComparingNonnullRefPtr h, ValueComparingRefPtr alpha = {}) @@ -33,7 +33,7 @@ public: protected: CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr l, ValueComparingNonnullRefPtr c, ValueComparingNonnullRefPtr h, ValueComparingNonnullRefPtr alpha) - : CSSColorValue(color_type, ColorSyntax::Modern) + : ColorStyleValue(color_type, ColorSyntax::Modern) , m_properties { .l = move(l), .c = move(c), .h = move(h), .alpha = move(alpha) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.h b/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.h index d6b8eccf196..888d10c5219 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.h @@ -6,12 +6,12 @@ #pragma once -#include +#include #include namespace Web::CSS { -class CSSLabLike : public CSSColorValue { +class CSSLabLike : public ColorStyleValue { public: template static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr l, ValueComparingNonnullRefPtr a, ValueComparingNonnullRefPtr b, ValueComparingRefPtr alpha = {}) @@ -34,7 +34,7 @@ public: protected: CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr l, ValueComparingNonnullRefPtr a, ValueComparingNonnullRefPtr b, ValueComparingNonnullRefPtr alpha) - : CSSColorValue(color_type, ColorSyntax::Modern) + : ColorStyleValue(color_type, ColorSyntax::Modern) , m_properties { .l = move(l), .a = move(a), .b = move(b), .alpha = move(alpha) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.h b/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.h index e60a0d7c45f..24e29791dc7 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.h @@ -6,12 +6,12 @@ #pragma once -#include +#include namespace Web::CSS { // https://drafts.csswg.org/css-color-5/#funcdef-light-dark -class CSSLightDark final : public CSSColorValue { +class CSSLightDark final : public ColorStyleValue { public: virtual ~CSSLightDark() override = default; @@ -26,7 +26,7 @@ public: private: CSSLightDark(ValueComparingNonnullRefPtr light, ValueComparingNonnullRefPtr dark) - : CSSColorValue(CSSColorValue::ColorType::LightDark, ColorSyntax::Modern) + : ColorStyleValue(ColorStyleValue::ColorType::LightDark, ColorSyntax::Modern) , m_properties { .light = move(light), .dark = move(dark) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSRGB.h b/Libraries/LibWeb/CSS/StyleValues/CSSRGB.h index cdf622e2eca..4120638fc89 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSRGB.h +++ b/Libraries/LibWeb/CSS/StyleValues/CSSRGB.h @@ -6,13 +6,13 @@ #pragma once -#include +#include #include namespace Web::CSS { // https://drafts.css-houdini.org/css-typed-om-1/#cssrgb -class CSSRGB final : public CSSColorValue { +class CSSRGB final : public ColorStyleValue { public: static ValueComparingNonnullRefPtr create(ValueComparingNonnullRefPtr r, ValueComparingNonnullRefPtr g, ValueComparingNonnullRefPtr b, ValueComparingRefPtr alpha, ColorSyntax color_syntax, Optional name = {}) { @@ -37,7 +37,7 @@ public: private: CSSRGB(ValueComparingNonnullRefPtr r, ValueComparingNonnullRefPtr g, ValueComparingNonnullRefPtr b, ValueComparingNonnullRefPtr alpha, ColorSyntax color_syntax, Optional name = {}) - : CSSColorValue(ColorType::RGB, color_syntax) + : ColorStyleValue(ColorType::RGB, color_syntax) , m_properties { .r = move(r), .g = move(g), .b = move(b), .alpha = move(alpha), .name = name } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.cpp index 8b9faf28be6..7671ce889b8 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.cpp @@ -15,44 +15,44 @@ namespace Web::CSS { namespace { -CSSColorValue::ColorType color_type_from_string_view(StringView color_space) +ColorStyleValue::ColorType color_type_from_string_view(StringView color_space) { if (color_space == "a98-rgb"sv) - return CSSColorValue::ColorType::A98RGB; + return ColorStyleValue::ColorType::A98RGB; if (color_space == "display-p3"sv) - return CSSColorValue::ColorType::DisplayP3; + return ColorStyleValue::ColorType::DisplayP3; if (color_space == "srgb"sv) - return CSSColorValue::ColorType::sRGB; + return ColorStyleValue::ColorType::sRGB; if (color_space == "srgb-linear"sv) - return CSSColorValue::ColorType::sRGBLinear; + return ColorStyleValue::ColorType::sRGBLinear; if (color_space == "prophoto-rgb"sv) - return CSSColorValue::ColorType::ProPhotoRGB; + return ColorStyleValue::ColorType::ProPhotoRGB; if (color_space == "rec2020"sv) - return CSSColorValue::ColorType::Rec2020; + return ColorStyleValue::ColorType::Rec2020; if (color_space == "xyz-d50"sv) - return CSSColorValue::ColorType::XYZD50; + return ColorStyleValue::ColorType::XYZD50; if (color_space == "xyz"sv || color_space == "xyz-d65") - return CSSColorValue::ColorType::XYZD65; + return ColorStyleValue::ColorType::XYZD65; VERIFY_NOT_REACHED(); } -StringView string_view_from_color_type(CSSColorValue::ColorType color_type) +StringView string_view_from_color_type(ColorStyleValue::ColorType color_type) { - if (color_type == CSSColorValue::ColorType::A98RGB) + if (color_type == ColorStyleValue::ColorType::A98RGB) return "a98-rgb"sv; - if (color_type == CSSColorValue::ColorType::DisplayP3) + if (color_type == ColorStyleValue::ColorType::DisplayP3) return "display-p3"sv; - if (color_type == CSSColorValue::ColorType::sRGB) + if (color_type == ColorStyleValue::ColorType::sRGB) return "srgb"sv; - if (color_type == CSSColorValue::ColorType::sRGBLinear) + if (color_type == ColorStyleValue::ColorType::sRGBLinear) return "srgb-linear"sv; - if (color_type == CSSColorValue::ColorType::ProPhotoRGB) + if (color_type == ColorStyleValue::ColorType::ProPhotoRGB) return "prophoto-rgb"sv; - if (color_type == CSSColorValue::ColorType::Rec2020) + if (color_type == ColorStyleValue::ColorType::Rec2020) return "rec2020"sv; - if (color_type == CSSColorValue::ColorType::XYZD50) + if (color_type == ColorStyleValue::ColorType::XYZD50) return "xyz-d50"sv; - if (color_type == CSSColorValue::ColorType::XYZD65) + if (color_type == ColorStyleValue::ColorType::XYZD65) return "xyz-d65"sv; VERIFY_NOT_REACHED(); } diff --git a/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h index 64fdd6b86be..b555881bf72 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h @@ -6,12 +6,11 @@ #pragma once -#include +#include namespace Web::CSS { -// https://drafts.css-houdini.org/css-typed-om-1/#csscolor -class ColorFunctionStyleValue final : public CSSColorValue { +class ColorFunctionStyleValue final : public ColorStyleValue { public: virtual ~ColorFunctionStyleValue() override = default; @@ -27,7 +26,7 @@ public: private: ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr c1, ValueComparingNonnullRefPtr c2, ValueComparingNonnullRefPtr c3, ValueComparingNonnullRefPtr alpha) - : CSSColorValue(color_type, ColorSyntax::Modern) + : ColorStyleValue(color_type, ColorSyntax::Modern) , m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) } { } diff --git a/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.cpp index fb94aa038f6..1fc2af73956 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.cpp @@ -17,7 +17,7 @@ ValueComparingNonnullRefPtr ColorMixStyleValue::create } ColorMixStyleValue::ColorMixStyleValue(ColorInterpolationMethod color_interpolation_method, ColorMixComponent first_component, ColorMixComponent second_component) - : CSSColorValue(ColorType::ColorMix, ColorSyntax::Modern) + : ColorStyleValue(ColorType::ColorMix, ColorSyntax::Modern) , m_properties { .color_interpolation_method = move(color_interpolation_method), .first_component = move(first_component), diff --git a/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.h index f647c4bed56..b3e710f0819 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/ColorMixStyleValue.h @@ -7,11 +7,11 @@ #pragma once #include -#include +#include namespace Web::CSS { -class ColorMixStyleValue final : public CSSColorValue { +class ColorMixStyleValue final : public ColorStyleValue { public: virtual ~ColorMixStyleValue() override = default; diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.cpp similarity index 87% rename from Libraries/LibWeb/CSS/StyleValues/CSSColorValue.cpp rename to Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.cpp index e13fe465678..0cdcbec86df 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.cpp @@ -7,7 +7,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include "CSSColorValue.h" +#include "ColorStyleValue.h" #include #include #include @@ -19,7 +19,7 @@ namespace Web::CSS { -ValueComparingNonnullRefPtr CSSColorValue::create_from_color(Color color, ColorSyntax color_syntax, Optional name) +ValueComparingNonnullRefPtr ColorStyleValue::create_from_color(Color color, ColorSyntax color_syntax, Optional name) { return CSSRGB::create( NumberStyleValue::create(color.red()), @@ -30,7 +30,7 @@ ValueComparingNonnullRefPtr CSSColorValue::create_from_colo name); } -Optional CSSColorValue::resolve_hue(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) +Optional ColorStyleValue::resolve_hue(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) { // | | none auto normalized = [](double number) { @@ -74,7 +74,7 @@ Optional CSSColorValue::resolve_hue(StyleValue const& style_value, Calcu return 0; } -Optional CSSColorValue::resolve_with_reference_value(StyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context) +Optional ColorStyleValue::resolve_with_reference_value(StyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context) { // | | none auto normalize_percentage = [one_hundred_percent_value](Percentage const& percentage) { @@ -111,7 +111,7 @@ Optional CSSColorValue::resolve_with_reference_value(StyleValue const& s return 0; } -Optional CSSColorValue::resolve_alpha(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) +Optional ColorStyleValue::resolve_alpha(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) { // | | none auto normalized = [](double number) { @@ -153,7 +153,7 @@ Optional CSSColorValue::resolve_alpha(StyleValue const& style_value, Cal return 1; } -void CSSColorValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional clamp_min, Optional clamp_max) const +void ColorStyleValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional clamp_min, Optional clamp_max) const { if (component.to_keyword() == Keyword::None) { builder.append("none"sv); @@ -185,7 +185,7 @@ void CSSColorValue::serialize_color_component(StringBuilder& builder, Serializat builder.append(resolved_string); } -void CSSColorValue::serialize_alpha_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const +void ColorStyleValue::serialize_alpha_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const { if (component.to_keyword() == Keyword::None) { builder.append("none"sv); @@ -206,7 +206,7 @@ void CSSColorValue::serialize_alpha_component(StringBuilder& builder, Serializat builder.appendff("{}", maybe_resolved_value.value()); } -void CSSColorValue::serialize_hue_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const +void ColorStyleValue::serialize_hue_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component) const { if (component.to_keyword() == Keyword::None) { builder.append("none"sv); diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h similarity index 85% rename from Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h rename to Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h index 9f956d709e4..f671be387d8 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColorValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h @@ -20,11 +20,10 @@ enum class ColorSyntax : u8 { Modern, }; -// https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue -class CSSColorValue : public StyleValue { +class ColorStyleValue : public StyleValue { public: - static ValueComparingNonnullRefPtr create_from_color(Color color, ColorSyntax color_syntax, Optional name = {}); - virtual ~CSSColorValue() override = default; + static ValueComparingNonnullRefPtr create_from_color(Color color, ColorSyntax color_syntax, Optional name = {}); + virtual ~ColorStyleValue() override = default; virtual bool has_color() const override { return true; } @@ -51,7 +50,7 @@ public: ColorSyntax color_syntax() const { return m_color_syntax; } protected: - explicit CSSColorValue(ColorType color_type, ColorSyntax color_syntax) + explicit ColorStyleValue(ColorType color_type, ColorSyntax color_syntax) : StyleValue(Type::Color) , m_color_type(color_type) , m_color_syntax(color_syntax) diff --git a/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.h index 0b64fc5a523..a81df9bda5a 100644 --- a/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include namespace Web::CSS { diff --git a/Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h index a55fa3987f4..9dfdfa2663c 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include namespace Web::CSS { diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp index 491d9abcbdf..02f3295914f 100644 --- a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp @@ -19,9 +19,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValue.h b/Libraries/LibWeb/CSS/StyleValues/StyleValue.h index 96958a1515c..2cfc712bcac 100644 --- a/Libraries/LibWeb/CSS/StyleValues/StyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/StyleValue.h @@ -38,8 +38,8 @@ namespace Web::CSS { __ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderImageSlice, border_image_slice, BorderImageSliceStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderRadius, border_radius, BorderRadiusStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(Calculated, calculated, CalculatedStyleValue) \ - __ENUMERATE_CSS_STYLE_VALUE_TYPE(Color, color, CSSColorValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(ColorScheme, color_scheme, ColorSchemeStyleValue) \ + __ENUMERATE_CSS_STYLE_VALUE_TYPE(Color, color, ColorStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(ConicGradient, conic_gradient, ConicGradientStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(Content, content, ContentStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(Counter, counter, CounterStyleValue) \ diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp index e893c34a6c1..e0a45627804 100644 --- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp +++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 2ebaac90bf9..ef15025f8f6 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -214,13 +214,13 @@ class CascadedProperties; class Clip; class ColorMixStyleValue; class ColorSchemeStyleValue; +class ColorStyleValue; class ConicGradientStyleValue; class ContentStyleValue; class CounterDefinitionsStyleValue; class CounterStyleValue; class CountersSet; class CSSAnimation; -class CSSColorValue; class CSSConditionRule; class CSSDescriptors; class CSSFontFaceDescriptors; diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 2da76e0a143..558ed786940 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -65,12 +65,12 @@ void HTMLBodyElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == HTML::AttributeNames::text) { // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-2 auto color = parse_legacy_color_value(value); if (color.has_value()) - cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == HTML::AttributeNames::background) { VERIFY(m_background_style_value); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundImage, *m_background_style_value); diff --git a/Libraries/LibWeb/HTML/HTMLFontElement.cpp b/Libraries/LibWeb/HTML/HTMLFontElement.cpp index dbedc07beea..a8454a31bdb 100644 --- a/Libraries/LibWeb/HTML/HTMLFontElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFontElement.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -129,7 +129,7 @@ void HTMLFontElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::Color, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == AttributeNames::size) { // When a font element has a size attribute, the user agent is expected to use the following steps, known as the rules for parsing a legacy font size, to treat the attribute as a presentational hint setting the element's 'font-size' property: auto font_size_or_empty = parse_legacy_font_size(value); diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Libraries/LibWeb/HTML/HTMLHRElement.cpp index e2fa20e6a07..4888896e029 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ void HTMLHRElement::apply_presentational_hints(GC::Ref // the user agent is expected to treat the attribute as a presentational hint setting the element's 'color' property to the resulting color. if (name == HTML::AttributeNames::color) { if (auto parsed_value = parse_legacy_color_value(value); parsed_value.has_value()) { - cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::CSSColorValue::create_from_color(*parsed_value, CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Color, CSS::ColorStyleValue::create_from_color(*parsed_value, CSS::ColorSyntax::Legacy)); } } // https://html.spec.whatwg.org/multipage/rendering.html#the-hr-element-2:maps-to-the-dimension-property diff --git a/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp b/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp index 4aae2d6a849..d87fc43fe96 100644 --- a/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ void HTMLMarqueeElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == HTML::AttributeNames::height) { // https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:maps-to-the-dimension-property if (auto parsed_value = parse_dimension_value(value)) { diff --git a/Libraries/LibWeb/HTML/HTMLMetaElement.cpp b/Libraries/LibWeb/HTML/HTMLMetaElement.cpp index 2e1cf0af599..8d92051992c 100644 --- a/Libraries/LibWeb/HTML/HTMLMetaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMetaElement.cpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 2e875ad186b..eaeb6182ff2 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); return; } if (name == HTML::AttributeNames::valign) { diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Libraries/LibWeb/HTML/HTMLTableElement.cpp index efc8f1e9221..2274064ef8a 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -102,7 +102,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); return; } if (name == HTML::AttributeNames::cellspacing) { @@ -118,7 +118,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(style_property, legacy_line_style); cascaded_properties->set_property_from_presentational_hint(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(border))); - cascaded_properties->set_property_from_presentational_hint(color_property, CSS::CSSColorValue::create_from_color(Color(128, 128, 128), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(color_property, CSS::ColorStyleValue::create_from_color(Color(128, 128, 128), CSS::ColorSyntax::Legacy)); }; apply_border_style(CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor); apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor); @@ -131,7 +131,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BorderTopColor, color_value); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderRightColor, color_value); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderBottomColor, color_value); diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index 4c4ff2c1828..8c3a34771f3 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ void HTMLTableRowElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == HTML::AttributeNames::background) { // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:encoding-parsing-and-serializing-a-url if (auto parsed_value = document().encoding_parse_url(value); parsed_value.has_value()) diff --git a/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index 61dbfef7a20..8d3586eeef2 100644 --- a/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -122,7 +122,7 @@ void HTMLTableSectionElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::CSSColorValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create_from_color(color.value(), CSS::ColorSyntax::Legacy)); } else if (name == HTML::AttributeNames::height) { if (auto parsed_value = parse_dimension_value(value)) cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Height, parsed_value.release_nonnull());