Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 aa906a5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 21 deletions.
1 change: 1 addition & 0 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions components/servo/lib.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/util/Cargo.toml
Expand Up @@ -48,3 +48,4 @@ fnv = "1.0"
cssparser = "0.3.1"
num = "0.1.24"
lazy_static = "0.1.10"
url = "*"
1 change: 1 addition & 0 deletions components/util/lib.rs
Expand Up @@ -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;

Expand Down
14 changes: 11 additions & 3 deletions components/util/opts.rs
Expand Up @@ -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`).
///
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions ports/cef/browser.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion ports/cef/core.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit aa906a5

Please sign in to comment.