diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-13 22:39:55 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-13 22:41:32 +0100 |
commit | 33e3f0c71ff1914424b6baf24371823654537e01 (patch) | |
tree | e686859aa8c11db9af30d57b28e45203079d9bb5 /Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h | |
parent | 0759f54bd33f3900c094f27d81481da76b9b4a03 (diff) | |
download | serenity-33e3f0c71ff1914424b6baf24371823654537e01.zip |
LibWeb: Expose barebones CSSStyleDeclaration to JavaScript
You can now access an element's inline style via Element.style.
The interface is not very capable yet though. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index b81b08dcdc..ec553198b8 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,6 +28,7 @@ #include <AK/String.h> #include <AK/Vector.h> +#include <LibWeb/Bindings/Wrappable.h> #include <LibWeb/CSS/StyleValue.h> namespace Web::CSS { @@ -38,8 +39,12 @@ struct StyleProperty { bool important { false }; }; -class CSSStyleDeclaration : public RefCounted<CSSStyleDeclaration> { +class CSSStyleDeclaration + : public RefCounted<CSSStyleDeclaration> + , public Bindings::Wrappable { public: + using WrapperType = Bindings::CSSStyleDeclarationWrapper; + static NonnullRefPtr<CSSStyleDeclaration> create(Vector<StyleProperty>&& properties) { return adopt(*new CSSStyleDeclaration(move(properties))); @@ -49,6 +54,9 @@ public: const Vector<StyleProperty>& properties() const { return m_properties; } + size_t length() const { return m_properties.size(); } + String item(size_t index) const; + private: explicit CSSStyleDeclaration(Vector<StyleProperty>&&); @@ -56,3 +64,9 @@ private: }; } + +namespace Web::Bindings { + +CSSStyleDeclarationWrapper* wrap(JS::GlobalObject&, CSS::CSSStyleDeclaration&); + +} |