mirror of
https://github.com/servo/servo.git
synced 2025-06-29 11:33:39 +01:00
Remove call to env::current_dir from Browser
Put it in util::opts instead.
This commit is contained in:
parent
dd04cf46d1
commit
aa906a54d3
8 changed files with 18 additions and 21 deletions
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -1231,6 +1231,7 @@ dependencies = [
|
||||||
"string_cache 0.1.0 (git+https://github.com/servo/string-cache)",
|
"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)",
|
"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)",
|
"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]]
|
[[package]]
|
||||||
|
|
|
@ -32,7 +32,6 @@ extern crate script;
|
||||||
extern crate layout;
|
extern crate layout;
|
||||||
extern crate gfx;
|
extern crate gfx;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate url;
|
|
||||||
extern crate webdriver_server;
|
extern crate webdriver_server;
|
||||||
|
|
||||||
use compositing::CompositorEventListener;
|
use compositing::CompositorEventListener;
|
||||||
|
@ -153,8 +152,6 @@ fn create_constellation(opts: opts::Opts,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
||||||
mem_profiler_chan: mem::ProfilerChan) -> ConstellationChan {
|
mem_profiler_chan: mem::ProfilerChan) -> ConstellationChan {
|
||||||
use std::env;
|
|
||||||
|
|
||||||
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||||
|
|
||||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||||
|
@ -173,17 +170,9 @@ fn create_constellation(opts: opts::Opts,
|
||||||
storage_task);
|
storage_task);
|
||||||
|
|
||||||
// Send the URL command to the constellation.
|
// 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;
|
let ConstellationChan(ref chan) = constellation_chan;
|
||||||
chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
chan.send(ConstellationMsg::InitLoadUrl(opts.url.clone())).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
constellation_chan
|
constellation_chan
|
||||||
|
|
|
@ -48,3 +48,4 @@ fnv = "1.0"
|
||||||
cssparser = "0.3.1"
|
cssparser = "0.3.1"
|
||||||
num = "0.1.24"
|
num = "0.1.24"
|
||||||
lazy_static = "0.1.10"
|
lazy_static = "0.1.10"
|
||||||
|
url = "*"
|
||||||
|
|
|
@ -36,6 +36,7 @@ extern crate rustc_serialize;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
extern crate smallvec as smallvec_;
|
extern crate smallvec as smallvec_;
|
||||||
extern crate string_cache;
|
extern crate string_cache;
|
||||||
|
extern crate url;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,13 @@ use std::env;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use url::{self, Url};
|
||||||
|
|
||||||
/// Global flags for Servo, currently set on the command line.
|
/// Global flags for Servo, currently set on the command line.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Opts {
|
pub struct Opts {
|
||||||
/// The initial URL to load.
|
/// The initial URL to load.
|
||||||
pub url: String,
|
pub url: Url,
|
||||||
|
|
||||||
/// How many threads to use for CPU painting (`-t`).
|
/// How many threads to use for CPU painting (`-t`).
|
||||||
///
|
///
|
||||||
|
@ -192,7 +193,7 @@ static FORCE_CPU_PAINTING: bool = false;
|
||||||
|
|
||||||
pub fn default_opts() -> Opts {
|
pub fn default_opts() -> Opts {
|
||||||
Opts {
|
Opts {
|
||||||
url: String::new(),
|
url: Url::parse("about:blank").unwrap(),
|
||||||
paint_threads: 1,
|
paint_threads: 1,
|
||||||
gpu_painting: false,
|
gpu_painting: false,
|
||||||
tile_size: 512,
|
tile_size: 512,
|
||||||
|
@ -293,7 +294,14 @@ pub fn from_cmdline_args(args: &[String]) -> bool {
|
||||||
args_fail("servo asks that you provide a URL");
|
args_fail("servo asks that you provide a URL");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} 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") {
|
let tile_size: usize = match opt_match.opt_str("s") {
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -1068,7 +1068,6 @@ dependencies = [
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script 0.0.1",
|
"script 0.0.1",
|
||||||
"time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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",
|
"util 0.0.1",
|
||||||
"webdriver_server 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 0.1.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_plugin 0.1.1 (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)",
|
"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]]
|
[[package]]
|
||||||
|
|
|
@ -15,7 +15,6 @@ use window;
|
||||||
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
|
use compositing::windowing::{WindowNavigateMsg, WindowEvent};
|
||||||
use glutin_app;
|
use glutin_app;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use util::opts;
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cell::{Cell, RefCell, BorrowState};
|
use std::cell::{Cell, RefCell, BorrowState};
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
|
@ -204,9 +203,6 @@ fn browser_host_create(window_info: &cef_window_info_t,
|
||||||
client: CefClient,
|
client: CefClient,
|
||||||
callback_executed: bool)
|
callback_executed: bool)
|
||||||
-> CefBrowser {
|
-> 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();
|
let browser = ServoCefBrowser::new(window_info, client).as_cef_interface();
|
||||||
browser.init(window_info);
|
browser.init(window_info);
|
||||||
if callback_executed {
|
if callback_executed {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use std::borrow::ToOwned;
|
||||||
use std::ffi;
|
use std::ffi;
|
||||||
use std::str;
|
use std::str;
|
||||||
use browser;
|
use browser;
|
||||||
|
use std_url::Url;
|
||||||
|
|
||||||
const MAX_RENDERING_THREADS: usize = 128;
|
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();
|
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.paint_threads = rendering_threads;
|
||||||
temp_opts.layout_threads = rendering_threads;
|
temp_opts.layout_threads = rendering_threads;
|
||||||
temp_opts.headless = false;
|
temp_opts.headless = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue