mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement window.frameElement, change window.parent to make use of it.
This commit is contained in:
parent
5436922169
commit
1e0e98b63c
10 changed files with 88 additions and 74 deletions
|
@ -11,6 +11,7 @@ use dom::bindings::proxyhandler::{get_property_descriptor, fill_property_descrip
|
|||
use dom::bindings::utils::{Reflectable, WindowProxyHandler};
|
||||
use dom::bindings::utils::get_array_index_from_id;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::Element;
|
||||
use dom::window::Window;
|
||||
use dom::window::WindowHelpers;
|
||||
|
||||
|
@ -33,16 +34,16 @@ pub struct BrowserContext {
|
|||
history: Vec<SessionHistoryEntry>,
|
||||
active_index: uint,
|
||||
window_proxy: *mut JSObject,
|
||||
parent: Option<JS<Window>>,
|
||||
frame_element: Option<JS<Element>>,
|
||||
}
|
||||
|
||||
impl BrowserContext {
|
||||
pub fn new(document: JSRef<Document>, parent: Option<JSRef<Window>>) -> BrowserContext {
|
||||
pub fn new(document: JSRef<Document>, frame_element: Option<JSRef<Element>>) -> 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)),
|
||||
frame_element: frame_element.map(JS::from_rooted),
|
||||
};
|
||||
context.create_window_proxy();
|
||||
context
|
||||
|
@ -57,17 +58,15 @@ impl BrowserContext {
|
|||
doc.r().window()
|
||||
}
|
||||
|
||||
pub fn frame_element(&self) -> Option<Temporary<Element>> {
|
||||
self.frame_element.map(Temporary::new)
|
||||
}
|
||||
|
||||
pub fn window_proxy(&self) -> *mut JSObject {
|
||||
assert!(!self.window_proxy.is_null());
|
||||
self.window_proxy
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Option<Temporary<Window>> {
|
||||
self.parent.map(|p| {
|
||||
p.root().r().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