mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWeb: Support window.alert() in multi-process context
Alerts are now delegated to the embedding GUI process.
This commit is contained in:
parent
aba793fb3e
commit
d9e39cb82d
11 changed files with 33 additions and 2 deletions
|
@ -57,7 +57,9 @@ void Window::set_wrapper(Badge<Bindings::WindowObject>, Bindings::WindowObject&
|
|||
|
||||
void Window::alert(const String& message)
|
||||
{
|
||||
GUI::MessageBox::show(nullptr, message, "Alert", GUI::MessageBox::Type::Information);
|
||||
if (!m_document.frame())
|
||||
return;
|
||||
m_document.frame()->page().client().page_did_request_alert(message);
|
||||
}
|
||||
|
||||
bool Window::confirm(const String& message)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
@ -43,6 +44,7 @@
|
|||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/LayoutBreak.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <LibWeb/Layout/LayoutNode.h>
|
||||
|
@ -50,7 +52,6 @@
|
|||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Page/EventHandler.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Painting/PaintContext.h>
|
||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||
#include <stdio.h>
|
||||
|
@ -416,4 +417,9 @@ void InProcessWebView::drop_event(GUI::DropEvent& event)
|
|||
ScrollableWidget::drop_event(event);
|
||||
}
|
||||
|
||||
void InProcessWebView::page_did_request_alert(const String& message)
|
||||
{
|
||||
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ private:
|
|||
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
|
||||
virtual void page_did_layout() override;
|
||||
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
|
||||
virtual void page_did_request_alert(const String&) override;
|
||||
|
||||
void layout_and_sync_size();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "OutOfProcessWebView.h"
|
||||
#include "WebContentClient.h"
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
@ -179,6 +180,11 @@ void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge<WebC
|
|||
on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position)));
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, const String& message)
|
||||
{
|
||||
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::did_scroll()
|
||||
{
|
||||
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
void notify_server_did_start_loading(Badge<WebContentClient>, const URL&);
|
||||
void notify_server_did_request_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&);
|
||||
void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers);
|
||||
void notify_server_did_request_alert(Badge<WebContentClient>, const String& message);
|
||||
|
||||
private:
|
||||
OutOfProcessWebView();
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
virtual void page_did_change_favicon(const Gfx::Bitmap&) { }
|
||||
virtual void page_did_layout() { }
|
||||
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { }
|
||||
virtual void page_did_request_alert(const String&) { }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -142,4 +142,10 @@ void WebContentClient::handle(const Messages::WebContentClient::DidRequestLinkCo
|
|||
m_view.notify_server_did_request_link_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers());
|
||||
}
|
||||
|
||||
OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestAlert& message)
|
||||
{
|
||||
m_view.notify_server_did_request_alert({}, message.message());
|
||||
return make<Messages::WebContentClient::DidRequestAlertResponse>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ private:
|
|||
virtual void handle(const Messages::WebContentClient::DidStartLoading&) override;
|
||||
virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override;
|
||||
virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override;
|
||||
virtual OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
|
||||
|
||||
OutOfProcessWebView& m_view;
|
||||
};
|
||||
|
|
|
@ -169,4 +169,9 @@ void PageHost::page_did_request_link_context_menu(const Gfx::IntPoint& content_p
|
|||
m_client.post_message(Messages::WebContentClient::DidRequestLinkContextMenu(content_position, url, target, modifiers));
|
||||
}
|
||||
|
||||
void PageHost::page_did_request_alert(const String& message)
|
||||
{
|
||||
m_client.send_sync<Messages::WebContentClient::DidRequestAlert>(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ private:
|
|||
virtual void page_did_request_context_menu(const Gfx::IntPoint&) override;
|
||||
virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override;
|
||||
virtual void page_did_start_loading(const URL&) override;
|
||||
virtual void page_did_request_alert(const String&) override;
|
||||
|
||||
explicit PageHost(ClientConnection&);
|
||||
|
||||
|
|
|
@ -14,4 +14,5 @@ endpoint WebContentClient = 90
|
|||
DidStartLoading(URL url) =|
|
||||
DidRequestContextMenu(Gfx::IntPoint content_position) =|
|
||||
DidRequestLinkContextMenu(Gfx::IntPoint content_position, URL url, String target, unsigned modifiers) =|
|
||||
DidRequestAlert(String message) => ()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue