Просмотр исходного кода

LibWeb: Move ComponentValue to CSS::Parser namespace

Sam Atkins 3 лет назад
Родитель
Сommit
fff2c35f51

+ 1 - 1
Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp

@@ -9,7 +9,7 @@
 #include <LibWeb/CSS/Parser/StyleBlockRule.h>
 #include <LibWeb/CSS/Parser/StyleFunctionRule.h>
 
-namespace Web::CSS {
+namespace Web::CSS::Parser {
 
 ComponentValue::ComponentValue(Token token)
     : m_value(token)

+ 3 - 1
Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.h

@@ -12,9 +12,11 @@
 #include <LibWeb/CSS/Parser/Token.h>
 
 namespace Web::CSS {
-
 class StyleBlockRule;
 class StyleFunctionRule;
+}
+
+namespace Web::CSS::Parser {
 
 // https://www.w3.org/TR/css-syntax-3/#component-value
 class ComponentValue {

+ 2 - 2
Userland/Libraries/LibWeb/CSS/Parser/Declaration.h

@@ -21,14 +21,14 @@ public:
     ~Declaration();
 
     String const& name() const { return m_name; }
-    Vector<ComponentValue> const& values() const { return m_values; }
+    Vector<Parser::ComponentValue> const& values() const { return m_values; }
     Important importance() const { return m_important; }
 
     String to_string() const;
 
 private:
     String m_name;
-    Vector<ComponentValue> m_values;
+    Vector<Parser::ComponentValue> m_values;
     Important m_important { Important::No };
 };
 

+ 3 - 3
Userland/Libraries/LibWeb/CSS/Parser/StyleBlockRule.h

@@ -20,7 +20,7 @@ class StyleBlockRule : public RefCounted<StyleBlockRule> {
 
 public:
     StyleBlockRule();
-    explicit StyleBlockRule(Token token, Vector<ComponentValue>&& values)
+    explicit StyleBlockRule(Token token, Vector<Parser::ComponentValue>&& values)
         : m_token(move(token))
         , m_values(move(values))
     {
@@ -33,12 +33,12 @@ public:
 
     Token const& token() const { return m_token; }
 
-    Vector<ComponentValue> const& values() const { return m_values; }
+    Vector<Parser::ComponentValue> const& values() const { return m_values; }
 
     String to_string() const;
 
 private:
     Token m_token;
-    Vector<ComponentValue> m_values;
+    Vector<Parser::ComponentValue> m_values;
 };
 }

+ 3 - 3
Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.h

@@ -20,16 +20,16 @@ class StyleFunctionRule : public RefCounted<StyleFunctionRule> {
 
 public:
     explicit StyleFunctionRule(String name);
-    StyleFunctionRule(String name, Vector<ComponentValue>&& values);
+    StyleFunctionRule(String name, Vector<Parser::ComponentValue>&& values);
     ~StyleFunctionRule();
 
     String const& name() const { return m_name; }
-    Vector<ComponentValue> const& values() const { return m_values; }
+    Vector<Parser::ComponentValue> const& values() const { return m_values; }
 
     String to_string() const;
 
 private:
     String m_name;
-    Vector<ComponentValue> m_values;
+    Vector<Parser::ComponentValue> m_values;
 };
 }

+ 2 - 2
Userland/Libraries/LibWeb/CSS/Parser/StyleRule.h

@@ -29,7 +29,7 @@ public:
     bool is_qualified_rule() const { return m_type == Type::Qualified; }
     bool is_at_rule() const { return m_type == Type::At; }
 
-    Vector<ComponentValue> const& prelude() const { return m_prelude; }
+    Vector<Parser::ComponentValue> const& prelude() const { return m_prelude; }
     RefPtr<StyleBlockRule const> block() const { return m_block; }
     String const& at_rule_name() const { return m_at_rule_name; }
 
@@ -38,7 +38,7 @@ public:
 private:
     Type const m_type;
     String m_at_rule_name;
-    Vector<ComponentValue> m_prelude;
+    Vector<Parser::ComponentValue> m_prelude;
     RefPtr<StyleBlockRule> m_block;
 };
 

+ 1 - 1
Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp

@@ -44,7 +44,7 @@ StyleFunctionRule::StyleFunctionRule(String name)
 {
 }
 
-StyleFunctionRule::StyleFunctionRule(String name, Vector<ComponentValue>&& values)
+StyleFunctionRule::StyleFunctionRule(String name, Vector<Parser::ComponentValue>&& values)
     : m_name(move(name))
     , m_values(move(values))
 {

+ 5 - 5
Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

@@ -526,10 +526,10 @@ static RefPtr<StyleValue> get_custom_property(DOM::Element const& element, FlySt
     return nullptr;
 }
 
-bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<ComponentValue> const& source, Vector<ComponentValue>& dest, size_t source_start_index) const
+bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<Parser::ComponentValue> const& source, Vector<Parser::ComponentValue>& dest, size_t source_start_index) const
 {
     // FIXME: Do this better!
-    // We build a copy of the tree of StyleComponentValueRules, with all var()s and attr()s replaced with their contents.
+    // We build a copy of the tree of ComponentValues, with all var()s and attr()s replaced with their contents.
     // This is a very naive solution, and we could do better if the CSS Parser could accept tokens one at a time.
 
     // Arbitrary large value chosen to avoid the billion-laughs attack.
@@ -619,7 +619,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
             }
 
             auto const& source_function = value.function();
-            Vector<ComponentValue> function_values;
+            Vector<Parser::ComponentValue> function_values;
             if (!expand_unresolved_values(element, property_name, dependencies, source_function.values(), function_values, 0))
                 return false;
             NonnullRefPtr<StyleFunctionRule> function = adopt_ref(*new StyleFunctionRule(source_function.name(), move(function_values)));
@@ -628,7 +628,7 @@ bool StyleComputer::expand_unresolved_values(DOM::Element& element, StringView p
         }
         if (value.is_block()) {
             auto const& source_block = value.block();
-            Vector<ComponentValue> block_values;
+            Vector<Parser::ComponentValue> block_values;
             if (!expand_unresolved_values(element, property_name, dependencies, source_block.values(), block_values, 0))
                 return false;
             NonnullRefPtr<StyleBlockRule> block = adopt_ref(*new StyleBlockRule(source_block.token(), move(block_values)));
@@ -647,7 +647,7 @@ RefPtr<StyleValue> StyleComputer::resolve_unresolved_style_value(DOM::Element& e
     // to produce a different StyleValue from it.
     VERIFY(unresolved.contains_var_or_attr());
 
-    Vector<ComponentValue> expanded_values;
+    Vector<Parser::ComponentValue> expanded_values;
     HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>> dependencies;
     if (!expand_unresolved_values(element, string_from_property_id(property_id), dependencies, unresolved.values(), expanded_values, 0))
         return {};

+ 1 - 1
Userland/Libraries/LibWeb/CSS/StyleComputer.h

@@ -86,7 +86,7 @@ private:
     void compute_defaulted_property_value(StyleProperties&, DOM::Element const*, CSS::PropertyID, Optional<CSS::Selector::PseudoElement>) const;
 
     RefPtr<StyleValue> resolve_unresolved_style_value(DOM::Element&, PropertyID, UnresolvedStyleValue const&) const;
-    bool expand_unresolved_values(DOM::Element&, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<ComponentValue> const& source, Vector<ComponentValue>& dest, size_t source_start_index) const;
+    bool expand_unresolved_values(DOM::Element&, StringView property_name, HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>>& dependencies, Vector<Parser::ComponentValue> const& source, Vector<Parser::ComponentValue>& dest, size_t source_start_index) const;
 
     template<typename Callback>
     void for_each_stylesheet(CascadeOrigin, Callback) const;

+ 4 - 4
Userland/Libraries/LibWeb/CSS/StyleValue.h

@@ -1625,7 +1625,7 @@ private:
 
 class UnresolvedStyleValue final : public StyleValue {
 public:
-    static NonnullRefPtr<UnresolvedStyleValue> create(Vector<ComponentValue>&& values, bool contains_var_or_attr)
+    static NonnullRefPtr<UnresolvedStyleValue> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
     {
         return adopt_ref(*new UnresolvedStyleValue(move(values), contains_var_or_attr));
     }
@@ -1633,18 +1633,18 @@ public:
 
     virtual String to_string() const override;
 
-    Vector<ComponentValue> const& values() const { return m_values; }
+    Vector<Parser::ComponentValue> const& values() const { return m_values; }
     bool contains_var_or_attr() const { return m_contains_var_or_attr; }
 
 private:
-    UnresolvedStyleValue(Vector<ComponentValue>&& values, bool contains_var_or_attr)
+    UnresolvedStyleValue(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
         : StyleValue(Type::Unresolved)
         , m_values(move(values))
         , m_contains_var_or_attr(contains_var_or_attr)
     {
     }
 
-    Vector<ComponentValue> m_values;
+    Vector<Parser::ComponentValue> m_values;
     bool m_contains_var_or_attr { false };
 };
 

+ 1 - 0
Userland/Libraries/LibWeb/Forward.h

@@ -99,6 +99,7 @@ enum class ValueID;
 }
 
 namespace Web::CSS::Parser {
+class ComponentValue;
 class Parser;
 }