2021-02-27 21:44:49 -06:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Brandon Scott <xeon.productions@gmail.com>
|
|
|
|
|
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
2022-11-19 16:12:19 +00:00
|
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
2021-02-27 21:44:49 -06:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-27 21:44:49 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-02-02 18:00:48 -07:00
|
|
|
#include <AK/Vector.h>
|
2021-02-27 21:44:49 -06:00
|
|
|
#include <LibJS/Console.h>
|
|
|
|
|
#include <LibJS/Forward.h>
|
2025-02-24 09:48:13 -05:00
|
|
|
#include <LibJS/Runtime/Value.h>
|
2021-02-27 21:44:49 -06:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
#include <WebContent/Forward.h>
|
|
|
|
|
|
|
|
|
|
namespace WebContent {
|
|
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
class WebContentConsoleClient : public JS::ConsoleClient {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(WebContentConsoleClient, JS::ConsoleClient);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(WebContentConsoleClient);
|
2024-04-20 21:19:51 +02:00
|
|
|
|
2021-02-27 21:44:49 -06:00
|
|
|
public:
|
2024-04-20 21:19:51 +02:00
|
|
|
virtual ~WebContentConsoleClient() override;
|
2021-02-27 21:44:49 -06:00
|
|
|
|
2025-02-23 08:57:40 -05:00
|
|
|
void handle_input(StringView js_source);
|
2021-02-27 21:44:49 -06:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
virtual void handle_result(JS::Value) = 0;
|
|
|
|
|
virtual void send_messages(i32 start_index) = 0;
|
2024-04-20 21:19:51 +02:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
protected:
|
|
|
|
|
WebContentConsoleClient(JS::Realm&, JS::Console&, PageClient&, ConsoleGlobalEnvironmentExtensions&);
|
2021-02-27 21:44:49 -06:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
2022-09-20 18:23:04 +01:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
void print_html(String const& line);
|
2021-09-03 10:16:36 +01:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
virtual void clear() override;
|
2021-02-27 21:44:49 -06:00
|
|
|
void clear_output();
|
2025-02-24 09:48:13 -05:00
|
|
|
|
2025-02-23 08:57:40 -05:00
|
|
|
void begin_group(String const& label, bool start_expanded);
|
2021-12-22 12:32:15 +00:00
|
|
|
virtual void end_group() override;
|
2021-09-04 11:45:36 +01:00
|
|
|
|
2025-02-24 09:48:13 -05:00
|
|
|
GC::Ref<JS::Realm> m_realm;
|
|
|
|
|
GC::Ref<PageClient> m_client;
|
|
|
|
|
GC::Ref<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
|
|
|
|
|
|
2021-09-04 11:45:36 +01:00
|
|
|
struct ConsoleOutput {
|
|
|
|
|
enum class Type {
|
|
|
|
|
HTML,
|
2021-12-22 12:32:15 +00:00
|
|
|
Clear,
|
|
|
|
|
BeginGroup,
|
|
|
|
|
BeginGroupCollapsed,
|
|
|
|
|
EndGroup,
|
2021-09-04 11:45:36 +01:00
|
|
|
};
|
|
|
|
|
Type type;
|
2025-02-23 08:57:40 -05:00
|
|
|
String data;
|
2021-09-04 11:45:36 +01:00
|
|
|
};
|
|
|
|
|
Vector<ConsoleOutput> m_message_log;
|
2021-02-27 21:44:49 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|