mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
LibWeb: Store custom properties in CSSStyleDeclaration
Keep them around when parsing and store them in the CSSStyleDeclaration when done.
This commit is contained in:
parent
f0c6160362
commit
0d7169b91a
3 changed files with 32 additions and 13 deletions
|
@ -16,6 +16,7 @@ namespace Web::CSS {
|
|||
struct StyleProperty {
|
||||
CSS::PropertyID property_id;
|
||||
NonnullRefPtr<StyleValue> value;
|
||||
String custom_name {};
|
||||
bool important { false };
|
||||
};
|
||||
|
||||
|
@ -25,25 +26,28 @@ class CSSStyleDeclaration
|
|||
public:
|
||||
using WrapperType = Bindings::CSSStyleDeclarationWrapper;
|
||||
|
||||
static NonnullRefPtr<CSSStyleDeclaration> create(Vector<StyleProperty>&& properties)
|
||||
static NonnullRefPtr<CSSStyleDeclaration> create(Vector<StyleProperty>&& properties, HashMap<String, StyleProperty>&& custom_properties)
|
||||
{
|
||||
return adopt_ref(*new CSSStyleDeclaration(move(properties)));
|
||||
return adopt_ref(*new CSSStyleDeclaration(move(properties), move(custom_properties)));
|
||||
}
|
||||
|
||||
virtual ~CSSStyleDeclaration();
|
||||
|
||||
const Vector<StyleProperty>& properties() const { return m_properties; }
|
||||
const Optional<StyleProperty> custom_property(const String& custom_property_name) const { return m_custom_properties.get(custom_property_name); }
|
||||
size_t custom_property_count() const { return m_custom_properties.size(); };
|
||||
|
||||
size_t length() const { return m_properties.size(); }
|
||||
String item(size_t index) const;
|
||||
|
||||
protected:
|
||||
explicit CSSStyleDeclaration(Vector<StyleProperty>&&);
|
||||
explicit CSSStyleDeclaration(Vector<StyleProperty>&&, HashMap<String, StyleProperty>&&);
|
||||
|
||||
private:
|
||||
friend class Bindings::CSSStyleDeclarationWrapper;
|
||||
|
||||
Vector<StyleProperty> m_properties;
|
||||
HashMap<String, StyleProperty> m_custom_properties;
|
||||
};
|
||||
|
||||
class ElementInlineCSSStyleDeclaration final : public CSSStyleDeclaration {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue