mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
Browser: Move show_console_window()
to Tab
Having the BrowserWindow assigning Tab's internals felt a bit wrong. This is also a step towards removing BrowserWindow as a friend class. While I was at it, changed the Tab to having a pointer to the ConsoleWidget instead of the Window, since that is usually what we want to use, and it's awkward having to static_cast the main-widget repeatedly.
This commit is contained in:
parent
931f462b6e
commit
2b2158595f
3 changed files with 28 additions and 21 deletions
|
@ -294,10 +294,8 @@ Tab::Tab(BrowserWindow& window)
|
|||
};
|
||||
|
||||
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);
|
||||
}
|
||||
if (m_console_widget)
|
||||
m_console_widget->handle_js_console_output(method, line);
|
||||
};
|
||||
|
||||
auto focus_location_box_action = GUI::Action::create(
|
||||
|
@ -503,4 +501,25 @@ void Tab::show_inspector_window(Browser::Tab::InspectorTarget inspector_target)
|
|||
window->move_to_front();
|
||||
}
|
||||
|
||||
void Tab::show_console_window()
|
||||
{
|
||||
if (!m_console_widget) {
|
||||
auto console_window = GUI::Window::construct(&window());
|
||||
console_window->resize(500, 300);
|
||||
console_window->set_title("JS Console");
|
||||
console_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"));
|
||||
m_console_widget = console_window->set_main_widget<ConsoleWidget>();
|
||||
m_console_widget->on_js_input = [this](String const& js_source) {
|
||||
m_web_content_view->js_console_input(js_source);
|
||||
};
|
||||
}
|
||||
|
||||
m_console_widget->clear_output();
|
||||
m_web_content_view->js_console_initialize();
|
||||
|
||||
auto* window = m_console_widget->window();
|
||||
window->show();
|
||||
window->move_to_front();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue