mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #6125 - zmike:renderrenderrenderrender, r=larsbergstrom
A collection of commits which improves embedding integration and rendering. @larsbergstrom <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6125) <!-- Reviewable:end -->
This commit is contained in:
commit
4a95bce9f2
18 changed files with 264 additions and 111 deletions
|
@ -1288,8 +1288,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.composite_specific_target(target);
|
self.composite_specific_target(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn composite_specific_target(&mut self, target: CompositeTarget) -> Option<png::Image> {
|
pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Option<png::Image> {
|
||||||
if !self.window.prepare_for_composite() {
|
if !self.context.is_some() {
|
||||||
|
return None
|
||||||
|
}
|
||||||
|
let (width, height) =
|
||||||
|
(self.window_size.width.get() as usize, self.window_size.height.get() as usize);
|
||||||
|
if !self.window.prepare_for_composite(width, height) {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1302,9 +1307,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (width, height) =
|
|
||||||
(self.window_size.width.get() as usize, self.window_size.height.get() as usize);
|
|
||||||
|
|
||||||
let (framebuffer_ids, texture_ids) = match target {
|
let (framebuffer_ids, texture_ids) = match target {
|
||||||
CompositeTarget::Window => (vec!(), vec!()),
|
CompositeTarget::Window => (vec!(), vec!()),
|
||||||
_ => initialize_png(width, height)
|
_ => initialize_png(width, height)
|
||||||
|
|
|
@ -123,7 +123,7 @@ pub trait WindowMethods {
|
||||||
/// Requests that the window system prepare a composite. Typically this will involve making
|
/// Requests that the window system prepare a composite. Typically this will involve making
|
||||||
/// some type of platform-specific graphics context current. Returns true if the composite may
|
/// some type of platform-specific graphics context current. Returns true if the composite may
|
||||||
/// proceed and false if it should not.
|
/// proceed and false if it should not.
|
||||||
fn prepare_for_composite(&self) -> bool;
|
fn prepare_for_composite(&self, width: usize, height: usize) -> bool;
|
||||||
|
|
||||||
/// Sets the cursor to be used in the window.
|
/// Sets the cursor to be used in the window.
|
||||||
fn set_cursor(&self, cursor: Cursor);
|
fn set_cursor(&self, cursor: Cursor);
|
||||||
|
|
16
components/servo/Cargo.lock
generated
16
components/servo/Cargo.lock
generated
|
@ -443,7 +443,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.0.26"
|
version = "0.0.26"
|
||||||
source = "git+https://github.com/servo/glutin?branch=servo#ec7a5e40c1cc7b8176eb1e1f7bf70c8a19559400"
|
source = "git+https://github.com/servo/glutin?branch=servo#e888dc79471f062ae0b5fae0ba9e0f01ac96048e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -460,7 +460,7 @@ dependencies = [
|
||||||
"osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"x11 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -481,6 +481,7 @@ dependencies = [
|
||||||
"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.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -616,7 +617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745"
|
source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
@ -630,7 +631,7 @@ dependencies = [
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -843,7 +844,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||||
|
@ -853,7 +854,7 @@ dependencies = [
|
||||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||||
"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)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1329,10 +1330,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x11"
|
name = "x11"
|
||||||
version = "0.0.33"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
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)",
|
||||||
|
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
25
ports/cef/Cargo.lock
generated
25
ports/cef/Cargo.lock
generated
|
@ -29,7 +29,7 @@ dependencies = [
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.33 (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)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -445,7 +445,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.0.26"
|
version = "0.0.26"
|
||||||
source = "git+https://github.com/servo/glutin?branch=servo#ec7a5e40c1cc7b8176eb1e1f7bf70c8a19559400"
|
source = "git+https://github.com/servo/glutin?branch=servo#e888dc79471f062ae0b5fae0ba9e0f01ac96048e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -462,7 +462,7 @@ dependencies = [
|
||||||
"osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"x11 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -483,6 +483,7 @@ dependencies = [
|
||||||
"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.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -618,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745"
|
source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
@ -632,7 +633,7 @@ dependencies = [
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -833,7 +834,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||||
|
@ -843,7 +844,7 @@ dependencies = [
|
||||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||||
"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)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1314,15 +1315,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x11"
|
name = "x11"
|
||||||
version = "0.0.33"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
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"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
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)",
|
||||||
|
|
|
@ -18,6 +18,7 @@ use glutin_app;
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use std::cell::{Cell, RefCell, BorrowState};
|
use std::cell::{Cell, RefCell, BorrowState};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
|
|
||||||
thread_local!(pub static ID_COUNTER: AtomicIsize = AtomicIsize::new(0));
|
thread_local!(pub static ID_COUNTER: AtomicIsize = AtomicIsize::new(0));
|
||||||
|
@ -87,6 +88,8 @@ pub struct ServoCefBrowser {
|
||||||
pub host: CefBrowserHost,
|
pub host: CefBrowserHost,
|
||||||
/// A reference to the browser client.
|
/// A reference to the browser client.
|
||||||
pub client: CefClient,
|
pub client: CefClient,
|
||||||
|
/// the glutin window when using windowed rendering
|
||||||
|
pub window: Option<Rc<glutin_app::window::Window>>,
|
||||||
/// Whether the on-created callback has fired yet.
|
/// Whether the on-created callback has fired yet.
|
||||||
pub callback_executed: Cell<bool>,
|
pub callback_executed: Cell<bool>,
|
||||||
/// the display system window handle: only to be used with host.get_window_handle()
|
/// the display system window handle: only to be used with host.get_window_handle()
|
||||||
|
@ -102,11 +105,15 @@ impl ServoCefBrowser {
|
||||||
let frame = ServoCefFrame::new().as_cef_interface();
|
let frame = ServoCefFrame::new().as_cef_interface();
|
||||||
let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface();
|
let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface();
|
||||||
let mut window_handle: cef_window_handle_t = get_null_window_handle();
|
let mut window_handle: cef_window_handle_t = get_null_window_handle();
|
||||||
|
let mut glutin_window: Option<Rc<glutin_app::window::Window>> = None;
|
||||||
|
|
||||||
let servo_browser = if window_info.windowless_rendering_enabled == 0 {
|
let servo_browser = if window_info.windowless_rendering_enabled == 0 {
|
||||||
let glutin_window = glutin_app::create_window(window_info.parent_window as glutin_app::WindowID);
|
glutin_window = Some(glutin_app::create_window(window_info.parent_window as glutin_app::WindowID));
|
||||||
let servo_browser = Browser::new(Some(glutin_window.clone()));
|
let servo_browser = Browser::new(glutin_window.clone());
|
||||||
window_handle = glutin_window.platform_window() as cef_window_handle_t;
|
window_handle = match glutin_window {
|
||||||
|
Some(ref win) => win.platform_window() as cef_window_handle_t,
|
||||||
|
None => get_null_window_handle()
|
||||||
|
};
|
||||||
ServoBrowser::OnScreen(servo_browser)
|
ServoBrowser::OnScreen(servo_browser)
|
||||||
} else {
|
} else {
|
||||||
ServoBrowser::Invalid
|
ServoBrowser::Invalid
|
||||||
|
@ -120,6 +127,7 @@ impl ServoCefBrowser {
|
||||||
frame: frame,
|
frame: frame,
|
||||||
host: host,
|
host: host,
|
||||||
client: client,
|
client: client,
|
||||||
|
window: glutin_window,
|
||||||
callback_executed: Cell::new(false),
|
callback_executed: Cell::new(false),
|
||||||
servo_browser: RefCell::new(servo_browser),
|
servo_browser: RefCell::new(servo_browser),
|
||||||
message_queue: RefCell::new(vec!()),
|
message_queue: RefCell::new(vec!()),
|
||||||
|
@ -139,9 +147,9 @@ pub trait ServoCefBrowserExtensions {
|
||||||
impl ServoCefBrowserExtensions for CefBrowser {
|
impl ServoCefBrowserExtensions for CefBrowser {
|
||||||
fn init(&self, window_info: &cef_window_info_t) {
|
fn init(&self, window_info: &cef_window_info_t) {
|
||||||
if window_info.windowless_rendering_enabled != 0 {
|
if window_info.windowless_rendering_enabled != 0 {
|
||||||
let window = window::Window::new();
|
let window = window::Window::new(window_info.width, window_info.height);
|
||||||
let servo_browser = Browser::new(Some(window.clone()));
|
|
||||||
window.set_browser(self.clone());
|
window.set_browser(self.clone());
|
||||||
|
let servo_browser = Browser::new(Some(window.clone()));
|
||||||
*self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser);
|
*self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +206,16 @@ pub fn update() {
|
||||||
if browser.downcast().callback_executed.get() == false {
|
if browser.downcast().callback_executed.get() == false {
|
||||||
browser_callback_after_created(browser.clone());
|
browser_callback_after_created(browser.clone());
|
||||||
}
|
}
|
||||||
browser.send_window_event(WindowEvent::Idle);
|
let mut events = match browser.downcast().window {
|
||||||
|
Some(ref win) => win.wait_events(),
|
||||||
|
None => vec![WindowEvent::Idle]
|
||||||
|
};
|
||||||
|
loop {
|
||||||
|
match events.pop() {
|
||||||
|
Some(event) => browser.send_window_event(event),
|
||||||
|
None => break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -238,9 +255,9 @@ fn browser_host_create(window_info: &cef_window_info_t,
|
||||||
if callback_executed {
|
if callback_executed {
|
||||||
browser_callback_after_created(browser.clone());
|
browser_callback_after_created(browser.clone());
|
||||||
}
|
}
|
||||||
if url != ptr::null() {
|
//if url != ptr::null() {
|
||||||
unsafe { browser.downcast().frame.load_url(CefWrap::to_rust(url)); }
|
//unsafe { browser.downcast().frame.load_url(CefWrap::to_rust(url)); }
|
||||||
}
|
//}
|
||||||
BROWSERS.with(|browsers| {
|
BROWSERS.with(|browsers| {
|
||||||
browsers.borrow_mut().push(browser.clone());
|
browsers.borrow_mut().push(browser.clone());
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_t, cef_brows
|
||||||
use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t};
|
use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t};
|
||||||
use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN};
|
use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN};
|
||||||
use browser::{self, ServoCefBrowserExtensions};
|
use browser::{self, ServoCefBrowserExtensions};
|
||||||
|
use wrappers::CefWrap;
|
||||||
|
|
||||||
use compositing::windowing::{WindowEvent, MouseWindowEvent};
|
use compositing::windowing::{WindowEvent, MouseWindowEvent};
|
||||||
use geom::point::TypedPoint2D;
|
use geom::point::TypedPoint2D;
|
||||||
|
@ -14,13 +15,15 @@ use geom::size::TypedSize2D;
|
||||||
use libc::{c_double, c_int};
|
use libc::{c_double, c_int};
|
||||||
use msg::constellation_msg::{self, KeyModifiers, KeyState};
|
use msg::constellation_msg::{self, KeyModifiers, KeyState};
|
||||||
use script_traits::MouseButton;
|
use script_traits::MouseButton;
|
||||||
use std::cell::RefCell;
|
use std::cell::{Cell, RefCell};
|
||||||
|
|
||||||
pub struct ServoCefBrowserHost {
|
pub struct ServoCefBrowserHost {
|
||||||
/// A reference to the browser.
|
/// A reference to the browser.
|
||||||
pub browser: RefCell<Option<CefBrowser>>,
|
pub browser: RefCell<Option<CefBrowser>>,
|
||||||
/// A reference to the client.
|
/// A reference to the client.
|
||||||
pub client: CefClient,
|
pub client: CefClient,
|
||||||
|
/// flag for return value of prepare_for_composite
|
||||||
|
pub composite_ok: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
full_cef_class_impl! {
|
full_cef_class_impl! {
|
||||||
|
@ -35,9 +38,19 @@ full_cef_class_impl! {
|
||||||
|
|
||||||
fn was_resized(&this,) -> () {{
|
fn was_resized(&this,) -> () {{
|
||||||
let mut rect = cef_rect_t::zero();
|
let mut rect = cef_rect_t::zero();
|
||||||
this.get_client()
|
if cfg!(target_os="macos") {
|
||||||
.get_render_handler()
|
if check_ptr_exist!(this.get_client(), get_render_handler) &&
|
||||||
.get_backing_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect);
|
check_ptr_exist!(this.get_client().get_render_handler(), get_backing_rect) {
|
||||||
|
this.get_client()
|
||||||
|
.get_render_handler()
|
||||||
|
.get_backing_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect);
|
||||||
|
}
|
||||||
|
} else if check_ptr_exist!(this.get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(this.get_client().get_render_handler(), get_view_rect) {
|
||||||
|
this.get_client()
|
||||||
|
.get_render_handler()
|
||||||
|
.get_view_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect);
|
||||||
|
}
|
||||||
let size = TypedSize2D(rect.width as u32, rect.height as u32);
|
let size = TypedSize2D(rect.width as u32, rect.height as u32);
|
||||||
this.downcast().send_window_event(WindowEvent::Resize(size));
|
this.downcast().send_window_event(WindowEvent::Resize(size));
|
||||||
}}
|
}}
|
||||||
|
@ -165,6 +178,12 @@ full_cef_class_impl! {
|
||||||
this.downcast().send_window_event(WindowEvent::InitializeCompositing);
|
this.downcast().send_window_event(WindowEvent::InitializeCompositing);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
fn composite(&this,) -> () {{
|
||||||
|
this.downcast().composite_ok.set(true);
|
||||||
|
this.downcast().send_window_event(WindowEvent::Refresh);
|
||||||
|
this.downcast().composite_ok.set(false);
|
||||||
|
}}
|
||||||
|
|
||||||
fn get_window_handle(&this,) -> cef_window_handle_t {{
|
fn get_window_handle(&this,) -> cef_window_handle_t {{
|
||||||
let t = this.downcast();
|
let t = this.downcast();
|
||||||
let browser = t.browser.borrow();
|
let browser = t.browser.borrow();
|
||||||
|
@ -178,6 +197,7 @@ impl ServoCefBrowserHost {
|
||||||
ServoCefBrowserHost {
|
ServoCefBrowserHost {
|
||||||
browser: RefCell::new(None),
|
browser: RefCell::new(None),
|
||||||
client: client,
|
client: client,
|
||||||
|
composite_ok: Cell::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,18 @@
|
||||||
use command_line::command_line_init;
|
use command_line::command_line_init;
|
||||||
use interfaces::cef_app_t;
|
use interfaces::cef_app_t;
|
||||||
use types::{cef_main_args_t, cef_settings_t};
|
use types::{cef_main_args_t, cef_settings_t};
|
||||||
|
use window::init_window;
|
||||||
|
|
||||||
use libc::{c_char, c_int, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
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;
|
||||||
|
|
||||||
//static HOME_URL: &'static str = "http://s27.postimg.org/vqbtrolyr/servo.jpg";
|
static HOME_URL: &'static str = "http://s27.postimg.org/vqbtrolyr/servo.jpg";
|
||||||
|
|
||||||
static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0";
|
static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0";
|
||||||
#[cfg(target_os="windows")]
|
#[cfg(target_os="windows")]
|
||||||
|
@ -65,8 +67,13 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
||||||
temp_opts.hard_fail = false;
|
temp_opts.hard_fail = false;
|
||||||
temp_opts.enable_text_antialiasing = true;
|
temp_opts.enable_text_antialiasing = true;
|
||||||
temp_opts.resources_path = None;
|
temp_opts.resources_path = None;
|
||||||
|
temp_opts.url = Url::parse(HOME_URL).unwrap();
|
||||||
opts::set(temp_opts);
|
opts::set(temp_opts);
|
||||||
|
|
||||||
|
if unsafe { (*settings).windowless_rendering_enabled != 0 } {
|
||||||
|
init_window();
|
||||||
|
}
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1320,6 +1320,13 @@ pub struct _cef_browser_host_t {
|
||||||
pub drag_source_system_drag_ended: Option<extern "C" fn(
|
pub drag_source_system_drag_ended: Option<extern "C" fn(
|
||||||
this: *mut cef_browser_host_t) -> ()>,
|
this: *mut cef_browser_host_t) -> ()>,
|
||||||
|
|
||||||
|
//
|
||||||
|
// Instructs the browser to perform an accelerated composite. The appropriate
|
||||||
|
// Direct3D or OpenGL state must have been set up before calling this
|
||||||
|
// function.
|
||||||
|
//
|
||||||
|
pub composite: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Instructs the browser to initialize accelerated compositing. The
|
// Instructs the browser to initialize accelerated compositing. The
|
||||||
// appropriate Direct3D or OpenGL state must have been set up before calling
|
// appropriate Direct3D or OpenGL state must have been set up before calling
|
||||||
|
@ -2214,6 +2221,23 @@ impl CefBrowserHost {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Instructs the browser to perform an accelerated composite. The appropriate
|
||||||
|
// Direct3D or OpenGL state must have been set up before calling this
|
||||||
|
// function.
|
||||||
|
//
|
||||||
|
pub fn composite(&self) -> () {
|
||||||
|
if self.c_object.is_null() ||
|
||||||
|
self.c_object as usize == mem::POST_DROP_USIZE {
|
||||||
|
panic!("called a CEF method on a null object")
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
CefWrap::to_rust(
|
||||||
|
((*self.c_object).composite.unwrap())(
|
||||||
|
self.c_object))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Instructs the browser to initialize accelerated compositing. The
|
// Instructs the browser to initialize accelerated compositing. The
|
||||||
// appropriate Direct3D or OpenGL state must have been set up before calling
|
// appropriate Direct3D or OpenGL state must have been set up before calling
|
||||||
|
|
|
@ -175,7 +175,7 @@ pub struct _cef_render_handler_t {
|
||||||
// Called to retrieve the backing size of the view rectangle which is relative
|
// Called to retrieve the backing size of the view rectangle which is relative
|
||||||
// to screen coordinates. On HiDPI displays, the backing size can differ from
|
// to screen coordinates. On HiDPI displays, the backing size can differ from
|
||||||
// the view size as returned by |GetViewRect|. Return true (1) if the
|
// the view size as returned by |GetViewRect|. Return true (1) if the
|
||||||
// rectangle was provided.
|
// rectangle was provided. Only used on Mac OS.
|
||||||
//
|
//
|
||||||
pub get_backing_rect: Option<extern "C" fn(this: *mut cef_render_handler_t,
|
pub get_backing_rect: Option<extern "C" fn(this: *mut cef_render_handler_t,
|
||||||
browser: *mut interfaces::cef_browser_t,
|
browser: *mut interfaces::cef_browser_t,
|
||||||
|
@ -527,7 +527,7 @@ impl CefRenderHandler {
|
||||||
// Called to retrieve the backing size of the view rectangle which is relative
|
// Called to retrieve the backing size of the view rectangle which is relative
|
||||||
// to screen coordinates. On HiDPI displays, the backing size can differ from
|
// to screen coordinates. On HiDPI displays, the backing size can differ from
|
||||||
// the view size as returned by |GetViewRect|. Return true (1) if the
|
// the view size as returned by |GetViewRect|. Return true (1) if the
|
||||||
// rectangle was provided.
|
// rectangle was provided. Only used on Mac OS.
|
||||||
//
|
//
|
||||||
pub fn get_backing_rect(&self, browser: interfaces::CefBrowser,
|
pub fn get_backing_rect(&self, browser: interfaces::CefBrowser,
|
||||||
rect: &mut types::cef_rect_t) -> libc::c_int {
|
rect: &mut types::cef_rect_t) -> libc::c_int {
|
||||||
|
|
|
@ -58,6 +58,7 @@ extern crate core_text;
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate objc;
|
extern crate objc;
|
||||||
|
#[cfg(target_os="linux")] extern crate x11;
|
||||||
|
|
||||||
// Must come first.
|
// Must come first.
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
|
|
||||||
#![macro_use]
|
#![macro_use]
|
||||||
|
|
||||||
|
|
||||||
|
macro_rules! check_ptr_exist {
|
||||||
|
($var:expr, $member:ident) => (
|
||||||
|
unsafe { (*CefWrap::to_c($var)).$member.is_some() }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Provides the implementation of a CEF class. An example follows:
|
// Provides the implementation of a CEF class. An example follows:
|
||||||
//
|
//
|
||||||
// struct ServoCefThing {
|
// struct ServoCefThing {
|
||||||
|
|
|
@ -8,12 +8,12 @@ use types::cef_paint_element_type_t::PET_VIEW;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
pub trait CefRenderHandlerExtensions {
|
pub trait CefRenderHandlerExtensions {
|
||||||
fn paint(&self, browser: CefBrowser);
|
fn paint(&self, browser: CefBrowser, width: usize, height: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CefRenderHandlerExtensions for CefRenderHandler {
|
impl CefRenderHandlerExtensions for CefRenderHandler {
|
||||||
fn paint(&self, browser: CefBrowser) {
|
fn paint(&self, browser: CefBrowser, width: usize, height: usize) {
|
||||||
self.on_paint(browser, PET_VIEW, 0, ptr::null(), &mut (), 0, 0)
|
self.on_paint(browser, PET_VIEW, 0, ptr::null(), &mut (), width as i32, height as i32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use interfaces::CefBrowser;
|
||||||
use render_handler::CefRenderHandlerExtensions;
|
use render_handler::CefRenderHandlerExtensions;
|
||||||
use rustc_unicode::str::Utf16Encoder;
|
use rustc_unicode::str::Utf16Encoder;
|
||||||
use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t};
|
use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t};
|
||||||
|
use wrappers::CefWrap;
|
||||||
|
|
||||||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||||
|
@ -20,7 +21,7 @@ use geom::size::TypedSize2D;
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use layers::platform::surface::NativeGraphicsMetadata;
|
use layers::platform::surface::NativeGraphicsMetadata;
|
||||||
use libc::{c_char, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers};
|
use msg::constellation_msg::{Key, KeyModifiers};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std_url::Url;
|
use std_url::Url;
|
||||||
|
@ -33,15 +34,17 @@ use std::sync::mpsc::{Sender, channel};
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
extern crate x11;
|
extern crate x11;
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
use self::x11::xlib::XOpenDisplay;
|
use self::x11::xlib::{XInitThreads,XOpenDisplay};
|
||||||
|
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
pub static mut DISPLAY: *mut c_void = 0 as *mut c_void;
|
||||||
|
|
||||||
/// The type of an off-screen window.
|
/// The type of an off-screen window.
|
||||||
#[allow(raw_pointer_derive)]
|
#[allow(raw_pointer_derive)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
cef_browser: RefCell<Option<CefBrowser>>,
|
cef_browser: RefCell<Option<CefBrowser>>,
|
||||||
#[cfg(target_os="linux")]
|
size: TypedSize2D<DevicePixel,u32>
|
||||||
display: *mut c_void,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
|
@ -76,21 +79,12 @@ fn load_gl() {
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
/// Creates a new window.
|
/// Creates a new window.
|
||||||
#[cfg(target_os="linux")]
|
pub fn new(width: u32, height: u32) -> Rc<Window> {
|
||||||
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();
|
load_gl();
|
||||||
|
|
||||||
Rc::new(Window {
|
Rc::new(Window {
|
||||||
cef_browser: RefCell::new(None),
|
cef_browser: RefCell::new(None),
|
||||||
|
size: TypedSize2D(width, height)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,14 +169,36 @@ impl WindowMethods for Window {
|
||||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel,u32> {
|
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel,u32> {
|
||||||
let browser = self.cef_browser.borrow();
|
let browser = self.cef_browser.borrow();
|
||||||
match *browser {
|
match *browser {
|
||||||
None => TypedSize2D(400, 300),
|
None => self.size,
|
||||||
Some(ref browser) => {
|
Some(ref browser) => {
|
||||||
let mut rect = cef_rect_t::zero();
|
if browser.downcast().callback_executed.get() != true {
|
||||||
browser.get_host()
|
self.size
|
||||||
.get_client()
|
} else {
|
||||||
.get_render_handler()
|
let mut rect = cef_rect_t::zero();
|
||||||
.get_backing_rect((*browser).clone(), &mut rect);
|
rect.width = self.size.width.get() as i32;
|
||||||
TypedSize2D(rect.width as u32, rect.height as u32)
|
rect.height = self.size.height.get() as i32;
|
||||||
|
if cfg!(target_os="macos") {
|
||||||
|
// osx relies on virtual pixel scaling to provide sizes different from actual
|
||||||
|
// pixel size on screen. other platforms are just 1.0 unless the desktop/toolkit says otherwise
|
||||||
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) {
|
||||||
|
browser.get_host()
|
||||||
|
.get_client()
|
||||||
|
.get_render_handler()
|
||||||
|
.get_backing_rect((*browser).clone(), &mut rect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) {
|
||||||
|
browser.get_host()
|
||||||
|
.get_client()
|
||||||
|
.get_render_handler()
|
||||||
|
.get_view_rect((*browser).clone(), &mut rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TypedSize2D(rect.width as u32, rect.height as u32)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,28 +223,43 @@ impl WindowMethods for Window {
|
||||||
match *browser {
|
match *browser {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ref browser) => {
|
Some(ref browser) => {
|
||||||
browser.get_host().get_client().get_render_handler().on_present(browser.clone());
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_present) {
|
||||||
|
browser.get_host().get_client().get_render_handler().on_present(browser.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx,DevicePixel,f32> {
|
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx,DevicePixel,f32> {
|
||||||
let browser = self.cef_browser.borrow();
|
if cfg!(target_os="macos") {
|
||||||
match *browser {
|
let browser = self.cef_browser.borrow();
|
||||||
None => ScaleFactor::new(1.0),
|
match *browser {
|
||||||
Some(ref browser) => {
|
None => ScaleFactor::new(1.0),
|
||||||
let mut view_rect = cef_rect_t::zero();
|
Some(ref browser) => {
|
||||||
browser.get_host()
|
let mut view_rect = cef_rect_t::zero();
|
||||||
.get_client()
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
.get_render_handler()
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) {
|
||||||
.get_view_rect((*browser).clone(), &mut view_rect);
|
browser.get_host()
|
||||||
let mut backing_rect = cef_rect_t::zero();
|
.get_client()
|
||||||
browser.get_host()
|
.get_render_handler()
|
||||||
.get_client()
|
.get_view_rect((*browser).clone(), &mut view_rect);
|
||||||
.get_render_handler()
|
}
|
||||||
.get_backing_rect((*browser).clone(), &mut backing_rect);
|
let mut backing_rect = cef_rect_t::zero();
|
||||||
ScaleFactor::new(backing_rect.width as f32 / view_rect.width as f32)
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) {
|
||||||
|
browser.get_host()
|
||||||
|
.get_client()
|
||||||
|
.get_render_handler()
|
||||||
|
.get_backing_rect((*browser).clone(), &mut backing_rect);
|
||||||
|
}
|
||||||
|
ScaleFactor::new(backing_rect.width as f32 / view_rect.width as f32)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// FIXME(zmike)
|
||||||
|
// need to figure out a method for actually getting the scale factor instead of this nonsense
|
||||||
|
ScaleFactor::new(1.0 as f32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,9 +277,12 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||||
NativeGraphicsMetadata {
|
use x11::xlib;
|
||||||
display: self.display,
|
unsafe {
|
||||||
}
|
NativeGraphicsMetadata {
|
||||||
|
display: DISPLAY as *mut xlib::Display,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
||||||
|
@ -260,15 +294,24 @@ impl WindowMethods for Window {
|
||||||
box receiver as Box<CompositorReceiver>)
|
box receiver as Box<CompositorReceiver>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_for_composite(&self) -> bool {
|
fn prepare_for_composite(&self, width: usize, height: usize) -> bool {
|
||||||
let browser = self.cef_browser.borrow();
|
let browser = self.cef_browser.borrow();
|
||||||
match *browser {
|
match *browser {
|
||||||
None => {}
|
None => {
|
||||||
|
panic!("No browser?!?");
|
||||||
|
}
|
||||||
Some(ref browser) => {
|
Some(ref browser) => {
|
||||||
browser.get_host().get_client().get_render_handler().paint(browser.clone());
|
if browser.downcast().host.downcast().composite_ok.get() == true {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_paint) {
|
||||||
|
browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height);
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_end(&self) {
|
fn load_end(&self) {
|
||||||
|
@ -278,10 +321,13 @@ impl WindowMethods for Window {
|
||||||
None => return,
|
None => return,
|
||||||
Some(ref browser) => browser,
|
Some(ref browser) => browser,
|
||||||
};
|
};
|
||||||
browser.get_host()
|
if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) &&
|
||||||
.get_client()
|
check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_end) {
|
||||||
.get_load_handler()
|
browser.get_host()
|
||||||
.on_load_end((*browser).clone(), browser.get_main_frame(), 200);
|
.get_client()
|
||||||
|
.get_load_handler()
|
||||||
|
.on_load_end((*browser).clone(), browser.get_main_frame(), 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_page_title(&self, string: Option<String>) {
|
fn set_page_title(&self, string: Option<String>) {
|
||||||
|
@ -332,11 +378,14 @@ impl WindowMethods for Window {
|
||||||
Some(ref browser) => {
|
Some(ref browser) => {
|
||||||
let cursor_handle = self.cursor_handle_for_cursor(cursor);
|
let cursor_handle = self.cursor_handle_for_cursor(cursor);
|
||||||
let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } };
|
let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } };
|
||||||
browser.get_host()
|
if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) &&
|
||||||
.get_client()
|
check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_cursor_change) {
|
||||||
.get_render_handler()
|
browser.get_host()
|
||||||
.on_cursor_change(browser.clone(), cursor_handle,
|
.get_client()
|
||||||
self.cursor_type_for_cursor(cursor), &info)
|
.get_render_handler()
|
||||||
|
.on_cursor_change(browser.clone(), cursor_handle,
|
||||||
|
self.cursor_type_for_cursor(cursor), &info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +427,6 @@ impl CompositorProxy for CefCompositorProxy {
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn send(&mut self, msg: compositor_task::Msg) {
|
fn send(&mut self, msg: compositor_task::Msg) {
|
||||||
// FIXME(pcwalton): Kick the GTK event loop awake?
|
|
||||||
self.sender.send(msg).unwrap();
|
self.sender.send(msg).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,3 +437,23 @@ impl CompositorProxy for CefCompositorProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
pub fn init_window() {
|
||||||
|
unsafe {
|
||||||
|
assert!(XInitThreads() != 0);
|
||||||
|
DISPLAY = XOpenDisplay(ptr::null()) as *mut c_void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os="linux"))]
|
||||||
|
pub fn init_window() {}
|
||||||
|
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn cef_get_xdisplay() -> *mut c_void {
|
||||||
|
unsafe { DISPLAY }
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os="linux"))]
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn cef_get_xdisplay() -> *mut c_void {
|
||||||
|
ptr::null_mut()
|
||||||
|
}
|
||||||
|
|
|
@ -47,3 +47,4 @@ time = "0.1.12"
|
||||||
bitflags = "*"
|
bitflags = "*"
|
||||||
libc = "*"
|
libc = "*"
|
||||||
url = "*"
|
url = "*"
|
||||||
|
x11 = "*"
|
||||||
|
|
|
@ -21,6 +21,7 @@ extern crate time;
|
||||||
extern crate util;
|
extern crate util;
|
||||||
extern crate egl;
|
extern crate egl;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
#[cfg(target_os="linux")] extern crate x11;
|
||||||
|
|
||||||
use compositing::windowing::WindowEvent;
|
use compositing::windowing::WindowEvent;
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
|
|
@ -552,14 +552,15 @@ impl WindowMethods for Window {
|
||||||
self.window.set_cursor(glutin_cursor);
|
self.window.set_cursor(glutin_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_for_composite(&self) -> bool {
|
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||||
|
use x11::xlib;
|
||||||
NativeGraphicsMetadata {
|
NativeGraphicsMetadata {
|
||||||
display: unsafe { self.window.platform_display() }
|
display: unsafe { self.window.platform_display() as *mut xlib::Display }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +692,7 @@ impl WindowMethods for Window {
|
||||||
fn set_cursor(&self, _: Cursor) {
|
fn set_cursor(&self, _: Cursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_for_composite(&self) -> bool {
|
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
ports/gonk/Cargo.lock
generated
17
ports/gonk/Cargo.lock
generated
|
@ -527,7 +527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "layers"
|
name = "layers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745"
|
source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
|
@ -541,7 +541,7 @@ dependencies = [
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -725,7 +725,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "offscreen_gl_context"
|
name = "offscreen_gl_context"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04"
|
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
|
||||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
|
||||||
|
@ -735,7 +735,7 @@ dependencies = [
|
||||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||||
"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)",
|
||||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
|
"x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1177,6 +1177,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.1.1"
|
||||||
|
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.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xlib"
|
name = "xlib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -831,7 +831,7 @@ impl WindowMethods for Window {
|
||||||
fn set_cursor(&self, _: Cursor) {
|
fn set_cursor(&self, _: Cursor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_for_composite(&self) -> bool {
|
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue