mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
LibWeb: Delay sub-Frame construction until host Document is attached
While we're parsing a new document, we don't have a Frame to grab at. We now use the Node::document_did_attach_to_frame() notification hook to delay subframe construction. With this, subframes now always have a valid reference to their enclosing main frame.
This commit is contained in:
parent
285a4165f3
commit
38ada2d102
4 changed files with 31 additions and 15 deletions
|
@ -43,7 +43,7 @@ class PageView;
|
|||
|
||||
class Frame : public TreeNode<Frame> {
|
||||
public:
|
||||
static NonnullRefPtr<Frame> create_subframe() { return adopt(*new Frame); }
|
||||
static NonnullRefPtr<Frame> create_subframe(Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); }
|
||||
static NonnullRefPtr<Frame> create(PageView& page_view) { return adopt(*new Frame(page_view)); }
|
||||
~Frame();
|
||||
|
||||
|
@ -76,12 +76,21 @@ public:
|
|||
|
||||
void scroll_to_anchor(const String&);
|
||||
|
||||
Frame& main_frame() { return m_main_frame; }
|
||||
const Frame& main_frame() const { return m_main_frame; }
|
||||
|
||||
Element* host_element() { return m_host_element; }
|
||||
const Element* host_element() const { return m_host_element; }
|
||||
|
||||
private:
|
||||
Frame();
|
||||
explicit Frame(Element& host_element, Frame& main_frame);
|
||||
explicit Frame(PageView&);
|
||||
|
||||
Frame& m_main_frame;
|
||||
|
||||
FrameLoader m_loader;
|
||||
|
||||
WeakPtr<Element> m_host_element;
|
||||
WeakPtr<PageView> m_page_view;
|
||||
RefPtr<Document> m_document;
|
||||
Gfx::Size m_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue