Browse Source

LibHTML: Add the outline of a CSS stylesheet object graph.

Andreas Kling 6 years ago
parent
commit
d99b1a9ea0

+ 9 - 0
LibHTML/CSS/Selector.cpp

@@ -0,0 +1,9 @@
+#include <LibHTML/CSS/Selector.h>
+
+Selector::Selector()
+{
+}
+
+Selector::~Selector()
+{
+}

+ 21 - 0
LibHTML/CSS/Selector.h

@@ -0,0 +1,21 @@
+#pragma once
+
+#include <AK/AKString.h>
+#include <AK/Vector.h>
+
+class Selector {
+public:
+    Selector();
+    ~Selector();
+
+    struct Component {
+        enum class Type { Invalid, TagName, Id, Class };
+        Type type { Type::Invalid };
+        String value;
+    };
+
+    const Vector<Component>& components() const { return m_components; }
+
+private:
+    Vector<Component> m_components;
+};

+ 9 - 0
LibHTML/CSS/StyleDeclaration.cpp

@@ -0,0 +1,9 @@
+#include <LibHTML/CSS/StyleDeclaration.h>
+
+StyleDeclaration::StyleDeclaration()
+{
+}
+
+StyleDeclaration::~StyleDeclaration()
+{
+}

+ 17 - 0
LibHTML/CSS/StyleDeclaration.h

@@ -0,0 +1,17 @@
+#pragma once
+
+#include <AK/AKString.h>
+#include <LibHTML/CSS/StyleValue.h>
+
+class StyleDeclaration {
+public:
+    StyleDeclaration();
+    ~StyleDeclaration();
+
+    const String& property_name() const { return m_property_name; }
+    const StyleValue& value() const { return *m_value; }
+
+public:
+    String m_property_name;
+    RetainPtr<StyleValue> m_value;
+};

+ 0 - 0
LibHTML/CSS/StyleRule.cpp


+ 15 - 0
LibHTML/CSS/StyleRule.h

@@ -0,0 +1,15 @@
+#pragma once
+
+#include <AK/Vector.h>
+#include <LibHTML/CSS/Selector.h>
+#include <LibHTML/CSS/StyleDeclaration.h>
+
+class StyleRule {
+public:
+    StyleRule();
+    ~StyleRule();
+
+private:
+    Vector<Selector> m_selectors;
+    Vector<StyleDeclaration> m_declarations;
+};

+ 9 - 0
LibHTML/CSS/StyleSheet.cpp

@@ -0,0 +1,9 @@
+#include <LibHTML/CSS/StyleSheet.h>
+
+StyleSheet::StyleSheet()
+{
+}
+
+StyleSheet::~StyleSheet()
+{
+}

+ 15 - 0
LibHTML/CSS/StyleSheet.h

@@ -0,0 +1,15 @@
+#pragma once
+
+#include <AK/Vector.h>
+#include <LibHTML/CSS/StyleRule.h>
+
+class StyleSheet {
+public:
+    StyleSheet();
+    ~StyleSheet();
+
+    const Vector<StyleRule>& rules() const { return m_rules; }
+
+private:
+    Vector<StyleRule> m_rules;
+};

+ 0 - 0
LibHTML/CSS/StyleValue.cpp


+ 23 - 0
LibHTML/CSS/StyleValue.h

@@ -0,0 +1,23 @@
+#pragma once
+
+#include <AK/Retainable.h>
+
+class StyleValue : public Retainable<StyleValue> {
+public:
+    virtual ~StyleValue();
+
+    enum Type {
+        Invalid,
+        Inherit,
+        Initial,
+        Primitive,
+    };
+
+    Type type() const { return m_type; }
+
+protected:
+    explicit StyleValue(Type);
+
+private:
+    Type m_type { Type::Invalid };
+};

+ 5 - 0
LibHTML/Makefile

@@ -6,6 +6,11 @@ LIBHTML_OBJS = \
     DOM/Element.o \
     DOM/Element.o \
     DOM/Document.o \
     DOM/Document.o \
     DOM/Text.o \
     DOM/Text.o \
+    CSS/Selector.o \
+    CSS/StyleSheet.o \
+    CSS/StyleRule.o \
+    CSS/StyleDeclaration.o \
+    CSS/StyleValue.o \
     Parser/Parser.o \
     Parser/Parser.o \
     Layout/LayoutNode.o \
     Layout/LayoutNode.o \
     Layout/LayoutText.o \
     Layout/LayoutText.o \