mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibWeb: Give each Node a unique ID
We maintain a directory of ID -> Node. Nodes add themselves to this directory when they are created, receiving a random ID. When a Node is destroyed, it removes itself from this directory. Anyone can request a Node from the directory by its ID using `Node::from_id()`. We reserve the `0` ID to mean "none". These IDs allow different processes to communicate about a given Node over IPC, for example the DOM Inspector.
This commit is contained in:
parent
48a2239f60
commit
d7485df928
3 changed files with 33 additions and 0 deletions
|
@ -179,6 +179,9 @@ public:
|
|||
bool is_shadow_including_ancestor_of(Node const&) const;
|
||||
bool is_shadow_including_inclusive_ancestor_of(Node const&) const;
|
||||
|
||||
i32 id() const { return m_id; }
|
||||
static Node* from_id(i32 node_id);
|
||||
|
||||
protected:
|
||||
Node(Document&, NodeType);
|
||||
|
||||
|
@ -187,6 +190,8 @@ protected:
|
|||
NodeType m_type { NodeType::INVALID };
|
||||
bool m_needs_style_update { false };
|
||||
bool m_child_needs_style_update { false };
|
||||
|
||||
i32 m_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue