mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:57:34 +00:00
Ladybird+LibWebView: Extract common JS console functionality to a helper
This creates WebView::ConsoleClient to handle functionality that will be common to the JS consoles of all Ladybird chromes. This will let each chrome focus on just the UI. Note that this includes the `console.group` functionality that only the Serenity chrome previously had. This was a FIXME in the Qt chrome, and it is implemented such that all chromes will receive this functionality for free.
This commit is contained in:
parent
c9b9278092
commit
bf59e06d2a
11 changed files with 300 additions and 366 deletions
|
@ -10,12 +10,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
#include <QLineEdit>
|
||||
#include <QWidget>
|
||||
|
||||
class QLineEdit;
|
||||
namespace Ladybird {
|
||||
|
||||
class WebContentView;
|
||||
|
@ -23,30 +23,19 @@ class WebContentView;
|
|||
class ConsoleWidget final : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConsoleWidget();
|
||||
virtual ~ConsoleWidget() = default;
|
||||
|
||||
void notify_about_new_console_message(i32 message_index);
|
||||
void handle_console_messages(i32 start_index, Vector<DeprecatedString> const& message_types, Vector<DeprecatedString> const& messages);
|
||||
void print_source_line(StringView);
|
||||
void print_html(StringView);
|
||||
void reset();
|
||||
explicit ConsoleWidget(WebContentView& content_view);
|
||||
virtual ~ConsoleWidget();
|
||||
|
||||
WebView::ConsoleClient& client() { return *m_console_client; }
|
||||
WebContentView& view() { return *m_output_view; }
|
||||
|
||||
Function<void(DeprecatedString const&)> on_js_input;
|
||||
Function<void(i32)> on_request_messages;
|
||||
void reset();
|
||||
|
||||
private:
|
||||
void request_console_messages();
|
||||
void clear_output();
|
||||
OwnPtr<WebView::ConsoleClient> m_console_client;
|
||||
|
||||
WebContentView* m_output_view { nullptr };
|
||||
QLineEdit* m_input { nullptr };
|
||||
|
||||
i32 m_highest_notified_message_index { -1 };
|
||||
i32 m_highest_received_message_index { -1 };
|
||||
bool m_waiting_for_messages { false };
|
||||
};
|
||||
|
||||
class ConsoleInputEdit final : public QLineEdit {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue