mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #10970 - servo:loaddata, r=KiChjang
Simplify load_data handling in handle_script_loaded_url_in_iframe_msg. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10970) <!-- Reviewable:end -->
This commit is contained in:
commit
e7caaa77b4
1 changed files with 13 additions and 17 deletions
|
@ -971,7 +971,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
.and_then(|old_subpage_id| self.subpage_map.get(&(load_info.containing_pipeline_id, old_subpage_id)))
|
.and_then(|old_subpage_id| self.subpage_map.get(&(load_info.containing_pipeline_id, old_subpage_id)))
|
||||||
.cloned();
|
.cloned();
|
||||||
|
|
||||||
let (new_url, script_chan, window_size) = {
|
let (load_data, script_chan, window_size) = {
|
||||||
|
|
||||||
let old_pipeline = old_pipeline_id
|
let old_pipeline = old_pipeline_id
|
||||||
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));
|
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));
|
||||||
|
@ -982,9 +982,13 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
};
|
};
|
||||||
|
|
||||||
// If no url is specified, reload.
|
// If no url is specified, reload.
|
||||||
let new_url = load_info.load_data.clone().map(|data| data.url)
|
let load_data = load_info.load_data.unwrap_or_else(|| {
|
||||||
.or_else(|| old_pipeline.map(|old_pipeline| old_pipeline.url.clone()))
|
let url = match old_pipeline {
|
||||||
.unwrap_or_else(|| Url::parse("about:blank").expect("infallible"));
|
Some(old_pipeline) => old_pipeline.url.clone(),
|
||||||
|
None => Url::parse("about:blank").expect("infallible"),
|
||||||
|
};
|
||||||
|
LoadData::new(url, None, None)
|
||||||
|
});
|
||||||
|
|
||||||
// Compare the pipeline's url to the new url. If the origin is the same,
|
// Compare the pipeline's url to the new url. If the origin is the same,
|
||||||
// then reuse the script thread in creating the new pipeline
|
// then reuse the script thread in creating the new pipeline
|
||||||
|
@ -992,18 +996,18 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
|
|
||||||
// FIXME(#10968): this should probably match the origin check in
|
// FIXME(#10968): this should probably match the origin check in
|
||||||
// HTMLIFrameElement::contentDocument.
|
// HTMLIFrameElement::contentDocument.
|
||||||
let same_script = source_url.host() == new_url.host() &&
|
let same_script = source_url.host() == load_data.url.host() &&
|
||||||
source_url.port() == new_url.port() &&
|
source_url.port() == load_data.url.port() &&
|
||||||
load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed;
|
load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed;
|
||||||
|
|
||||||
// Reuse the script thread if the URL is same-origin
|
// Reuse the script thread if the URL is same-origin
|
||||||
let script_chan = if same_script {
|
let script_chan = if same_script {
|
||||||
debug!("Constellation: loading same-origin iframe, \
|
debug!("Constellation: loading same-origin iframe, \
|
||||||
parent url {:?}, iframe url {:?}", source_url, new_url);
|
parent url {:?}, iframe url {:?}", source_url, load_data.url);
|
||||||
Some(source_pipeline.script_chan.clone())
|
Some(source_pipeline.script_chan.clone())
|
||||||
} else {
|
} else {
|
||||||
debug!("Constellation: loading cross-origin iframe, \
|
debug!("Constellation: loading cross-origin iframe, \
|
||||||
parent url {:?}, iframe url {:?}", source_url, new_url);
|
parent url {:?}, iframe url {:?}", source_url, load_data.url);
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1013,18 +1017,10 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
old_pipeline.freeze();
|
old_pipeline.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
(new_url, script_chan, window_size)
|
(load_data, script_chan, window_size)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let load_data = if let Some(mut data) = load_info.load_data {
|
|
||||||
data.url = new_url;
|
|
||||||
data
|
|
||||||
} else {
|
|
||||||
// TODO - loaddata here should have referrer info (not None, None)
|
|
||||||
LoadData::new(new_url, None, None)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the new pipeline, attached to the parent and push to pending frames
|
// Create the new pipeline, attached to the parent and push to pending frames
|
||||||
self.new_pipeline(load_info.new_pipeline_id,
|
self.new_pipeline(load_info.new_pipeline_id,
|
||||||
Some((load_info.containing_pipeline_id, load_info.new_subpage_id)),
|
Some((load_info.containing_pipeline_id, load_info.new_subpage_id)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue