@@ -6,7 +6,6 @@ use dom::attr::{Attr, AttrValue};
66use dom:: bindings:: codegen:: Bindings :: BrowserElementBinding :: BrowserElementIconChangeEventDetail ;
77use dom:: bindings:: codegen:: Bindings :: HTMLIFrameElementBinding ;
88use dom:: bindings:: codegen:: Bindings :: HTMLIFrameElementBinding :: HTMLIFrameElementMethods ;
9- use dom:: bindings:: codegen:: Bindings :: WindowBinding :: WindowMethods ;
109use dom:: bindings:: conversions:: { ToJSValConvertible } ;
1110use dom:: bindings:: error:: { Error , ErrorResult , Fallible } ;
1211use dom:: bindings:: global:: GlobalRef ;
@@ -21,7 +20,6 @@ use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
2120use dom:: event:: { Event , EventBubbles , EventCancelable } ;
2221use dom:: htmlelement:: HTMLElement ;
2322use dom:: node:: { Node , window_from_node} ;
24- use dom:: urlhelper:: UrlHelper ;
2523use dom:: virtualmethods:: VirtualMethods ;
2624use dom:: window:: Window ;
2725use ipc_channel:: ipc;
@@ -32,7 +30,6 @@ use msg::constellation_msg::ScriptMsg as ConstellationMsg;
3230use msg:: constellation_msg:: { ConstellationChan , IframeLoadInfo , MozBrowserEvent } ;
3331use msg:: constellation_msg:: { IFrameLoadType , AsyncIFrameLoad } ;
3432use msg:: constellation_msg:: { NavigationDirection , PipelineId , SubpageId } ;
35- use page:: IterablePage ;
3633use script_task:: { ScriptTaskEventCategory , CommonScriptMsg , ScriptTask , Runnable } ;
3734use script_traits:: ConstellationControlMsg ;
3835use std:: ascii:: AsciiExt ;
@@ -391,28 +388,22 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
391388
392389 // https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
393390 fn GetContentWindow ( & self ) -> Option < Root < Window > > {
394- self . subpage_id . get ( ) . and_then ( |subpage_id| {
395- let window = window_from_node ( self ) ;
396- let window = window. r ( ) ;
397- let children = window. page ( ) . children . borrow ( ) ;
398- children. iter ( ) . find ( |page| {
399- let window = page. window ( ) ;
400- window. subpage ( ) == Some ( subpage_id)
401- } ) . map ( |page| page. window ( ) )
391+ self . nested_browsing_context . get ( ) . and_then ( |context| {
392+ let window = context. active_window ( ) ;
393+ if window. is_local ( ) {
394+ Some ( Root :: from_ref ( window. as_local ( ) ) )
395+ } else {
396+ None
397+ }
402398 } )
403399 }
404400
405401 // https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
406402 fn GetContentDocument ( & self ) -> Option < Root < Document > > {
407- self . GetContentWindow ( ) . and_then ( |window| {
408- let self_url = match self . get_url ( ) {
409- Some ( self_url) => self_url,
410- None => return None ,
411- } ;
412- let win_url = window_from_node ( self ) . get_url ( ) ;
413-
414- if UrlHelper :: SameOrigin ( & self_url, & win_url) {
415- Some ( window. Document ( ) )
403+ self . nested_browsing_context . get ( ) . map ( |context| {
404+ let document = context. active_document ( ) ;
405+ if document. is_local ( ) {
406+ Some ( Root :: from_ref ( document. as_local ( ) ) )
416407 } else {
417408 None
418409 }
0 commit comments