mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibWeb: Add DOM::Window::page()
This helps us to get from a Window to the containing Page, without clients having to go through Document.
This commit is contained in:
parent
84fcf879f9
commit
d392349b6e
4 changed files with 18 additions and 5 deletions
|
@ -19,7 +19,7 @@ Screen::Screen(DOM::Window& window)
|
||||||
|
|
||||||
Gfx::IntRect Screen::screen_rect() const
|
Gfx::IntRect Screen::screen_rect() const
|
||||||
{
|
{
|
||||||
return m_window.document().page()->screen_rect();
|
return m_window.page()->screen_rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,20 +42,20 @@ void Window::set_wrapper(Badge<Bindings::WindowObject>, Bindings::WindowObject&
|
||||||
|
|
||||||
void Window::alert(const String& message)
|
void Window::alert(const String& message)
|
||||||
{
|
{
|
||||||
if (auto* page = m_document.page())
|
if (auto* page = this->page())
|
||||||
page->client().page_did_request_alert(message);
|
page->client().page_did_request_alert(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::confirm(const String& message)
|
bool Window::confirm(const String& message)
|
||||||
{
|
{
|
||||||
if (auto* page = m_document.page())
|
if (auto* page = this->page())
|
||||||
return page->client().page_did_request_confirm(message);
|
return page->client().page_did_request_confirm(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Window::prompt(const String& message, const String& default_)
|
String Window::prompt(const String& message, const String& default_)
|
||||||
{
|
{
|
||||||
if (auto* page = m_document.page())
|
if (auto* page = this->page())
|
||||||
return page->client().page_did_request_prompt(message, default_);
|
return page->client().page_did_request_prompt(message, default_);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -177,4 +177,14 @@ int Window::inner_height() const
|
||||||
return document().layout_node()->height();
|
return document().layout_node()->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Page* Window::page()
|
||||||
|
{
|
||||||
|
return document().page();
|
||||||
|
}
|
||||||
|
|
||||||
|
Page const* Window::page() const
|
||||||
|
{
|
||||||
|
return document().page();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@ public:
|
||||||
virtual bool dispatch_event(NonnullRefPtr<Event>) override;
|
virtual bool dispatch_event(NonnullRefPtr<Event>) override;
|
||||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||||
|
|
||||||
|
Page* page();
|
||||||
|
Page const* page() const;
|
||||||
|
|
||||||
const Document& document() const { return m_document; }
|
const Document& document() const { return m_document; }
|
||||||
Document& document() { return m_document; }
|
Document& document() { return m_document; }
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto request = LoadRequest::create_for_url_on_page(request_url, m_window->document().page());
|
auto request = LoadRequest::create_for_url_on_page(request_url, m_window->page());
|
||||||
request.set_method(m_method);
|
request.set_method(m_method);
|
||||||
for (auto& it : m_request_headers)
|
for (auto& it : m_request_headers)
|
||||||
request.set_header(it.key, it.value);
|
request.set_header(it.key, it.value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue