mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibDevTools: Associate node actors with a DOM node identifier
This is a prepatory commit to be able to handle DOM mutations. Once a node actor is created, the DOM node it is created for must continue to be associated with the same actor even after DOM mutations. This change stores an identifier on the node actor, and only creates new actors when an actor for a node does not exist.
This commit is contained in:
parent
ee88edc750
commit
ddea67034f
Notes:
github-actions[bot]
2025-03-08 00:28:03 +00:00
Author: https://github.com/trflynn89
Commit: ddea67034f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3850
6 changed files with 80 additions and 28 deletions
|
@ -8,20 +8,35 @@
|
|||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibDevTools/Actor.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace DevTools {
|
||||
|
||||
struct NodeIdentifier {
|
||||
static NodeIdentifier for_node(JsonObject const& node);
|
||||
|
||||
bool operator==(NodeIdentifier const&) const = default;
|
||||
|
||||
Web::UniqueNodeID id { 0 };
|
||||
Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element;
|
||||
};
|
||||
|
||||
class NodeActor final : public Actor {
|
||||
public:
|
||||
static constexpr auto base_name = "node"sv;
|
||||
|
||||
static NonnullRefPtr<NodeActor> create(DevToolsServer&, String name, WeakPtr<WalkerActor>);
|
||||
static NonnullRefPtr<NodeActor> create(DevToolsServer&, String name, NodeIdentifier, WeakPtr<WalkerActor>);
|
||||
virtual ~NodeActor() override;
|
||||
|
||||
virtual void handle_message(StringView type, JsonObject const&) override;
|
||||
|
||||
NodeIdentifier const& node_identifier() const { return m_node_identifier; }
|
||||
|
||||
private:
|
||||
NodeActor(DevToolsServer&, String name, WeakPtr<WalkerActor>);
|
||||
NodeActor(DevToolsServer&, String name, NodeIdentifier, WeakPtr<WalkerActor>);
|
||||
|
||||
NodeIdentifier m_node_identifier;
|
||||
|
||||
WeakPtr<WalkerActor> m_walker;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue