1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

LibHTML: Fix incorrect CSS object model

A StyleRule has a StyleDeclaration which has many StyleProperty. :^)
This commit is contained in:
Andreas Kling 2019-09-30 20:06:17 +02:00
parent ac20919b13
commit 8d797fc62e
7 changed files with 26 additions and 31 deletions

View file

@ -3,21 +3,24 @@
#include <AK/String.h>
#include <LibHTML/CSS/StyleValue.h>
struct StyleProperty {
String name;
NonnullRefPtr<StyleValue> value;
};
class StyleDeclaration : public RefCounted<StyleDeclaration> {
public:
static NonnullRefPtr<StyleDeclaration> create(const String& property_name, NonnullRefPtr<StyleValue>&& value)
static NonnullRefPtr<StyleDeclaration> create(Vector<StyleProperty>&& properties)
{
return adopt(*new StyleDeclaration(property_name, move(value)));
return adopt(*new StyleDeclaration(move(properties)));
}
~StyleDeclaration();
const String& property_name() const { return m_property_name; }
const StyleValue& value() const { return *m_value; }
const Vector<StyleProperty>& properties() const { return m_properties; }
public:
StyleDeclaration(const String& property_name, NonnullRefPtr<StyleValue>&&);
explicit StyleDeclaration(Vector<StyleProperty>&&);
String m_property_name;
NonnullRefPtr<StyleValue> m_value;
Vector<StyleProperty> m_properties;
};