mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #21705 - mandreyel:coalesce-script-to-constellation-msgs, r=paulrouget
Create ScriptMsg::GetBrowsingContextInfo Script used to send two messages to constellation to first retrieve the id of the browsing context in which a pipeline resides and then its parent pipeline's id. This patch introduces a minor optimization to instead retrieve those fields in a single message. Also, fixed a potential bug introduced in #21559 where if a browsing context wasn't found for a pipeline in response to `GetParentInfo` (which is now deleted), constellation sent nothing back, presumably causing the script thread to hang on the receiving channel. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #21703 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because no new behaviour was introduced. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21705) <!-- Reviewable:end -->
This commit is contained in:
commit
170e232606
3 changed files with 40 additions and 52 deletions
|
@ -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 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.");
|
||||
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> {
|
||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
||||
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,
|
||||
browsing_context_id: BrowsingContextId)
|
||||
-> Option<TopLevelBrowsingContextId> {
|
||||
fn ask_constellation_for_top_level_info(
|
||||
&self,
|
||||
sender_pipeline: PipelineId,
|
||||
browsing_context_id: BrowsingContextId
|
||||
) -> Option<TopLevelBrowsingContextId> {
|
||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
||||
let msg = ScriptMsg::GetTopForBrowsingContext(browsing_context_id, result_sender);
|
||||
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,
|
||||
// construct a new dissimilar-origin browsing context, add it
|
||||
// to the `window_proxies` map, and return it.
|
||||
fn remote_window_proxy(&self,
|
||||
global_to_clone: &GlobalScope,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
pipeline_id: PipelineId,
|
||||
opener: Option<BrowsingContextId>)
|
||||
-> Option<DomRoot<WindowProxy>>
|
||||
{
|
||||
let browsing_context_id = self.ask_constellation_for_browsing_context_id(pipeline_id)?;
|
||||
fn remote_window_proxy(
|
||||
&self,
|
||||
global_to_clone: &GlobalScope,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
pipeline_id: PipelineId,
|
||||
opener: Option<BrowsingContextId>
|
||||
) -> Option<DomRoot<WindowProxy>> {
|
||||
let (browsing_context_id, parent_pipeline_id) =
|
||||
self.ask_constellation_for_browsing_context_info(pipeline_id)?;
|
||||
if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) {
|
||||
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)
|
||||
});
|
||||
let window_proxy = WindowProxy::new_dissimilar_origin(global_to_clone,
|
||||
browsing_context_id,
|
||||
top_level_browsing_context_id,
|
||||
parent.r(),
|
||||
opener);
|
||||
let window_proxy = WindowProxy::new_dissimilar_origin(
|
||||
global_to_clone,
|
||||
browsing_context_id,
|
||||
top_level_browsing_context_id,
|
||||
parent.r(),
|
||||
opener
|
||||
);
|
||||
self.window_proxies.borrow_mut().insert(browsing_context_id, Dom::from_ref(&*window_proxy));
|
||||
Some(window_proxy)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue