mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LibWebView+WebContent: Create a different console client for DevTools
Our existing WebContentConsoleClient is very specific to our home-grown Inspector. It renders console output to an HTML string. For DevTools, we will not want this behavior; we will want to send representations of raw JS values. This patch makes WebContentConsoleClient a base class to handle console input from the user, either from the Inspector or from DevTools. It then moves the HTML rendering needed for the Inspector to a new class, InspectorConsoleClient. And we add a DevToolsConsoleClient (currently just stubbed) to handle needs specific to DevTools. We choose at runtime which console client to install, based on the --devtools command line flag.
This commit is contained in:
parent
a8d3252f93
commit
37f07c176a
Notes:
github-actions[bot]
2025-02-28 12:09:47 +00:00
Author: https://github.com/trflynn89
Commit: 37f07c176a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3686
12 changed files with 419 additions and 229 deletions
|
@ -24,6 +24,8 @@
|
|||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
#include <LibWebView/Attribute.h>
|
||||
#include <WebContent/ConnectionFromClient.h>
|
||||
#include <WebContent/DevToolsConsoleClient.h>
|
||||
#include <WebContent/InspectorConsoleClient.h>
|
||||
#include <WebContent/PageClient.h>
|
||||
#include <WebContent/PageHost.h>
|
||||
#include <WebContent/WebContentClientEndpoint.h>
|
||||
|
@ -33,6 +35,7 @@ namespace WebContent {
|
|||
|
||||
static PageClient::UseSkiaPainter s_use_skia_painter = PageClient::UseSkiaPainter::GPUBackendIfAvailable;
|
||||
static bool s_is_headless { false };
|
||||
static bool s_devtools_enabled { false };
|
||||
|
||||
GC_DEFINE_ALLOCATOR(PageClient);
|
||||
|
||||
|
@ -51,6 +54,11 @@ void PageClient::set_is_headless(bool is_headless)
|
|||
s_is_headless = is_headless;
|
||||
}
|
||||
|
||||
void PageClient::set_devtools_enabled(bool devtools_enabled)
|
||||
{
|
||||
s_devtools_enabled = devtools_enabled;
|
||||
}
|
||||
|
||||
GC::Ref<PageClient> PageClient::create(JS::VM& vm, PageHost& page_host, u64 id)
|
||||
{
|
||||
return vm.heap().allocate<PageClient>(page_host, id);
|
||||
|
@ -731,9 +739,13 @@ void PageClient::initialize_js_console(Web::DOM::Document& document)
|
|||
return;
|
||||
|
||||
auto& realm = document.realm();
|
||||
|
||||
auto console_object = realm.intrinsics().console_object();
|
||||
auto console_client = heap().allocate<WebContentConsoleClient>(console_object->console(), document.realm(), *this);
|
||||
|
||||
GC::Ptr<JS::ConsoleClient> console_client;
|
||||
if (s_devtools_enabled)
|
||||
console_client = DevToolsConsoleClient::create(document.realm(), console_object->console(), *this);
|
||||
else
|
||||
console_client = InspectorConsoleClient::create(document.realm(), console_object->console(), *this);
|
||||
|
||||
document.set_console_client(console_client);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue