From 9559f0f123fcd1c2fddba625d4bdc4806bb8bd68 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 14 Aug 2024 11:46:56 +0100 Subject: [PATCH] LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue This matches the name in the CSS Typed OM spec. https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue --- .../Libraries/LibWeb/CSS/StyleValues/BUILD.gn | 2 +- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- .../Libraries/LibWeb/CSS/CSSStyleValue.cpp | 26 ++++++------ Userland/Libraries/LibWeb/CSS/CSSStyleValue.h | 10 ++--- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 26 ++++++------ .../CSS/ResolvedCSSStyleDeclaration.cpp | 22 +++++----- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 40 +++++++++---------- .../Libraries/LibWeb/CSS/StyleProperties.cpp | 24 +++++------ ...fierStyleValue.cpp => CSSKeywordValue.cpp} | 12 +++--- ...entifierStyleValue.h => CSSKeywordValue.h} | 17 ++++---- Userland/Libraries/LibWeb/DOM/Element.cpp | 4 +- Userland/Libraries/LibWeb/Forward.h | 2 +- .../LibWeb/HTML/HTMLCanvasElement.cpp | 4 +- .../Libraries/LibWeb/HTML/HTMLDivElement.cpp | 10 ++--- .../LibWeb/HTML/HTMLHeadingElement.cpp | 10 ++--- .../LibWeb/HTML/HTMLInputElement.cpp | 4 +- .../LibWeb/HTML/HTMLParagraphElement.cpp | 10 ++--- .../Libraries/LibWeb/HTML/HTMLPreElement.cpp | 4 +- .../LibWeb/HTML/HTMLTableCaptionElement.cpp | 4 +- .../LibWeb/HTML/HTMLTableCellElement.cpp | 10 ++--- .../LibWeb/HTML/HTMLTableElement.cpp | 8 ++-- .../LibWeb/HTML/HTMLTableRowElement.cpp | 2 +- Userland/Libraries/LibWeb/Layout/Node.cpp | 16 ++++---- .../Libraries/LibWeb/Layout/TreeBuilder.cpp | 2 +- .../Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 2 +- 25 files changed, 137 insertions(+), 136 deletions(-) rename Userland/Libraries/LibWeb/CSS/StyleValues/{IdentifierStyleValue.cpp => CSSKeywordValue.cpp} (97%) rename Userland/Libraries/LibWeb/CSS/StyleValues/{IdentifierStyleValue.h => CSSKeywordValue.h} (54%) diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn index fcf3125e28e..56560c6aa1e 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn @@ -7,6 +7,7 @@ source_set("StyleValues") { "BackgroundSizeStyleValue.cpp", "BasicShapeStyleValue.cpp", "BorderRadiusStyleValue.cpp", + "CSSKeywordValue.cpp", "CalculatedStyleValue.cpp", "ColorStyleValue.cpp", "ConicGradientStyleValue.cpp", @@ -19,7 +20,6 @@ source_set("StyleValues") { "GridTemplateAreaStyleValue.cpp", "GridTrackPlacementStyleValue.cpp", "GridTrackSizeListStyleValue.cpp", - "IdentifierStyleValue.cpp", "ImageStyleValue.cpp", "IntegerStyleValue.cpp", "LengthStyleValue.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 1fe1dfa3805..829aa8a5dc1 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -113,6 +113,7 @@ set(SOURCES CSS/StyleValues/ContentStyleValue.cpp CSS/StyleValues/CounterDefinitionsStyleValue.cpp CSS/StyleValues/CounterStyleValue.cpp + CSS/StyleValues/CSSKeywordValue.cpp CSS/StyleValues/DisplayStyleValue.cpp CSS/StyleValues/EasingStyleValue.cpp CSS/StyleValues/EdgeStyleValue.cpp @@ -121,7 +122,6 @@ set(SOURCES CSS/StyleValues/GridTemplateAreaStyleValue.cpp CSS/StyleValues/GridTrackPlacementStyleValue.cpp CSS/StyleValues/GridTrackSizeListStyleValue.cpp - CSS/StyleValues/IdentifierStyleValue.cpp CSS/StyleValues/ImageStyleValue.cpp CSS/StyleValues/IntegerStyleValue.cpp CSS/StyleValues/LengthStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp index d9c7978420e..4d27844465c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -206,10 +206,10 @@ GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() cons return static_cast(*this); } -IdentifierStyleValue const& CSSStyleValue::as_identifier() const +CSSKeywordValue const& CSSStyleValue::as_keyword() const { - VERIFY(is_identifier()); - return static_cast(*this); + VERIFY(is_keyword()); + return static_cast(*this); } ImageStyleValue const& CSSStyleValue::as_image() const @@ -375,20 +375,20 @@ ValueComparingNonnullRefPtr CSSStyleValue::absolutized(CSSP 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 { - if (is_identifier()) - return as_identifier().id(); + if (is_keyword()) + return as_keyword().id(); return ValueID::Invalid; } int CSSStyleValue::to_font_weight() const { - if (is_identifier()) { - switch (static_cast(*this).id()) { + if (is_keyword()) { + switch (static_cast(*this).id()) { case CSS::ValueID::Normal: return Gfx::FontWeight::Regular; case CSS::ValueID::Bold: @@ -417,8 +417,8 @@ int CSSStyleValue::to_font_weight() const int CSSStyleValue::to_font_slope() const { // FIXME: Implement oblique - if (is_identifier()) { - switch (static_cast(*this).id()) { + if (is_keyword()) { + switch (static_cast(*this).id()) { case CSS::ValueID::Italic: { static int italic_slope = Gfx::name_to_slope("Italic"sv); return italic_slope; @@ -438,8 +438,8 @@ int CSSStyleValue::to_font_slope() const int CSSStyleValue::to_font_stretch_width() const { int width = Gfx::FontWidth::Normal; - if (is_identifier()) { - switch (static_cast(*this).id()) { + if (is_keyword()) { + switch (static_cast(*this).id()) { case CSS::ValueID::UltraCondensed: width = Gfx::FontWidth::UltraCondensed; break; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h index 0e32fb3e221..c7eac96004c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -110,11 +110,11 @@ public: GridTemplateArea, GridTrackPlacement, GridTrackSizeList, - Identifier, Image, Inherit, Initial, Integer, + Keyword, Length, LinearGradient, MathDepth, @@ -236,10 +236,6 @@ public: GridTrackSizeListStyleValue const& as_grid_track_size_list() const; GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast(const_cast(*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(const_cast(*this).as_identifier()); } - bool is_image() const { return type() == Type::Image; } ImageStyleValue const& as_image() const; ImageStyleValue& as_image() { return const_cast(const_cast(*this).as_image()); } @@ -256,6 +252,10 @@ public: IntegerStyleValue const& as_integer() const; IntegerStyleValue& as_integer() { return const_cast(const_cast(*this).as_integer()); } + bool is_keyword() const { return type() == Type::Keyword; } + CSSKeywordValue const& as_keyword() const; + CSSKeywordValue& as_keyword() { return const_cast(const_cast(*this).as_keyword()); } + bool is_length() const { return type() == Type::Length; } LengthStyleValue const& as_length() const; LengthStyleValue& as_length() { return const_cast(const_cast(*this).as_length()); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 31fc43ce86b..83ef65b77f2 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -2378,7 +2378,7 @@ RefPtr Parser::parse_identifier_value(TokenStream auto value_id = value_id_from_string(peek_token.token().ident()); if (value_id.has_value()) { (void)tokens.next_token(); // ident - return IdentifierStyleValue::create(value_id.value()); + return CSSKeywordValue::create(value_id.value()); } } @@ -3231,7 +3231,7 @@ RefPtr Parser::parse_paint_value(TokenStream& tok switch (*maybe_ident) { case ValueID::None: (void)tokens.next_token(); - return IdentifierStyleValue::create(*maybe_ident); + return CSSKeywordValue::create(*maybe_ident); default: return nullptr; } @@ -3626,7 +3626,7 @@ RefPtr Parser::parse_all_as_single_none_value(TokenStream& properties, PropertyID property_to_remove) @@ -3654,7 +3654,7 @@ RefPtr Parser::parse_aspect_ratio_value(TokenStreamis_identifier() && maybe_value->as_identifier().id() == ValueID::Auto) { + if (maybe_value->is_keyword() && maybe_value->as_keyword().id() == ValueID::Auto) { if (auto_value) return nullptr; auto_value = maybe_value.release_nonnull(); @@ -3943,7 +3943,7 @@ RefPtr Parser::parse_single_background_position_x_or_y_value(Toke if (!value) return nullptr; - if (value->is_identifier()) { + if (value->is_keyword()) { auto identifier = value->to_identifier(); if (identifier == ValueID::Center) { transaction.commit(); @@ -4819,9 +4819,9 @@ RefPtr Parser::parse_flex_value(TokenStream& toke return make_flex_shorthand(one, one, *value); } 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); - return make_flex_shorthand(zero, zero, IdentifierStyleValue::create(ValueID::Auto)); + return make_flex_shorthand(zero, zero, CSSKeywordValue::create(ValueID::Auto)); } break; } @@ -5091,7 +5091,7 @@ RefPtr Parser::parse_font_family_value(TokenStream Parser::parse_list_style_value(TokenStream if (found_nones == 2) { if (list_image || list_type) return nullptr; - auto none = IdentifierStyleValue::create(ValueID::None); + auto none = CSSKeywordValue::create(ValueID::None); list_image = none; list_type = none; } else if (found_nones == 1) { if (list_image && list_type) return nullptr; - auto none = IdentifierStyleValue::create(ValueID::None); + auto none = CSSKeywordValue::create(ValueID::None); if (!list_image) list_image = none; if (!list_type) @@ -6011,7 +6011,7 @@ RefPtr Parser::parse_transform_origin_value(TokenStreamas_percentage() }; if (value->is_length()) return AxisOffset { Axis::None, value->as_length() }; - if (value->is_identifier()) { + if (value->is_keyword()) { switch (value->to_identifier()) { case ValueID::Top: return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(0)) }; @@ -7343,7 +7343,7 @@ Optional Parser::parse_css_value_for_properties(Readon if (ident.has_value()) { if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) { (void)tokens.next_token(); - return PropertyAndValue { *property, IdentifierStyleValue::create(ident.value()) }; + return PropertyAndValue { *property, CSSKeywordValue::create(ident.value()) }; } } diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 375cc104959..a26dfa0c08a 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -100,7 +100,7 @@ static NonnullRefPtr style_value_for_background_property(La static NonnullRefPtr style_value_for_length_percentage(LengthPercentage const& length_percentage) { if (length_percentage.is_auto()) - return IdentifierStyleValue::create(ValueID::Auto); + return CSSKeywordValue::create(ValueID::Auto); if (length_percentage.is_percentage()) return PercentageStyleValue::create(length_percentage.percentage()); if (length_percentage.is_length()) @@ -111,22 +111,22 @@ static NonnullRefPtr style_value_for_length_percentage(Leng static NonnullRefPtr style_value_for_size(Size const& size) { if (size.is_none()) - return IdentifierStyleValue::create(ValueID::None); + return CSSKeywordValue::create(ValueID::None); if (size.is_percentage()) return PercentageStyleValue::create(size.percentage()); if (size.is_length()) return LengthStyleValue::create(size.length()); if (size.is_auto()) - return IdentifierStyleValue::create(ValueID::Auto); + return CSSKeywordValue::create(ValueID::Auto); if (size.is_calculated()) return size.calculated(); if (size.is_min_content()) - return IdentifierStyleValue::create(ValueID::MinContent); + return CSSKeywordValue::create(ValueID::MinContent); if (size.is_max_content()) - return IdentifierStyleValue::create(ValueID::MaxContent); + return CSSKeywordValue::create(ValueID::MaxContent); // FIXME: Support fit-content() if (size.is_fit_content()) - return IdentifierStyleValue::create(ValueID::FitContent); + return CSSKeywordValue::create(ValueID::FitContent); TODO(); } @@ -172,7 +172,7 @@ static RefPtr style_value_for_length_box_logical_side(Layou static RefPtr style_value_for_shadow(Vector const& shadow_data) { if (shadow_data.is_empty()) - return IdentifierStyleValue::create(ValueID::None); + return CSSKeywordValue::create(ValueID::None); auto make_shadow_style_value = [](ShadowData const& shadow) { return ShadowStyleValue::create( @@ -263,7 +263,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert // The resolved value is normal if the computed value is normal, or the used value otherwise. case PropertyID::LineHeight: { 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 LengthStyleValue::create(Length::make_px(layout_node.computed_values().line_height())); } @@ -370,7 +370,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert case PropertyID::Transform: { auto transformations = layout_node.computed_values().transformations(); 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 // The transform property is a resolved value special case property. [CSSOM] @@ -516,7 +516,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert case PropertyID::WebkitTextFillColor: return ColorStyleValue::create(layout_node.computed_values().webkit_text_fill_color()); case PropertyID::Invalid: - return IdentifierStyleValue::create(ValueID::Invalid); + return CSSKeywordValue::create(ValueID::Invalid); case PropertyID::Custom: dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for custom properties was requested (?)"); return nullptr; diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index ab3c06b4a85..8d1e0c8b9a6 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -784,10 +784,10 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i if (property_id == CSS::PropertyID::Transition) { if (!value.is_transition()) { // 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::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; } 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. 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; } 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; } } @@ -1307,7 +1307,7 @@ static NonnullRefPtr interpolate_box_shadow(DOM::Element& e } } else if (value.is_shadow()) { 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(); } return shadows; @@ -1627,7 +1627,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional {} 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 (duration_value->is_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". duration = {}; } @@ -1652,26 +1652,26 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties& double iteration_count = 1.0; 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; else if (iteration_count_value->is_number()) iteration_count = iteration_count_value->as_number().number(); } 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()) fill_mode = *fill_mode_value; } 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()) direction = *direction_value; } 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()) play_state = *play_state_value; } @@ -2071,7 +2071,7 @@ RefPtr StyleComputer::compute_font_for_style_values( }; 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 auto get_absolute_size_mapping = [](Web::CSS::ValueID identifier) -> CSSPixelFraction { switch (identifier) { @@ -2100,7 +2100,7 @@ RefPtr StyleComputer::compute_font_for_style_values( } }; - auto const identifier = static_cast(font_size).id(); + auto const identifier = static_cast(font_size).id(); if (identifier == ValueID::Math) { auto math_scaling_factor = [&]() { @@ -2258,7 +2258,7 @@ RefPtr StyleComputer::compute_font_for_style_values( auto const& family_list = static_cast(font_family).values(); for (auto const& family : family_list) { RefPtr other_font_list; - if (family->is_identifier()) { + if (family->is_keyword()) { other_font_list = find_generic_font(family->to_identifier()); } else if (family->is_string()) { other_font_list = find_font(family->as_string().string_value()); @@ -2268,7 +2268,7 @@ RefPtr StyleComputer::compute_font_for_style_values( if (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())) font_list->extend(*other_font_list); } 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; if (!overflow_x_is_visible_or_clip || !overflow_y_is_visible_or_clip) { 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) - 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) - 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) - style.set_property(CSS::PropertyID::OverflowY, IdentifierStyleValue::create(CSS::ValueID::Hidden)); + style.set_property(CSS::PropertyID::OverflowY, CSSKeywordValue::create(CSS::ValueID::Hidden)); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index c2370d7a61f..3ed446e3ffc 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -18,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -124,7 +124,7 @@ RefPtr StyleProperties::maybe_null_property(CSS::PropertyID CSS::Size StyleProperties::size_value(CSS::PropertyID id) const { auto value = property(id); - if (value->is_identifier()) { + if (value->is_keyword()) { switch (value->to_identifier()) { case ValueID::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); - 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; if (line_height->is_length()) { @@ -355,7 +355,7 @@ Optional StyleProperties::flex_basis() const { 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 size_value(CSS::PropertyID::FlexBasis); @@ -443,7 +443,7 @@ Optional StyleProperties::justify_self() const Vector 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 {}; if (!value.is_value_list()) @@ -729,7 +729,7 @@ StyleProperties::ContentDataAndQuoteNestingLevel StyleProperties::content(DOM::E for (auto const& item : content_style_value.content().values()) { if (item->is_string()) { builder.append(item->as_string().string_value()); - } else if (item->is_identifier()) { + } else if (item->is_keyword()) { switch (item->to_identifier()) { case ValueID::OpenQuote: builder.append(get_quote_string(true, quote_nesting_level++)); @@ -809,7 +809,7 @@ Optional StyleProperties::cursor() const Optional StyleProperties::visibility() const { auto value = property(CSS::PropertyID::Visibility); - if (!value->is_identifier()) + if (!value->is_keyword()) return {}; return value_id_to_visibility(value->to_identifier()); } @@ -836,7 +836,7 @@ Vector StyleProperties::text_decoration_line() const return lines; } - if (value->is_identifier() && value->to_identifier() == ValueID::None) + if (value->is_keyword() && value->to_identifier() == ValueID::None) return {}; dbgln("FIXME: Unsupported value for text-decoration-line: {}", value->to_string()); @@ -963,7 +963,7 @@ Variant StyleProperties::vertical_ali { 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(); if (value->is_length()) @@ -1100,9 +1100,9 @@ Optional StyleProperties::mask_type() const Color StyleProperties::stop_color() const { auto value = property(CSS::PropertyID::StopColor); - if (value->is_identifier()) { + if (value->is_keyword()) { // 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) value = property(CSS::PropertyID::Color); } @@ -1124,7 +1124,7 @@ void StyleProperties::set_math_depth(int math_depth) QuotesData StyleProperties::quotes() const { auto value = property(CSS::PropertyID::Quotes); - if (value->is_identifier()) { + if (value->is_keyword()) { switch (value->to_identifier()) { case ValueID::Auto: return QuotesData { .type = QuotesData::Type::Auto }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.cpp similarity index 97% rename from Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.cpp rename to Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.cpp index c8b192fc889..8de0b196238 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.cpp @@ -1,13 +1,13 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Tobias Christiansen - * Copyright (c) 2021-2023, Sam Atkins + * Copyright (c) 2021-2024, Sam Atkins * Copyright (c) 2022-2023, MacDue * * SPDX-License-Identifier: BSD-2-Clause */ -#include "IdentifierStyleValue.h" +#include "CSSKeywordValue.h" #include #include #include @@ -16,12 +16,12 @@ 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))); } -bool IdentifierStyleValue::is_color(ValueID value_id) +bool CSSKeywordValue::is_color(ValueID value_id) { switch (value_id) { 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); } -Color IdentifierStyleValue::to_color(Optional node) const +Color CSSKeywordValue::to_color(Optional node) const { if (id() == CSS::ValueID::Currentcolor) { if (!node.has_value() || !node->has_style()) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h similarity index 54% rename from Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.h rename to Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h index 2aab17711cd..27399828a55 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/IdentifierStyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CSSKeywordValue.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Tobias Christiansen - * Copyright (c) 2021-2023, Sam Atkins + * Copyright (c) 2021-2024, Sam Atkins * Copyright (c) 2022-2023, MacDue * * SPDX-License-Identifier: BSD-2-Clause @@ -14,13 +14,14 @@ namespace Web::CSS { -class IdentifierStyleValue final : public StyleValueWithDefaultOperators { +// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue +class CSSKeywordValue final : public StyleValueWithDefaultOperators { public: - static ValueComparingNonnullRefPtr create(ValueID id) + static ValueComparingNonnullRefPtr 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; } @@ -29,11 +30,11 @@ public: virtual Color to_color(Optional node) 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: - explicit IdentifierStyleValue(ValueID id) - : StyleValueWithDefaultOperators(Type::Identifier) + explicit CSSKeywordValue(ValueID id) + : StyleValueWithDefaultOperators(Type::Keyword) , m_id(id) { } diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 1d53c883e43..8f46c08771d 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -542,7 +542,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style() if (is(*this)) { 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)) - 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; diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 7a17c956cc5..82d014310e1 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -107,6 +107,7 @@ class CSSGroupingRule; class CSSImportRule; class CSSKeyframeRule; class CSSKeyframesRule; +class CSSKeywordValue; class CSSMediaRule; class CSSRule; class CSSRuleList; @@ -150,7 +151,6 @@ class GridTrackPlacement; class GridTrackPlacementStyleValue; class GridTrackSizeList; class GridTrackSizeListStyleValue; -class IdentifierStyleValue; class ImageStyleValue; class InheritStyleValue; class InitialStyleValue; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index d0f51ba2ee8..fc5615fd6d4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -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. style.set_property(CSS::PropertyID::AspectRatio, CSS::StyleValueList::create(CSS::StyleValueVector { - CSS::IdentifierStyleValue::create(CSS::ValueID::Auto), + CSS::CSSKeywordValue::create(CSS::ValueID::Auto), CSS::RatioStyleValue::create(CSS::Ratio { static_cast(w.value()), static_cast(h.value()) }) }, CSS::StyleValueList::Separator::Space)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp index f338518355a..badf8029924 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace Web::HTML { @@ -27,13 +27,13 @@ void HTMLDivElement::apply_presentational_hints(CSS::StyleProperties& style) con for_each_attribute([&](auto& name, auto& value) { if (name.equals_ignoring_ascii_case("align"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)) - 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)) - 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)) - style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); + style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify)); } }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index 84aec4cd3d7..53a01d85107 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace Web::HTML { @@ -34,13 +34,13 @@ void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style) for_each_attribute([&](auto& name, auto& value) { if (name.equals_ignoring_ascii_case("align"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) - 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) - 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) - style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); + style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify)); } }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 0b352935ec8..7b5879146cd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -135,7 +135,7 @@ void HTMLInputElement::adjust_computed_style(CSS::StyleProperties& style) double current_line_height = style.line_height().to_double(); 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) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp index 784ccf0792b..19a2be96a37 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace Web::HTML { @@ -34,13 +34,13 @@ void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& styl for_each_attribute([&](auto& name, auto& value) { if (name.equals_ignoring_ascii_case("align"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) - 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) - 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) - style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); + style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify)); } }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp index bb5e3696713..ef7ab324909 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con for_each_attribute([&](auto const& name, auto const&) { 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)); }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp index 70f561ff38e..6453f1611d8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include namespace Web::HTML { @@ -34,7 +34,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& s for_each_attribute([&](auto& name, auto& value) { if (name.equals_ignoring_ascii_case("align"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)); } }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index d7f5e147b78..e73414f275f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -54,11 +54,11 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl } if (name == HTML::AttributeNames::align) { 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)) { - 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)) { - 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 (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign)) style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); @@ -96,7 +96,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl if (!border) return; 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(color_property, table_element->computed_css_values()->property(color_property)); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 8fe9468e318..ed98109aee2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -65,8 +65,8 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c } if (name == HTML::AttributeNames::align) { 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::MarginRight, 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::CSSKeywordValue::create(CSS::ValueID::Auto)); } 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()); } @@ -89,7 +89,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c if (!border) return; 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(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(border))); style.set_property(color_property, CSS::ColorStyleValue::create(Color(128, 128, 128))); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index 7773c7cd626..1f600cc71e6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 22da1dbbd0b..ce1b6ce4772 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -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()) { case CSS::ValueID::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()); } - 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()); } @@ -430,7 +430,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) layer.size_type = CSS::BackgroundSize::LengthPercentage; layer.size_x = size.size_x(); layer.size_y = size.size_y(); - } else if (size_value->is_identifier()) { + } else if (size_value->is_keyword()) { switch (size_value->to_identifier()) { case CSS::ValueID::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)); if (value->is_length()) 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 switch (value->to_identifier()) { case CSS::ValueID::Thin: @@ -843,11 +843,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) if (aspect_ratio->is_value_list()) { auto& values_list = aspect_ratio->as_value_list().values(); 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()) { 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, {} }); } else if (aspect_ratio->is_ratio()) { computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() }); diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index f09f6f56920..bd5fa7d593d 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index ce035b0d364..3312cc32aec 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include #include