mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
Ladybird: Reimplement the DOM inspector :^)
This has been broken since the switch to the multiprocess architecture (and even before then was very limited). This restores the previous functionally and also implements the ability to inspect individual elements (by selecting them in the tree view). The inspector also now correctly updates when navigating between pages.
This commit is contained in:
parent
0313814d3b
commit
aa85a88158
5 changed files with 176 additions and 24 deletions
46
Ladybird/InspectorWidget.h
Normal file
46
Ladybird/InspectorWidget.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ModelTranslator.h"
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <QWidget>
|
||||
|
||||
class QTreeView;
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class InspectorWidget final : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InspectorWidget();
|
||||
virtual ~InspectorWidget() = default;
|
||||
|
||||
struct Selection {
|
||||
i32 dom_node_id { 0 };
|
||||
Optional<Web::CSS::Selector::PseudoElement> pseudo_element {};
|
||||
bool operator==(Selection const& other) const = default;
|
||||
};
|
||||
|
||||
void clear_dom_json();
|
||||
void set_dom_json(StringView dom_json);
|
||||
|
||||
Function<void(i32, Optional<Web::CSS::Selector::PseudoElement>)> on_dom_node_inspected;
|
||||
Function<void()> on_close;
|
||||
|
||||
private:
|
||||
void set_selection(GUI::ModelIndex);
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
|
||||
QTreeView* m_tree_view { nullptr };
|
||||
ModelTranslator m_dom_model {};
|
||||
Selection m_selection;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue