diff options
author | Andreas Kling <kling@serenityos.org> | 2021-12-05 15:30:40 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-06 19:22:16 +0100 |
commit | e8b85b13e2522d87a2514ea953fc0c80cfbcfee9 (patch) | |
tree | 5b8afd517dee3ecd599314701e0f60409ffbd955 /Userland/Libraries/LibWeb | |
parent | f47c658275e2f5f5b35f8926a997a976ec60de11 (diff) | |
download | serenity-e8b85b13e2522d87a2514ea953fc0c80cfbcfee9.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSRule.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/CSSRule.h b/Userland/Libraries/LibWeb/CSS/CSSRule.h index 6d04af17bb..156c055436 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRule.h @@ -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; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 9d08ef21ed..3ebe1877ce 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -52,8 +52,7 @@ private: NonnullRefPtr<CSSRuleList> m_rules; - // FIXME: Use WeakPtr. - CSSRule* m_owner_css_rule { nullptr }; + WeakPtr<CSSRule> m_owner_css_rule; }; } |