Implement iframe.contentWindow.

This commit is contained in:
Ms2ger 2014-05-14 17:58:40 +02:00
parent 85285113e4
commit 765cea73d9
2 changed files with 14 additions and 2 deletions

View file

@ -14,6 +14,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId, window_from_node}; use dom::node::{Node, ElementNodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use dom::window::Window; use dom::window::Window;
use script_task::IterablePage;
use servo_msg::constellation_msg::{PipelineId, SubpageId}; use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed}; use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg}; use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg};
@ -184,7 +185,18 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
} }
fn GetContentWindow(&self) -> Option<Temporary<Window>> { fn GetContentWindow(&self) -> Option<Temporary<Window>> {
None self.size.and_then(|size| {
let window = window_from_node(self).root();
let children = &*window.deref().page.children.deref().borrow();
let child = children.iter().find(|child| {
child.subpage_id.unwrap() == size.subpage_id
});
child.and_then(|page| {
page.frame.deref().borrow().as_ref().map(|frame| {
Temporary::new(frame.window.clone())
})
})
})
} }
fn Align(&self) -> DOMString { fn Align(&self) -> DOMString {

View file

@ -173,7 +173,7 @@ pub struct PageIterator {
stack: Vec<Rc<Page>>, stack: Vec<Rc<Page>>,
} }
trait IterablePage { pub trait IterablePage {
fn iter(&self) -> PageIterator; fn iter(&self) -> PageIterator;
fn find(&self, id: PipelineId) -> Option<Rc<Page>>; fn find(&self, id: PipelineId) -> Option<Rc<Page>>;
} }