mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Previously, console messages were sent using an index-based system where DevTools would be notified of new message indices and then request them in batches. This created synchronization issues during page navigation when the WebContent process resets while DevTools still has stale index state. This changes to a push-based model where console messages are sent immediately as resources when they are logged, matching how Firefox DevTools handles console messages. Each message is pushed through IPC and forwarded to DevTools as a "console-message" or "error-message" resource. This eliminates the need for index tracking in FrameActor and simplifies the entire console message pipeline from WebContent through to DevTools.
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Time.h>
|
|
#include <LibIPC/Forward.h>
|
|
#include <LibJS/Console.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWebView/ConsoleOutput.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 end_group() override { }
|
|
virtual void clear() override { }
|
|
|
|
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel, PrinterArguments) override;
|
|
|
|
void send_console_output(WebView::ConsoleOutput);
|
|
};
|
|
|
|
}
|