mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
Create ScriptMsg::GetBrowsingContextInfo
This commit is contained in:
parent
7b3feb7ffe
commit
bed16ddd89
3 changed files with 40 additions and 52 deletions
|
@ -1218,28 +1218,14 @@ where
|
||||||
FromScriptMsg::TouchEventProcessed(result) => self
|
FromScriptMsg::TouchEventProcessed(result) => self
|
||||||
.compositor_proxy
|
.compositor_proxy
|
||||||
.send(ToCompositorMsg::TouchEventProcessed(result)),
|
.send(ToCompositorMsg::TouchEventProcessed(result)),
|
||||||
FromScriptMsg::GetBrowsingContextId(pipeline_id, sender) => {
|
FromScriptMsg::GetBrowsingContextInfo(pipeline_id, sender) => {
|
||||||
let result = self
|
let result = self
|
||||||
.pipelines
|
.pipelines
|
||||||
.get(&pipeline_id)
|
.get(&pipeline_id)
|
||||||
.map(|pipeline| pipeline.browsing_context_id);
|
.and_then(|pipeline| self.browsing_contexts.get(&pipeline.browsing_context_id))
|
||||||
|
.map(|ctx| (ctx.id, ctx.parent_pipeline_id));
|
||||||
if let Err(e) = sender.send(result) {
|
if let Err(e) = sender.send(result) {
|
||||||
warn!("Sending reply to get browsing context failed ({:?}).", e);
|
warn!("Sending reply to get browsing context info failed ({:?}).", e);
|
||||||
}
|
|
||||||
},
|
|
||||||
// TODO(mandreyel): maybe change semantics of this message to
|
|
||||||
// reflect moving parent_info into BrowsingContext, i.e. message
|
|
||||||
// could be: GetParentInfo(BrowsingContextId, Sender)
|
|
||||||
FromScriptMsg::GetParentInfo(pipeline_id, sender) => {
|
|
||||||
let browsing_context = self.pipelines
|
|
||||||
.get(&pipeline_id)
|
|
||||||
.and_then(|pipeline| self.browsing_contexts.get(&pipeline.browsing_context_id));
|
|
||||||
if let Some(browsing_context) = browsing_context {
|
|
||||||
if let Err(e) = sender.send(browsing_context.parent_pipeline_id) {
|
|
||||||
warn!("Sending reply to get parent info failed ({:?}).", e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
warn!("GetParentInfo for pipeline {} with no browsing context.", pipeline_id)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FromScriptMsg::GetTopForBrowsingContext(browsing_context_id, sender) => {
|
FromScriptMsg::GetTopForBrowsingContext(browsing_context_id, sender) => {
|
||||||
|
|
|
@ -2065,24 +2065,21 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_constellation_for_browsing_context_id(&self, pipeline_id: PipelineId) -> Option<BrowsingContextId> {
|
fn ask_constellation_for_browsing_context_info(
|
||||||
|
&self,
|
||||||
|
pipeline_id: PipelineId
|
||||||
|
) -> Option<(BrowsingContextId, Option<PipelineId>)> {
|
||||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
||||||
let msg = ScriptMsg::GetBrowsingContextId(pipeline_id, result_sender);
|
let msg = ScriptMsg::GetBrowsingContextInfo(pipeline_id, result_sender);
|
||||||
self.script_sender.send((pipeline_id, msg)).expect("Failed to send to constellation.");
|
self.script_sender.send((pipeline_id, msg)).expect("Failed to send to constellation.");
|
||||||
result_receiver.recv().expect("Failed to get frame id from constellation.")
|
result_receiver.recv().expect("Failed to get browsing context info from constellation.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_constellation_for_parent_info(&self, pipeline_id: PipelineId) -> Option<PipelineId> {
|
fn ask_constellation_for_top_level_info(
|
||||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
&self,
|
||||||
let msg = ScriptMsg::GetParentInfo(pipeline_id, result_sender);
|
|
||||||
self.script_sender.send((pipeline_id, msg)).expect("Failed to send to constellation.");
|
|
||||||
result_receiver.recv().expect("Failed to get frame id from constellation.")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ask_constellation_for_top_level_info(&self,
|
|
||||||
sender_pipeline: PipelineId,
|
sender_pipeline: PipelineId,
|
||||||
browsing_context_id: BrowsingContextId)
|
browsing_context_id: BrowsingContextId
|
||||||
-> Option<TopLevelBrowsingContextId> {
|
) -> Option<TopLevelBrowsingContextId> {
|
||||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
||||||
let msg = ScriptMsg::GetTopForBrowsingContext(browsing_context_id, result_sender);
|
let msg = ScriptMsg::GetTopForBrowsingContext(browsing_context_id, result_sender);
|
||||||
self.script_sender.send((sender_pipeline, msg)).expect("Failed to send to constellation.");
|
self.script_sender.send((sender_pipeline, msg)).expect("Failed to send to constellation.");
|
||||||
|
@ -2095,25 +2092,29 @@ impl ScriptThread {
|
||||||
// get the browsing context for the parent if there is one,
|
// get the browsing context for the parent if there is one,
|
||||||
// construct a new dissimilar-origin browsing context, add it
|
// construct a new dissimilar-origin browsing context, add it
|
||||||
// to the `window_proxies` map, and return it.
|
// to the `window_proxies` map, and return it.
|
||||||
fn remote_window_proxy(&self,
|
fn remote_window_proxy(
|
||||||
|
&self,
|
||||||
global_to_clone: &GlobalScope,
|
global_to_clone: &GlobalScope,
|
||||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
opener: Option<BrowsingContextId>)
|
opener: Option<BrowsingContextId>
|
||||||
-> Option<DomRoot<WindowProxy>>
|
) -> Option<DomRoot<WindowProxy>> {
|
||||||
{
|
let (browsing_context_id, parent_pipeline_id) =
|
||||||
let browsing_context_id = self.ask_constellation_for_browsing_context_id(pipeline_id)?;
|
self.ask_constellation_for_browsing_context_info(pipeline_id)?;
|
||||||
if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) {
|
if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) {
|
||||||
return Some(DomRoot::from_ref(window_proxy));
|
return Some(DomRoot::from_ref(window_proxy));
|
||||||
}
|
}
|
||||||
let parent = self.ask_constellation_for_parent_info(pipeline_id).and_then(|parent_id| {
|
|
||||||
|
let parent = parent_pipeline_id.and_then(|parent_id| {
|
||||||
self.remote_window_proxy(global_to_clone, top_level_browsing_context_id, parent_id, opener)
|
self.remote_window_proxy(global_to_clone, top_level_browsing_context_id, parent_id, opener)
|
||||||
});
|
});
|
||||||
let window_proxy = WindowProxy::new_dissimilar_origin(global_to_clone,
|
let window_proxy = WindowProxy::new_dissimilar_origin(
|
||||||
|
global_to_clone,
|
||||||
browsing_context_id,
|
browsing_context_id,
|
||||||
top_level_browsing_context_id,
|
top_level_browsing_context_id,
|
||||||
parent.r(),
|
parent.r(),
|
||||||
opener);
|
opener
|
||||||
|
);
|
||||||
self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy));
|
self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy));
|
||||||
Some(window_proxy)
|
Some(window_proxy)
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,15 +108,17 @@ pub enum ScriptMsg {
|
||||||
Focus,
|
Focus,
|
||||||
/// Requests that the constellation retrieve the current contents of the clipboard
|
/// Requests that the constellation retrieve the current contents of the clipboard
|
||||||
GetClipboardContents(IpcSender<String>),
|
GetClipboardContents(IpcSender<String>),
|
||||||
/// Get the browsing context id for a given pipeline.
|
|
||||||
GetBrowsingContextId(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
|
||||||
/// Get the parent info for a given pipeline.
|
|
||||||
GetParentInfo(PipelineId, IpcSender<Option<PipelineId>>),
|
|
||||||
/// Get the top-level browsing context info for a given browsing context.
|
/// Get the top-level browsing context info for a given browsing context.
|
||||||
GetTopForBrowsingContext(
|
GetTopForBrowsingContext(
|
||||||
BrowsingContextId,
|
BrowsingContextId,
|
||||||
IpcSender<Option<TopLevelBrowsingContextId>>,
|
IpcSender<Option<TopLevelBrowsingContextId>>,
|
||||||
),
|
),
|
||||||
|
/// Get the browsing context id of the browsing context in which pipeline is
|
||||||
|
/// embedded and the parent pipeline id of that browsing context.
|
||||||
|
GetBrowsingContextInfo(
|
||||||
|
PipelineId,
|
||||||
|
IpcSender<Option<(BrowsingContextId, Option<PipelineId>)>>,
|
||||||
|
),
|
||||||
/// Get the nth child browsing context ID for a given browsing context, sorted in tree order.
|
/// Get the nth child browsing context ID for a given browsing context, sorted in tree order.
|
||||||
GetChildBrowsingContextId(
|
GetChildBrowsingContextId(
|
||||||
BrowsingContextId,
|
BrowsingContextId,
|
||||||
|
@ -201,8 +203,7 @@ impl fmt::Debug for ScriptMsg {
|
||||||
CreateCanvasPaintThread(..) => "CreateCanvasPaintThread",
|
CreateCanvasPaintThread(..) => "CreateCanvasPaintThread",
|
||||||
Focus => "Focus",
|
Focus => "Focus",
|
||||||
GetClipboardContents(..) => "GetClipboardContents",
|
GetClipboardContents(..) => "GetClipboardContents",
|
||||||
GetBrowsingContextId(..) => "GetBrowsingContextId",
|
GetBrowsingContextInfo(..) => "GetBrowsingContextInfo",
|
||||||
GetParentInfo(..) => "GetParentInfo",
|
|
||||||
GetTopForBrowsingContext(..) => "GetParentBrowsingContext",
|
GetTopForBrowsingContext(..) => "GetParentBrowsingContext",
|
||||||
GetChildBrowsingContextId(..) => "GetChildBrowsingContextId",
|
GetChildBrowsingContextId(..) => "GetChildBrowsingContextId",
|
||||||
LoadComplete => "LoadComplete",
|
LoadComplete => "LoadComplete",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue