forked from LadybirdBrowser/ancient-history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleClient.h
61 lines (47 loc) · 1.46 KB
/
ConsoleClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (c) 2022, Brandon Scott <[email protected]>
* Copyright (c) 2020, Hunter Salyer <[email protected]>
* Copyright (c) 2021, Sam Atkins <[email protected]>
* Copyright (c) 2022, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#define AK_DONT_REPLACE_STD
#include "ConsoleGlobalObject.h"
#include <AK/WeakPtr.h>
#include <LibJS/Console.h>
#include <LibJS/Forward.h>
#include <LibWeb/Forward.h>
class WebView;
namespace Ladybird {
class ConsoleClient final : public JS::ConsoleClient {
public:
ConsoleClient(JS::Console&, JS::Realm&, WebView&);
void handle_input(String const& js_source);
void send_messages(i32 start_index);
private:
virtual void clear() override;
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments) override;
WebView& m_view;
WeakPtr<JS::Interpreter> m_interpreter;
JS::Handle<ConsoleGlobalObject> m_console_global_object;
void clear_output();
void print_html(String const& line);
void begin_group(String const& label, bool start_expanded);
virtual void end_group() override;
struct ConsoleOutput {
enum class Type {
HTML,
Clear,
BeginGroup,
BeginGroupCollapsed,
EndGroup,
};
Type type;
String data;
};
Vector<ConsoleOutput> m_message_log;
WeakPtr<JS::Realm> m_realm;
};
}