Permalink
Browse files

Auto merge of #22376 - cbrewster:constellation_nll_cleanup, r=jdm

Cleanup constellation after nll

<!-- Please describe your changes on the following line: -->
This cleans up a couple cases where we had to add extra scopes to appease the borrowck, now that nll has landed, this cleans these up.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because cleanup

<!-- 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/22376)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Dec 6, 2018
2 parents a2c4eba + aecb48d commit 920056ca0207a2ccd50d32e3193dbc15b7fcd9cf
Showing with 110 additions and 135 deletions.
  1. +110 −135 components/constellation/constellation.rs
@@ -1599,20 +1599,14 @@ where
EmbedderMsg::Panic(reason, backtrace),
));

let (window_size, pipeline_id, is_visible) = {
let browsing_context = self.browsing_contexts.get(&browsing_context_id);
let window_size = browsing_context.and_then(|ctx| ctx.size);
let pipeline_id = browsing_context.map(|ctx| ctx.pipeline_id);
let is_visible = browsing_context.map(|ctx| ctx.is_visible);
(window_size, pipeline_id, is_visible)
};
let browsing_context = self.browsing_contexts.get(&browsing_context_id);
let window_size = browsing_context.and_then(|ctx| ctx.size);
let pipeline_id = browsing_context.map(|ctx| ctx.pipeline_id);
let is_visible = browsing_context.map(|ctx| ctx.is_visible);

let (pipeline_url, opener) = {
let pipeline = pipeline_id.and_then(|id| self.pipelines.get(&id));
let pipeline_url = pipeline.map(|pipeline| pipeline.url.clone());
let opener = pipeline.and_then(|pipeline| pipeline.opener);
(pipeline_url, opener)
};
let pipeline = pipeline_id.and_then(|id| self.pipelines.get(&id));
let pipeline_url = pipeline.map(|pipeline| pipeline.url.clone());
let opener = pipeline.and_then(|pipeline| pipeline.opener);

self.close_browsing_context_children(
browsing_context_id,
@@ -1855,65 +1849,56 @@ where
replace,
} = load_info.info;

let (load_data, is_private) = {
// If no url is specified, reload.
let old_pipeline = load_info
.old_pipeline_id
.and_then(|id| self.pipelines.get(&id));
let load_data = load_info.load_data.unwrap_or_else(|| {
let url = match old_pipeline {
Some(old_pipeline) => old_pipeline.url.clone(),
None => ServoUrl::parse("about:blank").expect("infallible"),
};

// TODO - loaddata here should have referrer info (not None, None)
LoadData::new(url, Some(parent_pipeline_id), None, None)
});

let is_parent_private = {
let parent_browsing_context_id = match self.pipelines.get(&parent_pipeline_id) {
Some(pipeline) => pipeline.browsing_context_id,
None => {
return warn!(
"Script loaded url in iframe {} in closed parent pipeline {}.",
browsing_context_id, parent_pipeline_id,
)
},
};
let is_parent_private =
match self.browsing_contexts.get(&parent_browsing_context_id) {
Some(ctx) => ctx.is_private,
None => {
return warn!(
"Script loaded url in iframe {} in closed parent browsing context {}.",
browsing_context_id,
parent_browsing_context_id,
)
},
};
is_parent_private
// If no url is specified, reload.
let old_pipeline = load_info
.old_pipeline_id
.and_then(|id| self.pipelines.get(&id));
let load_data = load_info.load_data.unwrap_or_else(|| {
let url = match old_pipeline {
Some(old_pipeline) => old_pipeline.url.clone(),
None => ServoUrl::parse("about:blank").expect("infallible"),
};
let is_private = is_private || is_parent_private;

(load_data, is_private)
};
// TODO - loaddata here should have referrer info (not None, None)
LoadData::new(url, Some(parent_pipeline_id), None, None)
});

let (replace, window_size, is_visible) = {
let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
Some(ctx) => ctx,
let is_parent_private = {
let parent_browsing_context_id = match self.pipelines.get(&parent_pipeline_id) {
Some(pipeline) => pipeline.browsing_context_id,
None => {
return warn!(
"Script loaded url in iframe with closed browsing context {}.",
browsing_context_id,
"Script loaded url in iframe {} in closed parent pipeline {}.",
browsing_context_id, parent_pipeline_id,
)
},
};
let replace = if replace {
Some(NeedsToReload::No(browsing_context.pipeline_id))
} else {
None
let is_parent_private = match self.browsing_contexts.get(&parent_browsing_context_id) {
Some(ctx) => ctx.is_private,
None => {
return warn!(
"Script loaded url in iframe {} in closed parent browsing context {}.",
browsing_context_id, parent_browsing_context_id,
)
},
};
(replace, browsing_context.size, browsing_context.is_visible)
is_parent_private
};
let is_private = is_private || is_parent_private;

let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
Some(ctx) => ctx,
None => {
return warn!(
"Script loaded url in iframe with closed browsing context {}.",
browsing_context_id,
)
},
};
let replace = if replace {
Some(NeedsToReload::No(browsing_context.pipeline_id))
} else {
None
};

// Create the new pipeline, attached to the parent and push to pending changes
@@ -1923,11 +1908,11 @@ where
top_level_browsing_context_id,
Some(parent_pipeline_id),
None,
window_size,
browsing_context.size,
load_data.clone(),
load_info.sandbox,
is_private,
is_visible,
browsing_context.is_visible,
);
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_browsing_context_id,
@@ -1958,40 +1943,34 @@ where
// TODO: Referrer?
let load_data = LoadData::new(url.clone(), Some(parent_pipeline_id), None, None);

let (pipeline, is_private, is_visible) = {
let (script_sender, parent_browsing_context_id) = match self
.pipelines
.get(&parent_pipeline_id)
{
let (script_sender, parent_browsing_context_id) =
match self.pipelines.get(&parent_pipeline_id) {
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
None => return warn!("Script loaded url in closed iframe {}.", parent_pipeline_id),
};
let (is_parent_private, is_parent_visible) =
match self.browsing_contexts.get(&parent_browsing_context_id) {
Some(ctx) => (ctx.is_private, ctx.is_visible),
None => {
return warn!(
"New iframe {} loaded in closed parent browsing context {}.",
browsing_context_id, parent_browsing_context_id,
)
},
};
let is_private = is_private || is_parent_private;
let pipeline = Pipeline::new(
new_pipeline_id,
browsing_context_id,
top_level_browsing_context_id,
None,
script_sender,
layout_sender,
self.compositor_proxy.clone(),
url,
is_parent_visible,
load_data,
);

(pipeline, is_private, is_parent_visible)
};
let (is_parent_private, is_parent_visible) =
match self.browsing_contexts.get(&parent_browsing_context_id) {
Some(ctx) => (ctx.is_private, ctx.is_visible),
None => {
return warn!(
"New iframe {} loaded in closed parent browsing context {}.",
browsing_context_id, parent_browsing_context_id,
)
},
};
let is_private = is_private || is_parent_private;
let pipeline = Pipeline::new(
new_pipeline_id,
browsing_context_id,
top_level_browsing_context_id,
None,
script_sender,
layout_sender,
self.compositor_proxy.clone(),
url,
is_parent_visible,
load_data,
);

assert!(!self.pipelines.contains_key(&new_pipeline_id));
self.pipelines.insert(new_pipeline_id, pipeline);
@@ -2004,7 +1983,7 @@ where
new_browsing_context_info: Some(NewBrowsingContextInfo {
parent_pipeline_id: Some(parent_pipeline_id),
is_private: is_private,
is_visible: is_visible,
is_visible: is_parent_visible,
}),
});
}
@@ -2026,42 +2005,38 @@ where
// TODO: Referrer?
let load_data = LoadData::new(url.clone(), None, None, None);

let (pipeline, is_private, is_visible) = {
let (script_sender, opener_browsing_context_id) =
match self.pipelines.get(&opener_pipeline_id) {
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
None => {
return warn!(
"Auxiliary loaded url in closed iframe {}.",
opener_pipeline_id
)
},
};
let (is_opener_private, is_opener_visible) =
match self.browsing_contexts.get(&opener_browsing_context_id) {
Some(ctx) => (ctx.is_private, ctx.is_visible),
None => {
return warn!(
"New auxiliary {} loaded in closed opener browsing context {}.",
new_browsing_context_id, opener_browsing_context_id,
)
},
};
let pipeline = Pipeline::new(
new_pipeline_id,
new_browsing_context_id,
new_top_level_browsing_context_id,
Some(opener_browsing_context_id),
script_sender,
layout_sender,
self.compositor_proxy.clone(),
url,
is_opener_visible,
load_data,
);

(pipeline, is_opener_private, is_opener_visible)
};
let (script_sender, opener_browsing_context_id) =
match self.pipelines.get(&opener_pipeline_id) {
Some(pipeline) => (pipeline.event_loop.clone(), pipeline.browsing_context_id),
None => {
return warn!(
"Auxiliary loaded url in closed iframe {}.",
opener_pipeline_id
)
},
};
let (is_opener_private, is_opener_visible) =
match self.browsing_contexts.get(&opener_browsing_context_id) {
Some(ctx) => (ctx.is_private, ctx.is_visible),
None => {
return warn!(
"New auxiliary {} loaded in closed opener browsing context {}.",
new_browsing_context_id, opener_browsing_context_id,
)
},
};
let pipeline = Pipeline::new(
new_pipeline_id,
new_browsing_context_id,
new_top_level_browsing_context_id,
Some(opener_browsing_context_id),
script_sender,
layout_sender,
self.compositor_proxy.clone(),
url,
is_opener_visible,
load_data,
);

assert!(!self.pipelines.contains_key(&new_pipeline_id));
self.pipelines.insert(new_pipeline_id, pipeline);
@@ -2080,8 +2055,8 @@ where
new_browsing_context_info: Some(NewBrowsingContextInfo {
// Auxiliary browsing contexts are always top-level.
parent_pipeline_id: None,
is_private: is_private,
is_visible: is_visible,
is_private: is_opener_private,
is_visible: is_opener_visible,
}),
});
}

0 comments on commit 920056c

Please sign in to comment.