mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
add new browser process interface method for main loop integration
regular CEF requires the user to either run the cef main loop or poll on a function to drain events. now the engine will trigger a callback in some application thread which will notify it that there is work to be done by the browser
This commit is contained in:
parent
83e605d2fb
commit
af1dce5a2e
3 changed files with 19 additions and 2 deletions
|
@ -26,6 +26,8 @@ static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650
|
|||
#[cfg(target_os="linux")]
|
||||
static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0";
|
||||
|
||||
pub static mut CEF_APP: *mut cef_app_t = 0 as *mut cef_app_t;
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
||||
|
@ -36,6 +38,11 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
|||
if args.is_null() {
|
||||
return 0;
|
||||
}
|
||||
unsafe {
|
||||
if !CEF_APP.is_null() {
|
||||
panic!("Attempting to call cef_initialize() multiple times!");
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
command_line_init((*args).argc, (*args).argv);
|
||||
|
@ -47,6 +54,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
|||
(*handler).on_context_initialized.map(|hcb| hcb(handler));
|
||||
}
|
||||
});
|
||||
CEF_APP = application;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
//! This is used for off-screen rendering mode only; on-screen windows (the default embedding mode)
|
||||
//! are managed by a platform toolkit (Glutin).
|
||||
|
||||
use core::CEF_APP;
|
||||
use eutil::Downcast;
|
||||
use interfaces::CefBrowser;
|
||||
use interfaces::{CefApp, CefBrowser};
|
||||
use render_handler::CefRenderHandlerExtensions;
|
||||
use rustc_unicode::str::Utf16Encoder;
|
||||
use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t};
|
||||
|
@ -428,6 +429,12 @@ impl CompositorProxy for CefCompositorProxy {
|
|||
#[cfg(target_os="linux")]
|
||||
fn send(&mut self, msg: compositor_task::Msg) {
|
||||
self.sender.send(msg).unwrap();
|
||||
unsafe { if CEF_APP.is_null() { return; } }
|
||||
let capp = unsafe { CefApp::from_c_object_addref(CEF_APP) };
|
||||
if unsafe { (*CEF_APP).get_browser_process_handler.is_some() } &&
|
||||
check_ptr_exist!(capp.get_browser_process_handler(), on_work_available) {
|
||||
capp.get_browser_process_handler().on_work_available();
|
||||
}
|
||||
}
|
||||
|
||||
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use interfaces::{cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement};
|
||||
use interfaces::{cef_app_t, CefApp, cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement};
|
||||
use interfaces::{CefV8Value};
|
||||
use interfaces::{cef_download_handler_t, cef_drag_handler_t, cef_context_menu_handler_t};
|
||||
use interfaces::{cef_dialog_handler_t, cef_focus_handler_t};
|
||||
|
@ -98,6 +98,7 @@ cef_pointer_wrapper!(());
|
|||
cef_pointer_wrapper!(*mut ());
|
||||
cef_pointer_wrapper!(*mut c_void);
|
||||
cef_pointer_wrapper!(c_void);
|
||||
cef_pointer_wrapper!(cef_app_t);
|
||||
cef_pointer_wrapper!(cef_base_t);
|
||||
cef_pointer_wrapper!(cef_browser_settings_t);
|
||||
cef_pointer_wrapper!(cef_cookie_t);
|
||||
|
@ -137,6 +138,7 @@ cef_noop_wrapper!(*mut cef_request_handler_t);
|
|||
cef_noop_wrapper!(*mut cef_string_list_t);
|
||||
cef_noop_wrapper!(*mut cef_string_utf16);
|
||||
cef_noop_wrapper!(c_int);
|
||||
cef_noop_wrapper!(CefApp);
|
||||
cef_noop_wrapper!(CefBrowserSettings);
|
||||
cef_noop_wrapper!(CefScreenInfo);
|
||||
cef_noop_wrapper!(CefRequestContextSettings);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue