diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_task.rs index 6d4bd61561a..66636487542 100644 --- a/components/net/image_cache_task.rs +++ b/components/net/image_cache_task.rs @@ -330,14 +330,21 @@ pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask { // Preload the placeholder image, used when images fail to load. let mut placeholder_url = resources_dir_path(); placeholder_url.push("rippy.jpg"); - let url = Url::from_file_path(&*placeholder_url).unwrap(); - let placeholder_image = match load_whole_resource(&resource_task, url) { - Err(..) => { - debug!("image_cache_task: failed loading the placeholder."); - None + let placeholder_image = match Url::from_file_path(&*placeholder_url) { + Ok(url) => { + match load_whole_resource(&resource_task, url) { + Err(..) => { + debug!("image_cache_task: failed loading the placeholder."); + None + } + Ok((_, image_data)) => { + Some(Arc::new(load_from_memory(&image_data).unwrap())) + } + } } - Ok((_, image_data)) => { - Some(Arc::new(load_from_memory(&image_data).unwrap())) + Err(..) => { + debug!("image_cache_task: url {}", placeholder_url.display()); + None } }; diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 79b95203668..6d3248bbc62 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -29,6 +29,7 @@ dependencies = [ "style 0.0.1", "url 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "x11 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1298,6 +1299,15 @@ dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "x11" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "xlib" version = "0.1.0" diff --git a/ports/cef/Cargo.toml b/ports/cef/Cargo.toml index 2e73e96319c..397dece478e 100644 --- a/ports/cef/Cargo.toml +++ b/ports/cef/Cargo.toml @@ -84,3 +84,9 @@ git = "https://github.com/servo/rust-cgl" url = "*" libc = "*" objc = "0.1" + +[target.i686-unknown-linux-gnu.dependencies] +x11 = "*" + +[target.x86_64-unknown-linux-gnu.dependencies] +x11 = "*" diff --git a/ports/cef/eutil.rs b/ports/cef/eutil.rs index dca208e165a..1291a7dce09 100644 --- a/ports/cef/eutil.rs +++ b/ports/cef/eutil.rs @@ -77,3 +77,6 @@ pub unsafe fn add_ref(c_object: *mut cef_base_t) { ((*c_object).add_ref.unwrap())(c_object); } +pub extern "C" fn servo_test() -> c_int { + 1 +} diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 1cc8051697d..6b032e26d24 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -23,6 +23,7 @@ use layers::platform::surface::NativeGraphicsMetadata; use libc::{c_char, c_void}; use msg::constellation_msg::{Key, KeyModifiers}; use msg::compositor_msg::{ReadyState, PaintState}; +use std::ptr; use std_url::Url; use util::cursor::Cursor; use util::geometry::ScreenPx; @@ -30,11 +31,17 @@ use std::cell::RefCell; use std::ffi::CString; use std::rc::Rc; use std::sync::mpsc::{Sender, channel}; +#[cfg(target_os="linux")] +extern crate x11; +#[cfg(target_os="linux")] +use self::x11::xlib::XOpenDisplay; /// The type of an off-screen window. #[derive(Clone)] pub struct Window { cef_browser: RefCell>, +#[cfg(target_os="linux")] + display: *mut c_void, } #[cfg(target_os="macos")] @@ -69,6 +76,16 @@ fn load_gl() { impl Window { /// Creates a new window. +#[cfg(target_os="linux")] + pub fn new() -> Rc { + load_gl(); + + Rc::new(Window { + cef_browser: RefCell::new(None), + display: unsafe { XOpenDisplay(ptr::null()) as *mut c_void }, + }) + } +#[cfg(not(target_os="linux"))] pub fn new() -> Rc { load_gl(); @@ -249,15 +266,9 @@ impl WindowMethods for Window { #[cfg(target_os="linux")] fn native_metadata(&self) -> NativeGraphicsMetadata { - extern { - fn cef_get_xdisplay() -> *mut c_void; - } - - unsafe { - NativeGraphicsMetadata { - display: cef_get_xdisplay() - } - } + NativeGraphicsMetadata { + display: self.display, + } } fn create_compositor_channel(_: &Option>)