diff --git a/Libraries/LibHTML/Frame.cpp b/Libraries/LibHTML/Frame.cpp
index f635528b70..ec0339f737 100644
--- a/Libraries/LibHTML/Frame.cpp
+++ b/Libraries/LibHTML/Frame.cpp
@@ -1,7 +1,9 @@
#include
#include
+#include
-Frame::Frame()
+Frame::Frame(HtmlView& html_view)
+ : m_html_view(html_view.make_weak_ptr())
{
}
diff --git a/Libraries/LibHTML/Frame.h b/Libraries/LibHTML/Frame.h
index 38a8d8bedb..bf28e8cd34 100644
--- a/Libraries/LibHTML/Frame.h
+++ b/Libraries/LibHTML/Frame.h
@@ -3,15 +3,17 @@
#include
#include
#include
+#include
#include
#include
#include
class Document;
+class HtmlView;
class Frame : public TreeNode {
public:
- static NonnullRefPtr create() { return adopt(*new Frame); }
+ static NonnullRefPtr create(HtmlView& html_view) { return adopt(*new Frame(html_view)); }
~Frame();
const Document* document() const { return m_document; }
@@ -19,6 +21,9 @@ public:
void set_document(Document*);
+ HtmlView* html_view() { return m_html_view; }
+ const HtmlView* html_view() const { return m_html_view; }
+
const Size& size() const { return m_size; }
void set_size(const Size&);
@@ -26,8 +31,9 @@ public:
Function on_set_needs_display;
private:
- Frame();
+ explicit Frame(HtmlView&);
+ WeakPtr m_html_view;
RefPtr m_document;
Size m_size;
};
diff --git a/Libraries/LibHTML/HtmlView.cpp b/Libraries/LibHTML/HtmlView.cpp
index 50f5d34525..dec45d1fef 100644
--- a/Libraries/LibHTML/HtmlView.cpp
+++ b/Libraries/LibHTML/HtmlView.cpp
@@ -22,7 +22,7 @@
HtmlView::HtmlView(GWidget* parent)
: GScrollableWidget(parent)
- , m_main_frame(Frame::create())
+ , m_main_frame(Frame::create(*this))
{
main_frame().on_set_needs_display = [this](auto& content_rect) {
if (content_rect.is_empty()) {