mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01: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.
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Console.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <WebContent/Forward.h>
|
|
#include <WebContent/WebContentConsoleClient.h>
|
|
|
|
namespace WebContent {
|
|
|
|
class DevToolsConsoleClient final : public WebContentConsoleClient {
|
|
GC_CELL(DevToolsConsoleClient, WebContentConsoleClient);
|
|
GC_DECLARE_ALLOCATOR(DevToolsConsoleClient);
|
|
|
|
public:
|
|
static GC::Ref<DevToolsConsoleClient> create(JS::Realm&, JS::Console&, PageClient&);
|
|
virtual ~DevToolsConsoleClient() override;
|
|
|
|
private:
|
|
DevToolsConsoleClient(JS::Realm&, JS::Console&, PageClient&, ConsoleGlobalEnvironmentExtensions&);
|
|
|
|
virtual void handle_result(JS::Value) override;
|
|
virtual void report_exception(JS::Error const&, bool) override;
|
|
virtual void send_messages(i32 start_index) override;
|
|
|
|
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments) override;
|
|
};
|
|
|
|
}
|