mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibHTML: More work on the CSS object model.
This commit is contained in:
parent
d343fb2429
commit
02e02ca3a5
Notes:
sideshowbarker
2024-07-19 13:32:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/02e02ca3a56
6 changed files with 41 additions and 12 deletions
|
@ -1,6 +1,8 @@
|
|||
#include <LibHTML/CSS/StyleDeclaration.h>
|
||||
|
||||
StyleDeclaration::StyleDeclaration()
|
||||
StyleDeclaration::StyleDeclaration(const String& property_name, NonnullRefPtr<StyleValue>&& value)
|
||||
: m_property_name(property_name)
|
||||
, m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,21 @@
|
|||
#include <AK/AKString.h>
|
||||
#include <LibHTML/CSS/StyleValue.h>
|
||||
|
||||
class StyleDeclaration {
|
||||
class StyleDeclaration : public RefCounted<StyleDeclaration> {
|
||||
public:
|
||||
StyleDeclaration();
|
||||
NonnullRefPtr<StyleDeclaration> create(const String& property_name, NonnullRefPtr<StyleValue>&& value)
|
||||
{
|
||||
return adopt(*new StyleDeclaration(property_name, move(value)));
|
||||
}
|
||||
|
||||
~StyleDeclaration();
|
||||
|
||||
const String& property_name() const { return m_property_name; }
|
||||
const StyleValue& value() const { return *m_value; }
|
||||
|
||||
public:
|
||||
StyleDeclaration(const String& property_name, NonnullRefPtr<StyleValue>&&);
|
||||
|
||||
String m_property_name;
|
||||
RefPtr<StyleValue> m_value;
|
||||
NonnullRefPtr<StyleValue> m_value;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#include <LibHTML/CSS/StyleRule.h>
|
||||
|
||||
StyleRule::StyleRule(Vector<Selector>&& selectors, Vector<NonnullRefPtr<StyleDeclaration>>&& declarations)
|
||||
: m_selectors(move(selectors))
|
||||
, m_declarations(move(declarations))
|
||||
{
|
||||
|
||||
}
|
|
@ -4,12 +4,18 @@
|
|||
#include <LibHTML/CSS/Selector.h>
|
||||
#include <LibHTML/CSS/StyleDeclaration.h>
|
||||
|
||||
class StyleRule {
|
||||
class StyleRule : public RefCounted<StyleRule> {
|
||||
public:
|
||||
StyleRule();
|
||||
NonnullRefPtr<StyleRule> create(Vector<Selector>&& selectors, Vector<NonnullRefPtr<StyleDeclaration>>&& declarations)
|
||||
{
|
||||
return adopt(*new StyleRule(move(selectors), move(declarations)));
|
||||
}
|
||||
|
||||
~StyleRule();
|
||||
|
||||
private:
|
||||
StyleRule(Vector<Selector>&&, Vector<NonnullRefPtr<StyleDeclaration>>&&);
|
||||
|
||||
Vector<Selector> m_selectors;
|
||||
Vector<StyleDeclaration> m_declarations;
|
||||
Vector<NonnullRefPtr<StyleDeclaration>> m_declarations;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <LibHTML/CSS/StyleSheet.h>
|
||||
|
||||
StyleSheet::StyleSheet()
|
||||
StyleSheet::StyleSheet(Vector<NonnullRefPtr<StyleRule>>&& rules)
|
||||
: m_rules(move(rules))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,19 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibHTML/CSS/StyleRule.h>
|
||||
|
||||
class StyleSheet {
|
||||
class StyleSheet : public RefCounted<StyleSheet> {
|
||||
public:
|
||||
StyleSheet();
|
||||
NonnullRefPtr<StyleSheet> create(Vector<NonnullRefPtr<StyleRule>>&& rules)
|
||||
{
|
||||
return adopt(*new StyleSheet(move(rules)));
|
||||
}
|
||||
|
||||
~StyleSheet();
|
||||
|
||||
const Vector<StyleRule>& rules() const { return m_rules; }
|
||||
const Vector<NonnullRefPtr<StyleRule>>& rules() const { return m_rules; }
|
||||
|
||||
private:
|
||||
Vector<StyleRule> m_rules;
|
||||
explicit StyleSheet(Vector<NonnullRefPtr<StyleRule>>&&);
|
||||
|
||||
Vector<NonnullRefPtr<StyleRule>> m_rules;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue