mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Add support for multiple cef browsers (multiple tabs).
This commit is contained in:
parent
94a4a55332
commit
f7b83d9a76
4 changed files with 170 additions and 149 deletions
|
@ -3,16 +3,19 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use eutil::Downcast;
|
||||
use interfaces::{CefFrame, CefStringVisitor, cef_frame_t, cef_string_visitor_t};
|
||||
use interfaces::{CefBrowser, CefFrame, CefStringVisitor, cef_frame_t, cef_string_visitor_t};
|
||||
use types::{cef_string_t, cef_string_userfree_t};
|
||||
use browser::ServoCefBrowserExtensions;
|
||||
|
||||
use core;
|
||||
use compositing::windowing::WindowEvent;
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub struct ServoCefFrame {
|
||||
pub title_visitor: RefCell<Option<CefStringVisitor>>,
|
||||
pub url: RefCell<String>,
|
||||
|
||||
/// A reference to the browser.
|
||||
pub browser: RefCell<Option<CefBrowser>>,
|
||||
}
|
||||
|
||||
impl ServoCefFrame {
|
||||
|
@ -20,6 +23,7 @@ impl ServoCefFrame {
|
|||
ServoCefFrame {
|
||||
title_visitor: RefCell::new(None),
|
||||
url: RefCell::new(String::new()),
|
||||
browser: RefCell::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +33,8 @@ cef_class_impl! {
|
|||
fn load_url(&this, url: *const cef_string_t) -> () {
|
||||
let this = this.downcast();
|
||||
*this.url.borrow_mut() = String::from_utf16(url).unwrap();
|
||||
core::send_window_event(WindowEvent::LoadUrl(String::from_utf16(url).unwrap()));
|
||||
let event = WindowEvent::LoadUrl(String::from_utf16(url).unwrap());
|
||||
this.browser.borrow_mut().as_mut().unwrap().send_window_event(event);
|
||||
}
|
||||
fn get_url(&this) -> cef_string_userfree_t {
|
||||
let this = this.downcast();
|
||||
|
@ -38,8 +43,17 @@ cef_class_impl! {
|
|||
fn get_text(&this, visitor: *mut cef_string_visitor_t) -> () {
|
||||
let this = this.downcast();
|
||||
*this.title_visitor.borrow_mut() = Some(visitor);
|
||||
core::get_title_for_main_frame();
|
||||
this.browser.borrow().as_ref().unwrap().get_title_for_main_frame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ServoCefFrameExtensions {
|
||||
fn set_browser(&self, browser: CefBrowser);
|
||||
}
|
||||
|
||||
impl ServoCefFrameExtensions for CefFrame {
|
||||
fn set_browser(&self, browser: CefBrowser) {
|
||||
*self.downcast().browser.borrow_mut() = Some(browser)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue