diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-22 21:57:08 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-23 14:30:23 +0200 |
commit | 4aca24481e19e76d29e9a0a10adc43ba62f4ab56 (patch) | |
tree | 1288829a359d7c5fadfe12cff2d5ef4b559b2bf5 /Ladybird/BrowserWindow.cpp | |
parent | 5af715e3942cf43579beb93fcb27bd8e164ec8bd (diff) | |
download | serenity-4aca24481e19e76d29e9a0a10adc43ba62f4ab56.zip |
Ladybird: Implement the JavaScript console using a WebContentView
This aligns the Ladybird console implementation with the Browser console
a bit more, which uses OutOfProcessWebView for rendering console output.
This allows us to style the console output to try and match the system
theme.
Using a WebContentView is simpler than trying to style the old QTextEdit
widget, as the console output is HTML with built-in "-libweb-palette-*"
colors. These will override any color we set on the QTextEdit widget.
Diffstat (limited to 'Ladybird/BrowserWindow.cpp')
-rw-r--r-- | Ladybird/BrowserWindow.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp index dc45a367c3..1d34d7b196 100644 --- a/Ladybird/BrowserWindow.cpp +++ b/Ladybird/BrowserWindow.cpp @@ -8,6 +8,7 @@ */ #include "BrowserWindow.h" +#include "ConsoleWidget.h" #include "Settings.h" #include "SettingsDialog.h" #include "Utilities.h" @@ -546,8 +547,13 @@ void BrowserWindow::reset_zoom() void BrowserWindow::select_all() { - if (auto* tab = m_current_tab) - tab->view().select_all(); + if (!m_current_tab) + return; + + if (auto* console = m_current_tab->view().console(); console && console->isActiveWindow()) + console->view().select_all(); + else + m_current_tab->view().select_all(); } void BrowserWindow::update_displayed_zoom_level() @@ -560,11 +566,18 @@ void BrowserWindow::update_displayed_zoom_level() void BrowserWindow::copy_selected_text() { - if (auto* tab = m_current_tab) { - auto text = tab->view().selected_text(); - auto* clipboard = QGuiApplication::clipboard(); - clipboard->setText(qstring_from_ak_deprecated_string(text)); - } + if (!m_current_tab) + return; + + DeprecatedString text; + + if (auto* console = m_current_tab->view().console(); console && console->isActiveWindow()) + text = console->view().selected_text(); + else + text = m_current_tab->view().selected_text(); + + auto* clipboard = QGuiApplication::clipboard(); + clipboard->setText(qstring_from_ak_deprecated_string(text)); } void BrowserWindow::resizeEvent(QResizeEvent* event) |