mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
Inspector: Show remote object properties in a table view
This patch expands the object model of this program quite a bit. We now have a RemoteProcess object that contains a list of remote root RemoteObject objects. The RemoteProcess vends a RemoteObjectGraphModel&, and indices in that model have internal_data() pointing to a corresponding RemoteObject. RemoteObjects in turn vend a RemoteObjectPropertyModel&, which is what we use to show the object properties. This is pretty cool :^)
This commit is contained in:
parent
736dc5f6c0
commit
4f3234148a
Notes:
sideshowbarker
2024-07-19 12:35:28 +09:00
Author: https://github.com/awesomekling
Commit: 4f3234148a
10 changed files with 252 additions and 76 deletions
46
DevTools/Inspector/RemoteObjectPropertyModel.cpp
Normal file
46
DevTools/Inspector/RemoteObjectPropertyModel.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include "RemoteObjectPropertyModel.h"
|
||||
#include "RemoteObject.h"
|
||||
|
||||
RemoteObjectPropertyModel::RemoteObjectPropertyModel(RemoteObject& object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
int RemoteObjectPropertyModel::row_count(const GModelIndex&) const
|
||||
{
|
||||
return m_properties.size();
|
||||
}
|
||||
|
||||
String RemoteObjectPropertyModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
case Column::Value:
|
||||
return "Value";
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GVariant RemoteObjectPropertyModel::data(const GModelIndex& index, Role role) const
|
||||
{
|
||||
auto& property = m_properties[index.row()];
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Name:
|
||||
return property.name;
|
||||
case Column::Value:
|
||||
return property.value;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void RemoteObjectPropertyModel::update()
|
||||
{
|
||||
m_properties.clear();
|
||||
m_object.json.for_each_member([this](auto& name, auto& value) {
|
||||
m_properties.append({ name, value });
|
||||
});
|
||||
did_update();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue