mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
Browser: Remove the standalone JavaScript console
This commit is contained in:
parent
d8a700d9be
commit
b385a44f6f
6 changed files with 1 additions and 144 deletions
|
@ -10,7 +10,6 @@
|
|||
#include "BrowserWindow.h"
|
||||
#include "BookmarksBarWidget.h"
|
||||
#include "Browser.h"
|
||||
#include "ConsoleWidget.h"
|
||||
#include "InspectorWidget.h"
|
||||
#include "Tab.h"
|
||||
#include <Applications/Browser/BrowserWindowGML.h>
|
||||
|
@ -256,14 +255,6 @@ void BrowserWindow::build_menus()
|
|||
inspect_menu->add_action(*m_view_source_action);
|
||||
inspect_menu->add_action(*m_inspect_dom_tree_action);
|
||||
|
||||
auto js_console_action = GUI::Action::create(
|
||||
"Open &JS Console", { Mod_Ctrl, Key_I }, g_icon_bag.filetype_javascript, [this](auto&) {
|
||||
active_tab().show_console_window();
|
||||
},
|
||||
this);
|
||||
js_console_action->set_status_tip("Open JavaScript console for this page"_string);
|
||||
inspect_menu->add_action(js_console_action);
|
||||
|
||||
auto storage_window_action = GUI::Action::create(
|
||||
"Open S&torage Inspector", g_icon_bag.cookie, [this](auto&) {
|
||||
active_tab().show_storage_inspector();
|
||||
|
|
|
@ -14,7 +14,6 @@ stringify_gml(Tab.gml TabGML.h tab_gml)
|
|||
set(SOURCES
|
||||
BookmarksBarWidget.cpp
|
||||
BrowserWindow.cpp
|
||||
ConsoleWidget.cpp
|
||||
CookiesModel.cpp
|
||||
DownloadWidget.cpp
|
||||
History/HistoryModel.cpp
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ConsoleWidget.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Applications/Browser/Browser.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGfx/Font/FontDatabase.h>
|
||||
#include <LibJS/MarkupGenerator.h>
|
||||
#include <LibJS/SyntaxHighlighter.h>
|
||||
#include <LibWebView/ConsoleClient.h>
|
||||
#include <LibWebView/OutOfProcessWebView.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
ConsoleWidget::ConsoleWidget(WebView::OutOfProcessWebView& content_view)
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
set_fill_with_background_color(true);
|
||||
|
||||
m_output_view = add<WebView::OutOfProcessWebView>();
|
||||
m_console_client = make<WebView::ConsoleClient>(content_view, *m_output_view);
|
||||
|
||||
auto& bottom_container = add<GUI::Widget>();
|
||||
bottom_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
bottom_container.set_fixed_height(22);
|
||||
|
||||
m_input = bottom_container.add<GUI::TextBox>();
|
||||
m_input->set_syntax_highlighter(make<JS::SyntaxHighlighter>());
|
||||
// FIXME: Syntax Highlighting breaks the cursor's position on non fixed-width fonts.
|
||||
m_input->set_font(Gfx::FontDatabase::default_fixed_width_font());
|
||||
m_input->set_history_enabled(true);
|
||||
|
||||
m_input->on_return_pressed = [this] {
|
||||
auto js_source = m_input->text();
|
||||
|
||||
if (js_source.is_whitespace())
|
||||
return;
|
||||
|
||||
m_input->add_current_text_to_history();
|
||||
m_input->clear();
|
||||
|
||||
m_console_client->execute(MUST(String::from_deprecated_string(js_source)));
|
||||
};
|
||||
|
||||
set_focus_proxy(m_input);
|
||||
|
||||
auto& clear_button = bottom_container.add<GUI::Button>();
|
||||
clear_button.set_fixed_size(22, 22);
|
||||
clear_button.set_icon(g_icon_bag.delete_icon);
|
||||
clear_button.set_tooltip("Clear the console output"_string);
|
||||
clear_button.on_click = [this](auto) {
|
||||
m_console_client->clear();
|
||||
};
|
||||
}
|
||||
|
||||
ConsoleWidget::~ConsoleWidget() = default;
|
||||
|
||||
void ConsoleWidget::reset()
|
||||
{
|
||||
m_console_client->reset();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
class ConsoleWidget final : public GUI::Widget {
|
||||
C_OBJECT(ConsoleWidget)
|
||||
public:
|
||||
virtual ~ConsoleWidget();
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
explicit ConsoleWidget(WebView::OutOfProcessWebView& content_view);
|
||||
|
||||
void request_console_messages();
|
||||
void clear_output();
|
||||
|
||||
OwnPtr<WebView::ConsoleClient> m_console_client;
|
||||
|
||||
RefPtr<GUI::TextBox> m_input;
|
||||
RefPtr<WebView::OutOfProcessWebView> m_output_view;
|
||||
};
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@
|
|||
#include "BookmarksBarWidget.h"
|
||||
#include "Browser.h"
|
||||
#include "BrowserWindow.h"
|
||||
#include "ConsoleWidget.h"
|
||||
#include "DownloadWidget.h"
|
||||
#include "History/HistoryWidget.h"
|
||||
#include "InspectorWidget.h"
|
||||
|
@ -233,9 +232,6 @@ Tab::Tab(BrowserWindow& window)
|
|||
|
||||
if (m_dom_inspector_widget)
|
||||
m_dom_inspector_widget->reset();
|
||||
|
||||
if (m_console_widget)
|
||||
m_console_widget->reset();
|
||||
};
|
||||
|
||||
view().on_load_finish = [this](auto&) {
|
||||
|
@ -895,26 +891,9 @@ void Tab::close_sub_widgets()
|
|||
}
|
||||
};
|
||||
close_widget_window(m_dom_inspector_widget);
|
||||
close_widget_window(m_console_widget);
|
||||
close_widget_window(m_storage_widget);
|
||||
}
|
||||
|
||||
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(g_icon_bag.filetype_javascript);
|
||||
|
||||
m_console_widget = console_window->set_main_widget<ConsoleWidget>(view());
|
||||
}
|
||||
|
||||
auto* window = m_console_widget->window();
|
||||
window->show();
|
||||
window->move_to_front();
|
||||
}
|
||||
|
||||
void Tab::show_storage_inspector()
|
||||
{
|
||||
if (!m_storage_widget) {
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace Browser {
|
|||
|
||||
class BrowserWindow;
|
||||
class InspectorWidget;
|
||||
class ConsoleWidget;
|
||||
class HistoryWidget;
|
||||
class StorageWidget;
|
||||
class URLBox;
|
||||
|
@ -89,7 +88,6 @@ public:
|
|||
};
|
||||
void show_inspector_window(InspectorTarget);
|
||||
|
||||
void show_console_window();
|
||||
void show_storage_inspector();
|
||||
void show_history_inspector();
|
||||
|
||||
|
@ -125,7 +123,6 @@ private:
|
|||
RefPtr<GUI::Button> m_reset_zoom_button;
|
||||
RefPtr<GUI::Button> m_bookmark_button;
|
||||
RefPtr<InspectorWidget> m_dom_inspector_widget;
|
||||
RefPtr<ConsoleWidget> m_console_widget;
|
||||
RefPtr<StorageWidget> m_storage_widget;
|
||||
RefPtr<HistoryWidget> m_history_widget;
|
||||
RefPtr<GUI::Statusbar> m_statusbar;
|
||||
|
@ -158,7 +155,7 @@ private:
|
|||
RefPtr<GUI::Menu> m_go_forward_context_menu;
|
||||
|
||||
DeprecatedString m_title;
|
||||
RefPtr<const Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
|
||||
Optional<URL> m_navigating_url;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue