1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:27:35 +00:00

Browser: Convert JS ConsoleWidget to new API

The console widget now requests messages and receives them in bulk,
using the shiny new IPC calls. This lets it display console messages
that occurred before the widget was created. :^)
This commit is contained in:
Sam Atkins 2021-09-04 12:12:12 +01:00 committed by Andreas Kling
parent f6a927fa20
commit 703bd4c9da
3 changed files with 88 additions and 11 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,18 +19,27 @@ class ConsoleWidget final : public GUI::Widget {
public:
virtual ~ConsoleWidget();
void handle_js_console_output(const String& method, const String& line);
void notify_about_new_console_message(i32 message_index);
void handle_console_messages(i32 start_index, Vector<String> const& message_types, Vector<String> const& messages);
void print_source_line(const StringView&);
void print_html(const StringView&);
void clear_output();
void reset();
Function<void(const String&)> on_js_input;
Function<void(i32)> on_request_messages;
private:
ConsoleWidget();
void request_console_messages();
void clear_output();
RefPtr<GUI::TextBox> m_input;
RefPtr<Web::OutOfProcessWebView> m_output_view;
i32 m_highest_notified_message_index { -1 };
i32 m_highest_received_message_index { -1 };
bool m_waiting_for_messages { false };
};
}