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

LibWeb+Browser: Support DOM Inspector for OutOfProcessWebView

This introduces a new DOMTreeJSONModel, which provides the Model for the
InspectorWidget when the Browser is running using the
OutOfProcessWebView.

This Model is constructed with a JSON object received via IPC from the
WebContentServer.
This commit is contained in:
Adam Hodgen 2021-06-07 22:21:16 +01:00 committed by Andreas Kling
parent cd6b9613c5
commit 1e5e02c70b
8 changed files with 330 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include "BrowserWindow.h"
#include "ConsoleWidget.h"
#include "DownloadWidget.h"
#include "InspectorWidget.h"
#include <AK/StringBuilder.h>
#include <AK/URL.h>
#include <Applications/Browser/TabGML.h>
@ -78,6 +79,20 @@ void Tab::view_source(const URL& url, const String& source)
window->show();
}
void Tab::view_dom_tree(const String& dom_tree)
{
auto window = GUI::Window::construct(&this->window());
window->resize(300, 500);
window->set_title("DOM inspector");
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
window->set_main_widget<InspectorWidget>();
auto* inspector_widget = static_cast<InspectorWidget*>(window->main_widget());
inspector_widget->set_dom_json(dom_tree);
window->show();
window->move_to_front();
}
Tab::Tab(BrowserWindow& window, Type type)
: m_type(type)
{
@ -264,6 +279,10 @@ Tab::Tab(BrowserWindow& window, Type type)
view_source(url, source);
};
hooks().on_get_dom_tree = [this](auto& dom_tree) {
view_dom_tree(dom_tree);
};
hooks().on_js_console_output = [this](auto& method, auto& line) {
if (m_console_window) {
auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget());