mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibHTML: Give Frame a (weak) back-pointer to the HtmlView
This will be the official path from DOM/layout code to the HtmlView for now. Perhaps in the future we will have a fancier abstraction.
This commit is contained in:
parent
94bc46ee70
commit
8dc6f7cd4f
3 changed files with 12 additions and 4 deletions
|
@ -1,7 +1,9 @@
|
||||||
#include <LibHTML/DOM/Document.h>
|
#include <LibHTML/DOM/Document.h>
|
||||||
#include <LibHTML/Frame.h>
|
#include <LibHTML/Frame.h>
|
||||||
|
#include <LibHTML/HtmlView.h>
|
||||||
|
|
||||||
Frame::Frame()
|
Frame::Frame(HtmlView& html_view)
|
||||||
|
: m_html_view(html_view.make_weak_ptr())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,17 @@
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/Noncopyable.h>
|
#include <AK/Noncopyable.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
|
#include <AK/WeakPtr.h>
|
||||||
#include <LibDraw/Rect.h>
|
#include <LibDraw/Rect.h>
|
||||||
#include <LibDraw/Size.h>
|
#include <LibDraw/Size.h>
|
||||||
#include <LibHTML/TreeNode.h>
|
#include <LibHTML/TreeNode.h>
|
||||||
|
|
||||||
class Document;
|
class Document;
|
||||||
|
class HtmlView;
|
||||||
|
|
||||||
class Frame : public TreeNode<Frame> {
|
class Frame : public TreeNode<Frame> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<Frame> create() { return adopt(*new Frame); }
|
static NonnullRefPtr<Frame> create(HtmlView& html_view) { return adopt(*new Frame(html_view)); }
|
||||||
~Frame();
|
~Frame();
|
||||||
|
|
||||||
const Document* document() const { return m_document; }
|
const Document* document() const { return m_document; }
|
||||||
|
@ -19,6 +21,9 @@ public:
|
||||||
|
|
||||||
void set_document(Document*);
|
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; }
|
const Size& size() const { return m_size; }
|
||||||
void set_size(const Size&);
|
void set_size(const Size&);
|
||||||
|
|
||||||
|
@ -26,8 +31,9 @@ public:
|
||||||
Function<void(const Rect&)> on_set_needs_display;
|
Function<void(const Rect&)> on_set_needs_display;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Frame();
|
explicit Frame(HtmlView&);
|
||||||
|
|
||||||
|
WeakPtr<HtmlView> m_html_view;
|
||||||
RefPtr<Document> m_document;
|
RefPtr<Document> m_document;
|
||||||
Size m_size;
|
Size m_size;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
HtmlView::HtmlView(GWidget* parent)
|
HtmlView::HtmlView(GWidget* parent)
|
||||||
: GScrollableWidget(parent)
|
: GScrollableWidget(parent)
|
||||||
, m_main_frame(Frame::create())
|
, m_main_frame(Frame::create(*this))
|
||||||
{
|
{
|
||||||
main_frame().on_set_needs_display = [this](auto& content_rect) {
|
main_frame().on_set_needs_display = [this](auto& content_rect) {
|
||||||
if (content_rect.is_empty()) {
|
if (content_rect.is_empty()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue