mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Fix cef to follow new Browser::new() interface
(with passing of ServoUrl) Review changes
This commit is contained in:
parent
be58b99b06
commit
185aa20279
1 changed files with 13 additions and 11 deletions
|
@ -9,7 +9,6 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, CefFrame, CefRequestCont
|
||||||
use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t};
|
use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t};
|
||||||
use interfaces::{cef_request_context_t};
|
use interfaces::{cef_request_context_t};
|
||||||
use servo::Browser;
|
use servo::Browser;
|
||||||
use servo::servo_config::prefs::PREFS;
|
|
||||||
use servo::servo_url::ServoUrl;
|
use servo::servo_url::ServoUrl;
|
||||||
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t};
|
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t};
|
||||||
use window;
|
use window;
|
||||||
|
@ -124,7 +123,7 @@ pub struct ServoCefBrowser {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServoCefBrowser {
|
impl ServoCefBrowser {
|
||||||
pub fn new(window_info: &cef_window_info_t, client: CefClient) -> ServoCefBrowser {
|
pub fn new(window_info: &cef_window_info_t, client: CefClient, target_url: ServoUrl) -> 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();
|
||||||
|
@ -132,9 +131,7 @@ impl ServoCefBrowser {
|
||||||
let (glutin_window, servo_browser) = if window_info.windowless_rendering_enabled == 0 {
|
let (glutin_window, servo_browser) = if window_info.windowless_rendering_enabled == 0 {
|
||||||
let parent_window = glutin_app::WindowID::new(window_info.parent_window as *mut _);
|
let parent_window = glutin_app::WindowID::new(window_info.parent_window as *mut _);
|
||||||
let glutin_window = glutin_app::create_window(Some(parent_window));
|
let glutin_window = glutin_app::create_window(Some(parent_window));
|
||||||
let home_url = ServoUrl::parse(PREFS.get("shell.homepage").as_string()
|
let servo_browser = Browser::new(glutin_window.clone(), target_url);
|
||||||
.unwrap_or("about:blank")).unwrap();
|
|
||||||
let servo_browser = Browser::new(glutin_window.clone(), home_url);
|
|
||||||
window_handle = glutin_window.platform_window().window as cef_window_handle_t;
|
window_handle = glutin_window.platform_window().window as cef_window_handle_t;
|
||||||
(Some(glutin_window), ServoBrowser::OnScreen(servo_browser))
|
(Some(glutin_window), ServoBrowser::OnScreen(servo_browser))
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,8 +172,7 @@ impl ServoCefBrowserExtensions for CefBrowser {
|
||||||
if window_info.windowless_rendering_enabled != 0 {
|
if window_info.windowless_rendering_enabled != 0 {
|
||||||
let window = window::Window::new(window_info.width, window_info.height);
|
let window = window::Window::new(window_info.width, window_info.height);
|
||||||
window.set_browser(self.clone());
|
window.set_browser(self.clone());
|
||||||
let home_url = ServoUrl::parse(PREFS.get("shell.homepage").as_string()
|
let home_url = ServoUrl::parse("about:blank").unwrap();
|
||||||
.unwrap_or("about:blank")).unwrap();
|
|
||||||
let servo_browser = Browser::new(window.clone(), home_url);
|
let servo_browser = Browser::new(window.clone(), home_url);
|
||||||
*self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser);
|
*self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser);
|
||||||
}
|
}
|
||||||
|
@ -274,11 +270,17 @@ fn browser_host_create(window_info: &cef_window_info_t,
|
||||||
url: *const cef_string_t,
|
url: *const cef_string_t,
|
||||||
callback_executed: bool)
|
callback_executed: bool)
|
||||||
-> CefBrowser {
|
-> CefBrowser {
|
||||||
let browser = ServoCefBrowser::new(window_info, client).as_cef_interface();
|
let url_string = if url != ptr::null() {
|
||||||
|
unsafe { String::from_utf16(CefWrap::to_rust(url)).ok() }
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let target_url = url_string
|
||||||
|
.and_then(|val| ServoUrl::parse(&val).ok())
|
||||||
|
.or(ServoUrl::parse("about:blank").ok())
|
||||||
|
.unwrap();
|
||||||
|
let browser = ServoCefBrowser::new(window_info, client, target_url).as_cef_interface();
|
||||||
browser.init(window_info);
|
browser.init(window_info);
|
||||||
if url != ptr::null() {
|
|
||||||
unsafe { browser.downcast().frame.set_url(CefWrap::to_rust(url)); }
|
|
||||||
}
|
|
||||||
if callback_executed {
|
if callback_executed {
|
||||||
browser_callback_after_created(browser.clone());
|
browser_callback_after_created(browser.clone());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue