2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2021-09-02 12:01:19 +01:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@gmail.com>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-01-02 14:55:19 +01:00
|
|
|
#include "InspectorWidget.h"
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
|
#include <LibGUI/Splitter.h>
|
2020-05-08 21:38:30 +02:00
|
|
|
#include <LibGUI/TabWidget.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/TableView.h>
|
|
|
|
|
#include <LibGUI/TreeView.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
|
#include <LibWeb/DOM/Element.h>
|
2021-06-07 22:21:16 +01:00
|
|
|
#include <LibWeb/DOMTreeJSONModel.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/DOMTreeModel.h>
|
|
|
|
|
#include <LibWeb/StylePropertiesModel.h>
|
2020-01-02 14:55:19 +01:00
|
|
|
|
2020-05-08 21:38:30 +02:00
|
|
|
namespace Browser {
|
|
|
|
|
|
2021-09-02 12:01:19 +01:00
|
|
|
void InspectorWidget::set_inspected_node(GUI::ModelIndex const)
|
2020-06-12 22:30:11 +02:00
|
|
|
{
|
2021-09-02 12:01:19 +01:00
|
|
|
// FIXME: Handle this for OutOfProcessWebView
|
2021-08-17 17:00:27 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-23 12:07:13 +01:00
|
|
|
InspectorWidget::InspectorWidget()
|
2020-01-02 14:55:19 +01:00
|
|
|
{
|
2020-03-04 09:43:54 +01:00
|
|
|
set_layout<GUI::VerticalBoxLayout>();
|
2020-03-04 19:07:55 +01:00
|
|
|
auto& splitter = add<GUI::VerticalSplitter>();
|
2020-06-12 22:30:11 +02:00
|
|
|
|
|
|
|
|
auto& top_tab_widget = splitter.add<GUI::TabWidget>();
|
|
|
|
|
|
|
|
|
|
m_dom_tree_view = top_tab_widget.add_tab<GUI::TreeView>("DOM");
|
2021-05-25 22:48:43 +02:00
|
|
|
m_dom_tree_view->on_selection_change = [this] {
|
|
|
|
|
const auto& index = m_dom_tree_view->selection().first();
|
2021-06-07 22:21:16 +01:00
|
|
|
set_inspected_node(index);
|
2020-06-12 22:30:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
m_layout_tree_view = top_tab_widget.add_tab<GUI::TreeView>("Layout");
|
2021-05-25 22:48:43 +02:00
|
|
|
m_layout_tree_view->on_selection_change = [this] {
|
|
|
|
|
const auto& index = m_layout_tree_view->selection().first();
|
2021-06-07 22:21:16 +01:00
|
|
|
set_inspected_node(index);
|
2020-01-02 14:55:19 +01:00
|
|
|
};
|
2020-02-23 12:23:48 +01:00
|
|
|
|
2020-06-12 22:30:11 +02:00
|
|
|
auto& bottom_tab_widget = splitter.add<GUI::TabWidget>();
|
2020-02-23 12:23:48 +01:00
|
|
|
|
2020-06-12 22:30:11 +02:00
|
|
|
m_style_table_view = bottom_tab_widget.add_tab<GUI::TableView>("Styles");
|
|
|
|
|
m_computed_style_table_view = bottom_tab_widget.add_tab<GUI::TableView>("Computed");
|
2020-01-02 14:55:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InspectorWidget::~InspectorWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-07 22:21:16 +01:00
|
|
|
void InspectorWidget::set_dom_json(String json)
|
|
|
|
|
{
|
|
|
|
|
if (m_dom_json.has_value() && m_dom_json.value() == json)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_dom_json = json;
|
|
|
|
|
m_dom_tree_view->set_model(Web::DOMTreeJSONModel::create(m_dom_json->view()));
|
|
|
|
|
|
|
|
|
|
// FIXME: Support the LayoutTreeModel
|
|
|
|
|
// m_layout_tree_view->set_model(Web::LayoutTreeModel::create(*document));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-08 21:38:30 +02:00
|
|
|
}
|