mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
devtools: Replace new with register for NodeActor (#44071)
Added a `register` method to `NodeActor` following the same pattern used by other actors in the devtools codebase. Updated `NodeInfoToProtocol::get_or_register_node_actor` to use it instead of constructing `NodeActor` directly. Testing: Ran `./mach try linux-unit-tests` and `./mach test-devtools`. No new failures introduced. Fixes:part of #43800 --------- Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
This commit is contained in:
@@ -258,6 +258,30 @@ impl Actor for NodeActor {
|
||||
}
|
||||
}
|
||||
|
||||
impl NodeActor {
|
||||
pub fn register(
|
||||
registry: &ActorRegistry,
|
||||
script_id: String,
|
||||
script_chan: GenericSender<DevtoolScriptControlMsg>,
|
||||
pipeline: PipelineId,
|
||||
walker: String,
|
||||
) -> String {
|
||||
let name = registry.new_name::<Self>();
|
||||
|
||||
registry.register_script_actor(script_id, name.clone());
|
||||
|
||||
let actor = Self {
|
||||
name: name.clone(),
|
||||
script_chan,
|
||||
pipeline,
|
||||
walker,
|
||||
style_rules: AtomicRefCell::new(HashMap::new()),
|
||||
};
|
||||
|
||||
registry.register(actor);
|
||||
name
|
||||
}
|
||||
}
|
||||
pub trait NodeInfoToProtocol {
|
||||
fn encode(
|
||||
self,
|
||||
@@ -278,18 +302,13 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||
) -> NodeActorMsg {
|
||||
let get_or_register_node_actor = |id: &str| {
|
||||
if !registry.script_actor_registered(id.to_string()) {
|
||||
let node_name = registry.new_name::<NodeActor>();
|
||||
registry.register_script_actor(id.to_string(), node_name.clone());
|
||||
|
||||
let node_actor = NodeActor {
|
||||
name: node_name.clone(),
|
||||
script_chan: script_chan.clone(),
|
||||
NodeActor::register(
|
||||
registry,
|
||||
id.to_string(),
|
||||
script_chan.clone(),
|
||||
pipeline,
|
||||
walker: walker.clone(),
|
||||
style_rules: AtomicRefCell::new(HashMap::new()),
|
||||
};
|
||||
registry.register(node_actor);
|
||||
node_name
|
||||
walker.clone(),
|
||||
)
|
||||
} else {
|
||||
registry.script_to_actor(id.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user