mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:48:11 +00:00
LibWeb: Move window.confirm() to using a PageClient callback
This allows us to move the GUI::MessageBox out of DOM::Window and up to the widget layer.
This commit is contained in:
parent
794ebb699c
commit
abf7c02acb
4 changed files with 11 additions and 3 deletions
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibGUI/DisplayLink.h>
|
#include <LibGUI/DisplayLink.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
|
||||||
#include <LibJS/Runtime/Function.h>
|
#include <LibJS/Runtime/Function.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
|
@ -67,8 +66,9 @@ void Window::alert(const String& message)
|
||||||
|
|
||||||
bool Window::confirm(const String& message)
|
bool Window::confirm(const String& message)
|
||||||
{
|
{
|
||||||
auto confirm_result = GUI::MessageBox::show(nullptr, message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
if (auto* page = m_document.page())
|
||||||
return confirm_result == GUI::Dialog::ExecResult::ExecOK;
|
return page->client().page_did_request_confirm(message);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 Window::set_interval(JS::Function& callback, i32 interval)
|
i32 Window::set_interval(JS::Function& callback, i32 interval)
|
||||||
|
|
|
@ -420,4 +420,10 @@ void InProcessWebView::page_did_request_alert(const String& message)
|
||||||
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
|
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InProcessWebView::page_did_request_confirm(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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ private:
|
||||||
virtual void page_did_layout() override;
|
virtual void page_did_layout() override;
|
||||||
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
|
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override;
|
||||||
virtual void page_did_request_alert(const String&) override;
|
virtual void page_did_request_alert(const String&) override;
|
||||||
|
virtual bool page_did_request_confirm(const String&) override;
|
||||||
|
|
||||||
void layout_and_sync_size();
|
void layout_and_sync_size();
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ public:
|
||||||
virtual void page_did_layout() { }
|
virtual void page_did_layout() { }
|
||||||
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { }
|
virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { }
|
||||||
virtual void page_did_request_alert(const String&) { }
|
virtual void page_did_request_alert(const String&) { }
|
||||||
|
virtual bool page_did_request_confirm(const String&) { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue