Auto merge of #6010 - brson:next, r=pcwalton

Just cleanup.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6010)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-05-12 03:26:54 -05:00
commit ca9c703bf5
11 changed files with 41 additions and 198 deletions

View file

@ -2,6 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! The `Constellation`, Servo's Grand Central Station
//!
//! The primary duty of a `Constellation` is to mediate between the
//! graphics compositor and the many `Pipeline`s in the browser's
//! navigation context, each `Pipeline` encompassing a `ScriptTask`,
//! `LayoutTask`, and `PaintTask`.
use pipeline::{Pipeline, CompositionPipeline};
use compositor_task::CompositorProxy;
@ -44,6 +51,11 @@ use clipboard::ClipboardContext;
use webdriver_traits::WebDriverScriptCommand;
/// Maintains the pipelines and navigation context and grants permission to composite.
///
/// It is parameterized over a `LayoutTaskFactory` and a
/// `ScriptTaskFactory` (which in practice are implemented by
/// `LayoutTask` in the `layout` crate, and `ScriptTask` in
/// the `script` crate).
pub struct Constellation<LTF, STF> {
/// A channel through which messages can be sent to this object.
pub chan: ConstellationChan,

View file

@ -1231,6 +1231,7 @@ dependencies = [
"string_cache 0.1.0 (git+https://github.com/servo/string-cache)",
"string_cache_plugin 0.1.1 (git+https://github.com/servo/string-cache)",
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View file

@ -32,7 +32,6 @@ extern crate script;
extern crate layout;
extern crate gfx;
extern crate libc;
extern crate url;
extern crate webdriver_server;
use compositing::CompositorEventListener;
@ -79,8 +78,6 @@ pub struct Browser {
impl Browser {
pub fn new<Window>(window: Option<Rc<Window>>) -> Browser
where Window: WindowMethods + 'static {
::util::opts::set_experimental_enabled(opts::get().enable_experimental);
// Global configuration options, parsed from the command line.
let opts = opts::get();
@ -147,14 +144,12 @@ impl Browser {
self.compositor.shutdown();
}
}
fn create_constellation(opts: opts::Opts,
compositor_proxy: Box<CompositorProxy+Send>,
time_profiler_chan: time::ProfilerChan,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan) -> ConstellationChan {
use std::env;
// Create a Servo instance.
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
let image_cache_task = new_image_cache_task(resource_task.clone());
@ -173,17 +168,9 @@ fn create_constellation(opts: opts::Opts,
storage_task);
// Send the URL command to the constellation.
let cwd = env::current_dir().unwrap();
let url = match url::Url::parse(&opts.url) {
Ok(url) => url,
Err(url::ParseError::RelativeUrlWithoutBase)
=> url::Url::from_file_path(&*cwd.join(&opts.url)).unwrap(),
Err(_) => panic!("URL parsing failed"),
};
{
let ConstellationChan(ref chan) = constellation_chan;
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
chan.send(ConstellationMsg::InitLoadUrl(opts.url.clone())).unwrap();
}
constellation_chan

View file

@ -48,3 +48,4 @@ fnv = "1.0"
cssparser = "0.3.1"
num = "0.1.24"
lazy_static = "0.1.10"
url = "*"

View file

@ -36,6 +36,7 @@ extern crate rustc_serialize;
extern crate selectors;
extern crate smallvec as smallvec_;
extern crate string_cache;
extern crate url;
use std::sync::Arc;

View file

@ -18,12 +18,13 @@ use std::env;
use std::io::{self, Write};
use std::mem;
use std::ptr;
use url::{self, Url};
/// Global flags for Servo, currently set on the command line.
#[derive(Clone)]
pub struct Opts {
/// The initial URL to load.
pub url: String,
pub url: Url,
/// How many threads to use for CPU painting (`-t`).
///
@ -192,7 +193,7 @@ static FORCE_CPU_PAINTING: bool = false;
pub fn default_opts() -> Opts {
Opts {
url: String::new(),
url: Url::parse("about:blank").unwrap(),
paint_threads: 1,
gpu_painting: false,
tile_size: 512,
@ -293,7 +294,14 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
args_fail("servo asks that you provide a URL");
return false;
} else {
opt_match.free[0].clone()
let ref url = opt_match.free[0];
let cwd = env::current_dir().unwrap();
match Url::parse(url) {
Ok(url) => url,
Err(url::ParseError::RelativeUrlWithoutBase)
=> Url::from_file_path(&*cwd.join(url)).unwrap(),
Err(_) => panic!("URL parsing failed"),
}
};
let tile_size: usize = match opt_match.opt_str("s") {
@ -392,12 +400,15 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
disable_share_style_cache: debug_options.contains(&"disable-share-style-cache"),
};
set_opts(opts);
set(opts);
true
}
static mut EXPERIMENTAL_ENABLED: bool = false;
/// Turn on experimental features globally. Normally this is done
/// during initialization by `set` or `from_cmdline_args`, but
/// tests that require experimental features will also set it.
pub fn set_experimental_enabled(new_value: bool) {
unsafe {
EXPERIMENTAL_ENABLED = new_value;
@ -415,8 +426,10 @@ pub fn experimental_enabled() -> bool {
// when passing through the DOM structures.
static mut OPTIONS: *mut Opts = 0 as *mut Opts;
pub fn set_opts(opts: Opts) {
pub fn set(opts: Opts) {
unsafe {
assert!(OPTIONS.is_null());
set_experimental_enabled(opts.enable_experimental);
let box_opts = box opts;
OPTIONS = mem::transmute(box_opts);
}
@ -430,7 +443,7 @@ pub fn get<'a>() -> &'a Opts {
// set of options. This is mostly useful for unit tests that
// run through a code path which queries the cmd line options.
if OPTIONS == ptr::null_mut() {
set_opts(default_opts());
set(default_opts());
}
mem::transmute(OPTIONS)
}