mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibWeb: Add DOMTreeModel::index_for_node()
This is needed for telling the DOM Inspector to select a given Node.
This commit is contained in:
parent
3ef4ba810a
commit
8eef509c1b
2 changed files with 18 additions and 0 deletions
|
@ -131,4 +131,20 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
|
|||
return {};
|
||||
}
|
||||
|
||||
GUI::ModelIndex DOMTreeModel::index_for_node(DOM::Node* node) const
|
||||
{
|
||||
if (!node)
|
||||
return {};
|
||||
|
||||
DOM::Node* parent = node->parent();
|
||||
if (!parent)
|
||||
return {};
|
||||
|
||||
auto maybe_row = parent->index_of_child(*node);
|
||||
if (maybe_row.has_value())
|
||||
return create_index(maybe_row.value(), 0, node);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue