mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibWeb: Make CSSRuleList GC-allocated
This commit is contained in:
parent
5366924f11
commit
5d6cb9cbdb
11 changed files with 50 additions and 29 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,8 +10,8 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/Iterator.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibWeb/Bindings/LegacyPlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -18,16 +19,14 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
// https://www.w3.org/TR/cssom/#the-cssrulelist-interface
|
||||
class CSSRuleList
|
||||
: public RefCounted<CSSRuleList>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::CSSRuleListWrapper;
|
||||
class CSSRuleList : public Bindings::LegacyPlatformObject {
|
||||
JS_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject);
|
||||
|
||||
static NonnullRefPtr<CSSRuleList> create(NonnullRefPtrVector<CSSRule>&& rules)
|
||||
{
|
||||
return adopt_ref(*new CSSRuleList(move(rules)));
|
||||
}
|
||||
public:
|
||||
CSSRuleList& impl() { return *this; }
|
||||
|
||||
static CSSRuleList* create(Bindings::WindowObject&, NonnullRefPtrVector<CSSRule>&& rules);
|
||||
CSSRuleList(Bindings::WindowObject&, NonnullRefPtrVector<CSSRule>&&);
|
||||
~CSSRuleList() = default;
|
||||
|
||||
RefPtr<CSSRule> item(size_t index) const
|
||||
|
@ -47,7 +46,8 @@ public:
|
|||
ConstIterator const end() const { return m_rules.end(); }
|
||||
Iterator end() { return m_rules.end(); }
|
||||
|
||||
bool is_supported_property_index(u32 index) const;
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
DOM::ExceptionOr<void> remove_a_css_rule(u32 index);
|
||||
DOM::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, NonnullRefPtr<CSSRule>>, u32 index);
|
||||
|
@ -57,9 +57,12 @@ public:
|
|||
bool evaluate_media_queries(HTML::Window const&);
|
||||
|
||||
private:
|
||||
explicit CSSRuleList(NonnullRefPtrVector<CSSRule>&&);
|
||||
|
||||
NonnullRefPtrVector<CSSRule> m_rules;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::GlobalObject&, Web::CSS::CSSRuleList& object) { return &object; }
|
||||
using CSSRuleListWrapper = Web::CSS::CSSRuleList;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue