mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibWeb: Add a way to construct HTML::Window without a DOM::Document
This will be used to implement the rather intricate construction order in the HTML spec.
This commit is contained in:
parent
eca0873245
commit
e756b5450d
Notes:
sideshowbarker
2024-07-17 08:25:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e756b5450d
@ -56,11 +56,24 @@ private:
|
||||
u32 m_handle { 0 };
|
||||
};
|
||||
|
||||
NonnullRefPtr<Window> Window::create()
|
||||
{
|
||||
return adopt_ref(*new Window);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Window> Window::create_with_document(DOM::Document& document)
|
||||
{
|
||||
return adopt_ref(*new Window(document));
|
||||
}
|
||||
|
||||
Window::Window()
|
||||
: DOM::EventTarget()
|
||||
, m_performance(make<HighResolutionTime::Performance>(*this))
|
||||
, m_crypto(Crypto::Crypto::create())
|
||||
, m_screen(CSS::Screen::create({}, *this))
|
||||
{
|
||||
}
|
||||
|
||||
Window::Window(DOM::Document& document)
|
||||
: DOM::EventTarget()
|
||||
, m_associated_document(document)
|
||||
@ -670,4 +683,9 @@ void Window::cancel_idle_callback(u32 handle)
|
||||
});
|
||||
}
|
||||
|
||||
void Window::set_associated_document(DOM::Document& document)
|
||||
{
|
||||
m_associated_document = document;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class Window final
|
||||
, public HTML::GlobalEventHandlers
|
||||
, public HTML::WindowEventHandlers {
|
||||
public:
|
||||
static NonnullRefPtr<Window> create();
|
||||
static NonnullRefPtr<Window> create_with_document(DOM::Document&);
|
||||
~Window();
|
||||
|
||||
@ -51,6 +52,7 @@ public:
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window
|
||||
DOM::Document const& associated_document() const { return *m_associated_document; }
|
||||
DOM::Document& associated_document() { return *m_associated_document; }
|
||||
void set_associated_document(DOM::Document&);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#window-bc
|
||||
HTML::BrowsingContext const* browsing_context() const { return m_associated_document->browsing_context(); }
|
||||
@ -127,6 +129,7 @@ public:
|
||||
AnimationFrameCallbackDriver& animation_frame_callback_driver() { return m_animation_frame_callback_driver; }
|
||||
|
||||
private:
|
||||
Window();
|
||||
explicit Window(DOM::Document&);
|
||||
|
||||
// ^HTML::GlobalEventHandlers
|
||||
|
Loading…
Reference in New Issue
Block a user