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

This commit is contained in:
Andreas Kling 2019-06-20 23:25:25 +02:00
parent 2e2b97dc8a
commit d99b1a9ea0
11 changed files with 123 additions and 0 deletions

9
LibHTML/CSS/Selector.cpp Normal file
View file

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

21
LibHTML/CSS/Selector.h Normal file
View file

@ -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;
};

View file

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

View file

@ -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;
};

View file

15
LibHTML/CSS/StyleRule.h Normal file
View file

@ -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;
};

View file

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

15
LibHTML/CSS/StyleSheet.h Normal file
View file

@ -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;
};

View file

23
LibHTML/CSS/StyleValue.h Normal file
View file

@ -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 };
};

View file

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