mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement window.parent for iframes.
This commit is contained in:
parent
7e3f504d94
commit
0873e5c8ca
11 changed files with 60 additions and 25 deletions
|
@ -33,14 +33,16 @@ pub struct BrowserContext {
|
|||
history: Vec<SessionHistoryEntry>,
|
||||
active_index: uint,
|
||||
window_proxy: *mut JSObject,
|
||||
parent: Option<JS<Window>>,
|
||||
}
|
||||
|
||||
impl BrowserContext {
|
||||
pub fn new(document: JSRef<Document>) -> BrowserContext {
|
||||
pub fn new(document: JSRef<Document>, parent: Option<JSRef<Window>>) -> BrowserContext {
|
||||
let mut context = BrowserContext {
|
||||
history: vec!(SessionHistoryEntry::new(document)),
|
||||
active_index: 0,
|
||||
window_proxy: ptr::null_mut(),
|
||||
parent: parent.map(|p| JS::from_rooted(p)),
|
||||
};
|
||||
context.create_window_proxy();
|
||||
context
|
||||
|
@ -60,6 +62,12 @@ impl BrowserContext {
|
|||
self.window_proxy
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Option<Temporary<Window>> {
|
||||
self.parent.map(|p| {
|
||||
p.root().browser_context().as_ref().unwrap().active_window()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
fn create_window_proxy(&mut self) {
|
||||
let win = self.active_window().root();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue