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.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
self.window_size, self.window_size,
self.opts.clone()); self.opts.clone(),
let url = parse_url("about:failure", None); parse_url("about:failure", None));
pipeline.load(url); pipeline.load();
let pipeline_wrapped = Rc::new(pipeline); let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange{ self.pending_frames.push(FrameChange{
@ -455,8 +455,9 @@ impl Constellation {
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
self.window_size, self.window_size,
self.opts.clone()); self.opts.clone(),
pipeline.load(url); url);
pipeline.load();
let pipeline_wrapped = Rc::new(pipeline); let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange { self.pending_frames.push(FrameChange {
@ -570,9 +571,7 @@ impl Constellation {
source Id of LoadIframeUrlMsg does have an associated pipeline in source Id of LoadIframeUrlMsg does have an associated pipeline in
constellation. This should be impossible.").clone(); constellation. This should be impossible.").clone();
let source_url = source_pipeline.url.borrow().clone().expect("Constellation: LoadUrlIframeMsg's let source_url = source_pipeline.url.clone();
source's Url is None. There should never be a LoadUrlIframeMsg from a pipeline
that was never given a url to load.");
let same_script = (source_url.host == url.host && let same_script = (source_url.host == url.host &&
source_url.port == url.port) && sandbox == IFrameUnsandboxed; source_url.port == url.port) && sandbox == IFrameUnsandboxed;
@ -587,7 +586,8 @@ impl Constellation {
self.image_cache_task.clone(), self.image_cache_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
self.opts.clone(), self.opts.clone(),
source_pipeline.clone()) source_pipeline.clone(),
url)
} else { } else {
debug!("Constellation: loading cross-origin iframe at {:?}", url); debug!("Constellation: loading cross-origin iframe at {:?}", url);
// Create a new script task if not same-origin url's // Create a new script task if not same-origin url's
@ -599,11 +599,12 @@ impl Constellation {
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
self.window_size, self.window_size,
self.opts.clone()) self.opts.clone(),
url)
}; };
debug!("Constellation: sending load msg to pipeline {:?}", pipeline.id); debug!("Constellation: sending load msg to pipeline {:?}", pipeline.id);
pipeline.load(url); pipeline.load();
let pipeline_wrapped = Rc::new(pipeline); let pipeline_wrapped = Rc::new(pipeline);
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id)); let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() { for frame_tree in frame_trees.iter() {
@ -654,9 +655,10 @@ impl Constellation {
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
self.window_size, self.window_size,
self.opts.clone()); self.opts.clone(),
url);
pipeline.load(url); pipeline.load();
let pipeline_wrapped = Rc::new(pipeline); let pipeline_wrapped = Rc::new(pipeline);
self.pending_frames.push(FrameChange{ self.pending_frames.push(FrameChange{
@ -706,7 +708,7 @@ impl Constellation {
}; };
for frame in destination_frame.iter() { for frame in destination_frame.iter() {
frame.pipeline.reload(); frame.pipeline.load();
} }
self.grant_paint_permission(destination_frame, constellation_msg::Navigate); 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_net::resource_task::ResourceTask;
use servo_util::opts::Opts; use servo_util::opts::Opts;
use servo_util::time::ProfilerChan; use servo_util::time::ProfilerChan;
use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use url::Url; use url::Url;
@ -31,7 +30,7 @@ pub struct Pipeline {
pub layout_shutdown_port: Receiver<()>, pub layout_shutdown_port: Receiver<()>,
pub render_shutdown_port: Receiver<()>, pub render_shutdown_port: Receiver<()>,
/// The most recently loaded url /// The most recently loaded url
pub url: RefCell<Option<Url>>, pub url: Url,
} }
/// The subset of the pipeline that is needed for layer composition. /// The subset of the pipeline that is needed for layer composition.
@ -52,7 +51,8 @@ impl Pipeline {
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
profiler_chan: ProfilerChan, profiler_chan: ProfilerChan,
opts: Opts, opts: Opts,
script_pipeline: Rc<Pipeline>) script_pipeline: Rc<Pipeline>,
url: Url)
-> Pipeline { -> Pipeline {
let (layout_port, layout_chan) = LayoutChan::new(); let (layout_port, layout_chan) = LayoutChan::new();
let (render_port, render_chan) = RenderChan::new(); let (render_port, render_chan) = RenderChan::new();
@ -100,7 +100,8 @@ impl Pipeline {
layout_chan, layout_chan,
render_chan, render_chan,
layout_shutdown_port, layout_shutdown_port,
render_shutdown_port) render_shutdown_port,
url)
} }
pub fn create(id: PipelineId, pub fn create(id: PipelineId,
@ -111,7 +112,8 @@ impl Pipeline {
resource_task: ResourceTask, resource_task: ResourceTask,
profiler_chan: ProfilerChan, profiler_chan: ProfilerChan,
window_size: Size2D<uint>, window_size: Size2D<uint>,
opts: Opts) opts: Opts,
url: Url)
-> Pipeline { -> Pipeline {
let (script_port, script_chan) = ScriptChan::new(); let (script_port, script_chan) = ScriptChan::new();
let (layout_port, layout_chan) = LayoutChan::new(); let (layout_port, layout_chan) = LayoutChan::new();
@ -124,7 +126,8 @@ impl Pipeline {
layout_chan.clone(), layout_chan.clone(),
render_chan.clone(), render_chan.clone(),
layout_shutdown_port, layout_shutdown_port,
render_shutdown_port); render_shutdown_port,
url);
let failure = Failure { let failure = Failure {
pipeline_id: id, pipeline_id: id,
@ -172,7 +175,8 @@ impl Pipeline {
layout_chan: LayoutChan, layout_chan: LayoutChan,
render_chan: RenderChan, render_chan: RenderChan,
layout_shutdown_port: Receiver<()>, layout_shutdown_port: Receiver<()>,
render_shutdown_port: Receiver<()>) render_shutdown_port: Receiver<()>,
url: Url)
-> Pipeline { -> Pipeline {
Pipeline { Pipeline {
id: id, id: id,
@ -182,14 +186,13 @@ impl Pipeline {
render_chan: render_chan, render_chan: render_chan,
layout_shutdown_port: layout_shutdown_port, layout_shutdown_port: layout_shutdown_port,
render_shutdown_port: render_shutdown_port, render_shutdown_port: render_shutdown_port,
url: RefCell::new(None), url: url,
} }
} }
pub fn load(&self, url: Url) { pub fn load(&self) {
*self.url.borrow_mut() = Some(url.clone());
let ScriptChan(ref chan) = self.script_chan; 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) { pub fn grant_paint_permission(&self) {
@ -201,13 +204,6 @@ impl Pipeline {
self.render_chan.chan.try_send(PaintPermissionRevoked); 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) { pub fn exit(&self) {
debug!("pipeline {:?} exiting", self.id); debug!("pipeline {:?} exiting", self.id);