mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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:
commit
892a740426
5 changed files with 53 additions and 16 deletions
|
@ -330,8 +330,9 @@ pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
||||||
// Preload the placeholder image, used when images fail to load.
|
// Preload the placeholder image, used when images fail to load.
|
||||||
let mut placeholder_url = resources_dir_path();
|
let mut placeholder_url = resources_dir_path();
|
||||||
placeholder_url.push("rippy.jpg");
|
placeholder_url.push("rippy.jpg");
|
||||||
let url = Url::from_file_path(&*placeholder_url).unwrap();
|
let placeholder_image = match Url::from_file_path(&*placeholder_url) {
|
||||||
let placeholder_image = match load_whole_resource(&resource_task, url) {
|
Ok(url) => {
|
||||||
|
match load_whole_resource(&resource_task, url) {
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
debug!("image_cache_task: failed loading the placeholder.");
|
debug!("image_cache_task: failed loading the placeholder.");
|
||||||
None
|
None
|
||||||
|
@ -339,6 +340,12 @@ pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask {
|
||||||
Ok((_, image_data)) => {
|
Ok((_, image_data)) => {
|
||||||
Some(Arc::new(load_from_memory(&image_data).unwrap()))
|
Some(Arc::new(load_from_memory(&image_data).unwrap()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(..) => {
|
||||||
|
debug!("image_cache_task: url {}", placeholder_url.display());
|
||||||
|
None
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut cache = ImageCache {
|
let mut cache = ImageCache {
|
||||||
|
|
10
ports/cef/Cargo.lock
generated
10
ports/cef/Cargo.lock
generated
|
@ -29,6 +29,7 @@ dependencies = [
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"url 0.2.31 (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",
|
||||||
|
"x11 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1298,6 +1299,15 @@ dependencies = [
|
||||||
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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]]
|
[[package]]
|
||||||
name = "xlib"
|
name = "xlib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -84,3 +84,9 @@ git = "https://github.com/servo/rust-cgl"
|
||||||
url = "*"
|
url = "*"
|
||||||
libc = "*"
|
libc = "*"
|
||||||
objc = "0.1"
|
objc = "0.1"
|
||||||
|
|
||||||
|
[target.i686-unknown-linux-gnu.dependencies]
|
||||||
|
x11 = "*"
|
||||||
|
|
||||||
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
||||||
|
x11 = "*"
|
||||||
|
|
|
@ -77,3 +77,6 @@ pub unsafe fn add_ref(c_object: *mut cef_base_t) {
|
||||||
((*c_object).add_ref.unwrap())(c_object);
|
((*c_object).add_ref.unwrap())(c_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub extern "C" fn servo_test() -> c_int {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use libc::{c_char, c_void};
|
use libc::{c_char, c_void};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use msg::compositor_msg::{ReadyState, PaintState};
|
use msg::compositor_msg::{ReadyState, PaintState};
|
||||||
|
use std::ptr;
|
||||||
use std_url::Url;
|
use std_url::Url;
|
||||||
use util::cursor::Cursor;
|
use util::cursor::Cursor;
|
||||||
use util::geometry::ScreenPx;
|
use util::geometry::ScreenPx;
|
||||||
|
@ -30,11 +31,17 @@ use std::cell::RefCell;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{Sender, channel};
|
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.
|
/// The type of an off-screen window.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
cef_browser: RefCell<Option<CefBrowser>>,
|
cef_browser: RefCell<Option<CefBrowser>>,
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
display: *mut c_void,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
|
@ -69,6 +76,16 @@ fn load_gl() {
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
/// Creates a new 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> {
|
pub fn new() -> Rc<Window> {
|
||||||
load_gl();
|
load_gl();
|
||||||
|
|
||||||
|
@ -249,14 +266,8 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||||
extern {
|
|
||||||
fn cef_get_xdisplay() -> *mut c_void;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
NativeGraphicsMetadata {
|
NativeGraphicsMetadata {
|
||||||
display: cef_get_xdisplay()
|
display: self.display,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue