Skip to content
Permalink
Browse files

Remove call to env::current_dir from Browser

Put it in util::opts instead.
  • Loading branch information
brson committed May 9, 2015
1 parent dd04cf4 commit aa906a54d3e199db6ecf3698376badc074b93128

Some generated files are not rendered by default. Learn more.

@@ -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;
@@ -153,8 +152,6 @@ fn create_constellation(opts: opts::Opts,
time_profiler_chan: time::ProfilerChan,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan) -> ConstellationChan {
use std::env;

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 +170,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
@@ -48,3 +48,4 @@ fnv = "1.0"
cssparser = "0.3.1"
num = "0.1.24"
lazy_static = "0.1.10"
url = "*"
@@ -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;

@@ -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") {

Some generated files are not rendered by default. Learn more.

@@ -15,7 +15,6 @@ use window;
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
use glutin_app;
use libc::c_int;
use util::opts;
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell, BorrowState};
use std::sync::atomic::{AtomicIsize, Ordering};
@@ -204,9 +203,6 @@ fn browser_host_create(window_info: &cef_window_info_t,
client: CefClient,
callback_executed: bool)
-> CefBrowser {
let url = "http://s27.postimg.org/vqbtrolyr/servo.jpg".to_owned();
let mut opts = opts::default_opts();
opts.url = url;
let browser = ServoCefBrowser::new(window_info, client).as_cef_interface();
browser.init(window_info);
if callback_executed {
@@ -12,6 +12,7 @@ use std::borrow::ToOwned;
use std::ffi;
use std::str;
use browser;
use std_url::Url;

const MAX_RENDERING_THREADS: usize = 128;

@@ -70,7 +71,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
};

let mut temp_opts = opts::default_opts();
temp_opts.url = HOME_URL.to_owned();
temp_opts.url = Url::parse(HOME_URL).unwrap();
temp_opts.paint_threads = rendering_threads;
temp_opts.layout_threads = rendering_threads;
temp_opts.headless = false;

0 comments on commit aa906a5

Please sign in to comment.
You can’t perform that action at this time.