mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
Ladybird/Qt: Port the Inspector to the WebView InspectorClient
This commit is contained in:
parent
39e32e80cd
commit
52b5bcdb6d
3 changed files with 72 additions and 190 deletions
|
@ -8,66 +8,45 @@
|
|||
|
||||
#include "ModelAdapter.h"
|
||||
#include "WebContentView.h"
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
#include <QWidget>
|
||||
|
||||
class QTreeView;
|
||||
class QTableView;
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class WebContentView;
|
||||
|
||||
class InspectorWidget final : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InspectorWidget();
|
||||
virtual ~InspectorWidget() = default;
|
||||
explicit InspectorWidget(WebContentView& content_view);
|
||||
virtual ~InspectorWidget() override;
|
||||
|
||||
struct Selection {
|
||||
i32 dom_node_id { 0 };
|
||||
Optional<Web::CSS::Selector::PseudoElement> pseudo_element {};
|
||||
bool operator==(Selection const& other) const = default;
|
||||
};
|
||||
|
||||
bool dom_loaded() const { return m_dom_loaded; }
|
||||
|
||||
void set_selection(Selection);
|
||||
void clear_selection();
|
||||
void inspect();
|
||||
void reset();
|
||||
|
||||
void select_hovered_node();
|
||||
void select_default_node();
|
||||
|
||||
void clear_dom_json();
|
||||
void set_dom_json(StringView dom_json);
|
||||
|
||||
void set_accessibility_json(StringView accessibility_json);
|
||||
|
||||
private:
|
||||
void load_style_json(StringView computed_style_json, StringView resolved_style_json, StringView custom_properties_json);
|
||||
void clear_style_json();
|
||||
|
||||
Function<ErrorOr<WebContentView::DOMNodeProperties>(i32, Optional<Web::CSS::Selector::PseudoElement>)> on_dom_node_inspected;
|
||||
Function<void()> on_close;
|
||||
|
||||
private:
|
||||
void set_selection(QModelIndex const&);
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
|
||||
Selection m_selection;
|
||||
OwnPtr<WebContentView> m_inspector_view;
|
||||
OwnPtr<WebView::InspectorClient> m_inspector_client;
|
||||
|
||||
OwnPtr<TreeModel> m_dom_model;
|
||||
OwnPtr<TreeModel> m_accessibility_model;
|
||||
OwnPtr<PropertyTableModel> m_computed_style_model;
|
||||
OwnPtr<PropertyTableModel> m_resolved_style_model;
|
||||
OwnPtr<PropertyTableModel> m_custom_properties_model;
|
||||
|
||||
QTreeView* m_dom_tree_view { nullptr };
|
||||
QTreeView* m_accessibility_tree_view { nullptr };
|
||||
QTableView* m_computed_style_table { nullptr };
|
||||
QTableView* m_resolved_style_table { nullptr };
|
||||
QTableView* m_custom_properties_table { nullptr };
|
||||
|
||||
bool m_dom_loaded { false };
|
||||
Optional<Selection> m_pending_selection {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue