Make Pipeline::url a plain Url.

It is never mutated, and never None.
This commit is contained in:
Ms2ger 2014-05-12 20:14:10 +02:00
parent 1e361e8b6f
commit f87f11ef48
2 changed files with 30 additions and 32 deletions

View file

@ -428,9 +428,9 @@ impl Constellation {
self.resource_task.clone(),
self.profiler_chan.clone(),
self.window_size,
self.opts.clone());
let url = parse_url("about:failure", None);
pipeline.load(url);
self.opts.clone(),
parse_url("about:failure", None));
pipeline.load();
let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange{
@ -455,8 +455,9 @@ impl Constellation {
self.resource_task.clone(),
self.profiler_chan.clone(),
self.window_size,
self.opts.clone());
pipeline.load(url);
self.opts.clone(),
url);
pipeline.load();
let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange {
@ -570,9 +571,7 @@ impl Constellation {
source Id of LoadIframeUrlMsg does have an associated pipeline in
constellation. This should be impossible.").clone();
let source_url = source_pipeline.url.borrow().clone().expect("Constellation: LoadUrlIframeMsg's
source's Url is None. There should never be a LoadUrlIframeMsg from a pipeline
that was never given a url to load.");
let source_url = source_pipeline.url.clone();
let same_script = (source_url.host == url.host &&
source_url.port == url.port) && sandbox == IFrameUnsandboxed;
@ -587,7 +586,8 @@ impl Constellation {
self.image_cache_task.clone(),
self.profiler_chan.clone(),
self.opts.clone(),
source_pipeline.clone())
source_pipeline.clone(),
url)
} else {
debug!("Constellation: loading cross-origin iframe at {:?}", url);
// Create a new script task if not same-origin url's
@ -599,11 +599,12 @@ impl Constellation {
self.resource_task.clone(),
self.profiler_chan.clone(),
self.window_size,
self.opts.clone())
self.opts.clone(),
url)
};
debug!("Constellation: sending load msg to pipeline {:?}", pipeline.id);
pipeline.load(url);
pipeline.load();
let pipeline_wrapped = Rc::new(pipeline);
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() {
@ -654,9 +655,10 @@ impl Constellation {
self.resource_task.clone(),
self.profiler_chan.clone(),
self.window_size,
self.opts.clone());
self.opts.clone(),
url);
pipeline.load(url);
pipeline.load();
let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange{
@ -706,7 +708,7 @@ impl Constellation {
};
for frame in destination_frame.iter() {
frame.pipeline.reload();
frame.pipeline.load();
}
self.grant_paint_permission(destination_frame, constellation_msg::Navigate);

View file

@ -17,7 +17,6 @@ use servo_net::image_cache_task::ImageCacheTask;
use servo_net::resource_task::ResourceTask;
use servo_util::opts::Opts;
use servo_util::time::ProfilerChan;
use std::cell::RefCell;
use std::rc::Rc;
use url::Url;
@ -31,7 +30,7 @@ pub struct Pipeline {
pub layout_shutdown_port: Receiver<()>,
pub render_shutdown_port: Receiver<()>,
/// The most recently loaded url
pub url: RefCell<Option<Url>>,
pub url: Url,
}
/// The subset of the pipeline that is needed for layer composition.
@ -52,7 +51,8 @@ impl Pipeline {
image_cache_task: ImageCacheTask,
profiler_chan: ProfilerChan,
opts: Opts,
script_pipeline: Rc<Pipeline>)
script_pipeline: Rc<Pipeline>,
url: Url)
-> Pipeline {
let (layout_port, layout_chan) = LayoutChan::new();
let (render_port, render_chan) = RenderChan::new();
@ -100,7 +100,8 @@ impl Pipeline {
layout_chan,
render_chan,
layout_shutdown_port,
render_shutdown_port)
render_shutdown_port,
url)
}
pub fn create(id: PipelineId,
@ -111,7 +112,8 @@ impl Pipeline {
resource_task: ResourceTask,
profiler_chan: ProfilerChan,
window_size: Size2D<uint>,
opts: Opts)
opts: Opts,
url: Url)
-> Pipeline {
let (script_port, script_chan) = ScriptChan::new();
let (layout_port, layout_chan) = LayoutChan::new();
@ -124,7 +126,8 @@ impl Pipeline {
layout_chan.clone(),
render_chan.clone(),
layout_shutdown_port,
render_shutdown_port);
render_shutdown_port,
url);
let failure = Failure {
pipeline_id: id,
@ -172,7 +175,8 @@ impl Pipeline {
layout_chan: LayoutChan,
render_chan: RenderChan,
layout_shutdown_port: Receiver<()>,
render_shutdown_port: Receiver<()>)
render_shutdown_port: Receiver<()>,
url: Url)
-> Pipeline {
Pipeline {
id: id,
@ -182,14 +186,13 @@ impl Pipeline {
render_chan: render_chan,
layout_shutdown_port: layout_shutdown_port,
render_shutdown_port: render_shutdown_port,
url: RefCell::new(None),
url: url,
}
}
pub fn load(&self, url: Url) {
*self.url.borrow_mut() = Some(url.clone());
pub fn load(&self) {
let ScriptChan(ref chan) = self.script_chan;
chan.send(LoadMsg(self.id, url));
chan.send(LoadMsg(self.id, self.url.clone()));
}
pub fn grant_paint_permission(&self) {
@ -201,13 +204,6 @@ impl Pipeline {
self.render_chan.chan.try_send(PaintPermissionRevoked);
}
pub fn reload(&self) {
let url = self.url.borrow().clone();
url.map(|url| {
self.load(url);
});
}
pub fn exit(&self) {
debug!("pipeline {:?} exiting", self.id);