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

LibWeb: Make CSSRule and CSSRuleList available to JavaScript :^)

This patch makes both of these classes inherit from RefCounted and
Bindings::Wrappable, plus some minimal rejigging to allow us to keep
using them internally while also exposing them to web content.
This commit is contained in:
Andreas Kling 2021-09-29 19:41:46 +02:00
parent 87f0059088
commit 3a4565beec
15 changed files with 64 additions and 13 deletions

View file

@ -15,10 +15,18 @@
namespace Web::CSS {
class CSSRuleList {
// https://drafts.csswg.org/cssom/#the-cssrulelist-interface
class CSSRuleList
: public RefCounted<CSSRuleList>
, public Bindings::Wrappable {
public:
explicit CSSRuleList(NonnullRefPtrVector<CSSRule>&&);
virtual ~CSSRuleList();
using WrapperType = Bindings::CSSRuleListWrapper;
static NonnullRefPtr<CSSRuleList> create(NonnullRefPtrVector<CSSRule>&& rules)
{
return adopt_ref(*new CSSRuleList(move(rules)));
}
~CSSRuleList();
RefPtr<CSSRule> item(size_t index) const
{
@ -37,7 +45,11 @@ public:
ConstIterator const end() const { return m_rules.end(); }
Iterator end() { return m_rules.end(); }
bool is_supported_property_index(u32 index) const;
private:
explicit CSSRuleList(NonnullRefPtrVector<CSSRule>&&);
NonnullRefPtrVector<CSSRule> m_rules;
};