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

LibWeb: Make CSSStyleSheet::m_owner_css_rule a WeakPtr

It's not safe for this to be a raw pointer, as the imported style sheet
can outlive the rule.
This commit is contained in:
Andreas Kling 2021-12-05 15:30:40 +01:00
parent f47c658275
commit e8b85b13e2
2 changed files with 4 additions and 3 deletions

View file

@ -8,6 +8,7 @@
#include <AK/RefCounted.h>
#include <AK/String.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/Selector.h>
@ -16,7 +17,8 @@ namespace Web::CSS {
class CSSRule
: public RefCounted<CSSRule>
, public Bindings::Wrappable {
, public Bindings::Wrappable
, public Weakable<CSSRule> {
public:
using WrapperType = Bindings::CSSRuleWrapper;

View file

@ -52,8 +52,7 @@ private:
NonnullRefPtr<CSSRuleList> m_rules;
// FIXME: Use WeakPtr.
CSSRule* m_owner_css_rule { nullptr };
WeakPtr<CSSRule> m_owner_css_rule;
};
}