Skip to content

Commit

Permalink
update cef interfaces from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
zmike committed Sep 14, 2015
1 parent f749fe4 commit 5f9aac6
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 35 deletions.
244 changes: 244 additions & 0 deletions ports/cef/interfaces/cef_browser.rs
Expand Up @@ -942,6 +942,157 @@ impl CefWrap<*mut cef_navigation_entry_visitor_t> for Option<CefNavigationEntryV
}


//
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
//
#[repr(C)]
pub struct _cef_pdf_print_callback_t {
//
// Base structure.
//
pub base: types::cef_base_t,

//
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
//
pub on_pdf_print_finished: Option<extern "C" fn(
this: *mut cef_pdf_print_callback_t, path: *const types::cef_string_t,
ok: libc::c_int) -> ()>,

//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: u32,

//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}

pub type cef_pdf_print_callback_t = _cef_pdf_print_callback_t;


//
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
// structure will be called on the browser process UI thread.
//
pub struct CefPdfPrintCallback {
c_object: *mut cef_pdf_print_callback_t,
}

impl Clone for CefPdfPrintCallback {
fn clone(&self) -> CefPdfPrintCallback{
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefPdfPrintCallback {
c_object: self.c_object,
}
}
}
}

impl Drop for CefPdfPrintCallback {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
}
}

impl CefPdfPrintCallback {
pub unsafe fn from_c_object(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
CefPdfPrintCallback {
c_object: c_object,
}
}

pub unsafe fn from_c_object_addref(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
if !c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefPdfPrintCallback {
c_object: c_object,
}
}

pub fn c_object(&self) -> *mut cef_pdf_print_callback_t {
self.c_object
}

pub fn c_object_addrefed(&self) -> *mut cef_pdf_print_callback_t {
unsafe {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
eutil::add_ref(self.c_object as *mut types::cef_base_t);
}
self.c_object
}
}

pub fn is_null_cef_object(&self) -> bool {
self.c_object.is_null() || self.c_object as usize == mem::POST_DROP_USIZE
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null() && self.c_object as usize != mem::POST_DROP_USIZE
}

//
// Method that will be executed when the PDF printing has completed. |path| is
// the output path. |ok| will be true (1) if the printing completed
// successfully or false (0) otherwise.
//
pub fn on_pdf_print_finished(&self, path: &[u16], ok: libc::c_int) -> () {
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).on_pdf_print_finished.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(ok)))
}
}
}

impl CefWrap<*mut cef_pdf_print_callback_t> for CefPdfPrintCallback {
fn to_c(rust_object: CefPdfPrintCallback) -> *mut cef_pdf_print_callback_t {
rust_object.c_object_addrefed()
}
unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> CefPdfPrintCallback {
CefPdfPrintCallback::from_c_object_addref(c_object)
}
}
impl CefWrap<*mut cef_pdf_print_callback_t> for Option<CefPdfPrintCallback> {
fn to_c(rust_object: Option<CefPdfPrintCallback>) -> *mut cef_pdf_print_callback_t {
match rust_object {
None => ptr::null_mut(),
Some(rust_object) => rust_object.c_object_addrefed(),
}
}
unsafe fn to_rust(c_object: *mut cef_pdf_print_callback_t) -> Option<CefPdfPrintCallback> {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefPdfPrintCallback::from_c_object_addref(c_object))
}
}
}


//
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
Expand Down Expand Up @@ -1062,6 +1213,17 @@ pub struct _cef_browser_host_t {
//
pub print: Option<extern "C" fn(this: *mut cef_browser_host_t) -> ()>,

//
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
//
pub print_to_pdf: Option<extern "C" fn(this: *mut cef_browser_host_t,
path: *const types::cef_string_t,
settings: *const interfaces::cef_pdf_print_settings_t,
callback: *mut interfaces::cef_pdf_print_callback_t) -> ()>,

//
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
Expand Down Expand Up @@ -1231,6 +1393,26 @@ pub struct _cef_browser_host_t {
pub notify_move_or_resize_started: Option<extern "C" fn(
this: *mut cef_browser_host_t) -> ()>,

//
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
//
pub get_windowless_frame_rate: Option<extern "C" fn(
this: *mut cef_browser_host_t) -> libc::c_int>,

//
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
//
pub set_windowless_frame_rate: Option<extern "C" fn(
this: *mut cef_browser_host_t, frame_rate: libc::c_int) -> ()>,

//
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.
Expand Down Expand Up @@ -1657,6 +1839,29 @@ impl CefBrowserHost {
}
}

//
// Print the current browser contents to the PDF file specified by |path| and
// execute |callback| on completion. The caller is responsible for deleting
// |path| when done. For PDF printing to work on Linux you must implement the
// cef_print_handler_t::GetPdfPaperSize function.
//
pub fn print_to_pdf(&self, path: &[u16],
settings: &interfaces::CefPdfPrintSettings,
callback: interfaces::CefPdfPrintCallback) -> () {
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).print_to_pdf.unwrap())(
self.c_object,
CefWrap::to_c(path),
CefWrap::to_c(settings),
CefWrap::to_c(callback)))
}
}

//
// Search for |searchText|. |identifier| can be used to have multiple searches
// running simultaniously. |forward| indicates whether to search forward or
Expand Down Expand Up @@ -2041,6 +2246,45 @@ impl CefBrowserHost {
}
}

//
// Returns the maximum rate in frames per second (fps) that
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
// actual fps may be lower if the browser cannot generate frames at the
// requested rate. The minimum value is 1 and the maximum value is 60 (default
// 30). This function can only be called on the UI thread.
//
pub fn get_windowless_frame_rate(&self) -> libc::c_int {
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).get_windowless_frame_rate.unwrap())(
self.c_object))
}
}

//
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
// OnPaint will be called for a windowless browser. The actual fps may be
// lower if the browser cannot generate frames at the requested rate. The
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
//
pub fn set_windowless_frame_rate(&self, frame_rate: libc::c_int) -> () {
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).set_windowless_frame_rate.unwrap())(
self.c_object,
CefWrap::to_c(frame_rate)))
}
}

//
// Get the NSTextInputContext implementation for enabling IME on Mac when
// window rendering is disabled.
Expand Down
16 changes: 8 additions & 8 deletions ports/cef/interfaces/cef_cookie.rs
Expand Up @@ -58,10 +58,10 @@ pub struct _cef_cookie_manager_t {
pub base: types::cef_base_t,

//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
//
pub set_supported_schemes: Option<extern "C" fn(
this: *mut cef_cookie_manager_t, schemes: &types::cef_string_list_t,
Expand Down Expand Up @@ -222,10 +222,10 @@ impl CefCookieManager {
}

//
// Set the schemes supported by this manager. By default only "http" and
// "https" schemes are supported. If |callback| is non-NULL it will be
// executed asnychronously on the IO thread after the change has been applied.
// Must be called before any cookies are accessed.
// Set the schemes supported by this manager. The default schemes ("http",
// "https", "ws" and "wss") will always be supported. If |callback| is non-
// NULL it will be executed asnychronously on the IO thread after the change
// has been applied. Must be called before any cookies are accessed.
//
pub fn set_supported_schemes(&self, schemes: &Vec<String>,
callback: interfaces::CefCompletionCallback) -> () {
Expand Down
33 changes: 33 additions & 0 deletions ports/cef/interfaces/cef_display_handler.rs
Expand Up @@ -79,6 +79,17 @@ pub struct _cef_display_handler_t {
this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t,
icon_urls: &types::cef_string_list_t) -> ()>,

//
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true (1) the content will automatically be sized to fill
// the browser content area. If |fullscreen| is false (0) the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
//
pub on_fullscreen_mode_change: Option<extern "C" fn(
this: *mut cef_display_handler_t, browser: *mut interfaces::cef_browser_t,
fullscreen: libc::c_int) -> ()>,

//
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the
Expand Down Expand Up @@ -248,6 +259,28 @@ impl CefDisplayHandler {
}
}

//
// Called when web content in the page has toggled fullscreen mode. If
// |fullscreen| is true (1) the content will automatically be sized to fill
// the browser content area. If |fullscreen| is false (0) the content will
// automatically return to its original size and position. The client is
// responsible for resizing the browser if desired.
//
pub fn on_fullscreen_mode_change(&self, browser: interfaces::CefBrowser,
fullscreen: libc::c_int) -> () {
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).on_fullscreen_mode_change.unwrap())(
self.c_object,
CefWrap::to_c(browser),
CefWrap::to_c(fullscreen)))
}
}

//
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the
Expand Down

0 comments on commit 5f9aac6

Please sign in to comment.