瀏覽代碼

LibWeb: Implement StyleComponentValueRule::to_string()

Sam Atkins 3 年之前
父節點
當前提交
933a271a78

+ 1 - 0
Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h

@@ -52,6 +52,7 @@ public:
     Token const& token() const { return m_token; }
     operator Token() const { return m_token; }
 
+    String to_string() const;
     String to_debug_string() const;
 
 private:

+ 19 - 0
Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp

@@ -133,6 +133,25 @@ String StyleBlockRule::to_string() const
     return builder.to_string();
 }
 
+String StyleComponentValueRule::to_string() const
+{
+    StringBuilder builder;
+
+    switch (m_type) {
+    case StyleComponentValueRule::ComponentType::Token:
+        builder.append(m_token.to_string());
+        break;
+    case StyleComponentValueRule::ComponentType::Function:
+        builder.append(m_function->to_string());
+        break;
+    case StyleComponentValueRule::ComponentType::Block:
+        builder.append(m_block->to_string());
+        break;
+    }
+
+    return builder.to_string();
+}
+
 String StyleComponentValueRule::to_debug_string() const
 {
     StringBuilder builder;