From c9062b4ed5396f270fbe70adcd442228fcc40b0d Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 3 Dec 2021 20:17:17 +0000 Subject: [PATCH] LibWeb: Remove now-unused CustomStyleValue --- .../LibWeb/Generate_CSS_PropertyID_cpp.cpp | 2 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 11 ++------- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 7 ------ Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 6 ----- Userland/Libraries/LibWeb/CSS/StyleValue.h | 24 ------------------- Userland/Libraries/LibWeb/Forward.h | 1 - 6 files changed, 3 insertions(+), 48 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp index b28977561e..12b0a84e38 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp @@ -267,7 +267,7 @@ bool property_has_quirk(PropertyID property_id, Quirk quirk) bool property_accepts_value(PropertyID property_id, StyleValue& style_value) { - if (style_value.is_builtin() || style_value.is_custom_property()) + if (style_value.is_builtin()) return true; switch (property_id) { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 61a12a0849..073b6a660c 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1908,15 +1908,8 @@ RefPtr Parser::parse_dynamic_value(StyleComponentValueRule const& co if (calc_expression) return CalculatedStyleValue::create("(FIXME:calc to string)", calc_expression.release_nonnull()); } else if (function.name().equals_ignoring_case("var")) { - // FIXME: Handle fallback value as second parameter - // https://www.w3.org/TR/css-variables-1/#using-variables - if (!component_value.function().values().is_empty()) { - auto& property_name_token = component_value.function().values().first(); - if (property_name_token.is(Token::Type::Ident)) - return CustomStyleValue::create(property_name_token.token().ident()); - else - dbgln("First argument to var() function was not an ident: '{}'", property_name_token.to_debug_string()); - } + // Declarations using `var()` should already be parsed as an UnresolvedStyleValue before this point. + VERIFY_NOT_REACHED(); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index a8af89d46f..0f5180c2b5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -572,13 +572,6 @@ void StyleComputer::cascade_declarations(StyleProperties& style, DOM::Element& e if (important != property.important) continue; auto property_value = property.value; - if (property.value->is_custom_property()) { - auto custom_property_name = property.value->as_custom_property().custom_property_name(); - auto resolved = resolve_custom_property(element, custom_property_name); - if (resolved.has_value()) { - property_value = resolved.value().value; - } - } if (property.value->is_unresolved()) { if (auto resolved = resolve_unresolved_style_value(element, property.property_id, property.value->as_unresolved())) property_value = resolved.release_nonnull(); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 74e6a850cd..bffce543c3 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -73,12 +73,6 @@ ColorStyleValue const& StyleValue::as_color() const return static_cast(*this); } -CustomStyleValue const& StyleValue::as_custom_property() const -{ - VERIFY(is_custom_property()); - return static_cast(*this); -} - FlexStyleValue const& StyleValue::as_flex() const { VERIFY(is_flex()); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index c49c977a13..14f52b4a2f 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -272,7 +272,6 @@ public: Calculated, Color, CombinedBorderRadius, - CustomProperty, Flex, FlexFlow, Font, @@ -304,7 +303,6 @@ public: bool is_box_shadow() const { return type() == Type::BoxShadow; } bool is_calculated() const { return type() == Type::Calculated; } bool is_color() const { return type() == Type::Color; } - bool is_custom_property() const { return type() == Type::CustomProperty; } bool is_flex() const { return type() == Type::Flex; } bool is_flex_flow() const { return type() == Type::FlexFlow; } bool is_font() const { return type() == Type::Font; } @@ -334,7 +332,6 @@ public: BoxShadowStyleValue const& as_box_shadow() const; CalculatedStyleValue const& as_calculated() const; ColorStyleValue const& as_color() const; - CustomStyleValue const& as_custom_property() const; FlexFlowStyleValue const& as_flex_flow() const; FlexStyleValue const& as_flex() const; FontStyleValue const& as_font() const; @@ -362,7 +359,6 @@ public: BoxShadowStyleValue& as_box_shadow() { return const_cast(const_cast(*this).as_box_shadow()); } CalculatedStyleValue& as_calculated() { return const_cast(const_cast(*this).as_calculated()); } ColorStyleValue& as_color() { return const_cast(const_cast(*this).as_color()); } - CustomStyleValue& as_custom_property() { return const_cast(const_cast(*this).as_custom_property()); } FlexFlowStyleValue& as_flex_flow() { return const_cast(const_cast(*this).as_flex_flow()); } FlexStyleValue& as_flex() { return const_cast(const_cast(*this).as_flex()); } FontStyleValue& as_font() { return const_cast(const_cast(*this).as_font()); } @@ -852,26 +848,6 @@ private: NonnullRefPtr m_bottom_left; }; -// FIXME: Allow for fallback -class CustomStyleValue : public StyleValue { -public: - static NonnullRefPtr create(String const& custom_property_name) - { - return adopt_ref(*new CustomStyleValue(custom_property_name)); - } - String custom_property_name() const { return m_custom_property_name; } - String to_string() const override { return m_custom_property_name; } - -private: - explicit CustomStyleValue(String const& custom_property_name) - : StyleValue(Type::CustomProperty) - , m_custom_property_name(custom_property_name) - { - } - - String m_custom_property_name {}; -}; - class FlexStyleValue final : public StyleValue { public: static NonnullRefPtr create( diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 0020c089ea..7205762ba7 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -35,7 +35,6 @@ class CSSStyleDeclaration; class CSSStyleRule; class CSSStyleSheet; class CSSSupportsRule; -class CustomStyleValue; class Display; class ElementInlineCSSStyleDeclaration; class FlexFlowStyleValue;