LibWeb: Make DOM::Window store its associated document in a WeakPtr

Let's err on the side of caution and use a WeakPtr instead of a
DOM::Document&. Even if the object lifetimes involved here should be
well-defined, they are fairly complicated.
This commit is contained in:
Andreas Kling 2021-09-09 14:15:14 +02:00
parent 90cdeebfb3
commit f1ce43bdbf

View file

@ -36,8 +36,8 @@ public:
Page* page();
Page const* page() const;
Document const& associated_document() const { return m_associated_document; }
Document& associated_document() { return m_associated_document; }
Document const& associated_document() const { return *m_associated_document; }
Document& associated_document() { return *m_associated_document; }
void alert(String const&);
bool confirm(String const&);
@ -76,7 +76,7 @@ private:
explicit Window(Document&);
// https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window
Document& m_associated_document;
WeakPtr<Document> m_associated_document;
WeakPtr<Bindings::WindowObject> m_wrapper;