mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:37:45 +00:00
Browser+LibWeb+WebContent: Make the "Debug" menu work in multi-process
This patch adds an IPC call for debugging requests. It's stringly typed and very simple, and allows us to easily implement all the features in the Browser's Debug menu.
This commit is contained in:
parent
1dad47c0f9
commit
df2a4adcd2
9 changed files with 64 additions and 6 deletions
|
@ -28,11 +28,21 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <WebContent/ClientConnection.h>
|
||||
#include <WebContent/PageHost.h>
|
||||
#include <WebContent/WebContentClientEndpoint.h>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
extern JS::VM& main_thread_vm();
|
||||
}
|
||||
|
||||
namespace WebContent {
|
||||
|
||||
static HashMap<int, RefPtr<ClientConnection>> s_connections;
|
||||
|
@ -165,4 +175,37 @@ void ClientConnection::handle(const Messages::WebContentServer::KeyDown& message
|
|||
page().handle_keydown((KeyCode)message.key(), message.modifiers(), message.code_point());
|
||||
}
|
||||
|
||||
void ClientConnection::handle(const Messages::WebContentServer::DebugRequest& message)
|
||||
{
|
||||
if (message.request() == "dump-dom-tree") {
|
||||
if (auto* doc = page().main_frame().document())
|
||||
Web::dump_tree(*doc);
|
||||
}
|
||||
|
||||
if (message.request() == "dump-layout-tree") {
|
||||
if (auto* doc = page().main_frame().document()) {
|
||||
if (auto* icb = doc->layout_node())
|
||||
Web::dump_tree(*icb);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.request() == "dump-style-sheets") {
|
||||
if (auto* doc = page().main_frame().document()) {
|
||||
for (auto& sheet : doc->style_sheets().sheets()) {
|
||||
Web::dump_sheet(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.request() == "collect-garbage") {
|
||||
::Web::DOM::main_thread_vm().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
|
||||
}
|
||||
|
||||
if (message.request() == "set-line-box-borders") {
|
||||
bool state = message.argument() == "on";
|
||||
m_page_host->set_should_show_line_box_borders(state);
|
||||
page().main_frame().set_needs_display(page().main_frame().viewport_rect());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
virtual void handle(const Messages::WebContentServer::KeyDown&) override;
|
||||
virtual void handle(const Messages::WebContentServer::AddBackingStore&) override;
|
||||
virtual void handle(const Messages::WebContentServer::RemoveBackingStore&) override;
|
||||
virtual void handle(const Messages::WebContentServer::DebugRequest&) override;
|
||||
|
||||
void flush_pending_paint_requests();
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
|
|||
painter.translate(-content_rect.x(), -content_rect.y());
|
||||
|
||||
Web::PaintContext context(painter, palette(), Gfx::IntPoint());
|
||||
context.set_should_show_line_box_borders(m_should_show_line_box_borders);
|
||||
context.set_viewport_rect(content_rect);
|
||||
layout_root->paint_all_phases(context);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
void set_palette_impl(const Gfx::PaletteImpl&);
|
||||
void set_viewport_rect(const Gfx::IntRect&);
|
||||
|
||||
void set_should_show_line_box_borders(bool b) { m_should_show_line_box_borders = b; }
|
||||
|
||||
private:
|
||||
// ^PageClient
|
||||
virtual bool is_multi_process() const override { return true; }
|
||||
|
@ -75,6 +77,7 @@ private:
|
|||
ClientConnection& m_client;
|
||||
NonnullOwnPtr<Web::Page> m_page;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette_impl;
|
||||
bool m_should_show_line_box_borders { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,6 @@ endpoint WebContentServer = 89
|
|||
MouseUp(Gfx::IntPoint position, unsigned button, unsigned buttons, unsigned modifiers) =|
|
||||
|
||||
KeyDown(i32 key, unsigned modifiers, u32 code_point) =|
|
||||
|
||||
DebugRequest(String request, String argument) =|
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue