diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/main/constellation.rs | 2 | ||||
-rw-r--r-- | src/components/main/pipeline.rs | 11 | ||||
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 22 | ||||
-rw-r--r-- | src/components/script/dom/htmliframeelement.rs | 14 | ||||
-rw-r--r-- | src/components/script/script_task.rs | 32 | ||||
m--------- | src/support/spidermonkey/rust-mozjs | 0 |
6 files changed, 49 insertions, 32 deletions
diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index fcd93ee238c..e2c63f16630 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -573,7 +573,7 @@ impl Constellation { debug!("Constellation: loading same-origin iframe at {:?}", url); // Reuse the script task if same-origin url's Pipeline::with_script(next_pipeline_id, - Some(subpage_id), + subpage_id, self.chan.clone(), self.compositor_chan.clone(), self.image_cache_task.clone(), diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs index 2b17085e6a2..02da6479e5f 100644 --- a/src/components/main/pipeline.rs +++ b/src/components/main/pipeline.rs @@ -45,7 +45,7 @@ impl Pipeline { /// Starts a render task, layout task, and script task. Returns the channels wrapped in a /// struct. pub fn with_script(id: PipelineId, - subpage_id: Option<SubpageId>, + subpage_id: SubpageId, constellation_chan: ConstellationChan, compositor_chan: CompositorChan, image_cache_task: ImageCacheTask, @@ -61,7 +61,7 @@ impl Pipeline { let failure = Failure { pipeline_id: id, - subpage_id: subpage_id, + subpage_id: Some(subpage_id), }; RenderTask::create(id, @@ -86,8 +86,9 @@ impl Pipeline { layout_shutdown_chan); let new_layout_info = NewLayoutInfo { - old_id: script_pipeline.id.clone(), - new_id: id, + old_pipeline_id: script_pipeline.id.clone(), + new_pipeline_id: id, + subpage_id: subpage_id, layout_chan: layout_chan.clone(), }; @@ -95,7 +96,7 @@ impl Pipeline { chan.send(AttachLayoutMsg(new_layout_info)); Pipeline::new(id, - subpage_id, + Some(subpage_id), script_pipeline.script_chan.clone(), layout_chan, render_chan, diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index f5b0f08849e..7c742efcbb2 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -37,6 +37,7 @@ use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative}; use js::jsapi::{JSFunctionSpec, JSPropertySpec}; use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses}; use js::jsapi::{JSString}; +use js::jsfriendapi::JS_ObjectToOuterObject; use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType; use js::jsval::JSVal; use js::jsval::{PrivateValue, ObjectValue, NullValue, ObjectOrNullValue}; @@ -594,19 +595,14 @@ pub fn CreateDOMGlobal(cx: *JSContext, class: *JSClass) -> *JSObject { pub extern fn wrap_for_same_compartment(cx: *JSContext, obj: *JSObject) -> *JSObject { unsafe { - let clasp = JS_GetClass(obj); - let clasp = clasp as *js::Class; - match (*clasp).ext.outerObject { - Some(outerize) => { - debug!("found an outerize hook"); - let obj = JSHandleObject { unnamed: &obj }; - outerize(cx, obj) - } - None => { - debug!("no outerize hook found"); - obj - } - } + JS_ObjectToOuterObject(cx as *mut _, obj as *mut _) as *_ + } +} + +pub extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject, + obj: *mut JSObject, _flags: c_uint) -> *mut JSObject { + unsafe { + JS_ObjectToOuterObject(cx, obj) } } diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs index f92fddabdaa..766d7a711f9 100644 --- a/src/components/script/dom/htmliframeelement.rs +++ b/src/components/script/dom/htmliframeelement.rs @@ -14,6 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{Node, ElementNodeTypeId, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom::window::Window; +use script_task::IterablePage; use servo_msg::constellation_msg::{PipelineId, SubpageId}; use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed}; use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg}; @@ -184,7 +185,18 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> { } 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 { diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index a750903e45d..0ce993d5e19 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -11,7 +11,8 @@ use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCas use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalSettable}; use dom::bindings::js::OptionalRootable; use dom::bindings::trace::{Traceable, Untraceable}; -use dom::bindings::utils::{Reflectable, GlobalStaticData, wrap_for_same_compartment}; +use dom::bindings::utils::{Reflectable, GlobalStaticData}; +use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap}; use dom::document::{Document, HTMLDocument, DocumentMethods, DocumentHelpers}; use dom::element::{Element, AttributeHandlers}; use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; @@ -91,8 +92,9 @@ pub enum ScriptMsg { } pub struct NewLayoutInfo { - pub old_id: PipelineId, - pub new_id: PipelineId, + pub old_pipeline_id: PipelineId, + pub new_pipeline_id: PipelineId, + pub subpage_id: SubpageId, pub layout_chan: LayoutChan, } @@ -120,6 +122,9 @@ pub struct Page { /// Pipeline id associated with this page. pub id: PipelineId, + /// Subpage id associated with this page, if any. + pub subpage_id: Option<SubpageId>, + /// Unique id for last reflow request; used for confirming completion reply. pub last_reflow_id: Traceable<Cell<uint>>, @@ -168,7 +173,7 @@ pub struct PageIterator { stack: Vec<Rc<Page>>, } -trait IterablePage { +pub trait IterablePage { fn iter(&self) -> PageIterator; fn find(&self, id: PipelineId) -> Option<Rc<Page>>; } @@ -190,7 +195,8 @@ impl IterablePage for Rc<Page> { } impl Page { - fn new(id: PipelineId, layout_chan: LayoutChan, + fn new(id: PipelineId, subpage_id: Option<SubpageId>, + layout_chan: LayoutChan, window_size: Size2D<uint>, resource_task: ResourceTask, constellation_chan: ConstellationChan, js_context: Rc<Cx>) -> Page { @@ -200,6 +206,7 @@ impl Page { }; Page { id: id, + subpage_id: subpage_id, frame: Traceable::new(RefCell::new(None)), layout_chan: Untraceable::new(layout_chan), layout_join_port: Untraceable::new(RefCell::new(None)), @@ -606,7 +613,7 @@ impl ScriptTask { window_size: Size2D<uint>) -> Rc<ScriptTask> { let (js_runtime, js_context) = ScriptTask::new_rt_and_cx(); - let page = Page::new(id, layout_chan, window_size, + let page = Page::new(id, None, layout_chan, window_size, resource_task.clone(), constellation_chan.clone(), js_context.clone()); @@ -641,11 +648,11 @@ impl ScriptTask { let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr, ptr::null(), wrap_for_same_compartment, - ptr::null()); + None); JS_SetWrapObjectCallbacks((*js_runtime).ptr, callback, wrap_for_same_compartment, - ptr::null()); + Some(pre_wrap)); } let js_context = js_runtime.cx(); @@ -782,18 +789,19 @@ impl ScriptTask { fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) { debug!("Script: new layout: {:?}", new_layout_info); let NewLayoutInfo { - old_id, - new_id, + old_pipeline_id, + new_pipeline_id, + subpage_id, layout_chan } = new_layout_info; let mut page = self.page.borrow_mut(); - let parent_page = page.find(old_id).expect("ScriptTask: received a layout + let parent_page = page.find(old_pipeline_id).expect("ScriptTask: received a layout whose parent has a PipelineId which does not correspond to a pipeline in the script task's page tree. This is a bug."); let new_page = { let window_size = parent_page.window_size.deref().get(); - Page::new(new_id, layout_chan, window_size, + Page::new(new_pipeline_id, Some(subpage_id), layout_chan, window_size, parent_page.resource_task.deref().clone(), self.constellation_chan.clone(), self.js_context.borrow().get_ref().clone()) diff --git a/src/support/spidermonkey/rust-mozjs b/src/support/spidermonkey/rust-mozjs -Subproject 07acb44df9b3f638743931f392c0ebe7040a7ba +Subproject ff296137c652248138eb7f5a377d8daac52ed23 |