Remove call to env::current_dir from Browser

Put it in util::opts instead.
This commit is contained in:
Brian Anderson 2015-05-09 00:48:25 -07:00
parent dd04cf46d1
commit aa906a54d3
8 changed files with 18 additions and 21 deletions

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;
@ -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

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

2
ports/cef/Cargo.lock generated
View file

@ -1068,7 +1068,6 @@ dependencies = [
"profile_traits 0.0.1",
"script 0.0.1",
"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)",
"util 0.0.1",
"webdriver_server 0.0.1",
]
@ -1224,6 +1223,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

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

View file

@ -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;