mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 11:06:10 +00:00
Browser: Implemented out of process JS console
Added input hook into console widget to allow input to be captured and sent to the external JS console via IPC. Output from the external JS console is fed into the console widget via handle_js_console_output().
This commit is contained in:
parent
0682af7b65
commit
269ec8b1f9
Notes:
sideshowbarker
2024-07-18 21:51:47 +09:00
Author: https://github.com/xeons
Commit: 269ec8b1f9
Pull-request: https://github.com/SerenityOS/serenity/pull/5556
3 changed files with 41 additions and 1 deletions
|
@ -251,6 +251,13 @@ Tab::Tab(Type type)
|
|||
view_source(url.to_string(), source);
|
||||
};
|
||||
|
||||
hooks().on_js_console_output = [this](auto& method, auto& line) {
|
||||
if (m_console_window) {
|
||||
auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget());
|
||||
console_widget->handle_js_console_output(method, line);
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Support JS console in multi-process mode.
|
||||
if (m_type == Type::InProcessWebView) {
|
||||
hooks().on_set_document = [this](auto* document) {
|
||||
|
@ -376,7 +383,21 @@ Tab::Tab(Type type)
|
|||
m_console_window->show();
|
||||
m_console_window->move_to_front();
|
||||
} else {
|
||||
TODO();
|
||||
if (!m_console_window) {
|
||||
m_console_window = GUI::Window::construct();
|
||||
m_console_window->resize(500, 300);
|
||||
m_console_window->set_title("JS Console");
|
||||
m_console_window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-javascript.png"));
|
||||
m_console_window->set_main_widget<ConsoleWidget>();
|
||||
}
|
||||
auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget());
|
||||
console_widget->on_js_input = [this](const String& js_source) {
|
||||
m_web_content_view->js_console_input(js_source);
|
||||
};
|
||||
console_widget->clear_output();
|
||||
m_web_content_view->js_console_initialize();
|
||||
m_console_window->show();
|
||||
m_console_window->move_to_front();
|
||||
}
|
||||
},
|
||||
this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue