1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

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.
This commit is contained in:
Timothy Flynn 2023-04-22 21:57:08 -04:00 committed by Andreas Kling
parent 5af715e394
commit 4aca24481e
5 changed files with 80 additions and 22 deletions

View file

@ -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)