mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
auto merge of #2434 : Ms2ger/servo/contentWindow, r=jdm
This commit is contained in:
commit
ca9396ff9c
6 changed files with 50 additions and 33 deletions
|
@ -573,7 +573,7 @@ impl Constellation {
|
||||||
debug!("Constellation: loading same-origin iframe at {:?}", url);
|
debug!("Constellation: loading same-origin iframe at {:?}", url);
|
||||||
// Reuse the script task if same-origin url's
|
// Reuse the script task if same-origin url's
|
||||||
Pipeline::with_script(next_pipeline_id,
|
Pipeline::with_script(next_pipeline_id,
|
||||||
Some(subpage_id),
|
subpage_id,
|
||||||
self.chan.clone(),
|
self.chan.clone(),
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl Pipeline {
|
||||||
/// Starts a render task, layout task, and script task. Returns the channels wrapped in a
|
/// Starts a render task, layout task, and script task. Returns the channels wrapped in a
|
||||||
/// struct.
|
/// struct.
|
||||||
pub fn with_script(id: PipelineId,
|
pub fn with_script(id: PipelineId,
|
||||||
subpage_id: Option<SubpageId>,
|
subpage_id: SubpageId,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
compositor_chan: CompositorChan,
|
compositor_chan: CompositorChan,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
|
@ -61,7 +61,7 @@ impl Pipeline {
|
||||||
|
|
||||||
let failure = Failure {
|
let failure = Failure {
|
||||||
pipeline_id: id,
|
pipeline_id: id,
|
||||||
subpage_id: subpage_id,
|
subpage_id: Some(subpage_id),
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderTask::create(id,
|
RenderTask::create(id,
|
||||||
|
@ -86,8 +86,9 @@ impl Pipeline {
|
||||||
layout_shutdown_chan);
|
layout_shutdown_chan);
|
||||||
|
|
||||||
let new_layout_info = NewLayoutInfo {
|
let new_layout_info = NewLayoutInfo {
|
||||||
old_id: script_pipeline.id.clone(),
|
old_pipeline_id: script_pipeline.id.clone(),
|
||||||
new_id: id,
|
new_pipeline_id: id,
|
||||||
|
subpage_id: subpage_id,
|
||||||
layout_chan: layout_chan.clone(),
|
layout_chan: layout_chan.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ impl Pipeline {
|
||||||
chan.send(AttachLayoutMsg(new_layout_info));
|
chan.send(AttachLayoutMsg(new_layout_info));
|
||||||
|
|
||||||
Pipeline::new(id,
|
Pipeline::new(id,
|
||||||
subpage_id,
|
Some(subpage_id),
|
||||||
script_pipeline.script_chan.clone(),
|
script_pipeline.script_chan.clone(),
|
||||||
layout_chan,
|
layout_chan,
|
||||||
render_chan,
|
render_chan,
|
||||||
|
|
|
@ -37,6 +37,7 @@ use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative};
|
||||||
use js::jsapi::{JSFunctionSpec, JSPropertySpec};
|
use js::jsapi::{JSFunctionSpec, JSPropertySpec};
|
||||||
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
|
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
|
||||||
use js::jsapi::{JSString};
|
use js::jsapi::{JSString};
|
||||||
|
use js::jsfriendapi::JS_ObjectToOuterObject;
|
||||||
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::jsval::{PrivateValue, ObjectValue, NullValue, ObjectOrNullValue};
|
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 {
|
pub extern fn wrap_for_same_compartment(cx: *JSContext, obj: *JSObject) -> *JSObject {
|
||||||
unsafe {
|
unsafe {
|
||||||
let clasp = JS_GetClass(obj);
|
JS_ObjectToOuterObject(cx as *mut _, obj as *mut _) as *_
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
|
||||||
|
obj: *mut JSObject, _flags: c_uint) -> *mut JSObject {
|
||||||
|
unsafe {
|
||||||
|
JS_ObjectToOuterObject(cx, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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::{JS, JSRef, RootCollection, Temporary, OptionalSettable};
|
||||||
use dom::bindings::js::OptionalRootable;
|
use dom::bindings::js::OptionalRootable;
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
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::document::{Document, HTMLDocument, DocumentMethods, DocumentHelpers};
|
||||||
use dom::element::{Element, AttributeHandlers};
|
use dom::element::{Element, AttributeHandlers};
|
||||||
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||||
|
@ -91,8 +92,9 @@ pub enum ScriptMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NewLayoutInfo {
|
pub struct NewLayoutInfo {
|
||||||
pub old_id: PipelineId,
|
pub old_pipeline_id: PipelineId,
|
||||||
pub new_id: PipelineId,
|
pub new_pipeline_id: PipelineId,
|
||||||
|
pub subpage_id: SubpageId,
|
||||||
pub layout_chan: LayoutChan,
|
pub layout_chan: LayoutChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +122,9 @@ pub struct Page {
|
||||||
/// Pipeline id associated with this page.
|
/// Pipeline id associated with this page.
|
||||||
pub id: PipelineId,
|
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.
|
/// Unique id for last reflow request; used for confirming completion reply.
|
||||||
pub last_reflow_id: Traceable<Cell<uint>>,
|
pub last_reflow_id: Traceable<Cell<uint>>,
|
||||||
|
|
||||||
|
@ -168,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>>;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +195,8 @@ impl IterablePage for Rc<Page> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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,
|
window_size: Size2D<uint>, resource_task: ResourceTask,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
js_context: Rc<Cx>) -> Page {
|
js_context: Rc<Cx>) -> Page {
|
||||||
|
@ -200,6 +206,7 @@ impl Page {
|
||||||
};
|
};
|
||||||
Page {
|
Page {
|
||||||
id: id,
|
id: id,
|
||||||
|
subpage_id: subpage_id,
|
||||||
frame: Traceable::new(RefCell::new(None)),
|
frame: Traceable::new(RefCell::new(None)),
|
||||||
layout_chan: Untraceable::new(layout_chan),
|
layout_chan: Untraceable::new(layout_chan),
|
||||||
layout_join_port: Untraceable::new(RefCell::new(None)),
|
layout_join_port: Untraceable::new(RefCell::new(None)),
|
||||||
|
@ -606,7 +613,7 @@ impl ScriptTask {
|
||||||
window_size: Size2D<uint>)
|
window_size: Size2D<uint>)
|
||||||
-> Rc<ScriptTask> {
|
-> Rc<ScriptTask> {
|
||||||
let (js_runtime, js_context) = ScriptTask::new_rt_and_cx();
|
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(),
|
resource_task.clone(),
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
js_context.clone());
|
js_context.clone());
|
||||||
|
@ -641,11 +648,11 @@ impl ScriptTask {
|
||||||
let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
wrap_for_same_compartment,
|
wrap_for_same_compartment,
|
||||||
ptr::null());
|
None);
|
||||||
JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
||||||
callback,
|
callback,
|
||||||
wrap_for_same_compartment,
|
wrap_for_same_compartment,
|
||||||
ptr::null());
|
Some(pre_wrap));
|
||||||
}
|
}
|
||||||
|
|
||||||
let js_context = js_runtime.cx();
|
let js_context = js_runtime.cx();
|
||||||
|
@ -782,18 +789,19 @@ impl ScriptTask {
|
||||||
fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) {
|
fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) {
|
||||||
debug!("Script: new layout: {:?}", new_layout_info);
|
debug!("Script: new layout: {:?}", new_layout_info);
|
||||||
let NewLayoutInfo {
|
let NewLayoutInfo {
|
||||||
old_id,
|
old_pipeline_id,
|
||||||
new_id,
|
new_pipeline_id,
|
||||||
|
subpage_id,
|
||||||
layout_chan
|
layout_chan
|
||||||
} = new_layout_info;
|
} = new_layout_info;
|
||||||
|
|
||||||
let mut page = self.page.borrow_mut();
|
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
|
whose parent has a PipelineId which does not correspond to a pipeline in the script
|
||||||
task's page tree. This is a bug.");
|
task's page tree. This is a bug.");
|
||||||
let new_page = {
|
let new_page = {
|
||||||
let window_size = parent_page.window_size.deref().get();
|
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(),
|
parent_page.resource_task.deref().clone(),
|
||||||
self.constellation_chan.clone(),
|
self.constellation_chan.clone(),
|
||||||
self.js_context.borrow().get_ref().clone())
|
self.js_context.borrow().get_ref().clone())
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 07acb44df9b3f638743931f392c0ebe7040a7bab
|
Subproject commit ff296137c652248138eb7f5a377d8daac52ed233
|
Loading…
Add table
Add a link
Reference in a new issue