summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/Browser/Tab.cpp10
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp3
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp5
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.h2
-rw-r--r--Userland/Services/WebContent/ClientConnection.cpp43
-rw-r--r--Userland/Services/WebContent/ClientConnection.h1
-rw-r--r--Userland/Services/WebContent/PageHost.cpp1
-rw-r--r--Userland/Services/WebContent/PageHost.h3
-rw-r--r--Userland/Services/WebContent/WebContentServer.ipc2
9 files changed, 64 insertions, 6 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index ea23d61d73..8a307ae684 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -362,7 +362,7 @@ Tab::Tab(Type type)
if (m_type == Type::InProcessWebView) {
Web::dump_tree(*m_page_view->document());
} else {
- TODO();
+ m_web_content_view->debug_request("dump-dom-tree");
}
},
this));
@@ -371,7 +371,7 @@ Tab::Tab(Type type)
if (m_type == Type::InProcessWebView) {
Web::dump_tree(*m_page_view->document()->layout_node());
} else {
- TODO();
+ m_web_content_view->debug_request("dump-layout-tree");
}
},
this));
@@ -382,7 +382,7 @@ Tab::Tab(Type type)
Web::dump_sheet(sheet);
}
} else {
- TODO();
+ m_web_content_view->debug_request("dump-style-sheets");
}
},
this));
@@ -396,7 +396,7 @@ Tab::Tab(Type type)
m_page_view->set_should_show_line_box_borders(action.is_checked());
m_page_view->update();
} else {
- TODO();
+ m_web_content_view->debug_request("set-line-box-borders", action.is_checked() ? "on" : "off");
}
},
this);
@@ -410,7 +410,7 @@ Tab::Tab(Type type)
document->interpreter().heap().collect_garbage(JS::Heap::CollectionType::CollectGarbage, true);
}
} else {
- TODO();
+ m_web_content_view->debug_request("collect-garbage");
}
}));
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 347e81dcae..83b8a3a2a1 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -534,7 +534,8 @@ Color Document::visited_link_color() const
return page()->palette().visited_link();
}
-static JS::VM& main_thread_vm()
+JS::VM& main_thread_vm();
+JS::VM& main_thread_vm()
{
static RefPtr<JS::VM> vm;
if (!vm) {
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
index 5fc2dc2d82..ff0eb2b63c 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -299,4 +299,9 @@ WebContentClient& OutOfProcessWebView::client()
return *m_client_state.client;
}
+void OutOfProcessWebView::debug_request(const String& request, const String& argument)
+{
+ client().post_message(Messages::WebContentServer::DebugRequest(request, argument));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
index 750da66d09..3bdfa39969 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
@@ -49,6 +49,8 @@ public:
void load_html(const StringView&, const URL&);
void load_empty_document();
+ void debug_request(const String& request, const String& argument = {});
+
void notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size);
void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id);
void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, const Gfx::IntRect&);
diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp
index 01af0de4ec..b41e35cb9b 100644
--- a/Userland/Services/WebContent/ClientConnection.cpp
+++ b/Userland/Services/WebContent/ClientConnection.cpp
@@ -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());
+ }
+}
+
}
diff --git a/Userland/Services/WebContent/ClientConnection.h b/Userland/Services/WebContent/ClientConnection.h
index 34a13713f3..39faf16165 100644
--- a/Userland/Services/WebContent/ClientConnection.h
+++ b/Userland/Services/WebContent/ClientConnection.h
@@ -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();
diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp
index f4a47e1259..d37ff61054 100644
--- a/Userland/Services/WebContent/PageHost.cpp
+++ b/Userland/Services/WebContent/PageHost.cpp
@@ -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);
}
diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h
index 6983421840..580685cfdb 100644
--- a/Userland/Services/WebContent/PageHost.h
+++ b/Userland/Services/WebContent/PageHost.h
@@ -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 };
};
}
diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc
index e025e0b0cd..81620f7ecf 100644
--- a/Userland/Services/WebContent/WebContentServer.ipc
+++ b/Userland/Services/WebContent/WebContentServer.ipc
@@ -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) =|
}