LibWeb/CSS: Rename CSSColorValue -> ColorStyleValue

The typed-om class will be a separate thing.
This commit is contained in:
Sam Atkins 2025-08-08 11:24:15 +01:00 committed by Tim Ledbetter
commit 6cad3f1921
Notes: github-actions[bot] 2025-08-08 14:20:25 +00:00
35 changed files with 97 additions and 99 deletions

View file

@ -196,11 +196,11 @@ set(SOURCES
CSS/StyleValues/ColorFunctionStyleValue.cpp CSS/StyleValues/ColorFunctionStyleValue.cpp
CSS/StyleValues/ColorMixStyleValue.cpp CSS/StyleValues/ColorMixStyleValue.cpp
CSS/StyleValues/ColorSchemeStyleValue.cpp CSS/StyleValues/ColorSchemeStyleValue.cpp
CSS/StyleValues/ColorStyleValue.cpp
CSS/StyleValues/ConicGradientStyleValue.cpp CSS/StyleValues/ConicGradientStyleValue.cpp
CSS/StyleValues/ContentStyleValue.cpp CSS/StyleValues/ContentStyleValue.cpp
CSS/StyleValues/CounterDefinitionsStyleValue.cpp CSS/StyleValues/CounterDefinitionsStyleValue.cpp
CSS/StyleValues/CounterStyleValue.cpp CSS/StyleValues/CounterStyleValue.cpp
CSS/StyleValues/CSSColorValue.cpp
CSS/StyleValues/CSSHSL.cpp CSS/StyleValues/CSSHSL.cpp
CSS/StyleValues/CSSHWB.cpp CSS/StyleValues/CSSHWB.cpp
CSS/StyleValues/CSSLabLike.cpp CSS/StyleValues/CSSLabLike.cpp

View file

@ -364,7 +364,7 @@ static RefPtr<StyleValue const> style_value_for_shadow(Vector<ShadowData> const&
auto make_shadow_style_value = [](ShadowData const& shadow) { auto make_shadow_style_value = [](ShadowData const& shadow) {
return ShadowStyleValue::create( 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_x),
style_value_for_length_percentage(shadow.offset_y), style_value_for_length_percentage(shadow.offset_y),
style_value_for_length_percentage(shadow.blur_radius), style_value_for_length_percentage(shadow.blur_radius),
@ -474,12 +474,12 @@ static RefPtr<StyleValue const> resolve_color_style_value(StyleValue const& styl
if (style_value.is_color_function()) if (style_value.is_color_function())
return style_value; return style_value;
if (style_value.is_color()) { if (style_value.is_color()) {
auto& color_style_value = static_cast<CSSColorValue const&>(style_value); auto& color_style_value = static_cast<ColorStyleValue const&>(style_value);
if (first_is_one_of(color_style_value.color_type(), CSSColorValue::ColorType::Lab, CSSColorValue::ColorType::OKLab, CSSColorValue::ColorType::LCH, CSSColorValue::ColorType::OKLCH)) 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 style_value;
} }
return CSSColorValue::create_from_color(computed_color, ColorSyntax::Modern); return ColorStyleValue::create_from_color(computed_color, ColorSyntax::Modern);
} }
RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const

View file

@ -14,8 +14,8 @@
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h> #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h> #include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/FontStyleStyleValue.h> #include <LibWeb/CSS/StyleValues/FontStyleStyleValue.h>
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h> #include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
@ -936,7 +936,7 @@ RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, Calculati
values.ensure_capacity(other.size()); values.ensure_capacity(other.size());
for (size_t i = values.size(); i < other.size(); i++) { for (size_t i = values.size(); i < other.size(); i++) {
values.unchecked_append(ShadowStyleValue::create( 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)), LengthStyleValue::create(Length::make_px(0)),
LengthStyleValue::create(Length::make_px(0)), LengthStyleValue::create(Length::make_px(0)),
@ -987,7 +987,7 @@ RefPtr<StyleValue const> interpolate_box_shadow(DOM::Element& element, Calculati
interpolated_color = interpolate_color(from_color.value(), to_color.value(), delta, color_syntax); interpolated_color = interpolate_color(from_color.value(), to_color.value(), delta, color_syntax);
auto result_shadow = ShadowStyleValue::create( 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_x,
*interpolated_offset_y, *interpolated_offset_y,
*interpolated_blur_radius, *interpolated_blur_radius,
@ -1119,7 +1119,7 @@ static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, Ca
if (from_color.has_value() && to_color.has_value()) if (from_color.has_value() && to_color.has_value())
interpolated_color = interpolate_color(from_color.value(), to_color.value(), delta, color_syntax); 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: { case StyleValue::Type::Edge: {
auto resolved_from = from.as_edge().resolved_value(calculation_context); auto resolved_from = from.as_edge().resolved_value(calculation_context);

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <LibWeb/CSS/Enums.h> #include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h> #include <LibWeb/CSS/StyleValues/StyleValue.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>

View file

@ -22,8 +22,8 @@
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderImageSliceStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderImageSliceStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h> #include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h> #include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
#include <LibWeb/CSS/StyleValues/CursorStyleValue.h> #include <LibWeb/CSS/StyleValues/CursorStyleValue.h>

View file

@ -27,7 +27,6 @@
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h> #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
#include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h> #include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/CSSHSL.h> #include <LibWeb/CSS/StyleValues/CSSHSL.h>
#include <LibWeb/CSS/StyleValues/CSSHWB.h> #include <LibWeb/CSS/StyleValues/CSSHWB.h>
#include <LibWeb/CSS/StyleValues/CSSLCHLike.h> #include <LibWeb/CSS/StyleValues/CSSLCHLike.h>
@ -36,6 +35,7 @@
#include <LibWeb/CSS/StyleValues/CSSRGB.h> #include <LibWeb/CSS/StyleValues/CSSRGB.h>
#include <LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorFunctionStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorMixStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorMixStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h> #include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h> #include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterStyleValue.h> #include <LibWeb/CSS/StyleValues/CounterStyleValue.h>
@ -2206,7 +2206,7 @@ RefPtr<StyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>&
auto color = Color::from_string(ident); auto color = Color::from_string(ident);
if (color.has_value()) { if (color.has_value()) {
transaction.commit(); 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 // Otherwise, fall through to the hashless-hex-color case
} }
@ -2215,7 +2215,7 @@ RefPtr<StyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>&
auto color = Color::from_string(MUST(String::formatted("#{}", component_value.token().hash_value()))); auto color = Color::from_string(MUST(String::formatted("#{}", component_value.token().hash_value())));
if (color.has_value()) { if (color.has_value()) {
transaction.commit(); transaction.commit();
return CSSColorValue::create_from_color(color.release_value(), ColorSyntax::Legacy); return ColorStyleValue::create_from_color(color.release_value(), ColorSyntax::Legacy);
} }
return {}; return {};
} }
@ -2299,7 +2299,7 @@ RefPtr<StyleValue const> Parser::parse_color_value(TokenStream<ComponentValue>&
auto color = Color::from_string(MUST(String::formatted("#{}", serialization))); auto color = Color::from_string(MUST(String::formatted("#{}", serialization)));
if (color.has_value()) { if (color.has_value()) {
transaction.commit(); transaction.commit();
return CSSColorValue::create_from_color(color.release_value(), ColorSyntax::Legacy); return ColorStyleValue::create_from_color(color.release_value(), ColorSyntax::Legacy);
} }
} }
} }

View file

@ -47,7 +47,7 @@
#include <LibWeb/CSS/StyleSheet.h> #include <LibWeb/CSS/StyleSheet.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h> #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h> #include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h> #include <LibWeb/CSS/StyleValues/EasingStyleValue.h>

View file

@ -12,7 +12,7 @@
#include <LibWeb/CSS/Enums.h> #include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/PercentageOr.h> #include <LibWeb/CSS/PercentageOr.h>
#include <LibWeb/CSS/Serialize.h> #include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h> #include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS { namespace Web::CSS {

View file

@ -6,13 +6,13 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csshsl // https://drafts.css-houdini.org/css-typed-om-1/#csshsl
class CSSHSL final : public CSSColorValue { class CSSHSL final : public ColorStyleValue {
public: public:
static ValueComparingNonnullRefPtr<CSSHSL const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax) static ValueComparingNonnullRefPtr<CSSHSL const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax)
{ {
@ -37,7 +37,7 @@ public:
private: private:
CSSHSL(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> alpha, ColorSyntax color_syntax) CSSHSL(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> s, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> 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) } , m_properties { .h = move(h), .s = move(s), .l = move(l), .alpha = move(alpha) }
{ {
} }

View file

@ -6,13 +6,13 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csshwb // https://drafts.css-houdini.org/css-typed-om-1/#csshwb
class CSSHWB final : public CSSColorValue { class CSSHWB final : public ColorStyleValue {
public: public:
static ValueComparingNonnullRefPtr<CSSHWB const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {}) static ValueComparingNonnullRefPtr<CSSHWB const> create(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {})
{ {
@ -37,7 +37,7 @@ public:
private: private:
CSSHWB(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha) CSSHWB(ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> w, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> 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) } , m_properties { .h = move(h), .w = move(w), .b = move(b), .alpha = move(alpha) }
{ {
} }

View file

@ -6,12 +6,12 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
class CSSLCHLike : public CSSColorValue { class CSSLCHLike : public ColorStyleValue {
public: public:
template<DerivedFrom<CSSLCHLike> T> template<DerivedFrom<CSSLCHLike> T>
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingRefPtr<StyleValue const> alpha = {}) static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingRefPtr<StyleValue const> alpha = {})
@ -33,7 +33,7 @@ public:
protected: protected:
CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> alpha) CSSLCHLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> c, ValueComparingNonnullRefPtr<StyleValue const> h, ValueComparingNonnullRefPtr<StyleValue const> 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) } , m_properties { .l = move(l), .c = move(c), .h = move(h), .alpha = move(alpha) }
{ {
} }

View file

@ -6,12 +6,12 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
class CSSLabLike : public CSSColorValue { class CSSLabLike : public ColorStyleValue {
public: public:
template<typename T> template<typename T>
static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {}) static ValueComparingNonnullRefPtr<T const> create(ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha = {})
@ -34,7 +34,7 @@ public:
protected: protected:
CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha) CSSLabLike(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> l, ValueComparingNonnullRefPtr<StyleValue const> a, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> 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) } , m_properties { .l = move(l), .a = move(a), .b = move(b), .alpha = move(alpha) }
{ {
} }

View file

@ -6,12 +6,12 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
// https://drafts.csswg.org/css-color-5/#funcdef-light-dark // https://drafts.csswg.org/css-color-5/#funcdef-light-dark
class CSSLightDark final : public CSSColorValue { class CSSLightDark final : public ColorStyleValue {
public: public:
virtual ~CSSLightDark() override = default; virtual ~CSSLightDark() override = default;
@ -26,7 +26,7 @@ public:
private: private:
CSSLightDark(ValueComparingNonnullRefPtr<StyleValue const> light, ValueComparingNonnullRefPtr<StyleValue const> dark) CSSLightDark(ValueComparingNonnullRefPtr<StyleValue const> light, ValueComparingNonnullRefPtr<StyleValue const> dark)
: CSSColorValue(CSSColorValue::ColorType::LightDark, ColorSyntax::Modern) : ColorStyleValue(ColorStyleValue::ColorType::LightDark, ColorSyntax::Modern)
, m_properties { .light = move(light), .dark = move(dark) } , m_properties { .light = move(light), .dark = move(dark) }
{ {
} }

View file

@ -6,13 +6,13 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#cssrgb // https://drafts.css-houdini.org/css-typed-om-1/#cssrgb
class CSSRGB final : public CSSColorValue { class CSSRGB final : public ColorStyleValue {
public: public:
static ValueComparingNonnullRefPtr<CSSRGB const> create(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {}) static ValueComparingNonnullRefPtr<CSSRGB const> create(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {})
{ {
@ -37,7 +37,7 @@ public:
private: private:
CSSRGB(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> name = {}) CSSRGB(ValueComparingNonnullRefPtr<StyleValue const> r, ValueComparingNonnullRefPtr<StyleValue const> g, ValueComparingNonnullRefPtr<StyleValue const> b, ValueComparingNonnullRefPtr<StyleValue const> alpha, ColorSyntax color_syntax, Optional<FlyString> 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 } , m_properties { .r = move(r), .g = move(g), .b = move(b), .alpha = move(alpha), .name = name }
{ {
} }

View file

@ -15,44 +15,44 @@ namespace Web::CSS {
namespace { 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) if (color_space == "a98-rgb"sv)
return CSSColorValue::ColorType::A98RGB; return ColorStyleValue::ColorType::A98RGB;
if (color_space == "display-p3"sv) if (color_space == "display-p3"sv)
return CSSColorValue::ColorType::DisplayP3; return ColorStyleValue::ColorType::DisplayP3;
if (color_space == "srgb"sv) if (color_space == "srgb"sv)
return CSSColorValue::ColorType::sRGB; return ColorStyleValue::ColorType::sRGB;
if (color_space == "srgb-linear"sv) if (color_space == "srgb-linear"sv)
return CSSColorValue::ColorType::sRGBLinear; return ColorStyleValue::ColorType::sRGBLinear;
if (color_space == "prophoto-rgb"sv) if (color_space == "prophoto-rgb"sv)
return CSSColorValue::ColorType::ProPhotoRGB; return ColorStyleValue::ColorType::ProPhotoRGB;
if (color_space == "rec2020"sv) if (color_space == "rec2020"sv)
return CSSColorValue::ColorType::Rec2020; return ColorStyleValue::ColorType::Rec2020;
if (color_space == "xyz-d50"sv) if (color_space == "xyz-d50"sv)
return CSSColorValue::ColorType::XYZD50; return ColorStyleValue::ColorType::XYZD50;
if (color_space == "xyz"sv || color_space == "xyz-d65") if (color_space == "xyz"sv || color_space == "xyz-d65")
return CSSColorValue::ColorType::XYZD65; return ColorStyleValue::ColorType::XYZD65;
VERIFY_NOT_REACHED(); 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; return "a98-rgb"sv;
if (color_type == CSSColorValue::ColorType::DisplayP3) if (color_type == ColorStyleValue::ColorType::DisplayP3)
return "display-p3"sv; return "display-p3"sv;
if (color_type == CSSColorValue::ColorType::sRGB) if (color_type == ColorStyleValue::ColorType::sRGB)
return "srgb"sv; return "srgb"sv;
if (color_type == CSSColorValue::ColorType::sRGBLinear) if (color_type == ColorStyleValue::ColorType::sRGBLinear)
return "srgb-linear"sv; return "srgb-linear"sv;
if (color_type == CSSColorValue::ColorType::ProPhotoRGB) if (color_type == ColorStyleValue::ColorType::ProPhotoRGB)
return "prophoto-rgb"sv; return "prophoto-rgb"sv;
if (color_type == CSSColorValue::ColorType::Rec2020) if (color_type == ColorStyleValue::ColorType::Rec2020)
return "rec2020"sv; return "rec2020"sv;
if (color_type == CSSColorValue::ColorType::XYZD50) if (color_type == ColorStyleValue::ColorType::XYZD50)
return "xyz-d50"sv; return "xyz-d50"sv;
if (color_type == CSSColorValue::ColorType::XYZD65) if (color_type == ColorStyleValue::ColorType::XYZD65)
return "xyz-d65"sv; return "xyz-d65"sv;
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }

View file

@ -6,12 +6,11 @@
#pragma once #pragma once
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csscolor class ColorFunctionStyleValue final : public ColorStyleValue {
class ColorFunctionStyleValue final : public CSSColorValue {
public: public:
virtual ~ColorFunctionStyleValue() override = default; virtual ~ColorFunctionStyleValue() override = default;
@ -27,7 +26,7 @@ public:
private: private:
ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> c1, ValueComparingNonnullRefPtr<StyleValue const> c2, ValueComparingNonnullRefPtr<StyleValue const> c3, ValueComparingNonnullRefPtr<StyleValue const> alpha) ColorFunctionStyleValue(ColorType color_type, ValueComparingNonnullRefPtr<StyleValue const> c1, ValueComparingNonnullRefPtr<StyleValue const> c2, ValueComparingNonnullRefPtr<StyleValue const> c3, ValueComparingNonnullRefPtr<StyleValue const> alpha)
: CSSColorValue(color_type, ColorSyntax::Modern) : ColorStyleValue(color_type, ColorSyntax::Modern)
, m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) } , m_properties { .channels = { move(c1), move(c2), move(c3) }, .alpha = move(alpha) }
{ {
} }

View file

@ -17,7 +17,7 @@ ValueComparingNonnullRefPtr<ColorMixStyleValue const> ColorMixStyleValue::create
} }
ColorMixStyleValue::ColorMixStyleValue(ColorInterpolationMethod color_interpolation_method, ColorMixComponent first_component, ColorMixComponent second_component) ColorMixStyleValue::ColorMixStyleValue(ColorInterpolationMethod color_interpolation_method, ColorMixComponent first_component, ColorMixComponent second_component)
: CSSColorValue(ColorType::ColorMix, ColorSyntax::Modern) : ColorStyleValue(ColorType::ColorMix, ColorSyntax::Modern)
, m_properties { , m_properties {
.color_interpolation_method = move(color_interpolation_method), .color_interpolation_method = move(color_interpolation_method),
.first_component = move(first_component), .first_component = move(first_component),

View file

@ -7,11 +7,11 @@
#pragma once #pragma once
#include <LibWeb/CSS/CalculatedOr.h> #include <LibWeb/CSS/CalculatedOr.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
namespace Web::CSS { namespace Web::CSS {
class ColorMixStyleValue final : public CSSColorValue { class ColorMixStyleValue final : public ColorStyleValue {
public: public:
virtual ~ColorMixStyleValue() override = default; virtual ~ColorMixStyleValue() override = default;

View file

@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include "CSSColorValue.h" #include "ColorStyleValue.h"
#include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/AbstractOperations.h>
#include <LibWeb/CSS/Serialize.h> #include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h> #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
@ -19,7 +19,7 @@
namespace Web::CSS { namespace Web::CSS {
ValueComparingNonnullRefPtr<CSSColorValue const> CSSColorValue::create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name) ValueComparingNonnullRefPtr<ColorStyleValue const> ColorStyleValue::create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name)
{ {
return CSSRGB::create( return CSSRGB::create(
NumberStyleValue::create(color.red()), NumberStyleValue::create(color.red()),
@ -30,7 +30,7 @@ ValueComparingNonnullRefPtr<CSSColorValue const> CSSColorValue::create_from_colo
name); name);
} }
Optional<double> CSSColorValue::resolve_hue(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) Optional<double> ColorStyleValue::resolve_hue(StyleValue const& style_value, CalculationResolutionContext const& resolution_context)
{ {
// <number> | <angle> | none // <number> | <angle> | none
auto normalized = [](double number) { auto normalized = [](double number) {
@ -74,7 +74,7 @@ Optional<double> CSSColorValue::resolve_hue(StyleValue const& style_value, Calcu
return 0; return 0;
} }
Optional<double> CSSColorValue::resolve_with_reference_value(StyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context) Optional<double> ColorStyleValue::resolve_with_reference_value(StyleValue const& style_value, float one_hundred_percent_value, CalculationResolutionContext const& resolution_context)
{ {
// <percentage> | <number> | none // <percentage> | <number> | none
auto normalize_percentage = [one_hundred_percent_value](Percentage const& percentage) { auto normalize_percentage = [one_hundred_percent_value](Percentage const& percentage) {
@ -111,7 +111,7 @@ Optional<double> CSSColorValue::resolve_with_reference_value(StyleValue const& s
return 0; return 0;
} }
Optional<double> CSSColorValue::resolve_alpha(StyleValue const& style_value, CalculationResolutionContext const& resolution_context) Optional<double> ColorStyleValue::resolve_alpha(StyleValue const& style_value, CalculationResolutionContext const& resolution_context)
{ {
// <number> | <percentage> | none // <number> | <percentage> | none
auto normalized = [](double number) { auto normalized = [](double number) {
@ -153,7 +153,7 @@ Optional<double> CSSColorValue::resolve_alpha(StyleValue const& style_value, Cal
return 1; return 1;
} }
void CSSColorValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min, Optional<double> clamp_max) const void ColorStyleValue::serialize_color_component(StringBuilder& builder, SerializationMode mode, StyleValue const& component, float one_hundred_percent_value, Optional<double> clamp_min, Optional<double> clamp_max) const
{ {
if (component.to_keyword() == Keyword::None) { if (component.to_keyword() == Keyword::None) {
builder.append("none"sv); builder.append("none"sv);
@ -185,7 +185,7 @@ void CSSColorValue::serialize_color_component(StringBuilder& builder, Serializat
builder.append(resolved_string); 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) { if (component.to_keyword() == Keyword::None) {
builder.append("none"sv); builder.append("none"sv);
@ -206,7 +206,7 @@ void CSSColorValue::serialize_alpha_component(StringBuilder& builder, Serializat
builder.appendff("{}", maybe_resolved_value.value()); 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) { if (component.to_keyword() == Keyword::None) {
builder.append("none"sv); builder.append("none"sv);

View file

@ -20,11 +20,10 @@ enum class ColorSyntax : u8 {
Modern, Modern,
}; };
// https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue class ColorStyleValue : public StyleValue {
class CSSColorValue : public StyleValue {
public: public:
static ValueComparingNonnullRefPtr<CSSColorValue const> create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name = {}); static ValueComparingNonnullRefPtr<ColorStyleValue const> create_from_color(Color color, ColorSyntax color_syntax, Optional<FlyString> name = {});
virtual ~CSSColorValue() override = default; virtual ~ColorStyleValue() override = default;
virtual bool has_color() const override { return true; } virtual bool has_color() const override { return true; }
@ -51,7 +50,7 @@ public:
ColorSyntax color_syntax() const { return m_color_syntax; } ColorSyntax color_syntax() const { return m_color_syntax; }
protected: protected:
explicit CSSColorValue(ColorType color_type, ColorSyntax color_syntax) explicit ColorStyleValue(ColorType color_type, ColorSyntax color_syntax)
: StyleValue(Type::Color) : StyleValue(Type::Color)
, m_color_type(color_type) , m_color_type(color_type)
, m_color_syntax(color_syntax) , m_color_syntax(color_syntax)

View file

@ -13,7 +13,7 @@
#include <LibWeb/CSS/Angle.h> #include <LibWeb/CSS/Angle.h>
#include <LibWeb/CSS/Percentage.h> #include <LibWeb/CSS/Percentage.h>
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h> #include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/Painting/GradientPainting.h> #include <LibWeb/Painting/GradientPainting.h>
namespace Web::CSS { namespace Web::CSS {

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h> #include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS { namespace Web::CSS {

View file

@ -19,9 +19,9 @@
#include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h> #include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderImageSliceStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderImageSliceStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h> #include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h> #include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h> #include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h> #include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>

View file

@ -38,8 +38,8 @@ namespace Web::CSS {
__ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderImageSlice, border_image_slice, BorderImageSliceStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderImageSlice, border_image_slice, BorderImageSliceStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderRadius, border_radius, BorderRadiusStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(BorderRadius, border_radius, BorderRadiusStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Calculated, calculated, CalculatedStyleValue) \ __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(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(ConicGradient, conic_gradient, ConicGradientStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Content, content, ContentStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(Content, content, ContentStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Counter, counter, CounterStyleValue) \ __ENUMERATE_CSS_STYLE_VALUE_TYPE(Counter, counter, CounterStyleValue) \

View file

@ -7,7 +7,7 @@
#include <LibGfx/Color.h> #include <LibGfx/Color.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h> #include <LibWeb/CSS/StyleValues/StyleValueList.h>

View file

@ -214,13 +214,13 @@ class CascadedProperties;
class Clip; class Clip;
class ColorMixStyleValue; class ColorMixStyleValue;
class ColorSchemeStyleValue; class ColorSchemeStyleValue;
class ColorStyleValue;
class ConicGradientStyleValue; class ConicGradientStyleValue;
class ContentStyleValue; class ContentStyleValue;
class CounterDefinitionsStyleValue; class CounterDefinitionsStyleValue;
class CounterStyleValue; class CounterStyleValue;
class CountersSet; class CountersSet;
class CSSAnimation; class CSSAnimation;
class CSSColorValue;
class CSSConditionRule; class CSSConditionRule;
class CSSDescriptors; class CSSDescriptors;
class CSSFontFaceDescriptors; class CSSFontFaceDescriptors;

View file

@ -6,7 +6,7 @@
#include <LibWeb/Bindings/HTMLBodyElementPrototype.h> #include <LibWeb/Bindings/HTMLBodyElementPrototype.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
@ -65,12 +65,12 @@ void HTMLBodyElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
cascaded_properties->set_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) { } else if (name == HTML::AttributeNames::text) {
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-2 // 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); auto color = parse_legacy_color_value(value);
if (color.has_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) { } else if (name == HTML::AttributeNames::background) {
VERIFY(m_background_style_value); VERIFY(m_background_style_value);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundImage, *m_background_style_value); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BackgroundImage, *m_background_style_value);

View file

@ -9,7 +9,7 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/HTML/HTMLFontElement.h> #include <LibWeb/HTML/HTMLFontElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h> #include <LibWeb/Infra/CharacterTypes.h>
@ -129,7 +129,7 @@ void HTMLFontElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties
// https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_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 == AttributeNames::size) { } 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: // 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); auto font_size_or_empty = parse_legacy_font_size(value);

View file

@ -8,7 +8,7 @@
#include <LibWeb/Bindings/HTMLHRElementPrototype.h> #include <LibWeb/Bindings/HTMLHRElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/HTML/HTMLHRElement.h> #include <LibWeb/HTML/HTMLHRElement.h>
@ -68,7 +68,7 @@ void HTMLHRElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties>
// the user agent is expected to treat the attribute as a presentational hint setting the element's 'color' property to the resulting color. // 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 (name == HTML::AttributeNames::color) {
if (auto parsed_value = parse_legacy_color_value(value); parsed_value.has_value()) { 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 // https://html.spec.whatwg.org/multipage/rendering.html#the-hr-element-2:maps-to-the-dimension-property

View file

@ -8,7 +8,7 @@
#include <LibWeb/Bindings/HTMLMarqueeElementPrototype.h> #include <LibWeb/Bindings/HTMLMarqueeElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/HTML/HTMLMarqueeElement.h> #include <LibWeb/HTML/HTMLMarqueeElement.h>
#include <LibWeb/HTML/Numbers.h> #include <LibWeb/HTML/Numbers.h>
#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Parser/HTMLParser.h>
@ -51,7 +51,7 @@ void HTMLMarqueeElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropert
// https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
cascaded_properties->set_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) { } else if (name == HTML::AttributeNames::height) {
// https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:maps-to-the-dimension-property // 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)) { if (auto parsed_value = parse_dimension_value(value)) {

View file

@ -10,8 +10,8 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h> #include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
#include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/ContentSecurityPolicy/Directives/Names.h> #include <LibWeb/ContentSecurityPolicy/Directives/Names.h>
#include <LibWeb/ContentSecurityPolicy/PolicyList.h> #include <LibWeb/ContentSecurityPolicy/PolicyList.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>

View file

@ -9,7 +9,7 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
@ -59,7 +59,7 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Ref<CSS::CascadedPrope
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
cascaded_properties->set_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; return;
} }
if (name == HTML::AttributeNames::valign) { if (name == HTML::AttributeNames::valign) {

View file

@ -9,7 +9,7 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
@ -102,7 +102,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropertie
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
cascaded_properties->set_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; return;
} }
if (name == HTML::AttributeNames::cellspacing) { if (name == HTML::AttributeNames::cellspacing) {
@ -118,7 +118,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropertie
auto legacy_line_style = CSS::KeywordStyleValue::create(CSS::Keyword::Outset); auto legacy_line_style = CSS::KeywordStyleValue::create(CSS::Keyword::Outset);
cascaded_properties->set_property_from_presentational_hint(style_property, legacy_line_style); cascaded_properties->set_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(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::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor);
apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor); apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor);
@ -131,7 +131,7 @@ void HTMLTableElement::apply_presentational_hints(GC::Ref<CSS::CascadedPropertie
// and if that does not return failure, the user agent is expected to treat the attribute as a presentational hint setting the element's // and if that does not return failure, the user agent is expected to treat the attribute as a presentational hint setting the element's
// 'border-top-color', 'border-right-color', 'border-bottom-color', and 'border-left-color' properties to the resulting color. // 'border-top-color', 'border-right-color', 'border-bottom-color', and 'border-left-color' properties to the resulting color.
if (auto parsed_color = parse_legacy_color_value(value); parsed_color.has_value()) { if (auto parsed_color = parse_legacy_color_value(value); parsed_color.has_value()) {
auto color_value = CSS::CSSColorValue::create_from_color(parsed_color.value(), CSS::ColorSyntax::Legacy); auto color_value = CSS::ColorStyleValue::create_from_color(parsed_color.value(), CSS::ColorSyntax::Legacy);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderTopColor, color_value); cascaded_properties->set_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::BorderRightColor, color_value);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderBottomColor, color_value); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderBottomColor, color_value);

View file

@ -8,7 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
@ -58,7 +58,7 @@ void HTMLTableRowElement::apply_presentational_hints(GC::Ref<CSS::CascadedProper
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
cascaded_properties->set_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) { } else if (name == HTML::AttributeNames::background) {
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:encoding-parsing-and-serializing-a-url // 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()) if (auto parsed_value = document().encoding_parse_url(value); parsed_value.has_value())

View file

@ -8,7 +8,7 @@
#include <LibWeb/Bindings/HTMLTableSectionElementPrototype.h> #include <LibWeb/Bindings/HTMLTableSectionElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/StyleValues/CSSColorValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
@ -122,7 +122,7 @@ void HTMLTableSectionElement::apply_presentational_hints(GC::Ref<CSS::CascadedPr
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
else if (name == HTML::AttributeNames::bgcolor) { else if (name == HTML::AttributeNames::bgcolor) {
if (auto color = parse_legacy_color_value(value); color.has_value()) if (auto color = parse_legacy_color_value(value); color.has_value())
cascaded_properties->set_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) { } else if (name == HTML::AttributeNames::height) {
if (auto parsed_value = parse_dimension_value(value)) if (auto parsed_value = parse_dimension_value(value))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Height, parsed_value.release_nonnull()); cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::Height, parsed_value.release_nonnull());