add back/forward/loading members to ServoCefBrowser with related browser methods

This commit is contained in:
Mike Blumenkrantz 2015-05-22 17:13:13 -04:00
parent 0d46a3b89a
commit 3f8d8a3cc9
2 changed files with 27 additions and 0 deletions

View file

@ -60,6 +60,18 @@ cef_class_impl! {
this.downcast().host.clone() this.downcast().host.clone()
}} }}
fn can_go_back(&this,) -> c_int {{
this.downcast().back.get() as c_int
}}
fn can_go_forward(&this,) -> c_int {{
this.downcast().forward.get() as c_int
}}
fn is_loading(&this,) -> c_int {{
this.downcast().loading.get() as c_int
}}
fn go_back(&this,) -> () {{ fn go_back(&this,) -> () {{
this.send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Back)); this.send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Back));
}} }}
@ -90,6 +102,12 @@ pub struct ServoCefBrowser {
pub window: Option<Rc<glutin_app::window::Window>>, 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>,
/// whether the browser can navigate back
pub back: Cell<bool>,
/// whether the browser can navigate forward
pub forward: Cell<bool>,
/// whether the browser is loading
pub loading: 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()
window_handle: cef_window_handle_t, window_handle: cef_window_handle_t,
@ -130,6 +148,9 @@ impl ServoCefBrowser {
servo_browser: RefCell::new(servo_browser), servo_browser: RefCell::new(servo_browser),
message_queue: RefCell::new(vec!()), message_queue: RefCell::new(vec!()),
id: id, id: id,
back: Cell::new(false),
forward: Cell::new(false),
loading: Cell::new(false),
window_handle: window_handle, window_handle: window_handle,
} }
} }

View file

@ -322,6 +322,9 @@ impl WindowMethods for Window {
None => return, None => return,
Some(ref browser) => browser, Some(ref browser) => browser,
}; };
browser.downcast().loading.set(true);
browser.downcast().back.set(back);
browser.downcast().forward.set(forward);
if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) &&
check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) { check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) {
browser.get_host() browser.get_host()
@ -338,6 +341,9 @@ impl WindowMethods for Window {
None => return, None => return,
Some(ref browser) => browser, Some(ref browser) => browser,
}; };
browser.downcast().loading.set(false);
browser.downcast().back.set(back);
browser.downcast().forward.set(forward);
if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) &&
check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) { check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_loading_state_change) {
browser.get_host() browser.get_host()