LibHTML: Add the outline of a CSS stylesheet object graph.
This commit is contained in:
parent
2e2b97dc8a
commit
d99b1a9ea0
Notes:
sideshowbarker
2024-07-19 13:32:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d99b1a9ea03
11 changed files with 123 additions and 0 deletions
9
LibHTML/CSS/Selector.cpp
Normal file
9
LibHTML/CSS/Selector.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <LibHTML/CSS/Selector.h>
|
||||||
|
|
||||||
|
Selector::Selector()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Selector::~Selector()
|
||||||
|
{
|
||||||
|
}
|
21
LibHTML/CSS/Selector.h
Normal file
21
LibHTML/CSS/Selector.h
Normal 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;
|
||||||
|
};
|
9
LibHTML/CSS/StyleDeclaration.cpp
Normal file
9
LibHTML/CSS/StyleDeclaration.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <LibHTML/CSS/StyleDeclaration.h>
|
||||||
|
|
||||||
|
StyleDeclaration::StyleDeclaration()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleDeclaration::~StyleDeclaration()
|
||||||
|
{
|
||||||
|
}
|
17
LibHTML/CSS/StyleDeclaration.h
Normal file
17
LibHTML/CSS/StyleDeclaration.h
Normal 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;
|
||||||
|
};
|
0
LibHTML/CSS/StyleRule.cpp
Normal file
0
LibHTML/CSS/StyleRule.cpp
Normal file
15
LibHTML/CSS/StyleRule.h
Normal file
15
LibHTML/CSS/StyleRule.h
Normal 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;
|
||||||
|
};
|
9
LibHTML/CSS/StyleSheet.cpp
Normal file
9
LibHTML/CSS/StyleSheet.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <LibHTML/CSS/StyleSheet.h>
|
||||||
|
|
||||||
|
StyleSheet::StyleSheet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleSheet::~StyleSheet()
|
||||||
|
{
|
||||||
|
}
|
15
LibHTML/CSS/StyleSheet.h
Normal file
15
LibHTML/CSS/StyleSheet.h
Normal 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;
|
||||||
|
};
|
0
LibHTML/CSS/StyleValue.cpp
Normal file
0
LibHTML/CSS/StyleValue.cpp
Normal file
23
LibHTML/CSS/StyleValue.h
Normal file
23
LibHTML/CSS/StyleValue.h
Normal 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 };
|
||||||
|
};
|
|
@ -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 \
|
||||||
|
|
Loading…
Add table
Reference in a new issue