mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:17:41 +00:00
LibWeb+WebContent: Support window.confirm() in OOPWV
This commit is contained in:
parent
abf7c02acb
commit
1ad65b173b
7 changed files with 23 additions and 2 deletions
|
@ -287,6 +287,12 @@ void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient
|
|||
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
|
||||
}
|
||||
|
||||
bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, const String& message)
|
||||
{
|
||||
auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
||||
return confirm_result == GUI::Dialog::ExecResult::ExecOK;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::did_scroll()
|
||||
{
|
||||
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
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);
|
||||
bool notify_server_did_request_confirm(Badge<WebContentClient>, const String& message);
|
||||
|
||||
private:
|
||||
OutOfProcessWebView();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -137,4 +137,10 @@ OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> WebContentClient::ha
|
|||
return make<Messages::WebContentClient::DidRequestAlertResponse>();
|
||||
}
|
||||
|
||||
OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestConfirm& message)
|
||||
{
|
||||
bool result = m_view.notify_server_did_request_confirm({}, message.message());
|
||||
return make<Messages::WebContentClient::DidRequestConfirmResponse>(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -65,6 +65,7 @@ private:
|
|||
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;
|
||||
virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> handle(const Messages::WebContentClient::DidRequestConfirm&) override;
|
||||
|
||||
OutOfProcessWebView& m_view;
|
||||
};
|
||||
|
|
|
@ -176,4 +176,9 @@ void PageHost::page_did_request_alert(const String& message)
|
|||
m_client.send_sync<Messages::WebContentClient::DidRequestAlert>(message);
|
||||
}
|
||||
|
||||
bool PageHost::page_did_request_confirm(const String& message)
|
||||
{
|
||||
return m_client.send_sync<Messages::WebContentClient::DidRequestConfirm>(message)->result();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
virtual void page_did_start_loading(const URL&) override;
|
||||
virtual void page_did_finish_loading(const URL&) override;
|
||||
virtual void page_did_request_alert(const String&) override;
|
||||
virtual bool page_did_request_confirm(const String&) override;
|
||||
|
||||
explicit PageHost(ClientConnection&);
|
||||
|
||||
|
|
|
@ -15,4 +15,5 @@ endpoint WebContentClient = 90
|
|||
DidRequestContextMenu(Gfx::IntPoint content_position) =|
|
||||
DidRequestLinkContextMenu(Gfx::IntPoint content_position, URL url, String target, unsigned modifiers) =|
|
||||
DidRequestAlert(String message) => ()
|
||||
DidRequestConfirm(String message) => (bool result)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue