mirror of
https://github.com/servo/servo.git
synced 2025-07-21 22:33:41 +01:00
devtools: Treat session history traversal like a navigation.
This commit is contained in:
parent
bd554a2a98
commit
fd9be5097d
4 changed files with 36 additions and 2 deletions
|
@ -112,7 +112,10 @@ use compositing::compositor_thread::Msg as ToCompositorMsg;
|
|||
use compositing::compositor_thread::WebrenderMsg;
|
||||
use compositing::{ConstellationMsg as FromCompositorMsg, SendableFrameTree};
|
||||
use crossbeam_channel::{after, never, unbounded, Receiver, Sender};
|
||||
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, DevtoolsControlMsg, DevtoolsPageInfo, NavigationState,
|
||||
ScriptToDevtoolsControlMsg,
|
||||
};
|
||||
use embedder_traits::{Cursor, EmbedderMsg, EmbedderProxy, EventLoopWaker};
|
||||
use embedder_traits::{MediaSessionEvent, MediaSessionPlaybackState};
|
||||
use euclid::{default::Size2D as UntypedSize2D, Size2D};
|
||||
|
@ -1934,6 +1937,11 @@ where
|
|||
BrowsingContextId::from(source_top_ctx_id),
|
||||
FromScriptMsg::GetWebGPUChan(sender),
|
||||
),
|
||||
FromScriptMsg::TitleChanged(pipeline, title) => {
|
||||
if let Some(pipeline) = self.pipelines.get_mut(&pipeline) {
|
||||
pipeline.title = title;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3935,6 +3943,21 @@ where
|
|||
old_pipeline.notify_visibility(false);
|
||||
}
|
||||
if let Some(new_pipeline) = self.pipelines.get(&new_pipeline_id) {
|
||||
if let Some(ref chan) = self.devtools_chan {
|
||||
let state = NavigationState::Start(new_pipeline.url.clone());
|
||||
let _ = chan.send(DevtoolsControlMsg::FromScript(
|
||||
ScriptToDevtoolsControlMsg::Navigate(browsing_context_id, state),
|
||||
));
|
||||
let page_info = DevtoolsPageInfo {
|
||||
title: new_pipeline.title.clone(),
|
||||
url: new_pipeline.url.clone(),
|
||||
};
|
||||
let state = NavigationState::Stop(new_pipeline.id, page_info);
|
||||
let _ = chan.send(DevtoolsControlMsg::FromScript(
|
||||
ScriptToDevtoolsControlMsg::Navigate(browsing_context_id, state),
|
||||
));
|
||||
}
|
||||
|
||||
new_pipeline.notify_visibility(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,9 @@ pub struct Pipeline {
|
|||
|
||||
/// Has this pipeline received a notification that it is completely loaded?
|
||||
pub completely_loaded: bool,
|
||||
|
||||
/// The title of this pipeline's document.
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
/// Initial setup data needed to construct a pipeline.
|
||||
|
@ -379,6 +382,7 @@ impl Pipeline {
|
|||
history_state_id: None,
|
||||
history_states: HashSet::new(),
|
||||
completely_loaded: false,
|
||||
title: String::new(),
|
||||
};
|
||||
|
||||
pipeline.notify_visibility(is_visible);
|
||||
|
|
|
@ -1142,9 +1142,13 @@ impl Document {
|
|||
pub fn title_changed(&self) {
|
||||
if self.browsing_context().is_some() {
|
||||
self.send_title_to_embedder();
|
||||
let title = String::from(self.Title());
|
||||
self.window.send_to_constellation(ScriptMsg::TitleChanged(
|
||||
self.window.pipeline_id(),
|
||||
title.clone(),
|
||||
));
|
||||
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,
|
||||
|
|
|
@ -282,6 +282,8 @@ pub enum ScriptMsg {
|
|||
),
|
||||
/// Get WebGPU channel
|
||||
GetWebGPUChan(IpcSender<WebGPU>),
|
||||
/// Notify the constellation of a pipeline's document's title.
|
||||
TitleChanged(PipelineId, String),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ScriptMsg {
|
||||
|
@ -341,6 +343,7 @@ impl fmt::Debug for ScriptMsg {
|
|||
MediaSessionEvent(..) => "MediaSessionEvent",
|
||||
RequestAdapter(..) => "RequestAdapter",
|
||||
GetWebGPUChan(..) => "GetWebGPUChan",
|
||||
TitleChanged(..) => "TitleChanged",
|
||||
};
|
||||
write!(formatter, "ScriptMsg::{}", variant)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue