mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +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
|
@ -8,18 +8,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Console.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <WebContent/ConsoleGlobalEnvironmentExtensions.h>
|
||||
#include <WebContent/Forward.h>
|
||||
|
||||
namespace WebContent {
|
||||
|
||||
class WebContentConsoleClient final : public JS::ConsoleClient {
|
||||
class WebContentConsoleClient : public JS::ConsoleClient {
|
||||
GC_CELL(WebContentConsoleClient, JS::ConsoleClient);
|
||||
GC_DECLARE_ALLOCATOR(WebContentConsoleClient);
|
||||
|
||||
|
@ -27,30 +25,27 @@ public:
|
|||
virtual ~WebContentConsoleClient() override;
|
||||
|
||||
void handle_input(StringView js_source);
|
||||
void send_messages(i32 start_index);
|
||||
void report_exception(JS::Error const&, bool) override;
|
||||
|
||||
private:
|
||||
WebContentConsoleClient(JS::Console&, JS::Realm&, PageClient&);
|
||||
virtual void handle_result(JS::Value) = 0;
|
||||
virtual void send_messages(i32 start_index) = 0;
|
||||
|
||||
protected:
|
||||
WebContentConsoleClient(JS::Realm&, JS::Console&, PageClient&, ConsoleGlobalEnvironmentExtensions&);
|
||||
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
virtual void clear() override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments) override;
|
||||
|
||||
virtual void add_css_style_to_current_message(StringView style) override
|
||||
{
|
||||
m_current_message_style.append(style);
|
||||
m_current_message_style.append(';');
|
||||
}
|
||||
|
||||
GC::Ref<PageClient> m_client;
|
||||
GC::Ptr<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
|
||||
|
||||
void clear_output();
|
||||
void print_html(String const& line);
|
||||
|
||||
virtual void clear() override;
|
||||
void clear_output();
|
||||
|
||||
void begin_group(String const& label, bool start_expanded);
|
||||
virtual void end_group() override;
|
||||
|
||||
GC::Ref<JS::Realm> m_realm;
|
||||
GC::Ref<PageClient> m_client;
|
||||
GC::Ref<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
|
||||
|
||||
struct ConsoleOutput {
|
||||
enum class Type {
|
||||
HTML,
|
||||
|
@ -63,8 +58,6 @@ private:
|
|||
String data;
|
||||
};
|
||||
Vector<ConsoleOutput> m_message_log;
|
||||
|
||||
StringBuilder m_current_message_style;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue