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

LibJS+WebContent+Browser+js: Implement console.group() methods

This implements:
- console.group()
- console.groupCollapsed()
- console.groupEnd()

In the Browser, we use `<details>` for the groups, which is not actually
implemented yet, so groups are always open.

In the REPL, groups are non-interactive, but still indent any output.
This looks weird since the console prompt and return values remain on
the far left, but this matches what Node does so it's probably fine. :^)
I expect `console.group()` is not used much outside of browsers.
This commit is contained in:
Sam Atkins 2021-12-22 12:32:15 +00:00 committed by Andreas Kling
parent ff5e07d718
commit d702678d16
10 changed files with 281 additions and 25 deletions

View file

@ -33,6 +33,8 @@ private:
void request_console_messages();
void clear_output();
void begin_group(StringView label, bool start_expanded);
void end_group();
RefPtr<GUI::TextBox> m_input;
RefPtr<Web::OutOfProcessWebView> m_output_view;
@ -40,6 +42,13 @@ private:
i32 m_highest_notified_message_index { -1 };
i32 m_highest_received_message_index { -1 };
bool m_waiting_for_messages { false };
struct Group {
int id { 0 };
String label;
};
Vector<Group> m_group_stack;
int m_next_group_id { 1 };
};
}