mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 18:17:41 +00:00
LibWeb: Make StyleSheet::m_parent_style_sheet a WeakPtr
It's not safe for this to be a raw pointer, as the child can outlive the parent.
This commit is contained in:
parent
e8b85b13e2
commit
58b99df16d
3 changed files with 11 additions and 4 deletions
|
@ -18,7 +18,9 @@ namespace Web::CSS {
|
||||||
|
|
||||||
class CSSImportRule;
|
class CSSImportRule;
|
||||||
|
|
||||||
class CSSStyleSheet final : public StyleSheet {
|
class CSSStyleSheet final
|
||||||
|
: public StyleSheet
|
||||||
|
, public Weakable<CSSStyleSheet> {
|
||||||
public:
|
public:
|
||||||
using WrapperType = Bindings::CSSStyleSheetWrapper;
|
using WrapperType = Bindings::CSSStyleSheetWrapper;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||||
#include <LibWeb/CSS/StyleSheet.h>
|
#include <LibWeb/CSS/StyleSheet.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
|
|
||||||
|
@ -18,4 +19,9 @@ void StyleSheet::set_owner_node(DOM::Element* element)
|
||||||
m_owner_node = nullptr;
|
m_owner_node = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StyleSheet::set_parent_css_style_sheet(CSSStyleSheet* parent)
|
||||||
|
{
|
||||||
|
m_parent_style_sheet = parent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
void set_disabled(bool disabled) { m_disabled = disabled; }
|
void set_disabled(bool disabled) { m_disabled = disabled; }
|
||||||
|
|
||||||
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
|
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
|
||||||
void set_parent_css_style_sheet(CSSStyleSheet* sheet) { m_parent_style_sheet = sheet; }
|
void set_parent_css_style_sheet(CSSStyleSheet*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StyleSheet() = default;
|
StyleSheet() = default;
|
||||||
|
@ -49,8 +49,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
WeakPtr<DOM::Element> m_owner_node;
|
WeakPtr<DOM::Element> m_owner_node;
|
||||||
|
|
||||||
// FIXME: Use WeakPtr.
|
WeakPtr<CSSStyleSheet> m_parent_style_sheet;
|
||||||
CSSStyleSheet* m_parent_style_sheet { nullptr };
|
|
||||||
|
|
||||||
String m_title;
|
String m_title;
|
||||||
String m_type_string;
|
String m_type_string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue