Skip to content

Commit

Permalink
Auto merge of #5985 - zmike:embedding-woodenbikeshed, r=larsbergstrom
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed May 8, 2015
2 parents a052c53 + f588c0b commit 892a740
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
19 changes: 13 additions & 6 deletions components/net/image_cache_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,22 @@ 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) {
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()))
}
}
}
Err(..) => {
debug!("image_cache_task: failed loading the placeholder.");
debug!("image_cache_task: url {}", placeholder_url.display());
None
}
Ok((_, image_data)) => {
Some(Arc::new(load_from_memory(&image_data).unwrap()))
}
};

let mut cache = ImageCache {
Expand Down
10 changes: 10 additions & 0 deletions ports/cef/Cargo.lock

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

6 changes: 6 additions & 0 deletions ports/cef/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
3 changes: 3 additions & 0 deletions ports/cef/eutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
29 changes: 20 additions & 9 deletions ports/cef/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@ 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;
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")]
Expand Down Expand Up @@ -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();

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

0 comments on commit 892a740

Please sign in to comment.