Skip to content

Commit

Permalink
when creating a cef browser, setup the url to load but don't load it
Browse files Browse the repository at this point in the history
cef apps will expect to enter their main loops before this happens due to
various callbacks being hit, so it's necessary to punt this loading off until
a later time
  • Loading branch information
Mike Blumenkrantz committed May 27, 2015
1 parent b1ae5e7 commit 81eb426
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ports/cef/browser.rs
Expand Up @@ -264,7 +264,7 @@ pub fn browser_callback_after_created(browser: CefBrowser) {
life_span_handler.on_after_created(browser.clone());
}
browser.downcast().callback_executed.set(true);
browser.downcast().host.was_resized();
browser.downcast().frame.load();
}

fn browser_host_create(window_info: &cef_window_info_t,
Expand All @@ -274,12 +274,12 @@ fn browser_host_create(window_info: &cef_window_info_t,
-> CefBrowser {
let browser = ServoCefBrowser::new(window_info, client).as_cef_interface();
browser.init(window_info);
if url != ptr::null() {
unsafe { browser.downcast().frame.set_url(CefWrap::to_rust(url)); }
}
if callback_executed {
browser_callback_after_created(browser.clone());
}
if url != ptr::null() {
unsafe { browser.downcast().frame.load_url(CefWrap::to_rust(url)); }
}
BROWSERS.with(|browsers| {
browsers.borrow_mut().push(browser.clone());
});
Expand Down
10 changes: 10 additions & 0 deletions ports/cef/frame.rs
Expand Up @@ -53,10 +53,20 @@ full_cef_class_impl! {

pub trait ServoCefFrameExtensions {
fn set_browser(&self, browser: CefBrowser);
fn set_url(&self, url: &[u16]);
fn load(&self);
}

impl ServoCefFrameExtensions for CefFrame {
fn set_browser(&self, browser: CefBrowser) {
*self.downcast().browser.borrow_mut() = Some(browser)
}
fn set_url(&self, url: &[u16]) {
let frame = self.downcast();
*frame.url.borrow_mut() = String::from_utf16(url).unwrap();
}
fn load(&self) {
let event = WindowEvent::LoadUrl(self.downcast().url.borrow().clone());
self.downcast().browser.borrow_mut().as_mut().unwrap().send_window_event(event);
}
}

0 comments on commit 81eb426

Please sign in to comment.