mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibDevTools: Implement a real actor for DOM nodes
The DevTools client will now send requests to the node actor, rather than just sending messages to other actors on the node's behalf. This exposed a slight issue in the way we assign actor IDs. Node actors are created in the walker actor constructor, which executes before the actor ID is incremented. So we must be sure to increment the actor ID before invoking any actor constructors. Otherwise, the walker actor and the first node actor have the same numeric ID.
This commit is contained in:
parent
6e8d77ff7f
commit
c56bf8ac93
Notes:
github-actions[bot]
2025-02-24 17:06:54 +00:00
Author: https://github.com/trflynn89
Commit: c56bf8ac93
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3666
Reviewed-by: https://github.com/AtkinsSJ
7 changed files with 83 additions and 6 deletions
|
@ -6,8 +6,10 @@
|
|||
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <LibDevTools/Actors/NodeActor.h>
|
||||
#include <LibDevTools/Actors/TabActor.h>
|
||||
#include <LibDevTools/Actors/WalkerActor.h>
|
||||
#include <LibDevTools/DevToolsServer.h>
|
||||
#include <LibWeb/DOM/NodeType.h>
|
||||
|
||||
namespace DevTools {
|
||||
|
@ -276,11 +278,12 @@ Optional<JsonObject const&> WalkerActor::find_node_by_selector(JsonObject const&
|
|||
|
||||
void WalkerActor::populate_dom_tree_cache(JsonObject& node, JsonObject const* parent)
|
||||
{
|
||||
auto& node_actor = devtools().register_actor<NodeActor>(*this);
|
||||
|
||||
m_dom_node_to_parent_map.set(&node, parent);
|
||||
|
||||
auto actor = MUST(String::formatted("{}-node{}", name(), m_dom_node_count++));
|
||||
m_actor_to_dom_node_map.set(actor, &node);
|
||||
node.set("actor"sv, actor);
|
||||
m_actor_to_dom_node_map.set(node_actor.name(), &node);
|
||||
node.set("actor"sv, node_actor.name());
|
||||
|
||||
auto children = node.get_array("children"sv);
|
||||
if (!children.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue