Add a new RPC call for getting a child browsing context ID

This commit is contained in:
Keith Yeung 2018-04-09 16:27:20 -07:00
parent 847115ba04
commit 4383b3053b
2 changed files with 11 additions and 0 deletions

View file

@ -1231,6 +1231,15 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
warn!("Sending reply to get parent info failed ({:?}).", e); warn!("Sending reply to get parent info failed ({:?}).", e);
} }
} }
FromScriptMsg::GetChildBrowsingContextId(browsing_context_id, index, sender) => {
// We increment here because the 0th element is the parent browsing context itself
let result = self.all_descendant_browsing_contexts_iter(browsing_context_id)
.nth(index + 1)
.map(|bc| bc.id);
if let Err(e) = sender.send(result) {
warn!("Sending reply to get child browsing context ID failed ({:?}).", e);
}
}
FromScriptMsg::RegisterServiceWorker(scope_things, scope) => { FromScriptMsg::RegisterServiceWorker(scope_things, scope) => {
debug!("constellation got store registration scope message"); debug!("constellation got store registration scope message");
self.handle_register_serviceworker(scope_things, scope); self.handle_register_serviceworker(scope_things, scope);

View file

@ -90,6 +90,8 @@ pub enum ScriptMsg {
GetBrowsingContextId(PipelineId, IpcSender<Option<BrowsingContextId>>), GetBrowsingContextId(PipelineId, IpcSender<Option<BrowsingContextId>>),
/// Get the parent info for a given pipeline. /// Get the parent info for a given pipeline.
GetParentInfo(PipelineId, IpcSender<Option<PipelineId>>), GetParentInfo(PipelineId, IpcSender<Option<PipelineId>>),
/// Get the nth child browsing context ID for a given browsing context, sorted in tree order.
GetChildBrowsingContextId(BrowsingContextId, usize, IpcSender<Option<BrowsingContextId>>),
/// <head> tag finished parsing /// <head> tag finished parsing
HeadParsed, HeadParsed,
/// All pending loads are complete, and the `load` event for this pipeline /// All pending loads are complete, and the `load` event for this pipeline