mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibWeb: Make CSSRule and all its subclasses GC-allocated
This commit is contained in:
parent
5d6cb9cbdb
commit
12042f0757
39 changed files with 338 additions and 236 deletions
|
@ -1,27 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class CSSRule
|
||||
: public RefCounted<CSSRule>
|
||||
, public Bindings::Wrappable
|
||||
, public Weakable<CSSRule> {
|
||||
public:
|
||||
using WrapperType = Bindings::CSSRuleWrapper;
|
||||
class CSSRule : public Bindings::PlatformObject {
|
||||
JS_OBJECT(CSSRule, JS::Object);
|
||||
|
||||
public:
|
||||
CSSRule& impl() { return *this; }
|
||||
virtual ~CSSRule() = default;
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssrule-type
|
||||
|
@ -33,26 +31,34 @@ public:
|
|||
Supports = 12,
|
||||
};
|
||||
|
||||
virtual StringView class_name() const = 0;
|
||||
virtual Type type() const = 0;
|
||||
|
||||
String css_text() const;
|
||||
void set_css_text(StringView);
|
||||
|
||||
CSSRule* parent_rule() { return m_parent_rule; }
|
||||
CSSRule* parent_rule() { return m_parent_rule.ptr(); }
|
||||
void set_parent_rule(CSSRule*);
|
||||
|
||||
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
|
||||
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet.ptr(); }
|
||||
virtual void set_parent_style_sheet(CSSStyleSheet*);
|
||||
|
||||
template<typename T>
|
||||
bool fast_is() const = delete;
|
||||
|
||||
protected:
|
||||
explicit CSSRule(Bindings::WindowObject&);
|
||||
|
||||
virtual String serialized() const = 0;
|
||||
|
||||
WeakPtr<CSSRule> m_parent_rule;
|
||||
WeakPtr<CSSStyleSheet> m_parent_style_sheet;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::GCPtr<CSSRule> m_parent_rule;
|
||||
JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::CSS::CSSRule& object) { return &object; }
|
||||
using CSSRuleWrapper = Web::CSS::CSSRule;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue