LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue

This matches the name in the CSS Typed OM spec.
https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
This commit is contained in:
Sam Atkins 2024-08-14 11:46:56 +01:00 committed by Sam Atkins
commit 9559f0f123
Notes: github-actions[bot] 2024-08-15 12:59:38 +00:00
25 changed files with 137 additions and 136 deletions

View file

@ -7,6 +7,7 @@ source_set("StyleValues") {
"BackgroundSizeStyleValue.cpp", "BackgroundSizeStyleValue.cpp",
"BasicShapeStyleValue.cpp", "BasicShapeStyleValue.cpp",
"BorderRadiusStyleValue.cpp", "BorderRadiusStyleValue.cpp",
"CSSKeywordValue.cpp",
"CalculatedStyleValue.cpp", "CalculatedStyleValue.cpp",
"ColorStyleValue.cpp", "ColorStyleValue.cpp",
"ConicGradientStyleValue.cpp", "ConicGradientStyleValue.cpp",
@ -19,7 +20,6 @@ source_set("StyleValues") {
"GridTemplateAreaStyleValue.cpp", "GridTemplateAreaStyleValue.cpp",
"GridTrackPlacementStyleValue.cpp", "GridTrackPlacementStyleValue.cpp",
"GridTrackSizeListStyleValue.cpp", "GridTrackSizeListStyleValue.cpp",
"IdentifierStyleValue.cpp",
"ImageStyleValue.cpp", "ImageStyleValue.cpp",
"IntegerStyleValue.cpp", "IntegerStyleValue.cpp",
"LengthStyleValue.cpp", "LengthStyleValue.cpp",

View file

@ -113,6 +113,7 @@ set(SOURCES
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/CSSKeywordValue.cpp
CSS/StyleValues/DisplayStyleValue.cpp CSS/StyleValues/DisplayStyleValue.cpp
CSS/StyleValues/EasingStyleValue.cpp CSS/StyleValues/EasingStyleValue.cpp
CSS/StyleValues/EdgeStyleValue.cpp CSS/StyleValues/EdgeStyleValue.cpp
@ -121,7 +122,6 @@ set(SOURCES
CSS/StyleValues/GridTemplateAreaStyleValue.cpp CSS/StyleValues/GridTemplateAreaStyleValue.cpp
CSS/StyleValues/GridTrackPlacementStyleValue.cpp CSS/StyleValues/GridTrackPlacementStyleValue.cpp
CSS/StyleValues/GridTrackSizeListStyleValue.cpp CSS/StyleValues/GridTrackSizeListStyleValue.cpp
CSS/StyleValues/IdentifierStyleValue.cpp
CSS/StyleValues/ImageStyleValue.cpp CSS/StyleValues/ImageStyleValue.cpp
CSS/StyleValues/IntegerStyleValue.cpp CSS/StyleValues/IntegerStyleValue.cpp
CSS/StyleValues/LengthStyleValue.cpp CSS/StyleValues/LengthStyleValue.cpp

View file

@ -16,6 +16,7 @@
#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/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h> #include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h> #include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
@ -33,7 +34,6 @@
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/InheritStyleValue.h> #include <LibWeb/CSS/StyleValues/InheritStyleValue.h>
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h> #include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
@ -206,10 +206,10 @@ GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() cons
return static_cast<GridTrackSizeListStyleValue const&>(*this); return static_cast<GridTrackSizeListStyleValue const&>(*this);
} }
IdentifierStyleValue const& CSSStyleValue::as_identifier() const CSSKeywordValue const& CSSStyleValue::as_keyword() const
{ {
VERIFY(is_identifier()); VERIFY(is_keyword());
return static_cast<IdentifierStyleValue const&>(*this); return static_cast<CSSKeywordValue const&>(*this);
} }
ImageStyleValue const& CSSStyleValue::as_image() const ImageStyleValue const& CSSStyleValue::as_image() const
@ -375,20 +375,20 @@ ValueComparingNonnullRefPtr<CSSStyleValue const> CSSStyleValue::absolutized(CSSP
bool CSSStyleValue::has_auto() const bool CSSStyleValue::has_auto() const
{ {
return is_identifier() && as_identifier().id() == ValueID::Auto; return is_keyword() && as_keyword().id() == ValueID::Auto;
} }
ValueID CSSStyleValue::to_identifier() const ValueID CSSStyleValue::to_identifier() const
{ {
if (is_identifier()) if (is_keyword())
return as_identifier().id(); return as_keyword().id();
return ValueID::Invalid; return ValueID::Invalid;
} }
int CSSStyleValue::to_font_weight() const int CSSStyleValue::to_font_weight() const
{ {
if (is_identifier()) { if (is_keyword()) {
switch (static_cast<IdentifierStyleValue const&>(*this).id()) { switch (static_cast<CSSKeywordValue const&>(*this).id()) {
case CSS::ValueID::Normal: case CSS::ValueID::Normal:
return Gfx::FontWeight::Regular; return Gfx::FontWeight::Regular;
case CSS::ValueID::Bold: case CSS::ValueID::Bold:
@ -417,8 +417,8 @@ int CSSStyleValue::to_font_weight() const
int CSSStyleValue::to_font_slope() const int CSSStyleValue::to_font_slope() const
{ {
// FIXME: Implement oblique <angle> // FIXME: Implement oblique <angle>
if (is_identifier()) { if (is_keyword()) {
switch (static_cast<IdentifierStyleValue const&>(*this).id()) { switch (static_cast<CSSKeywordValue const&>(*this).id()) {
case CSS::ValueID::Italic: { case CSS::ValueID::Italic: {
static int italic_slope = Gfx::name_to_slope("Italic"sv); static int italic_slope = Gfx::name_to_slope("Italic"sv);
return italic_slope; return italic_slope;
@ -438,8 +438,8 @@ int CSSStyleValue::to_font_slope() const
int CSSStyleValue::to_font_stretch_width() const int CSSStyleValue::to_font_stretch_width() const
{ {
int width = Gfx::FontWidth::Normal; int width = Gfx::FontWidth::Normal;
if (is_identifier()) { if (is_keyword()) {
switch (static_cast<IdentifierStyleValue const&>(*this).id()) { switch (static_cast<CSSKeywordValue const&>(*this).id()) {
case CSS::ValueID::UltraCondensed: case CSS::ValueID::UltraCondensed:
width = Gfx::FontWidth::UltraCondensed; width = Gfx::FontWidth::UltraCondensed;
break; break;

View file

@ -110,11 +110,11 @@ public:
GridTemplateArea, GridTemplateArea,
GridTrackPlacement, GridTrackPlacement,
GridTrackSizeList, GridTrackSizeList,
Identifier,
Image, Image,
Inherit, Inherit,
Initial, Initial,
Integer, Integer,
Keyword,
Length, Length,
LinearGradient, LinearGradient,
MathDepth, MathDepth,
@ -236,10 +236,6 @@ public:
GridTrackSizeListStyleValue const& as_grid_track_size_list() const; GridTrackSizeListStyleValue const& as_grid_track_size_list() const;
GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_size_list()); } GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_size_list()); }
bool is_identifier() const { return type() == Type::Identifier; }
IdentifierStyleValue const& as_identifier() const;
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_identifier()); }
bool is_image() const { return type() == Type::Image; } bool is_image() const { return type() == Type::Image; }
ImageStyleValue const& as_image() const; ImageStyleValue const& as_image() const;
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_image()); } ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_image()); }
@ -256,6 +252,10 @@ public:
IntegerStyleValue const& as_integer() const; IntegerStyleValue const& as_integer() const;
IntegerStyleValue& as_integer() { return const_cast<IntegerStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_integer()); } IntegerStyleValue& as_integer() { return const_cast<IntegerStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_integer()); }
bool is_keyword() const { return type() == Type::Keyword; }
CSSKeywordValue const& as_keyword() const;
CSSKeywordValue& as_keyword() { return const_cast<CSSKeywordValue&>(const_cast<CSSStyleValue const&>(*this).as_keyword()); }
bool is_length() const { return type() == Type::Length; } bool is_length() const { return type() == Type::Length; }
LengthStyleValue const& as_length() const; LengthStyleValue const& as_length() const;
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_length()); } LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_length()); }

View file

@ -42,6 +42,7 @@
#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/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.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>
@ -57,7 +58,6 @@
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h> #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
#include <LibWeb/CSS/StyleValues/InheritStyleValue.h> #include <LibWeb/CSS/StyleValues/InheritStyleValue.h>
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h> #include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
@ -2378,7 +2378,7 @@ RefPtr<CSSStyleValue> Parser::parse_identifier_value(TokenStream<ComponentValue>
auto value_id = value_id_from_string(peek_token.token().ident()); auto value_id = value_id_from_string(peek_token.token().ident());
if (value_id.has_value()) { if (value_id.has_value()) {
(void)tokens.next_token(); // ident (void)tokens.next_token(); // ident
return IdentifierStyleValue::create(value_id.value()); return CSSKeywordValue::create(value_id.value());
} }
} }
@ -3231,7 +3231,7 @@ RefPtr<CSSStyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tok
switch (*maybe_ident) { switch (*maybe_ident) {
case ValueID::None: case ValueID::None:
(void)tokens.next_token(); (void)tokens.next_token();
return IdentifierStyleValue::create(*maybe_ident); return CSSKeywordValue::create(*maybe_ident);
default: default:
return nullptr; return nullptr;
} }
@ -3626,7 +3626,7 @@ RefPtr<CSSStyleValue> Parser::parse_all_as_single_none_value(TokenStream<Compone
return {}; return {};
transaction.commit(); transaction.commit();
return IdentifierStyleValue::create(ValueID::None); return CSSKeywordValue::create(ValueID::None);
} }
static void remove_property(Vector<PropertyID>& properties, PropertyID property_to_remove) static void remove_property(Vector<PropertyID>& properties, PropertyID property_to_remove)
@ -3654,7 +3654,7 @@ RefPtr<CSSStyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValu
continue; continue;
} }
if (maybe_value->is_identifier() && maybe_value->as_identifier().id() == ValueID::Auto) { if (maybe_value->is_keyword() && maybe_value->as_keyword().id() == ValueID::Auto) {
if (auto_value) if (auto_value)
return nullptr; return nullptr;
auto_value = maybe_value.release_nonnull(); auto_value = maybe_value.release_nonnull();
@ -3943,7 +3943,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_position_x_or_y_value(Toke
if (!value) if (!value)
return nullptr; return nullptr;
if (value->is_identifier()) { if (value->is_keyword()) {
auto identifier = value->to_identifier(); auto identifier = value->to_identifier();
if (identifier == ValueID::Center) { if (identifier == ValueID::Center) {
transaction.commit(); transaction.commit();
@ -4819,9 +4819,9 @@ RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& toke
return make_flex_shorthand(one, one, *value); return make_flex_shorthand(one, one, *value);
} }
case PropertyID::Flex: { case PropertyID::Flex: {
if (value->is_identifier() && value->to_identifier() == ValueID::None) { if (value->is_keyword() && value->to_identifier() == ValueID::None) {
auto zero = NumberStyleValue::create(0); auto zero = NumberStyleValue::create(0);
return make_flex_shorthand(zero, zero, IdentifierStyleValue::create(ValueID::Auto)); return make_flex_shorthand(zero, zero, CSSKeywordValue::create(ValueID::Auto));
} }
break; break;
} }
@ -5091,7 +5091,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue
(void)tokens.next_token(); // Ident (void)tokens.next_token(); // Ident
if (!next_is_comma_or_eof()) if (!next_is_comma_or_eof())
return nullptr; return nullptr;
font_families.append(IdentifierStyleValue::create(maybe_ident.value())); font_families.append(CSSKeywordValue::create(maybe_ident.value()));
(void)tokens.next_token(); // Comma (void)tokens.next_token(); // Comma
continue; continue;
} }
@ -5381,14 +5381,14 @@ RefPtr<CSSStyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>
if (found_nones == 2) { if (found_nones == 2) {
if (list_image || list_type) if (list_image || list_type)
return nullptr; return nullptr;
auto none = IdentifierStyleValue::create(ValueID::None); auto none = CSSKeywordValue::create(ValueID::None);
list_image = none; list_image = none;
list_type = none; list_type = none;
} else if (found_nones == 1) { } else if (found_nones == 1) {
if (list_image && list_type) if (list_image && list_type)
return nullptr; return nullptr;
auto none = IdentifierStyleValue::create(ValueID::None); auto none = CSSKeywordValue::create(ValueID::None);
if (!list_image) if (!list_image)
list_image = none; list_image = none;
if (!list_type) if (!list_type)
@ -6011,7 +6011,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
return AxisOffset { Axis::None, value->as_percentage() }; return AxisOffset { Axis::None, value->as_percentage() };
if (value->is_length()) if (value->is_length())
return AxisOffset { Axis::None, value->as_length() }; return AxisOffset { Axis::None, value->as_length() };
if (value->is_identifier()) { if (value->is_keyword()) {
switch (value->to_identifier()) { switch (value->to_identifier()) {
case ValueID::Top: case ValueID::Top:
return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(0)) }; return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(0)) };
@ -7343,7 +7343,7 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
if (ident.has_value()) { if (ident.has_value()) {
if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) { if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) {
(void)tokens.next_token(); (void)tokens.next_token();
return PropertyAndValue { *property, IdentifierStyleValue::create(ident.value()) }; return PropertyAndValue { *property, CSSKeywordValue::create(ident.value()) };
} }
} }

View file

@ -15,12 +15,12 @@
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h> #include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h> #include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h> #include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
@ -100,7 +100,7 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_background_property(La
static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage) static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
{ {
if (length_percentage.is_auto()) if (length_percentage.is_auto())
return IdentifierStyleValue::create(ValueID::Auto); return CSSKeywordValue::create(ValueID::Auto);
if (length_percentage.is_percentage()) if (length_percentage.is_percentage())
return PercentageStyleValue::create(length_percentage.percentage()); return PercentageStyleValue::create(length_percentage.percentage());
if (length_percentage.is_length()) if (length_percentage.is_length())
@ -111,22 +111,22 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(Leng
static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size) static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size)
{ {
if (size.is_none()) if (size.is_none())
return IdentifierStyleValue::create(ValueID::None); return CSSKeywordValue::create(ValueID::None);
if (size.is_percentage()) if (size.is_percentage())
return PercentageStyleValue::create(size.percentage()); return PercentageStyleValue::create(size.percentage());
if (size.is_length()) if (size.is_length())
return LengthStyleValue::create(size.length()); return LengthStyleValue::create(size.length());
if (size.is_auto()) if (size.is_auto())
return IdentifierStyleValue::create(ValueID::Auto); return CSSKeywordValue::create(ValueID::Auto);
if (size.is_calculated()) if (size.is_calculated())
return size.calculated(); return size.calculated();
if (size.is_min_content()) if (size.is_min_content())
return IdentifierStyleValue::create(ValueID::MinContent); return CSSKeywordValue::create(ValueID::MinContent);
if (size.is_max_content()) if (size.is_max_content())
return IdentifierStyleValue::create(ValueID::MaxContent); return CSSKeywordValue::create(ValueID::MaxContent);
// FIXME: Support fit-content(<length>) // FIXME: Support fit-content(<length>)
if (size.is_fit_content()) if (size.is_fit_content())
return IdentifierStyleValue::create(ValueID::FitContent); return CSSKeywordValue::create(ValueID::FitContent);
TODO(); TODO();
} }
@ -172,7 +172,7 @@ static RefPtr<CSSStyleValue const> style_value_for_length_box_logical_side(Layou
static RefPtr<CSSStyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data) static RefPtr<CSSStyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
{ {
if (shadow_data.is_empty()) if (shadow_data.is_empty())
return IdentifierStyleValue::create(ValueID::None); return CSSKeywordValue::create(ValueID::None);
auto make_shadow_style_value = [](ShadowData const& shadow) { auto make_shadow_style_value = [](ShadowData const& shadow) {
return ShadowStyleValue::create( return ShadowStyleValue::create(
@ -263,7 +263,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
// The resolved value is normal if the computed value is normal, or the used value otherwise. // The resolved value is normal if the computed value is normal, or the used value otherwise.
case PropertyID::LineHeight: { case PropertyID::LineHeight: {
auto line_height = get_computed_value(property_id); auto line_height = get_computed_value(property_id);
if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal) if (line_height->is_keyword() && line_height->to_identifier() == ValueID::Normal)
return line_height; return line_height;
return LengthStyleValue::create(Length::make_px(layout_node.computed_values().line_height())); return LengthStyleValue::create(Length::make_px(layout_node.computed_values().line_height()));
} }
@ -370,7 +370,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
case PropertyID::Transform: { case PropertyID::Transform: {
auto transformations = layout_node.computed_values().transformations(); auto transformations = layout_node.computed_values().transformations();
if (transformations.is_empty()) if (transformations.is_empty())
return IdentifierStyleValue::create(ValueID::None); return CSSKeywordValue::create(ValueID::None);
// https://drafts.csswg.org/css-transforms-2/#serialization-of-the-computed-value // https://drafts.csswg.org/css-transforms-2/#serialization-of-the-computed-value
// The transform property is a resolved value special case property. [CSSOM] // The transform property is a resolved value special case property. [CSSOM]
@ -516,7 +516,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
case PropertyID::WebkitTextFillColor: case PropertyID::WebkitTextFillColor:
return ColorStyleValue::create(layout_node.computed_values().webkit_text_fill_color()); return ColorStyleValue::create(layout_node.computed_values().webkit_text_fill_color());
case PropertyID::Invalid: case PropertyID::Invalid:
return IdentifierStyleValue::create(ValueID::Invalid); return CSSKeywordValue::create(ValueID::Invalid);
case PropertyID::Custom: case PropertyID::Custom:
dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for custom properties was requested (?)"); dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for custom properties was requested (?)");
return nullptr; return nullptr;

View file

@ -37,6 +37,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/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.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>
@ -45,7 +46,6 @@
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h> #include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
@ -784,10 +784,10 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
if (property_id == CSS::PropertyID::Transition) { if (property_id == CSS::PropertyID::Transition) {
if (!value.is_transition()) { if (!value.is_transition()) {
// Handle `none` as a shorthand for `all 0s ease 0s`. // Handle `none` as a shorthand for `all 0s ease 0s`.
set_longhand_property(CSS::PropertyID::TransitionProperty, IdentifierStyleValue::create(CSS::ValueID::All)); set_longhand_property(CSS::PropertyID::TransitionProperty, CSSKeywordValue::create(CSS::ValueID::All));
set_longhand_property(CSS::PropertyID::TransitionDuration, TimeStyleValue::create(CSS::Time::make_seconds(0))); set_longhand_property(CSS::PropertyID::TransitionDuration, TimeStyleValue::create(CSS::Time::make_seconds(0)));
set_longhand_property(CSS::PropertyID::TransitionDelay, TimeStyleValue::create(CSS::Time::make_seconds(0))); set_longhand_property(CSS::PropertyID::TransitionDelay, TimeStyleValue::create(CSS::Time::make_seconds(0)));
set_longhand_property(CSS::PropertyID::TransitionTimingFunction, IdentifierStyleValue::create(CSS::ValueID::Ease)); set_longhand_property(CSS::PropertyID::TransitionTimingFunction, CSSKeywordValue::create(CSS::ValueID::Ease));
return; return;
} }
auto const& transitions = value.as_transition().transitions(); auto const& transitions = value.as_transition().transitions();
@ -812,10 +812,10 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
// FIXME: Honor writing-mode, direction and text-orientation. // FIXME: Honor writing-mode, direction and text-orientation.
if (ident == CSS::ValueID::InlineStart) { if (ident == CSS::ValueID::InlineStart) {
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Left)); set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(CSS::ValueID::Left));
return; return;
} else if (ident == CSS::ValueID::InlineEnd) { } else if (ident == CSS::ValueID::InlineEnd) {
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Right)); set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(CSS::ValueID::Right));
return; return;
} }
} }
@ -1307,7 +1307,7 @@ static NonnullRefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& e
} }
} else if (value.is_shadow()) { } else if (value.is_shadow()) {
shadows.append(value); shadows.append(value);
} else if (!value.is_identifier() || value.as_identifier().id() != ValueID::None) { } else if (!value.is_keyword() || value.as_keyword().id() != ValueID::None) {
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }
return shadows; return shadows;
@ -1627,7 +1627,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
} else { } else {
// If interpolate_property() fails, the element should not be rendered // If interpolate_property() fails, the element should not be rendered
dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} is invalid", string_from_property_id(it.key), progress_in_keyframe, start->to_string(), end->to_string()); dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} is invalid", string_from_property_id(it.key), progress_in_keyframe, start->to_string(), end->to_string());
style_properties.set_animated_property(PropertyID::Visibility, IdentifierStyleValue::create(ValueID::Hidden)); style_properties.set_animated_property(PropertyID::Visibility, CSSKeywordValue::create(ValueID::Hidden));
} }
} }
} }
@ -1640,7 +1640,7 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&
if (auto duration_value = style.maybe_null_property(PropertyID::AnimationDuration); duration_value) { if (auto duration_value = style.maybe_null_property(PropertyID::AnimationDuration); duration_value) {
if (duration_value->is_time()) { if (duration_value->is_time()) {
duration = duration_value->as_time().time(); duration = duration_value->as_time().time();
} else if (duration_value->is_identifier() && duration_value->as_identifier().id() == ValueID::Auto) { } else if (duration_value->is_keyword() && duration_value->as_keyword().id() == ValueID::Auto) {
// We use empty optional to represent "auto". // We use empty optional to represent "auto".
duration = {}; duration = {};
} }
@ -1652,26 +1652,26 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&
double iteration_count = 1.0; double iteration_count = 1.0;
if (auto iteration_count_value = style.maybe_null_property(PropertyID::AnimationIterationCount); iteration_count_value) { if (auto iteration_count_value = style.maybe_null_property(PropertyID::AnimationIterationCount); iteration_count_value) {
if (iteration_count_value->is_identifier() && iteration_count_value->to_identifier() == ValueID::Infinite) if (iteration_count_value->is_keyword() && iteration_count_value->to_identifier() == ValueID::Infinite)
iteration_count = HUGE_VAL; iteration_count = HUGE_VAL;
else if (iteration_count_value->is_number()) else if (iteration_count_value->is_number())
iteration_count = iteration_count_value->as_number().number(); iteration_count = iteration_count_value->as_number().number();
} }
CSS::AnimationFillMode fill_mode { CSS::AnimationFillMode::None }; CSS::AnimationFillMode fill_mode { CSS::AnimationFillMode::None };
if (auto fill_mode_property = style.maybe_null_property(PropertyID::AnimationFillMode); fill_mode_property && fill_mode_property->is_identifier()) { if (auto fill_mode_property = style.maybe_null_property(PropertyID::AnimationFillMode); fill_mode_property && fill_mode_property->is_keyword()) {
if (auto fill_mode_value = value_id_to_animation_fill_mode(fill_mode_property->to_identifier()); fill_mode_value.has_value()) if (auto fill_mode_value = value_id_to_animation_fill_mode(fill_mode_property->to_identifier()); fill_mode_value.has_value())
fill_mode = *fill_mode_value; fill_mode = *fill_mode_value;
} }
CSS::AnimationDirection direction { CSS::AnimationDirection::Normal }; CSS::AnimationDirection direction { CSS::AnimationDirection::Normal };
if (auto direction_property = style.maybe_null_property(PropertyID::AnimationDirection); direction_property && direction_property->is_identifier()) { if (auto direction_property = style.maybe_null_property(PropertyID::AnimationDirection); direction_property && direction_property->is_keyword()) {
if (auto direction_value = value_id_to_animation_direction(direction_property->to_identifier()); direction_value.has_value()) if (auto direction_value = value_id_to_animation_direction(direction_property->to_identifier()); direction_value.has_value())
direction = *direction_value; direction = *direction_value;
} }
CSS::AnimationPlayState play_state { CSS::AnimationPlayState::Running }; CSS::AnimationPlayState play_state { CSS::AnimationPlayState::Running };
if (auto play_state_property = style.maybe_null_property(PropertyID::AnimationPlayState); play_state_property && play_state_property->is_identifier()) { if (auto play_state_property = style.maybe_null_property(PropertyID::AnimationPlayState); play_state_property && play_state_property->is_keyword()) {
if (auto play_state_value = value_id_to_animation_play_state(play_state_property->to_identifier()); play_state_value.has_value()) if (auto play_state_value = value_id_to_animation_play_state(play_state_property->to_identifier()); play_state_value.has_value())
play_state = *play_state_value; play_state = *play_state_value;
} }
@ -2071,7 +2071,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
}; };
Length::FontMetrics font_metrics { parent_font_size(), font_pixel_metrics }; Length::FontMetrics font_metrics { parent_font_size(), font_pixel_metrics };
if (font_size.is_identifier()) { if (font_size.is_keyword()) {
// https://w3c.github.io/csswg-drafts/css-fonts/#absolute-size-mapping // https://w3c.github.io/csswg-drafts/css-fonts/#absolute-size-mapping
auto get_absolute_size_mapping = [](Web::CSS::ValueID identifier) -> CSSPixelFraction { auto get_absolute_size_mapping = [](Web::CSS::ValueID identifier) -> CSSPixelFraction {
switch (identifier) { switch (identifier) {
@ -2100,7 +2100,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
} }
}; };
auto const identifier = static_cast<IdentifierStyleValue const&>(font_size).id(); auto const identifier = static_cast<CSSKeywordValue const&>(font_size).id();
if (identifier == ValueID::Math) { if (identifier == ValueID::Math) {
auto math_scaling_factor = [&]() { auto math_scaling_factor = [&]() {
@ -2258,7 +2258,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
auto const& family_list = static_cast<StyleValueList const&>(font_family).values(); auto const& family_list = static_cast<StyleValueList const&>(font_family).values();
for (auto const& family : family_list) { for (auto const& family : family_list) {
RefPtr<Gfx::FontCascadeList const> other_font_list; RefPtr<Gfx::FontCascadeList const> other_font_list;
if (family->is_identifier()) { if (family->is_keyword()) {
other_font_list = find_generic_font(family->to_identifier()); other_font_list = find_generic_font(family->to_identifier());
} else if (family->is_string()) { } else if (family->is_string()) {
other_font_list = find_font(family->as_string().string_value()); other_font_list = find_font(family->as_string().string_value());
@ -2268,7 +2268,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
if (other_font_list) if (other_font_list)
font_list->extend(*other_font_list); font_list->extend(*other_font_list);
} }
} else if (font_family.is_identifier()) { } else if (font_family.is_keyword()) {
if (auto other_font_list = find_generic_font(font_family.to_identifier())) if (auto other_font_list = find_generic_font(font_family.to_identifier()))
font_list->extend(*other_font_list); font_list->extend(*other_font_list);
} else if (font_family.is_string()) { } else if (font_family.is_string()) {
@ -2372,13 +2372,13 @@ void StyleComputer::resolve_effective_overflow_values(StyleProperties& style) co
auto overflow_y_is_visible_or_clip = overflow_y == Overflow::Visible || overflow_y == Overflow::Clip; auto overflow_y_is_visible_or_clip = overflow_y == Overflow::Visible || overflow_y == Overflow::Clip;
if (!overflow_x_is_visible_or_clip || !overflow_y_is_visible_or_clip) { if (!overflow_x_is_visible_or_clip || !overflow_y_is_visible_or_clip) {
if (overflow_x == CSS::Overflow::Visible) if (overflow_x == CSS::Overflow::Visible)
style.set_property(CSS::PropertyID::OverflowX, IdentifierStyleValue::create(CSS::ValueID::Auto)); style.set_property(CSS::PropertyID::OverflowX, CSSKeywordValue::create(CSS::ValueID::Auto));
if (overflow_x == CSS::Overflow::Clip) if (overflow_x == CSS::Overflow::Clip)
style.set_property(CSS::PropertyID::OverflowX, IdentifierStyleValue::create(CSS::ValueID::Hidden)); style.set_property(CSS::PropertyID::OverflowX, CSSKeywordValue::create(CSS::ValueID::Hidden));
if (overflow_y == CSS::Overflow::Visible) if (overflow_y == CSS::Overflow::Visible)
style.set_property(CSS::PropertyID::OverflowY, IdentifierStyleValue::create(CSS::ValueID::Auto)); style.set_property(CSS::PropertyID::OverflowY, CSSKeywordValue::create(CSS::ValueID::Auto));
if (overflow_y == CSS::Overflow::Clip) if (overflow_y == CSS::Overflow::Clip)
style.set_property(CSS::PropertyID::OverflowY, IdentifierStyleValue::create(CSS::ValueID::Hidden)); style.set_property(CSS::PropertyID::OverflowY, CSSKeywordValue::create(CSS::ValueID::Hidden));
} }
} }

View file

@ -10,6 +10,7 @@
#include <LibWeb/CSS/Clip.h> #include <LibWeb/CSS/Clip.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h> #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.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/CounterStyleValue.h> #include <LibWeb/CSS/StyleValues/CounterStyleValue.h>
@ -18,7 +19,6 @@
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
@ -124,7 +124,7 @@ RefPtr<CSSStyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID
CSS::Size StyleProperties::size_value(CSS::PropertyID id) const CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
{ {
auto value = property(id); auto value = property(id);
if (value->is_identifier()) { if (value->is_keyword()) {
switch (value->to_identifier()) { switch (value->to_identifier()) {
case ValueID::Auto: case ValueID::Auto:
return CSS::Size::make_auto(); return CSS::Size::make_auto();
@ -219,7 +219,7 @@ CSSPixels StyleProperties::compute_line_height(CSSPixelRect const& viewport_rect
{ {
auto line_height = property(CSS::PropertyID::LineHeight); auto line_height = property(CSS::PropertyID::LineHeight);
if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal) if (line_height->is_keyword() && line_height->to_identifier() == ValueID::Normal)
return font_metrics.line_height; return font_metrics.line_height;
if (line_height->is_length()) { if (line_height->is_length()) {
@ -355,7 +355,7 @@ Optional<CSS::FlexBasis> StyleProperties::flex_basis() const
{ {
auto value = property(CSS::PropertyID::FlexBasis); auto value = property(CSS::PropertyID::FlexBasis);
if (value->is_identifier() && value->to_identifier() == CSS::ValueID::Content) if (value->is_keyword() && value->to_identifier() == CSS::ValueID::Content)
return CSS::FlexBasisContent {}; return CSS::FlexBasisContent {};
return size_value(CSS::PropertyID::FlexBasis); return size_value(CSS::PropertyID::FlexBasis);
@ -443,7 +443,7 @@ Optional<CSS::JustifySelf> StyleProperties::justify_self() const
Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(CSSStyleValue const& value) Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(CSSStyleValue const& value)
{ {
if (value.is_identifier() && value.to_identifier() == CSS::ValueID::None) if (value.is_keyword() && value.to_identifier() == CSS::ValueID::None)
return {}; return {};
if (!value.is_value_list()) if (!value.is_value_list())
@ -729,7 +729,7 @@ StyleProperties::ContentDataAndQuoteNestingLevel StyleProperties::content(DOM::E
for (auto const& item : content_style_value.content().values()) { for (auto const& item : content_style_value.content().values()) {
if (item->is_string()) { if (item->is_string()) {
builder.append(item->as_string().string_value()); builder.append(item->as_string().string_value());
} else if (item->is_identifier()) { } else if (item->is_keyword()) {
switch (item->to_identifier()) { switch (item->to_identifier()) {
case ValueID::OpenQuote: case ValueID::OpenQuote:
builder.append(get_quote_string(true, quote_nesting_level++)); builder.append(get_quote_string(true, quote_nesting_level++));
@ -809,7 +809,7 @@ Optional<CSS::Cursor> StyleProperties::cursor() const
Optional<CSS::Visibility> StyleProperties::visibility() const Optional<CSS::Visibility> StyleProperties::visibility() const
{ {
auto value = property(CSS::PropertyID::Visibility); auto value = property(CSS::PropertyID::Visibility);
if (!value->is_identifier()) if (!value->is_keyword())
return {}; return {};
return value_id_to_visibility(value->to_identifier()); return value_id_to_visibility(value->to_identifier());
} }
@ -836,7 +836,7 @@ Vector<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const
return lines; return lines;
} }
if (value->is_identifier() && value->to_identifier() == ValueID::None) if (value->is_keyword() && value->to_identifier() == ValueID::None)
return {}; return {};
dbgln("FIXME: Unsupported value for text-decoration-line: {}", value->to_string()); dbgln("FIXME: Unsupported value for text-decoration-line: {}", value->to_string());
@ -963,7 +963,7 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
{ {
auto value = property(CSS::PropertyID::VerticalAlign); auto value = property(CSS::PropertyID::VerticalAlign);
if (value->is_identifier()) if (value->is_keyword())
return value_id_to_vertical_align(value->to_identifier()).release_value(); return value_id_to_vertical_align(value->to_identifier()).release_value();
if (value->is_length()) if (value->is_length())
@ -1100,9 +1100,9 @@ Optional<CSS::MaskType> StyleProperties::mask_type() const
Color StyleProperties::stop_color() const Color StyleProperties::stop_color() const
{ {
auto value = property(CSS::PropertyID::StopColor); auto value = property(CSS::PropertyID::StopColor);
if (value->is_identifier()) { if (value->is_keyword()) {
// Workaround lack of layout node to resolve current color. // Workaround lack of layout node to resolve current color.
auto& ident = value->as_identifier(); auto& ident = value->as_keyword();
if (ident.id() == CSS::ValueID::Currentcolor) if (ident.id() == CSS::ValueID::Currentcolor)
value = property(CSS::PropertyID::Color); value = property(CSS::PropertyID::Color);
} }
@ -1124,7 +1124,7 @@ void StyleProperties::set_math_depth(int math_depth)
QuotesData StyleProperties::quotes() const QuotesData StyleProperties::quotes() const
{ {
auto value = property(CSS::PropertyID::Quotes); auto value = property(CSS::PropertyID::Quotes);
if (value->is_identifier()) { if (value->is_keyword()) {
switch (value->to_identifier()) { switch (value->to_identifier()) {
case ValueID::Auto: case ValueID::Auto:
return QuotesData { .type = QuotesData::Type::Auto }; return QuotesData { .type = QuotesData::Type::Auto };

View file

@ -1,13 +1,13 @@
/* /*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include "IdentifierStyleValue.h" #include "CSSKeywordValue.h"
#include <LibGfx/Palette.h> #include <LibGfx/Palette.h>
#include <LibWeb/CSS/SystemColor.h> #include <LibWeb/CSS/SystemColor.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
@ -16,12 +16,12 @@
namespace Web::CSS { namespace Web::CSS {
String IdentifierStyleValue::to_string() const String CSSKeywordValue::to_string() const
{ {
return MUST(String::from_utf8(CSS::string_from_value_id(m_id))); return MUST(String::from_utf8(CSS::string_from_value_id(m_id)));
} }
bool IdentifierStyleValue::is_color(ValueID value_id) bool CSSKeywordValue::is_color(ValueID value_id)
{ {
switch (value_id) { switch (value_id) {
case ValueID::Accentcolor: case ValueID::Accentcolor:
@ -128,12 +128,12 @@ bool IdentifierStyleValue::is_color(ValueID value_id)
} }
} }
bool IdentifierStyleValue::has_color() const bool CSSKeywordValue::has_color() const
{ {
return is_color(m_id); return is_color(m_id);
} }
Color IdentifierStyleValue::to_color(Optional<Layout::NodeWithStyle const&> node) const Color CSSKeywordValue::to_color(Optional<Layout::NodeWithStyle const&> node) const
{ {
if (id() == CSS::ValueID::Currentcolor) { if (id() == CSS::ValueID::Currentcolor) {
if (!node.has_value() || !node->has_style()) if (!node.has_value() || !node->has_style())

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
@ -14,13 +14,14 @@
namespace Web::CSS { namespace Web::CSS {
class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> { // https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
class CSSKeywordValue final : public StyleValueWithDefaultOperators<CSSKeywordValue> {
public: public:
static ValueComparingNonnullRefPtr<IdentifierStyleValue> create(ValueID id) static ValueComparingNonnullRefPtr<CSSKeywordValue> create(ValueID id)
{ {
return adopt_ref(*new (nothrow) IdentifierStyleValue(id)); return adopt_ref(*new (nothrow) CSSKeywordValue(id));
} }
virtual ~IdentifierStyleValue() override = default; virtual ~CSSKeywordValue() override = default;
ValueID id() const { return m_id; } ValueID id() const { return m_id; }
@ -29,11 +30,11 @@ public:
virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override; virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override;
virtual String to_string() const override; virtual String to_string() const override;
bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; } bool properties_equal(CSSKeywordValue const& other) const { return m_id == other.m_id; }
private: private:
explicit IdentifierStyleValue(ValueID id) explicit CSSKeywordValue(ValueID id)
: StyleValueWithDefaultOperators(Type::Identifier) : StyleValueWithDefaultOperators(Type::Keyword)
, m_id(id) , m_id(id)
{ {
} }

View file

@ -18,7 +18,7 @@
#include <LibWeb/CSS/SelectorEngine.h> #include <LibWeb/CSS/SelectorEngine.h>
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h> #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/DOM/Attr.h> #include <LibWeb/DOM/Attr.h>
#include <LibWeb/DOM/DOMTokenList.h> #include <LibWeb/DOM/DOMTokenList.h>
@ -542,7 +542,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
if (is<HTML::HTMLTableElement>(*this)) { if (is<HTML::HTMLTableElement>(*this)) {
auto text_align = new_computed_css_values->text_align(); auto text_align = new_computed_css_values->text_align();
if (text_align.has_value() && (text_align.value() == CSS::TextAlign::LibwebLeft || text_align.value() == CSS::TextAlign::LibwebCenter || text_align.value() == CSS::TextAlign::LibwebRight)) if (text_align.has_value() && (text_align.value() == CSS::TextAlign::LibwebLeft || text_align.value() == CSS::TextAlign::LibwebCenter || text_align.value() == CSS::TextAlign::LibwebRight))
new_computed_css_values->set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Start)); new_computed_css_values->set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Start));
} }
CSS::RequiredInvalidationAfterStyleChange invalidation; CSS::RequiredInvalidationAfterStyleChange invalidation;

View file

@ -107,6 +107,7 @@ class CSSGroupingRule;
class CSSImportRule; class CSSImportRule;
class CSSKeyframeRule; class CSSKeyframeRule;
class CSSKeyframesRule; class CSSKeyframesRule;
class CSSKeywordValue;
class CSSMediaRule; class CSSMediaRule;
class CSSRule; class CSSRule;
class CSSRuleList; class CSSRuleList;
@ -150,7 +151,6 @@ class GridTrackPlacement;
class GridTrackPlacementStyleValue; class GridTrackPlacementStyleValue;
class GridTrackSizeList; class GridTrackSizeList;
class GridTrackSizeListStyleValue; class GridTrackSizeListStyleValue;
class IdentifierStyleValue;
class ImageStyleValue; class ImageStyleValue;
class InheritStyleValue; class InheritStyleValue;
class InitialStyleValue; class InitialStyleValue;

View file

@ -13,7 +13,7 @@
#include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HTMLCanvasElementPrototype.h> #include <LibWeb/Bindings/HTMLCanvasElementPrototype.h>
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/RatioStyleValue.h> #include <LibWeb/CSS/StyleValues/RatioStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h> #include <LibWeb/CSS/StyleValues/StyleValueList.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
@ -74,7 +74,7 @@ void HTMLCanvasElement::apply_presentational_hints(CSS::StyleProperties& style)
// then the user agent is expected to use the parsed integers as a presentational hint for the 'aspect-ratio' property of the form auto w / h. // then the user agent is expected to use the parsed integers as a presentational hint for the 'aspect-ratio' property of the form auto w / h.
style.set_property(CSS::PropertyID::AspectRatio, style.set_property(CSS::PropertyID::AspectRatio,
CSS::StyleValueList::create(CSS::StyleValueVector { CSS::StyleValueList::create(CSS::StyleValueVector {
CSS::IdentifierStyleValue::create(CSS::ValueID::Auto), CSS::CSSKeywordValue::create(CSS::ValueID::Auto),
CSS::RatioStyleValue::create(CSS::Ratio { static_cast<double>(w.value()), static_cast<double>(h.value()) }) }, CSS::RatioStyleValue::create(CSS::Ratio { static_cast<double>(w.value()), static_cast<double>(h.value()) }) },
CSS::StyleValueList::Separator::Space)); CSS::StyleValueList::Separator::Space));

View file

@ -7,7 +7,7 @@
#include <LibWeb/Bindings/HTMLDivElementPrototype.h> #include <LibWeb/Bindings/HTMLDivElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLDivElement.h> #include <LibWeb/HTML/HTMLDivElement.h>
namespace Web::HTML { namespace Web::HTML {
@ -27,13 +27,13 @@ void HTMLDivElement::apply_presentational_hints(CSS::StyleProperties& style) con
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value.equals_ignoring_ascii_case("left"sv)) if (value.equals_ignoring_ascii_case("left"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebLeft));
else if (value.equals_ignoring_ascii_case("right"sv)) else if (value.equals_ignoring_ascii_case("right"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebRight));
else if (value.equals_ignoring_ascii_case("center"sv)) else if (value.equals_ignoring_ascii_case("center"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebCenter));
else if (value.equals_ignoring_ascii_case("justify"sv)) else if (value.equals_ignoring_ascii_case("justify"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -7,7 +7,7 @@
#include <LibWeb/Bindings/HTMLHeadingElementPrototype.h> #include <LibWeb/Bindings/HTMLHeadingElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLHeadingElement.h> #include <LibWeb/HTML/HTMLHeadingElement.h>
namespace Web::HTML { namespace Web::HTML {
@ -34,13 +34,13 @@ void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style)
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv) if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Left));
else if (value == "right"sv) else if (value == "right"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Right));
else if (value == "center"sv) else if (value == "center"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Center));
else if (value == "justify"sv) else if (value == "justify"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -11,8 +11,8 @@
#include <LibJS/Runtime/Date.h> #include <LibJS/Runtime/Date.h>
#include <LibJS/Runtime/NativeFunction.h> #include <LibJS/Runtime/NativeFunction.h>
#include <LibWeb/Bindings/HTMLInputElementPrototype.h> #include <LibWeb/Bindings/HTMLInputElementPrototype.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
@ -135,7 +135,7 @@ void HTMLInputElement::adjust_computed_style(CSS::StyleProperties& style)
double current_line_height = style.line_height().to_double(); double current_line_height = style.line_height().to_double();
if (is_single_line() && current_line_height < normal_line_height) if (is_single_line() && current_line_height < normal_line_height)
style.set_property(CSS::PropertyID::LineHeight, CSS::IdentifierStyleValue::create(CSS::ValueID::Normal)); style.set_property(CSS::PropertyID::LineHeight, CSS::CSSKeywordValue::create(CSS::ValueID::Normal));
} }
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source) void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)

View file

@ -7,7 +7,7 @@
#include <LibWeb/Bindings/HTMLParagraphElementPrototype.h> #include <LibWeb/Bindings/HTMLParagraphElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLParagraphElement.h> #include <LibWeb/HTML/HTMLParagraphElement.h>
namespace Web::HTML { namespace Web::HTML {
@ -34,13 +34,13 @@ void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& styl
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv) if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Left));
else if (value == "right"sv) else if (value == "right"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Right));
else if (value == "center"sv) else if (value == "center"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Center));
else if (value == "justify"sv) else if (value == "justify"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -7,7 +7,7 @@
#include <LibWeb/Bindings/HTMLPreElementPrototype.h> #include <LibWeb/Bindings/HTMLPreElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLPreElement.h> #include <LibWeb/HTML/HTMLPreElement.h>
#include <LibWeb/HTML/Numbers.h> #include <LibWeb/HTML/Numbers.h>
@ -34,7 +34,7 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con
for_each_attribute([&](auto const& name, auto const&) { for_each_attribute([&](auto const& name, auto const&) {
if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap)) if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap)); style.set_property(CSS::PropertyID::WhiteSpace, CSS::CSSKeywordValue::create(CSS::ValueID::PreWrap));
}); });
} }

View file

@ -7,7 +7,7 @@
#include <LibWeb/Bindings/HTMLTableCaptionElementPrototype.h> #include <LibWeb/Bindings/HTMLTableCaptionElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/HTML/HTMLTableCaptionElement.h> #include <LibWeb/HTML/HTMLTableCaptionElement.h>
namespace Web::HTML { namespace Web::HTML {
@ -34,7 +34,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& s
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "bottom"sv) if (value == "bottom"sv)
style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom)); style.set_property(CSS::PropertyID::CaptionSide, CSS::CSSKeywordValue::create(CSS::ValueID::Bottom));
} }
}); });
} }

View file

@ -9,8 +9,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/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.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>
@ -54,11 +54,11 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
} }
if (name == HTML::AttributeNames::align) { if (name == HTML::AttributeNames::align) {
if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) { if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebCenter));
} else if (value.equals_ignoring_ascii_case("left"sv)) { } else if (value.equals_ignoring_ascii_case("left"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebLeft));
} else if (value.equals_ignoring_ascii_case("right"sv)) { } else if (value.equals_ignoring_ascii_case("right"sv)) {
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight)); style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebRight));
} else { } else {
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign)) if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign))
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
@ -96,7 +96,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
if (!border) if (!border)
return; return;
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) { auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
style.set_property(style_property, CSS::IdentifierStyleValue::create(CSS::ValueID::Inset)); style.set_property(style_property, CSS::CSSKeywordValue::create(CSS::ValueID::Inset));
style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1))); style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1)));
style.set_property(color_property, table_element->computed_css_values()->property(color_property)); style.set_property(color_property, table_element->computed_css_values()->property(color_property));
}; };

View file

@ -9,8 +9,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/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/HTMLCollection.h> #include <LibWeb/DOM/HTMLCollection.h>
@ -65,8 +65,8 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
} }
if (name == HTML::AttributeNames::align) { if (name == HTML::AttributeNames::align) {
if (value.equals_ignoring_ascii_case("center"sv)) { if (value.equals_ignoring_ascii_case("center"sv)) {
style.set_property(CSS::PropertyID::MarginLeft, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto)); style.set_property(CSS::PropertyID::MarginLeft, CSS::CSSKeywordValue::create(CSS::ValueID::Auto));
style.set_property(CSS::PropertyID::MarginRight, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto)); style.set_property(CSS::PropertyID::MarginRight, CSS::CSSKeywordValue::create(CSS::ValueID::Auto));
} else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::Float)) { } else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::Float)) {
style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull()); style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull());
} }
@ -89,7 +89,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
if (!border) if (!border)
return; return;
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) { auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
auto legacy_line_style = CSS::IdentifierStyleValue::create(CSS::ValueID::Outset); auto legacy_line_style = CSS::CSSKeywordValue::create(CSS::ValueID::Outset);
style.set_property(style_property, legacy_line_style); style.set_property(style_property, legacy_line_style);
style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(border))); style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(border)));
style.set_property(color_property, CSS::ColorStyleValue::create(Color(128, 128, 128))); style.set_property(color_property, CSS::ColorStyleValue::create(Color(128, 128, 128)));

View file

@ -9,8 +9,8 @@
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/Parser/ParsingContext.h> #include <LibWeb/CSS/Parser/ParsingContext.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h> #include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.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>

View file

@ -10,8 +10,8 @@
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h> #include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h> #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
@ -373,7 +373,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
} }
} }
if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->is_identifier()) { if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->is_keyword()) {
switch (attachment_value->to_identifier()) { switch (attachment_value->to_identifier()) {
case CSS::ValueID::Fixed: case CSS::ValueID::Fixed:
layer.attachment = CSS::BackgroundAttachment::Fixed; layer.attachment = CSS::BackgroundAttachment::Fixed;
@ -404,11 +404,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
} }
}; };
if (auto origin_value = value_for_layer(origins, layer_index); origin_value && origin_value->is_identifier()) { if (auto origin_value = value_for_layer(origins, layer_index); origin_value && origin_value->is_keyword()) {
layer.origin = as_box(origin_value->to_identifier()); layer.origin = as_box(origin_value->to_identifier());
} }
if (auto clip_value = value_for_layer(clips, layer_index); clip_value && clip_value->is_identifier()) { if (auto clip_value = value_for_layer(clips, layer_index); clip_value && clip_value->is_keyword()) {
layer.clip = as_box(clip_value->to_identifier()); layer.clip = as_box(clip_value->to_identifier());
} }
@ -430,7 +430,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
layer.size_type = CSS::BackgroundSize::LengthPercentage; layer.size_type = CSS::BackgroundSize::LengthPercentage;
layer.size_x = size.size_x(); layer.size_x = size.size_x();
layer.size_y = size.size_y(); layer.size_y = size.size_y();
} else if (size_value->is_identifier()) { } else if (size_value->is_keyword()) {
switch (size_value->to_identifier()) { switch (size_value->to_identifier()) {
case CSS::ValueID::Contain: case CSS::ValueID::Contain:
layer.size_type = CSS::BackgroundSize::Contain; layer.size_type = CSS::BackgroundSize::Contain;
@ -720,7 +720,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
return max(CSSPixels { 0 }, value->as_calculated().resolve_length(*this)->to_px(*this)); return max(CSSPixels { 0 }, value->as_calculated().resolve_length(*this)->to_px(*this));
if (value->is_length()) if (value->is_length())
return value->as_length().length().to_px(*this); return value->as_length().length().to_px(*this);
if (value->is_identifier()) { if (value->is_keyword()) {
// https://www.w3.org/TR/css-backgrounds-3/#valdef-line-width-thin // https://www.w3.org/TR/css-backgrounds-3/#valdef-line-width-thin
switch (value->to_identifier()) { switch (value->to_identifier()) {
case CSS::ValueID::Thin: case CSS::ValueID::Thin:
@ -843,11 +843,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
if (aspect_ratio->is_value_list()) { if (aspect_ratio->is_value_list()) {
auto& values_list = aspect_ratio->as_value_list().values(); auto& values_list = aspect_ratio->as_value_list().values();
if (values_list.size() == 2 if (values_list.size() == 2
&& values_list[0]->is_identifier() && values_list[0]->as_identifier().id() == CSS::ValueID::Auto && values_list[0]->is_keyword() && values_list[0]->as_keyword().id() == CSS::ValueID::Auto
&& values_list[1]->is_ratio()) { && values_list[1]->is_ratio()) {
computed_values.set_aspect_ratio({ true, values_list[1]->as_ratio().ratio() }); computed_values.set_aspect_ratio({ true, values_list[1]->as_ratio().ratio() });
} }
} else if (aspect_ratio->is_identifier() && aspect_ratio->as_identifier().id() == CSS::ValueID::Auto) { } else if (aspect_ratio->is_keyword() && aspect_ratio->as_keyword().id() == CSS::ValueID::Auto) {
computed_values.set_aspect_ratio({ true, {} }); computed_values.set_aspect_ratio({ true, {} });
} else if (aspect_ratio->is_ratio()) { } else if (aspect_ratio->is_ratio()) {
computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() }); computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() });

View file

@ -10,8 +10,8 @@
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/TemporaryChange.h> #include <AK/TemporaryChange.h>
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>

View file

@ -7,8 +7,8 @@
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/SVGSymbolElementPrototype.h> #include <LibWeb/Bindings/SVGSymbolElementPrototype.h>
#include <LibWeb/CSS/StyleProperties.h> #include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h> #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h> #include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/DOM/ShadowRoot.h> #include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/Layout/SVGGraphicsBox.h> #include <LibWeb/Layout/SVGGraphicsBox.h>