mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-17 07:41:54 +00:00
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.
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
#include <LibWeb/HTML/Window.h>
|
|
#include <WebContent/ConsoleGlobalEnvironmentExtensions.h>
|
|
#include <WebContent/DevToolsConsoleClient.h>
|
|
#include <WebContent/PageClient.h>
|
|
|
|
namespace WebContent {
|
|
|
|
GC_DEFINE_ALLOCATOR(DevToolsConsoleClient);
|
|
|
|
GC::Ref<DevToolsConsoleClient> DevToolsConsoleClient::create(JS::Realm& realm, JS::Console& console, PageClient& client)
|
|
{
|
|
auto& window = as<Web::HTML::Window>(realm.global_object());
|
|
auto console_global_environment_extensions = realm.create<ConsoleGlobalEnvironmentExtensions>(realm, window);
|
|
|
|
return realm.heap().allocate<DevToolsConsoleClient>(realm, console, client, console_global_environment_extensions);
|
|
}
|
|
|
|
DevToolsConsoleClient::DevToolsConsoleClient(JS::Realm& realm, JS::Console& console, PageClient& client, ConsoleGlobalEnvironmentExtensions& console_global_environment_extensions)
|
|
: WebContentConsoleClient(realm, console, client, console_global_environment_extensions)
|
|
{
|
|
}
|
|
|
|
DevToolsConsoleClient::~DevToolsConsoleClient() = default;
|
|
|
|
void DevToolsConsoleClient::handle_result(JS::Value result)
|
|
{
|
|
(void)result;
|
|
}
|
|
|
|
void DevToolsConsoleClient::report_exception(JS::Error const& exception, bool in_promise)
|
|
{
|
|
(void)exception;
|
|
(void)in_promise;
|
|
}
|
|
|
|
void DevToolsConsoleClient::send_messages(i32 start_index)
|
|
{
|
|
(void)start_index;
|
|
}
|
|
|
|
// 2.3. Printer(logLevel, args[, options]), https://console.spec.whatwg.org/#printer
|
|
JS::ThrowCompletionOr<JS::Value> DevToolsConsoleClient::printer(JS::Console::LogLevel log_level, PrinterArguments arguments)
|
|
{
|
|
(void)log_level;
|
|
(void)arguments;
|
|
return JS::js_undefined();
|
|
}
|
|
|
|
}
|