summaryrefslogtreecommitdiff
path: root/Ladybird/InspectorWidget.h
blob: ab367784be525c269863fe34e3c74b5297c54b5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
};

}