mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Add Node notifications for Document<=>Frame attach/detach
Some DOM nodes will want to do stuff when we attach/detach from a Frame and this seems like a simple enough way to let them know.
This commit is contained in:
parent
07e726729c
commit
285a4165f3
Notes:
sideshowbarker
2024-07-19 05:48:03 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/285a4165f39
2 changed files with 12 additions and 1 deletions
|
@ -161,11 +161,19 @@ String Document::title() const
|
|||
void Document::attach_to_frame(Badge<Frame>, Frame& frame)
|
||||
{
|
||||
m_frame = frame.make_weak_ptr();
|
||||
for_each_in_subtree([&](auto& node) {
|
||||
node.document_did_attach_to_frame(frame);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
layout();
|
||||
}
|
||||
|
||||
void Document::detach_from_frame(Badge<Frame>, Frame&)
|
||||
void Document::detach_from_frame(Badge<Frame>, Frame& frame)
|
||||
{
|
||||
for_each_in_subtree([&](auto& node) {
|
||||
node.document_will_detach_from_frame(frame);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
m_layout_root = nullptr;
|
||||
m_frame = nullptr;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,9 @@ public:
|
|||
|
||||
bool is_link() const;
|
||||
|
||||
virtual void document_did_attach_to_frame(Frame&) {}
|
||||
virtual void document_will_detach_from_frame(Frame&) {}
|
||||
|
||||
protected:
|
||||
Node(Document&, NodeType);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue