mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
Ladybird+LibWebView: Migrate dialog APIs to LibWebView callbacks
This commit is contained in:
parent
e6c01ef6e2
commit
ebdcba8b3b
Notes:
sideshowbarker
2024-07-16 16:23:32 +09:00
Author: https://github.com/trflynn89
Commit: ebdcba8b3b
Pull-request: https://github.com/SerenityOS/serenity/pull/20723
Reviewed-by: https://github.com/AtkinsSJ ✅
15 changed files with 153 additions and 225 deletions
|
@ -416,7 +416,7 @@ struct HideCursor {
|
|||
[NSMenu popUpContextMenu:self.video_context_menu withEvent:event forView:self];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_alert = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_alert = [self](auto const& message) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
|
||||
self.dialog = [[NSAlert alloc] init];
|
||||
|
@ -429,7 +429,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_confirm = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_confirm = [self](auto const& message) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
|
||||
self.dialog = [[NSAlert alloc] init];
|
||||
|
@ -444,7 +444,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_prompt = [self](auto const& message, auto const& default_) {
|
||||
m_web_view_bridge->on_request_prompt = [self](auto const& message, auto const& default_) {
|
||||
auto* ns_message = Ladybird::string_to_ns_string(message);
|
||||
auto* ns_default = Ladybird::string_to_ns_string(default_);
|
||||
|
||||
|
@ -472,7 +472,7 @@ struct HideCursor {
|
|||
}];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_prompt_text_changed = [self](auto const& message) {
|
||||
m_web_view_bridge->on_request_set_prompt_text = [self](auto const& message) {
|
||||
if (self.dialog == nil || [self.dialog accessoryView] == nil) {
|
||||
return;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ struct HideCursor {
|
|||
[input setStringValue:ns_message];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_dialog_accepted = [self]() {
|
||||
m_web_view_bridge->on_request_accept_dialog = [self]() {
|
||||
if (self.dialog == nil) {
|
||||
return;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ struct HideCursor {
|
|||
returnCode:NSModalResponseOK];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_dialog_dismissed = [self]() {
|
||||
m_web_view_bridge->on_request_dismiss_dialog = [self]() {
|
||||
if (self.dialog == nil) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -197,58 +197,6 @@ void WebViewBridge::notify_server_did_leave_tooltip_area(Badge<WebView::WebConte
|
|||
if (on_tooltip_left)
|
||||
on_tooltip_left();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_alert(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_alert)
|
||||
on_alert(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::alert_closed()
|
||||
{
|
||||
client().async_alert_closed();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_confirm(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_confirm)
|
||||
on_confirm(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::confirm_closed(bool accepted)
|
||||
{
|
||||
client().async_confirm_closed(accepted);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_prompt(Badge<WebView::WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
if (on_prompt)
|
||||
on_prompt(message, default_);
|
||||
}
|
||||
|
||||
void WebViewBridge::prompt_closed(Optional<String> response)
|
||||
{
|
||||
client().async_prompt_closed(move(response));
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_set_prompt_text(Badge<WebView::WebContentClient>, String const& message)
|
||||
{
|
||||
if (on_prompt_text_changed)
|
||||
on_prompt_text_changed(message);
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_accept_dialog(Badge<WebView::WebContentClient>)
|
||||
{
|
||||
if (on_dialog_accepted)
|
||||
on_dialog_accepted();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_dismiss_dialog(Badge<WebView::WebContentClient>)
|
||||
{
|
||||
if (on_dialog_dismissed)
|
||||
on_dialog_dismissed();
|
||||
}
|
||||
|
||||
void WebViewBridge::notify_server_did_request_file(Badge<WebView::WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
|
|
|
@ -59,19 +59,6 @@ public:
|
|||
Function<void(DeprecatedString const&)> on_tooltip_entered;
|
||||
Function<void()> on_tooltip_left;
|
||||
|
||||
Function<void(String const&)> on_alert;
|
||||
void alert_closed();
|
||||
|
||||
Function<void(String const&)> on_confirm;
|
||||
void confirm_closed(bool);
|
||||
|
||||
Function<void(String const&, String const&)> on_prompt;
|
||||
Function<void(String const&)> on_prompt_text_changed;
|
||||
void prompt_closed(Optional<String>);
|
||||
|
||||
Function<void()> on_dialog_accepted;
|
||||
Function<void()> on_dialog_dismissed;
|
||||
|
||||
private:
|
||||
WebViewBridge(Vector<Gfx::IntRect> screen_rects, float device_pixel_ratio, Optional<StringView> webdriver_content_ipc_path);
|
||||
|
||||
|
@ -85,12 +72,6 @@ private:
|
|||
virtual void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override;
|
||||
virtual void notify_server_did_enter_tooltip_area(Badge<WebView::WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
|
||||
virtual void notify_server_did_leave_tooltip_area(Badge<WebView::WebContentClient>) override;
|
||||
virtual void notify_server_did_request_alert(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebView::WebContentClient>, String const& message, String const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebView::WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebView::WebContentClient>) override;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebView::WebContentClient>) override;
|
||||
virtual void notify_server_did_request_file(Badge<WebView::WebContentClient>, DeprecatedString const& path, i32) override;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QFontMetrics>
|
||||
#include <QGuiApplication>
|
||||
#include <QImage>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
|
@ -165,6 +166,53 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
|
|||
emit favicon_changed(tab_index(), QIcon(qpixmap));
|
||||
};
|
||||
|
||||
view().on_request_alert = [this](auto const& message) {
|
||||
m_dialog = new QMessageBox(QMessageBox::Icon::Warning, "Ladybird", qstring_from_ak_string(message), QMessageBox::StandardButton::Ok, &view());
|
||||
m_dialog->exec();
|
||||
|
||||
view().alert_closed();
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_confirm = [this](auto const& message) {
|
||||
m_dialog = new QMessageBox(QMessageBox::Icon::Question, "Ladybird", qstring_from_ak_string(message), QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel, &view());
|
||||
auto result = m_dialog->exec();
|
||||
|
||||
view().confirm_closed(result == QMessageBox::StandardButton::Ok || result == QDialog::Accepted);
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_prompt = [this](auto const& message, auto const& default_) {
|
||||
m_dialog = new QInputDialog(&view());
|
||||
auto& dialog = static_cast<QInputDialog&>(*m_dialog);
|
||||
|
||||
dialog.setWindowTitle("Ladybird");
|
||||
dialog.setLabelText(qstring_from_ak_string(message));
|
||||
dialog.setTextValue(qstring_from_ak_string(default_));
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
view().prompt_closed(ak_string_from_qstring(dialog.textValue()).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
view().prompt_closed({});
|
||||
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_set_prompt_text = [this](auto const& message) {
|
||||
if (m_dialog && is<QInputDialog>(*m_dialog))
|
||||
static_cast<QInputDialog&>(*m_dialog).setTextValue(qstring_from_ak_string(message));
|
||||
};
|
||||
|
||||
view().on_request_accept_dialog = [this]() {
|
||||
if (m_dialog)
|
||||
m_dialog->accept();
|
||||
};
|
||||
|
||||
view().on_request_dismiss_dialog = [this]() {
|
||||
if (m_dialog)
|
||||
m_dialog->reject();
|
||||
};
|
||||
|
||||
QObject::connect(focus_location_editor_action, &QAction::triggered, this, &Tab::focus_location_editor);
|
||||
|
||||
view().on_get_source = [this](auto const& url, auto const& source) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QPointer>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
@ -111,6 +112,8 @@ private:
|
|||
Ladybird::ConsoleWidget* m_console_widget { nullptr };
|
||||
OwnPtr<QMenu> m_console_context_menu;
|
||||
Ladybird::InspectorWidget* m_inspector_widget { nullptr };
|
||||
|
||||
QPointer<QDialog> m_dialog;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
#include <QCursor>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QPaintEvent>
|
||||
|
@ -727,59 +725,6 @@ void WebContentView::notify_server_did_leave_tooltip_area(Badge<WebContentClient
|
|||
QToolTip::hideText();
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = new QMessageBox(QMessageBox::Icon::Warning, "Ladybird", qstring_from_ak_string(message), QMessageBox::StandardButton::Ok, this);
|
||||
m_dialog->exec();
|
||||
|
||||
client().async_alert_closed();
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = new QMessageBox(QMessageBox::Icon::Question, "Ladybird", qstring_from_ak_string(message), QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel, this);
|
||||
auto result = m_dialog->exec();
|
||||
|
||||
client().async_confirm_closed(result == QMessageBox::StandardButton::Ok || result == QDialog::Accepted);
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
m_dialog = new QInputDialog(this);
|
||||
auto& dialog = static_cast<QInputDialog&>(*m_dialog);
|
||||
|
||||
dialog.setWindowTitle("Ladybird");
|
||||
dialog.setLabelText(qstring_from_ak_string(message));
|
||||
dialog.setTextValue(qstring_from_ak_string(default_));
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
client().async_prompt_closed(ak_string_from_qstring(dialog.textValue()).release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
client().async_prompt_closed({});
|
||||
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
if (m_dialog && is<QInputDialog>(*m_dialog))
|
||||
static_cast<QInputDialog&>(*m_dialog).setTextValue(qstring_from_ak_string(message));
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_accept_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->accept();
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_dismiss_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->reject();
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QPointer>
|
||||
#include <QUrl>
|
||||
|
||||
class QTextEdit;
|
||||
|
@ -87,12 +86,6 @@ public:
|
|||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
||||
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
|
||||
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) override;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
||||
|
||||
|
@ -113,8 +106,6 @@ private:
|
|||
bool m_should_show_line_box_borders { false };
|
||||
UseLagomNetworking m_use_lagom_networking {};
|
||||
|
||||
QPointer<QDialog> m_dialog;
|
||||
|
||||
Gfx::IntRect m_viewport_rect;
|
||||
|
||||
StringView m_webdriver_content_ipc_path;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Statusbar.h>
|
||||
|
@ -508,6 +510,61 @@ Tab::Tab(BrowserWindow& window)
|
|||
on_update_cookie(cookie);
|
||||
};
|
||||
|
||||
view().on_request_alert = [this](String const& message) {
|
||||
auto& window = this->window();
|
||||
|
||||
m_dialog = GUI::MessageBox::create(&window, message, "Alert"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window.icon());
|
||||
m_dialog->exec();
|
||||
|
||||
view().alert_closed();
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_confirm = [this](String const& message) {
|
||||
auto& window = this->window();
|
||||
|
||||
m_dialog = GUI::MessageBox::create(&window, message, "Confirm"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window.icon());
|
||||
|
||||
view().confirm_closed(m_dialog->exec() == GUI::Dialog::ExecResult::OK);
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_prompt = [this](String const& message, String const& default_) {
|
||||
auto& window = this->window();
|
||||
|
||||
String mutable_value = default_;
|
||||
m_dialog = GUI::InputBox::create(&window, mutable_value, message, "Prompt"sv, GUI::InputType::Text).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window.icon());
|
||||
|
||||
if (m_dialog->exec() == GUI::InputBox::ExecResult::OK) {
|
||||
auto const& dialog = static_cast<GUI::InputBox const&>(*m_dialog);
|
||||
auto response = dialog.text_value();
|
||||
|
||||
view().prompt_closed(move(response));
|
||||
} else {
|
||||
view().prompt_closed({});
|
||||
}
|
||||
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_request_set_prompt_text = [this](String const& message) {
|
||||
if (m_dialog && is<GUI::InputBox>(*m_dialog))
|
||||
static_cast<GUI::InputBox&>(*m_dialog).set_text_value(message);
|
||||
};
|
||||
|
||||
view().on_request_accept_dialog = [this]() {
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::OK);
|
||||
};
|
||||
|
||||
view().on_request_dismiss_dialog = [this]() {
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::Cancel);
|
||||
};
|
||||
|
||||
view().on_get_source = [this](auto& url, auto& source) {
|
||||
view_source(url, source);
|
||||
};
|
||||
|
|
|
@ -136,6 +136,8 @@ private:
|
|||
RefPtr<GUI::Statusbar> m_statusbar;
|
||||
RefPtr<GUI::ToolbarContainer> m_toolbar_container;
|
||||
|
||||
RefPtr<GUI::Dialog> m_dialog;
|
||||
|
||||
RefPtr<GUI::Menu> m_link_context_menu;
|
||||
RefPtr<GUI::Action> m_link_context_menu_default_action;
|
||||
URL m_link_context_menu_url;
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Scrollbar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
@ -234,61 +231,6 @@ void OutOfProcessWebView::notify_server_did_leave_tooltip_area(Badge<WebContentC
|
|||
GUI::Application::the()->hide_tooltip();
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = GUI::MessageBox::create(window(), message, "Alert"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window()->icon());
|
||||
m_dialog->exec();
|
||||
|
||||
client().async_alert_closed();
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
m_dialog = GUI::MessageBox::create(window(), message, "Confirm"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
||||
client().async_confirm_closed(m_dialog->exec() == GUI::Dialog::ExecResult::OK);
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
String mutable_value = default_;
|
||||
m_dialog = GUI::InputBox::create(window(), mutable_value, message, "Prompt"sv, GUI::InputType::Text).release_value_but_fixme_should_propagate_errors();
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
||||
if (m_dialog->exec() == GUI::InputBox::ExecResult::OK) {
|
||||
auto const& dialog = static_cast<GUI::InputBox const&>(*m_dialog);
|
||||
auto response = dialog.text_value();
|
||||
|
||||
client().async_prompt_closed(move(response));
|
||||
} else {
|
||||
client().async_prompt_closed({});
|
||||
}
|
||||
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
if (m_dialog && is<GUI::InputBox>(*m_dialog))
|
||||
static_cast<GUI::InputBox&>(*m_dialog).set_text_value(message);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_accept_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::OK);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_dismiss_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::Cancel);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window(), path);
|
||||
|
|
|
@ -92,12 +92,6 @@ private:
|
|||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
||||
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override;
|
||||
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) override;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) override;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) override;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
|
||||
|
||||
|
@ -109,8 +103,6 @@ private:
|
|||
void enqueue_input_event(InputEvent const&);
|
||||
void process_next_input_event();
|
||||
|
||||
RefPtr<GUI::Dialog> m_dialog;
|
||||
|
||||
bool m_is_awaiting_response_for_input_event { false };
|
||||
Queue<InputEvent> m_pending_input_events;
|
||||
|
||||
|
|
|
@ -152,6 +152,21 @@ void ViewImplementation::js_console_request_messages(i32 start_index)
|
|||
client().async_js_console_request_messages(start_index);
|
||||
}
|
||||
|
||||
void ViewImplementation::alert_closed()
|
||||
{
|
||||
client().async_alert_closed();
|
||||
}
|
||||
|
||||
void ViewImplementation::confirm_closed(bool accepted)
|
||||
{
|
||||
client().async_confirm_closed(accepted);
|
||||
}
|
||||
|
||||
void ViewImplementation::prompt_closed(Optional<String> response)
|
||||
{
|
||||
client().async_prompt_closed(move(response));
|
||||
}
|
||||
|
||||
void ViewImplementation::toggle_media_play_state()
|
||||
{
|
||||
client().async_toggle_media_play_state();
|
||||
|
|
|
@ -75,6 +75,10 @@ public:
|
|||
void js_console_input(DeprecatedString const& js_source);
|
||||
void js_console_request_messages(i32 start_index);
|
||||
|
||||
void alert_closed();
|
||||
void confirm_closed(bool accepted);
|
||||
void prompt_closed(Optional<String> response);
|
||||
|
||||
void toggle_media_play_state();
|
||||
void toggle_media_mute_state();
|
||||
void toggle_media_loop_state();
|
||||
|
@ -104,6 +108,12 @@ public:
|
|||
Function<void()> on_navigate_forward;
|
||||
Function<void()> on_refresh;
|
||||
Function<void(Gfx::Bitmap const&)> on_favicon_change;
|
||||
Function<void(String const& message)> on_request_alert;
|
||||
Function<void(String const& message)> on_request_confirm;
|
||||
Function<void(String const& message, String const& default_)> on_request_prompt;
|
||||
Function<void(String const& message)> on_request_set_prompt_text;
|
||||
Function<void()> on_request_accept_dialog;
|
||||
Function<void()> on_request_dismiss_dialog;
|
||||
Function<void(const AK::URL&, DeprecatedString const&)> on_get_source;
|
||||
Function<void(DeprecatedString const&)> on_get_dom_tree;
|
||||
Function<void(i32 node_id, DeprecatedString const& computed_style, DeprecatedString const& resolved_style, DeprecatedString const& custom_properties, DeprecatedString const& node_box_sizing, DeprecatedString const& aria_properties_state)> on_get_dom_node_properties;
|
||||
|
@ -133,12 +143,6 @@ public:
|
|||
virtual void notify_server_did_request_scroll_into_view(Badge<WebContentClient>, Gfx::IntRect const&) = 0;
|
||||
virtual void notify_server_did_enter_tooltip_area(Badge<WebContentClient>, Gfx::IntPoint, DeprecatedString const&) = 0;
|
||||
virtual void notify_server_did_leave_tooltip_area(Badge<WebContentClient>) = 0;
|
||||
virtual void notify_server_did_request_alert(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) = 0;
|
||||
virtual void notify_server_did_request_set_prompt_text(Badge<WebContentClient>, String const& message) = 0;
|
||||
virtual void notify_server_did_request_accept_dialog(Badge<WebContentClient>) = 0;
|
||||
virtual void notify_server_did_request_dismiss_dialog(Badge<WebContentClient>) = 0;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) = 0;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) = 0;
|
||||
|
||||
|
|
|
@ -220,32 +220,38 @@ void WebContentClient::did_get_js_console_messages(i32 start_index, Vector<Depre
|
|||
|
||||
void WebContentClient::did_request_alert(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_alert({}, message);
|
||||
if (m_view.on_request_alert)
|
||||
m_view.on_request_alert(message);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_confirm(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_confirm({}, message);
|
||||
if (m_view.on_request_confirm)
|
||||
m_view.on_request_confirm(message);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_prompt(String const& message, String const& default_)
|
||||
{
|
||||
m_view.notify_server_did_request_prompt({}, message, default_);
|
||||
if (m_view.on_request_prompt)
|
||||
m_view.on_request_prompt(message, default_);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_set_prompt_text(String const& message)
|
||||
{
|
||||
m_view.notify_server_did_request_set_prompt_text({}, message);
|
||||
if (m_view.on_request_set_prompt_text)
|
||||
m_view.on_request_set_prompt_text(message);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_accept_dialog()
|
||||
{
|
||||
m_view.notify_server_did_request_accept_dialog({});
|
||||
if (m_view.on_request_accept_dialog)
|
||||
m_view.on_request_accept_dialog();
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_dismiss_dialog()
|
||||
{
|
||||
m_view.notify_server_did_request_dismiss_dialog({});
|
||||
if (m_view.on_request_dismiss_dialog)
|
||||
m_view.on_request_dismiss_dialog();
|
||||
}
|
||||
|
||||
void WebContentClient::did_change_favicon(Gfx::ShareableBitmap const& favicon)
|
||||
|
|
|
@ -112,12 +112,6 @@ private:
|
|||
void notify_server_did_request_scroll_into_view(Badge<WebView::WebContentClient>, Gfx::IntRect const&) override { }
|
||||
void notify_server_did_enter_tooltip_area(Badge<WebView::WebContentClient>, Gfx::IntPoint, DeprecatedString const&) override { }
|
||||
void notify_server_did_leave_tooltip_area(Badge<WebView::WebContentClient>) override { }
|
||||
void notify_server_did_request_alert(Badge<WebView::WebContentClient>, String const&) override { }
|
||||
void notify_server_did_request_confirm(Badge<WebView::WebContentClient>, String const&) override { }
|
||||
void notify_server_did_request_prompt(Badge<WebView::WebContentClient>, String const&, String const&) override { }
|
||||
void notify_server_did_request_set_prompt_text(Badge<WebView::WebContentClient>, String const&) override { }
|
||||
void notify_server_did_request_accept_dialog(Badge<WebView::WebContentClient>) override { }
|
||||
void notify_server_did_request_dismiss_dialog(Badge<WebView::WebContentClient>) override { }
|
||||
|
||||
void notify_server_did_request_file(Badge<WebView::WebContentClient>, DeprecatedString const& path, i32 request_id) override
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue