mirror of
https://github.com/RGBCube/serenity
synced 2025-06-03 02:28:11 +00:00

When selecting an element in the browser's DOM inspector, we now also show the resolved CSS properties (and their values) for that element. Since the inspector was growing a bit more complex, I moved it out of the "show inspector" action callback and into its own class. In the future, we will probably want to migrate the inspector down to LibHTML to make it accessible to other clients of the library, but for now we can keep working on it inside Browser. :^)
33 lines
976 B
C++
33 lines
976 B
C++
#include <AK/NonnullRefPtrVector.h>
|
|
#include <LibGUI/GModel.h>
|
|
|
|
class Element;
|
|
|
|
class DOMElementStyleModel final : public GModel {
|
|
public:
|
|
enum Column {
|
|
PropertyName,
|
|
PropertyValue,
|
|
__Count
|
|
};
|
|
|
|
static NonnullRefPtr<DOMElementStyleModel> create(const Element& element) { return adopt(*new DOMElementStyleModel(element)); }
|
|
|
|
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
|
|
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; }
|
|
virtual String column_name(int) const override;
|
|
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
|
virtual void update() override;
|
|
|
|
private:
|
|
explicit DOMElementStyleModel(const Element&);
|
|
const Element& element() const { return *m_element; }
|
|
|
|
NonnullRefPtr<Element> m_element;
|
|
|
|
struct Value {
|
|
String name;
|
|
String value;
|
|
};
|
|
Vector<Value> m_values;
|
|
};
|