mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update devtools page titles.
This commit is contained in:
parent
b53ce5c79a
commit
02ce6188aa
4 changed files with 48 additions and 0 deletions
|
@ -347,6 +347,13 @@ impl BrowsingContextActor {
|
|||
stream.write_json_packet(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn title_changed(&self, pipeline: PipelineId, title: String) {
|
||||
if pipeline != self.active_pipeline.get() {
|
||||
return;
|
||||
}
|
||||
*self.title.borrow_mut() = title;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
|
|
@ -235,6 +235,26 @@ fn run_server(
|
|||
.navigate(state);
|
||||
}
|
||||
|
||||
fn handle_title_changed(
|
||||
actors: Arc<Mutex<ActorRegistry>>,
|
||||
pipelines: &HashMap<PipelineId, BrowsingContextId>,
|
||||
browsing_contexts: &HashMap<BrowsingContextId, String>,
|
||||
pipeline: PipelineId,
|
||||
title: String,
|
||||
) {
|
||||
let bc = match pipelines.get(&pipeline) {
|
||||
Some(bc) => bc,
|
||||
None => return,
|
||||
};
|
||||
let name = match browsing_contexts.get(&bc) {
|
||||
Some(name) => name,
|
||||
None => return,
|
||||
};
|
||||
let actors = actors.lock().unwrap();
|
||||
let browsing_context = actors.find::<BrowsingContextActor>(name);
|
||||
browsing_context.title_changed(pipeline, title);
|
||||
}
|
||||
|
||||
// We need separate actor representations for each script global that exists;
|
||||
// clients can theoretically connect to multiple globals simultaneously.
|
||||
// TODO: move this into the root or target modules?
|
||||
|
@ -578,6 +598,16 @@ fn run_server(
|
|||
actor_name,
|
||||
tick,
|
||||
)) => handle_framerate_tick(actors.clone(), actor_name, tick),
|
||||
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::TitleChanged(
|
||||
pipeline,
|
||||
title,
|
||||
)) => handle_title_changed(
|
||||
actors.clone(),
|
||||
&pipelines,
|
||||
&browsing_contexts,
|
||||
pipeline,
|
||||
title,
|
||||
),
|
||||
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::NewGlobal(
|
||||
ids,
|
||||
script_sender,
|
||||
|
|
|
@ -97,6 +97,9 @@ pub enum ScriptToDevtoolsControlMsg {
|
|||
|
||||
/// Report a page error for the given pipeline
|
||||
ReportPageError(PipelineId, PageError),
|
||||
|
||||
/// Report a page title change
|
||||
TitleChanged(PipelineId, String),
|
||||
}
|
||||
|
||||
/// Serialized JS return values
|
||||
|
|
|
@ -934,6 +934,14 @@ impl Document {
|
|||
pub fn title_changed(&self) {
|
||||
if self.browsing_context().is_some() {
|
||||
self.send_title_to_embedder();
|
||||
let global = self.window.upcast::<GlobalScope>();
|
||||
if let Some(ref chan) = global.devtools_chan() {
|
||||
let title = String::from(self.Title());
|
||||
let _ = chan.send(ScriptToDevtoolsControlMsg::TitleChanged(
|
||||
global.pipeline_id(),
|
||||
title,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue