Auto merge of #5985 - zmike:embedding-woodenbikeshed, r=larsbergstrom

Some small changes.

@larsbergstrom or whoever cares the most at this exact moment.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5985)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-05-08 15:03:52 -05:00
commit 892a740426
5 changed files with 53 additions and 16 deletions

View file

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

10
ports/cef/Cargo.lock generated
View file

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

View file

@ -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 = "*"

View file

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

View file

@ -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<Option<CefBrowser>>,
#[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<Window> {
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<Window> {
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<Rc<Window>>)