mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
De-@mut the script crate.
This commit is contained in:
parent
021d32368d
commit
fa542e5de7
12 changed files with 396 additions and 250 deletions
|
@ -60,6 +60,9 @@ impl ScriptListener for CompositorChan {
|
||||||
port.recv();
|
port.recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dup(&self) -> ~ScriptListener {
|
||||||
|
~self.clone() as ~ScriptListener
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of the abstract `RenderListener` interface.
|
/// Implementation of the abstract `RenderListener` interface.
|
||||||
|
|
|
@ -134,7 +134,7 @@ impl Pipeline {
|
||||||
};
|
};
|
||||||
|
|
||||||
ScriptTask::create(id,
|
ScriptTask::create(id,
|
||||||
compositor_chan.clone(),
|
~compositor_chan.clone(),
|
||||||
layout_chan.clone(),
|
layout_chan.clone(),
|
||||||
script_port,
|
script_port,
|
||||||
script_chan.clone(),
|
script_chan.clone(),
|
||||||
|
|
|
@ -94,6 +94,7 @@ pub trait ScriptListener : Clone {
|
||||||
fn invalidate_rect(&self, PipelineId, Rect<uint>);
|
fn invalidate_rect(&self, PipelineId, Rect<uint>);
|
||||||
fn scroll_fragment_point(&self, PipelineId, Point2D<f32>);
|
fn scroll_fragment_point(&self, PipelineId, Point2D<f32>);
|
||||||
fn close(&self);
|
fn close(&self);
|
||||||
|
fn dup(&self) -> ~ScriptListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Encoder> Encodable<S> for @ScriptListener {
|
impl<S: Encoder> Encodable<S> for @ScriptListener {
|
||||||
|
|
|
@ -2578,7 +2578,8 @@ def CreateBindingJSObject(descriptor, parent=None):
|
||||||
assert not descriptor.createGlobal
|
assert not descriptor.createGlobal
|
||||||
handler = """
|
handler = """
|
||||||
let page = page_from_context(aCx);
|
let page = page_from_context(aCx);
|
||||||
let handler = (*page).js_info.get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
|
let mut js_info = (*page).js_info();
|
||||||
|
let handler = js_info.get().get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
|
||||||
""" % descriptor.name
|
""" % descriptor.name
|
||||||
create += handler + """ let obj = NewProxyObject(aCx, *handler,
|
create += handler + """ let obj = NewProxyObject(aCx, *handler,
|
||||||
ptr::to_unsafe_ptr(&RUST_PRIVATE_TO_JSVAL(squirrel_away_unique(aObject) as *libc::c_void)),
|
ptr::to_unsafe_ptr(&RUST_PRIVATE_TO_JSVAL(squirrel_away_unique(aObject) as *libc::c_void)),
|
||||||
|
@ -2727,7 +2728,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
idsToInit.append(props.variableName(False))
|
idsToInit.append(props.variableName(False))
|
||||||
if len(idsToInit) > 0:
|
if len(idsToInit) > 0:
|
||||||
setup = CGList([CGGeneric("let page = page_from_context(aCx);"),
|
setup = CGList([CGGeneric("let page = page_from_context(aCx);"),
|
||||||
CGList([CGGeneric("let %s_ids_mut = (*page).js_info.get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
|
CGList([CGGeneric("let mut js_info = (*page).js_info();\n"
|
||||||
|
"let %s_ids_mut = js_info.get().get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
|
||||||
initIds = CGList(
|
initIds = CGList(
|
||||||
[CGGeneric("!InitIds(aCx, %s, *%s_ids_mut)" % (varname, varname)) for
|
[CGGeneric("!InitIds(aCx, %s, *%s_ids_mut)" % (varname, varname)) for
|
||||||
varname in idsToInit], ' ||\n')
|
varname in idsToInit], ' ||\n')
|
||||||
|
@ -2884,8 +2886,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
a given interface.
|
a given interface.
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('*JSContext', 'aCx'), Argument('*JSObject', 'aReceiver'),
|
args = [Argument('&mut JSPageInfo', 'js_info')]
|
||||||
Argument('*mut bool', 'aEnabled')]
|
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'bool', args, pub=True)
|
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'bool', args, pub=True)
|
||||||
|
|
||||||
def declare(self):
|
def declare(self):
|
||||||
|
@ -2903,7 +2904,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
else:
|
else:
|
||||||
getter = "GetConstructorObject"
|
getter = "GetConstructorObject"
|
||||||
|
|
||||||
body = "let page = page_from_context(aCx);"
|
body = ""
|
||||||
#XXXjdm This self.descriptor.concrete check shouldn't be necessary
|
#XXXjdm This self.descriptor.concrete check shouldn't be necessary
|
||||||
if not self.descriptor.concrete or self.descriptor.proxy:
|
if not self.descriptor.concrete or self.descriptor.proxy:
|
||||||
body += """ let traps = ProxyTraps {
|
body += """ let traps = ProxyTraps {
|
||||||
|
@ -2937,22 +2938,22 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
getPrototypeOf: ptr::null(),
|
getPrototypeOf: ptr::null(),
|
||||||
trace: %s
|
trace: %s
|
||||||
};
|
};
|
||||||
(*page).js_info.get_mut_ref().dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
|
js_info.dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
|
||||||
CreateProxyHandler(ptr::to_unsafe_ptr(&traps), ptr::to_unsafe_ptr(&Class) as *libc::c_void));
|
CreateProxyHandler(ptr::to_unsafe_ptr(&traps), ptr::to_unsafe_ptr(&Class) as *libc::c_void));
|
||||||
|
|
||||||
""" % (FINALIZE_HOOK_NAME,
|
""" % (FINALIZE_HOOK_NAME,
|
||||||
('Some(%s)' % TRACE_HOOK_NAME),
|
('Some(%s)' % TRACE_HOOK_NAME),
|
||||||
self.descriptor.name)
|
self.descriptor.name)
|
||||||
else:
|
else:
|
||||||
body += """ (*page).js_info.get_ref().dom_static.attribute_ids.insert(PrototypeList::id::%s as uint,
|
body += """ js_info.dom_static.attribute_ids.insert(PrototypeList::id::%s as uint,
|
||||||
vec::cast_to_mut(vec::from_slice(sAttributes_ids)));
|
vec::cast_to_mut(vec::from_slice(sAttributes_ids)));
|
||||||
""" % self.descriptor.name
|
""" % self.descriptor.name
|
||||||
body = "" #XXXjdm xray stuff isn't necessary yet
|
body = "" #XXXjdm xray stuff isn't necessary yet
|
||||||
|
|
||||||
return (body + " let global: *JSObject = JS_GetGlobalForObject(aCx, aReceiver);\n" +
|
return (body + """ let cx = js_info.js_context.borrow().ptr;
|
||||||
"""
|
let receiver = js_info.js_compartment.borrow().global_obj.borrow().ptr;
|
||||||
*aEnabled = true;
|
let global: *JSObject = JS_GetGlobalForObject(cx, receiver);
|
||||||
return %s(aCx, global, aReceiver).is_not_null();""" % (getter))
|
return %s(cx, global, receiver).is_not_null();""" % (getter))
|
||||||
|
|
||||||
def needCx(returnType, arguments, extendedAttributes, considerTypes):
|
def needCx(returnType, arguments, extendedAttributes, considerTypes):
|
||||||
return (considerTypes and
|
return (considerTypes and
|
||||||
|
@ -4306,7 +4307,8 @@ class CGXrayHelper(CGAbstractExternMethod):
|
||||||
methods = self.properties.methods
|
methods = self.properties.methods
|
||||||
if methods.hasNonChromeOnly() or methods.hasChromeOnly():
|
if methods.hasNonChromeOnly() or methods.hasChromeOnly():
|
||||||
methodArgs = "Some(zip_copies(%(methods)s, *method_ids))" % varNames
|
methodArgs = "Some(zip_copies(%(methods)s, *method_ids))" % varNames
|
||||||
setup += "let method_ids = (*page).js_info.get_ref().dom_static.method_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
setup += "let mut js_info = (*page).js_info();\n" \
|
||||||
|
"let method_ids = js_info.get().get_ref().dom_static.method_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
||||||
else:
|
else:
|
||||||
methodArgs = "None"
|
methodArgs = "None"
|
||||||
methodArgs = CGGeneric(methodArgs)
|
methodArgs = CGGeneric(methodArgs)
|
||||||
|
@ -4314,7 +4316,8 @@ class CGXrayHelper(CGAbstractExternMethod):
|
||||||
attrs = self.properties.attrs
|
attrs = self.properties.attrs
|
||||||
if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
|
if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
|
||||||
attrArgs = "Some(zip_copies(%(attrs)s, *attr_ids))" % varNames
|
attrArgs = "Some(zip_copies(%(attrs)s, *attr_ids))" % varNames
|
||||||
setup += "let attr_ids = (*page).js_info.get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
setup += "let mut js_info = (*page).js_info();\n" \
|
||||||
|
"let attr_ids = js_info.get().get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
||||||
else:
|
else:
|
||||||
attrArgs = "None"
|
attrArgs = "None"
|
||||||
attrArgs = CGGeneric(attrArgs)
|
attrArgs = CGGeneric(attrArgs)
|
||||||
|
@ -4322,7 +4325,8 @@ class CGXrayHelper(CGAbstractExternMethod):
|
||||||
consts = self.properties.consts
|
consts = self.properties.consts
|
||||||
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
|
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
|
||||||
constArgs = "Some(zip_copies(%(consts)s, *const_ids))" % varNames
|
constArgs = "Some(zip_copies(%(consts)s, *const_ids))" % varNames
|
||||||
setup += "let const_ids = (*page).js_info.get_ref().dom_static.constant_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
setup += "let mut js_info = (*page).js_info();\n" \
|
||||||
|
"let const_ids = js_info.get().get_ref().dom_static.constant_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
|
||||||
else:
|
else:
|
||||||
constArgs = "None"
|
constArgs = "None"
|
||||||
constArgs = CGGeneric(constArgs)
|
constArgs = CGGeneric(constArgs)
|
||||||
|
@ -4815,7 +4819,8 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
||||||
// or through unwrapping a slot or something). We'll punt and get the Window
|
// or through unwrapping a slot or something). We'll punt and get the Window
|
||||||
// from the context for now.
|
// from the context for now.
|
||||||
let page = page_from_context(cx);
|
let page = page_from_context(cx);
|
||||||
let global = (*page).frame.get_ref().window.clone();
|
let frame = (*page).frame();
|
||||||
|
let global = frame.get().get_ref().window.clone();
|
||||||
let obj = global.reflector().get_jsobject();
|
let obj = global.reflector().get_jsobject();
|
||||||
"""
|
"""
|
||||||
nativeName = MakeNativeName(self._ctor.identifier.name)
|
nativeName = MakeNativeName(self._ctor.identifier.name)
|
||||||
|
@ -5241,21 +5246,18 @@ class CGDictionary(CGThing):
|
||||||
class CGRegisterProtos(CGAbstractMethod):
|
class CGRegisterProtos(CGAbstractMethod):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
CGAbstractMethod.__init__(self, None, 'Register', 'void',
|
CGAbstractMethod.__init__(self, None, 'Register', 'void',
|
||||||
[Argument('@mut Compartment', 'compartment')],
|
[Argument('&mut JSPageInfo', 'js_info')],
|
||||||
unsafe=False, pub=True)
|
unsafe=False, pub=True)
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def _registerProtos(self):
|
def _registerProtos(self):
|
||||||
lines = [" assert!(codegen::%sBinding::DefineDOMInterface(\n"
|
lines = [" assert!(codegen::%sBinding::DefineDOMInterface(js_info));" % (desc.name)
|
||||||
" compartment.cx.ptr,\n"
|
|
||||||
" compartment.global_obj.ptr,\n"
|
|
||||||
" &mut unused));" % (desc.name)
|
|
||||||
for desc in self.config.getDescriptors(hasInterfaceObject=True,
|
for desc in self.config.getDescriptors(hasInterfaceObject=True,
|
||||||
isExternal=False,
|
isExternal=False,
|
||||||
register=True)]
|
register=True)]
|
||||||
return '\n'.join(lines) + '\n'
|
return '\n'.join(lines) + '\n'
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return " let mut unused = false;\n" + self._registerProtos()
|
return self._registerProtos()
|
||||||
|
|
||||||
class CGBindingRoot(CGThing):
|
class CGBindingRoot(CGThing):
|
||||||
"""
|
"""
|
||||||
|
@ -6322,7 +6324,7 @@ class GlobalGenRoots():
|
||||||
for desc in config.getDescriptors(hasInterfaceObject=True,
|
for desc in config.getDescriptors(hasInterfaceObject=True,
|
||||||
register=True)]
|
register=True)]
|
||||||
curr = CGImports([], [], ['dom::bindings::codegen',
|
curr = CGImports([], [], ['dom::bindings::codegen',
|
||||||
'js::rust::Compartment'], defineIncludes, curr)
|
'script_task::JSPageInfo'], defineIncludes, curr)
|
||||||
|
|
||||||
# Done.
|
# Done.
|
||||||
return curr
|
return curr
|
||||||
|
|
|
@ -193,11 +193,11 @@ pub fn unwrap_value<T>(val: *JSVal, proto_id: PrototypeList::id::ID, proto_depth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn squirrel_away<T>(x: @mut T) -> *Box<T> {
|
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *Box<T> {
|
||||||
cast::transmute(x)
|
cast::transmute(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *Box<T> {
|
pub unsafe fn squirrel_away_unboxed<T>(x: ~T) -> *T {
|
||||||
cast::transmute(x)
|
cast::transmute(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,14 +556,12 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVa
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initialize_global(global: *JSObject) {
|
pub fn initialize_global(global: *JSObject) {
|
||||||
let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
|
let protoArray = ~([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
|
||||||
unsafe {
|
unsafe {
|
||||||
//XXXjdm we should be storing the box pointer instead of the inner
|
let box_ = squirrel_away_unboxed(protoArray);
|
||||||
let box_ = squirrel_away(protoArray);
|
|
||||||
let inner = ptr::to_unsafe_ptr(&(*box_).data);
|
|
||||||
JS_SetReservedSlot(global,
|
JS_SetReservedSlot(global,
|
||||||
DOM_PROTOTYPE_SLOT,
|
DOM_PROTOTYPE_SLOT,
|
||||||
RUST_PRIVATE_TO_JSVAL(inner as *libc::c_void));
|
RUST_PRIVATE_TO_JSVAL(box_ as *libc::c_void));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,8 +815,9 @@ fn global_object_for_js_object(obj: *JSObject) -> *Box<window::Window> {
|
||||||
fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext {
|
fn cx_for_dom_reflector(obj: *JSObject) -> *JSContext {
|
||||||
unsafe {
|
unsafe {
|
||||||
let win = global_object_for_js_object(obj);
|
let win = global_object_for_js_object(obj);
|
||||||
match (*win).data.page.js_info {
|
let js_info = (*win).data.page().js_info();
|
||||||
Some(ref info) => info.js_context.ptr,
|
match *js_info.get() {
|
||||||
|
Some(ref info) => info.js_context.borrow().ptr,
|
||||||
None => fail!("no JS context for DOM global")
|
None => fail!("no JS context for DOM global")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ impl Element {
|
||||||
let (port, chan) = Chan::new();
|
let (port, chan) = Chan::new();
|
||||||
let addr = node.to_trusted_node_address();
|
let addr = node.to_trusted_node_address();
|
||||||
let rects =
|
let rects =
|
||||||
match win.get().page.query_layout(ContentBoxesQuery(addr, chan), port) {
|
match win.get().page().query_layout(ContentBoxesQuery(addr, chan), port) {
|
||||||
ContentBoxesResponse(rects) => {
|
ContentBoxesResponse(rects) => {
|
||||||
rects.map(|r| {
|
rects.map(|r| {
|
||||||
ClientRect::new(
|
ClientRect::new(
|
||||||
|
@ -555,7 +555,7 @@ impl Element {
|
||||||
let node: JS<Node> = NodeCast::from(abstract_self);
|
let node: JS<Node> = NodeCast::from(abstract_self);
|
||||||
let (port, chan) = Chan::new();
|
let (port, chan) = Chan::new();
|
||||||
let addr = node.to_trusted_node_address();
|
let addr = node.to_trusted_node_address();
|
||||||
match win.get().page.query_layout(ContentBoxQuery(addr, chan), port) {
|
match win.get().page().query_layout(ContentBoxQuery(addr, chan), port) {
|
||||||
ContentBoxResponse(rect) => {
|
ContentBoxResponse(rect) => {
|
||||||
ClientRect::new(
|
ClientRect::new(
|
||||||
win,
|
win,
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl HTMLImageElement {
|
||||||
pub fn Width(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
|
pub fn Width(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
|
||||||
let node: JS<Node> = NodeCast::from(abstract_self);
|
let node: JS<Node> = NodeCast::from(abstract_self);
|
||||||
let doc = node.get().owner_doc();
|
let doc = node.get().owner_doc();
|
||||||
let page = doc.get().window.get().page;
|
let page = doc.get().window.get().page();
|
||||||
let (port, chan) = Chan::new();
|
let (port, chan) = Chan::new();
|
||||||
let addr = node.to_trusted_node_address();
|
let addr = node.to_trusted_node_address();
|
||||||
match page.query_layout(ContentBoxQuery(addr, chan), port) {
|
match page.query_layout(ContentBoxQuery(addr, chan), port) {
|
||||||
|
@ -167,7 +167,7 @@ impl HTMLImageElement {
|
||||||
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
|
pub fn Height(&self, abstract_self: &JS<HTMLImageElement>) -> u32 {
|
||||||
let node = &self.htmlelement.element.node;
|
let node = &self.htmlelement.element.node;
|
||||||
let doc = node.owner_doc();
|
let doc = node.owner_doc();
|
||||||
let page = doc.get().window.get().page;
|
let page = doc.get().window.get().page();
|
||||||
let (port, chan) = Chan::new();
|
let (port, chan) = Chan::new();
|
||||||
let this_node: JS<Node> = NodeCast::from(abstract_self);
|
let this_node: JS<Node> = NodeCast::from(abstract_self);
|
||||||
let addr = this_node.to_trusted_node_address();
|
let addr = this_node.to_trusted_node_address();
|
||||||
|
|
|
@ -10,22 +10,38 @@ use dom::window::Window;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use script_task::{Page};
|
use script_task::{Page};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use extra::serialize::{Encoder, Encodable};
|
||||||
|
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct Location {
|
pub struct Location {
|
||||||
reflector_: Reflector, //XXXjdm cycle: window->Location->window
|
reflector_: Reflector, //XXXjdm cycle: window->Location->window
|
||||||
page: @mut Page,
|
extra: Untraceable,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Untraceable {
|
||||||
|
page: Rc<Page>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<S: Encoder> Encodable<S> for Untraceable {
|
||||||
|
fn encode(&self, s: &mut S) {
|
||||||
|
self.page.borrow().encode(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Location {
|
impl Location {
|
||||||
pub fn new_inherited(page: @mut Page) -> Location {
|
pub fn new_inherited(page: Rc<Page>) -> Location {
|
||||||
Location {
|
Location {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
extra: Untraceable {
|
||||||
page: page
|
page: page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window, page: @mut Page) -> JS<Location> {
|
pub fn new(window: &Window, page: Rc<Page>) -> JS<Location> {
|
||||||
reflect_dom_object(~Location::new_inherited(page),
|
reflect_dom_object(~Location::new_inherited(page),
|
||||||
window,
|
window,
|
||||||
LocationBinding::Wrap)
|
LocationBinding::Wrap)
|
||||||
|
@ -44,7 +60,7 @@ impl Location {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Href(&self) -> DOMString {
|
pub fn Href(&self) -> DOMString {
|
||||||
self.page.get_url().to_str()
|
self.extra.page.borrow().get_url().to_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetHref(&self, _href: DOMString) -> Fallible<()> {
|
pub fn SetHref(&self, _href: DOMString) -> Fallible<()> {
|
||||||
|
|
|
@ -30,6 +30,7 @@ use std::hashmap::HashSet;
|
||||||
use std::io::timer::Timer;
|
use std::io::timer::Timer;
|
||||||
use std::num;
|
use std::num;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::to_bytes::Cb;
|
use std::to_bytes::Cb;
|
||||||
|
|
||||||
use extra::serialize::{Encoder, Encodable};
|
use extra::serialize::{Encoder, Encodable};
|
||||||
|
@ -72,9 +73,7 @@ impl TimerHandle {
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
eventtarget: EventTarget,
|
eventtarget: EventTarget,
|
||||||
page: @mut Page,
|
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
compositor: @ScriptListener,
|
|
||||||
console: Option<JS<Console>>,
|
console: Option<JS<Console>>,
|
||||||
location: Option<JS<Location>>,
|
location: Option<JS<Location>>,
|
||||||
navigator: Option<JS<Navigator>>,
|
navigator: Option<JS<Navigator>>,
|
||||||
|
@ -85,20 +84,30 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Untraceable {
|
struct Untraceable {
|
||||||
|
page: Rc<Page>,
|
||||||
|
compositor: ~ScriptListener,
|
||||||
timer_chan: SharedChan<TimerControlMsg>,
|
timer_chan: SharedChan<TimerControlMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Encoder> Encodable<S> for Untraceable {
|
impl<S: Encoder> Encodable<S> for Untraceable {
|
||||||
fn encode(&self, _: &mut S) {
|
fn encode(&self, s: &mut S) {
|
||||||
|
let page = self.page.borrow();
|
||||||
|
page.encode(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn get_cx(&self) -> *JSObject {
|
pub fn get_cx(&self) -> *JSObject {
|
||||||
self.page.js_info.get_ref().js_compartment.cx.ptr
|
let js_info = self.page().js_info();
|
||||||
|
(*js_info.get()).get_ref().js_compartment.borrow().cx.borrow().ptr
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page<'a>(&'a self) -> &'a Page {
|
||||||
|
let page = &self.extra.page;
|
||||||
|
page.borrow()
|
||||||
}
|
}
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
self.page.get_url()
|
self.page().get_url()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +141,8 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Document(&self) -> JS<Document> {
|
pub fn Document(&self) -> JS<Document> {
|
||||||
self.page.frame.get_ref().document.clone()
|
let frame = self.page().frame();
|
||||||
|
(*frame.get()).get_ref().document.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Name(&self) -> DOMString {
|
pub fn Name(&self) -> DOMString {
|
||||||
|
@ -168,7 +178,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn Location(&mut self) -> JS<Location> {
|
pub fn Location(&mut self) -> JS<Location> {
|
||||||
if self.location.is_none() {
|
if self.location.is_none() {
|
||||||
self.location = Some(Location::new(self, self.page));
|
self.location = Some(Location::new(self, self.extra.page.clone()));
|
||||||
}
|
}
|
||||||
self.location.get_ref().clone()
|
self.location.get_ref().clone()
|
||||||
}
|
}
|
||||||
|
@ -255,32 +265,32 @@ impl Window {
|
||||||
// FIXME This should probably be ReflowForQuery, not Display. All queries currently
|
// FIXME This should probably be ReflowForQuery, not Display. All queries currently
|
||||||
// currently rely on the display list, which means we can't destroy it by
|
// currently rely on the display list, which means we can't destroy it by
|
||||||
// doing a query reflow.
|
// doing a query reflow.
|
||||||
self.page.damage(damage);
|
self.page().damage(damage);
|
||||||
self.page.reflow(ReflowForDisplay, self.script_chan.clone(), self.compositor);
|
self.page().reflow(ReflowForDisplay, self.script_chan.clone(), self.extra.compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait_until_safe_to_modify_dom(&self) {
|
pub fn wait_until_safe_to_modify_dom(&self) {
|
||||||
// FIXME: This disables concurrent layout while we are modifying the DOM, since
|
// FIXME: This disables concurrent layout while we are modifying the DOM, since
|
||||||
// our current architecture is entirely unsafe in the presence of races.
|
// our current architecture is entirely unsafe in the presence of races.
|
||||||
self.page.join_layout();
|
self.page().join_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(cx: *JSContext,
|
pub fn new(cx: *JSContext,
|
||||||
page: @mut Page,
|
page: Rc<Page>,
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
compositor: @ScriptListener,
|
compositor: ~ScriptListener,
|
||||||
image_cache_task: ImageCacheTask)
|
image_cache_task: ImageCacheTask)
|
||||||
-> JS<Window> {
|
-> JS<Window> {
|
||||||
let mut win = ~Window {
|
let mut win = ~Window {
|
||||||
eventtarget: EventTarget::new_inherited(WindowTypeId),
|
eventtarget: EventTarget::new_inherited(WindowTypeId),
|
||||||
page: page,
|
|
||||||
script_chan: script_chan.clone(),
|
script_chan: script_chan.clone(),
|
||||||
compositor: compositor,
|
|
||||||
console: None,
|
console: None,
|
||||||
extra: Untraceable {
|
extra: Untraceable {
|
||||||
|
compositor: compositor,
|
||||||
|
page: page.clone(),
|
||||||
timer_chan: {
|
timer_chan: {
|
||||||
let (timer_port, timer_chan): (Port<TimerControlMsg>, SharedChan<TimerControlMsg>) = SharedChan::new();
|
let (timer_port, timer_chan): (Port<TimerControlMsg>, SharedChan<TimerControlMsg>) = SharedChan::new();
|
||||||
let id = page.id.clone();
|
let id = page.borrow().id.clone();
|
||||||
spawn_named("timer controller", proc() {
|
spawn_named("timer controller", proc() {
|
||||||
loop {
|
loop {
|
||||||
match timer_port.recv() {
|
match timer_port.recv() {
|
||||||
|
|
|
@ -15,11 +15,10 @@ use dom::htmlformelement::HTMLFormElement;
|
||||||
use dom::node::{ElementNodeTypeId, INode, NodeHelpers};
|
use dom::node::{ElementNodeTypeId, INode, NodeHelpers};
|
||||||
use dom::types::*;
|
use dom::types::*;
|
||||||
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
|
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
|
||||||
use script_task::page_from_context;
|
use script_task::Page;
|
||||||
|
|
||||||
use extra::url::Url;
|
use extra::url::Url;
|
||||||
use hubbub::hubbub;
|
use hubbub::hubbub;
|
||||||
use js::jsapi::JSContext;
|
|
||||||
use servo_msg::constellation_msg::SubpageId;
|
use servo_msg::constellation_msg::SubpageId;
|
||||||
use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_resource};
|
use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_resource};
|
||||||
use servo_util::namespace::Null;
|
use servo_util::namespace::Null;
|
||||||
|
@ -246,7 +245,7 @@ pub fn build_element_from_tag(tag: DOMString, document: &JS<Document>) -> JS<Ele
|
||||||
return ElementCast::from(&HTMLUnknownElement::new(tag, document));
|
return ElementCast::from(&HTMLUnknownElement::new(tag, document));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_html(cx: *JSContext,
|
pub fn parse_html(page: &Page,
|
||||||
document: &mut JS<Document>,
|
document: &mut JS<Document>,
|
||||||
url: Url,
|
url: Url,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
|
@ -282,17 +281,16 @@ pub fn parse_html(cx: *JSContext,
|
||||||
let url2 = base_url.clone();
|
let url2 = base_url.clone();
|
||||||
let url3 = url2.clone();
|
let url3 = url2.clone();
|
||||||
|
|
||||||
|
{
|
||||||
// Store the final URL before we start parsing, so that DOM routines
|
// Store the final URL before we start parsing, so that DOM routines
|
||||||
// (e.g. HTMLImageElement::update_image) can resolve relative URLs
|
// (e.g. HTMLImageElement::update_image) can resolve relative URLs
|
||||||
// correctly.
|
// correctly.
|
||||||
//
|
let mut page_url = page.mut_url();
|
||||||
// FIXME: is this safe? When we instead pass an &mut Page to parse_html,
|
*page_url.get() = Some((url2.clone(), true));
|
||||||
// we crash with a dynamic borrow failure.
|
|
||||||
let page = page_from_context(cx);
|
|
||||||
unsafe {
|
|
||||||
(*page).url = Some((url2.clone(), true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let pipeline_id = page.id;
|
||||||
|
|
||||||
let mut parser = hubbub::Parser("UTF-8", false);
|
let mut parser = hubbub::Parser("UTF-8", false);
|
||||||
debug!("created parser");
|
debug!("created parser");
|
||||||
|
|
||||||
|
@ -365,12 +363,6 @@ pub fn parse_html(cx: *JSContext,
|
||||||
let subpage_id = next_subpage_id.get();
|
let subpage_id = next_subpage_id.get();
|
||||||
next_subpage_id.set(SubpageId(*subpage_id + 1));
|
next_subpage_id.set(SubpageId(*subpage_id + 1));
|
||||||
|
|
||||||
// Pipeline Id
|
|
||||||
let pipeline_id = {
|
|
||||||
let page = page_from_context(cx);
|
|
||||||
unsafe { (*page).id }
|
|
||||||
};
|
|
||||||
|
|
||||||
iframe_element.get_mut().size = Some(IFrameSize {
|
iframe_element.get_mut().size = Some(IFrameSize {
|
||||||
pipeline_id: pipeline_id,
|
pipeline_id: pipeline_id,
|
||||||
subpage_id: subpage_id,
|
subpage_id: subpage_id,
|
||||||
|
|
|
@ -33,11 +33,11 @@ use extra::url::Url;
|
||||||
use geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
use js::JSVAL_NULL;
|
use js::JSVAL_NULL;
|
||||||
use js::global::debug_fns;
|
use js::global::DEBUG_FNS;
|
||||||
use js::glue::RUST_JSVAL_TO_OBJECT;
|
use js::glue::RUST_JSVAL_TO_OBJECT;
|
||||||
use js::jsapi::{JSContext, JSObject, JS_InhibitGC, JS_AllowGC};
|
use js::jsapi::{JSContext, JSObject, JS_InhibitGC, JS_AllowGC};
|
||||||
use js::jsapi::{JS_CallFunctionValue, JS_GetContextPrivate};
|
use js::jsapi::{JS_CallFunctionValue, JS_GetContextPrivate};
|
||||||
use js::rust::{Compartment, Cx};
|
use js::rust::{Compartment, Cx, CxUtils, RtUtils};
|
||||||
use js;
|
use js;
|
||||||
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
|
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, IFrameSandboxed, IFrameUnsandboxed};
|
use servo_msg::constellation_msg::{ConstellationChan, IFrameSandboxed, IFrameUnsandboxed};
|
||||||
|
@ -50,8 +50,11 @@ use servo_util::geometry::to_frac_px;
|
||||||
use servo_util::url::parse_url;
|
use servo_util::url::parse_url;
|
||||||
use servo_util::task::send_on_failure;
|
use servo_util::task::send_on_failure;
|
||||||
use servo_util::namespace::Null;
|
use servo_util::namespace::Null;
|
||||||
|
use std::cast;
|
||||||
|
use std::cell::{RefCell, Ref, RefMut};
|
||||||
use std::comm::{Port, SharedChan};
|
use std::comm::{Port, SharedChan};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::util::replace;
|
use std::util::replace;
|
||||||
|
|
||||||
|
@ -110,48 +113,49 @@ pub struct Page {
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
|
|
||||||
/// Unique id for last reflow request; used for confirming completion reply.
|
/// Unique id for last reflow request; used for confirming completion reply.
|
||||||
last_reflow_id: uint,
|
last_reflow_id: RefCell<uint>,
|
||||||
|
|
||||||
/// The outermost frame containing the document, window, and page URL.
|
/// The outermost frame containing the document, window, and page URL.
|
||||||
frame: Option<Frame>,
|
frame: RefCell<Option<Frame>>,
|
||||||
|
|
||||||
/// A handle for communicating messages to the layout task.
|
/// A handle for communicating messages to the layout task.
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
|
|
||||||
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
||||||
layout_join_port: Option<Port<()>>,
|
layout_join_port: RefCell<Option<Port<()>>>,
|
||||||
|
|
||||||
/// What parts of the document are dirty, if any.
|
/// What parts of the document are dirty, if any.
|
||||||
damage: Option<DocumentDamage>,
|
damage: RefCell<Option<DocumentDamage>>,
|
||||||
|
|
||||||
/// The current size of the window, in pixels.
|
/// The current size of the window, in pixels.
|
||||||
window_size: Size2D<uint>,
|
window_size: RefCell<Size2D<uint>>,
|
||||||
|
|
||||||
js_info: Option<JSPageInfo>,
|
js_info: RefCell<Option<JSPageInfo>>,
|
||||||
|
|
||||||
/// Cached copy of the most recent url loaded by the script
|
/// Cached copy of the most recent url loaded by the script
|
||||||
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
/// TODO(tkuehn): this currently does not follow any particular caching policy
|
||||||
/// and simply caches pages forever (!). The bool indicates if reflow is required
|
/// and simply caches pages forever (!). The bool indicates if reflow is required
|
||||||
/// when reloading.
|
/// when reloading.
|
||||||
url: Option<(Url, bool)>,
|
url: RefCell<Option<(Url, bool)>>,
|
||||||
|
|
||||||
next_subpage_id: SubpageId,
|
next_subpage_id: RefCell<SubpageId>,
|
||||||
|
|
||||||
/// Pending resize event, if any.
|
/// Pending resize event, if any.
|
||||||
resize_event: Option<Size2D<uint>>,
|
resize_event: RefCell<Option<Size2D<uint>>>,
|
||||||
|
|
||||||
/// Pending scroll to fragment event, if any
|
/// Pending scroll to fragment event, if any
|
||||||
fragment_node: Option<JS<Element>>
|
fragment_node: RefCell<Option<JS<Element>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Encoder> Encodable<S> for Page {
|
impl<S: Encoder> Encodable<S> for Page {
|
||||||
fn encode(&self, s: &mut S) {
|
fn encode(&self, s: &mut S) {
|
||||||
self.fragment_node.encode(s);
|
let fragment_node = self.fragment_node.borrow();
|
||||||
|
fragment_node.get().encode(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PageTree {
|
pub struct PageTree {
|
||||||
page: @mut Page,
|
page: Rc<Page>,
|
||||||
inner: ~[PageTree],
|
inner: ~[PageTree],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,26 +166,34 @@ pub struct PageTreeIterator<'a> {
|
||||||
impl PageTree {
|
impl PageTree {
|
||||||
fn new(id: PipelineId, layout_chan: LayoutChan, window_size: Size2D<uint>) -> PageTree {
|
fn new(id: PipelineId, layout_chan: LayoutChan, window_size: Size2D<uint>) -> PageTree {
|
||||||
PageTree {
|
PageTree {
|
||||||
page: @mut Page {
|
page: unsafe { Rc::new_unchecked(Page {
|
||||||
id: id,
|
id: id,
|
||||||
frame: None,
|
frame: RefCell::new(None),
|
||||||
layout_chan: layout_chan,
|
layout_chan: layout_chan,
|
||||||
layout_join_port: None,
|
layout_join_port: RefCell::new(None),
|
||||||
damage: None,
|
damage: RefCell::new(None),
|
||||||
window_size: window_size,
|
window_size: RefCell::new(window_size),
|
||||||
js_info: None,
|
js_info: RefCell::new(None),
|
||||||
url: None,
|
url: RefCell::new(None),
|
||||||
next_subpage_id: SubpageId(0),
|
next_subpage_id: RefCell::new(SubpageId(0)),
|
||||||
resize_event: None,
|
resize_event: RefCell::new(None),
|
||||||
fragment_node: None,
|
fragment_node: RefCell::new(None),
|
||||||
last_reflow_id: 0
|
last_reflow_id: RefCell::new(0)
|
||||||
},
|
}) },
|
||||||
inner: ~[],
|
inner: ~[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn id(&self) -> PipelineId {
|
||||||
|
self.page().id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn page<'a>(&'a self) -> &'a Page {
|
||||||
|
self.page.borrow()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn find<'a> (&'a mut self, id: PipelineId) -> Option<&'a mut PageTree> {
|
pub fn find<'a> (&'a mut self, id: PipelineId) -> Option<&'a mut PageTree> {
|
||||||
if self.page.id == id { return Some(self); }
|
if self.page().id == id { return Some(self); }
|
||||||
for page_tree in self.inner.mut_iter() {
|
for page_tree in self.inner.mut_iter() {
|
||||||
let found = page_tree.find(id);
|
let found = page_tree.find(id);
|
||||||
if found.is_some() { return found; }
|
if found.is_some() { return found; }
|
||||||
|
@ -200,7 +212,13 @@ impl PageTree {
|
||||||
let remove_idx = {
|
let remove_idx = {
|
||||||
self.inner.mut_iter()
|
self.inner.mut_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.find(|&(_idx, ref page_tree)| page_tree.page.id == id)
|
.find(|&(_idx, ref page_tree)| {
|
||||||
|
// FIXME: page_tree has a lifetime such that it's unusable for anything.
|
||||||
|
let page_tree = unsafe {
|
||||||
|
cast::transmute_region(page_tree)
|
||||||
|
};
|
||||||
|
page_tree.id() == id
|
||||||
|
})
|
||||||
.map(|(idx, _)| idx)
|
.map(|(idx, _)| idx)
|
||||||
};
|
};
|
||||||
match remove_idx {
|
match remove_idx {
|
||||||
|
@ -218,8 +236,8 @@ impl PageTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator<@mut Page> for PageTreeIterator<'a> {
|
impl<'a> Iterator<Rc<Page>> for PageTreeIterator<'a> {
|
||||||
fn next(&mut self) -> Option<@mut Page> {
|
fn next(&mut self) -> Option<Rc<Page>> {
|
||||||
if !self.stack.is_empty() {
|
if !self.stack.is_empty() {
|
||||||
let next = self.stack.pop();
|
let next = self.stack.pop();
|
||||||
{
|
{
|
||||||
|
@ -227,7 +245,7 @@ impl<'a> Iterator<@mut Page> for PageTreeIterator<'a> {
|
||||||
self.stack.push(child);
|
self.stack.push(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(next.page)
|
Some(next.page.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -235,9 +253,34 @@ impl<'a> Iterator<@mut Page> for PageTreeIterator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
|
pub fn mut_js_info<'a>(&'a self) -> RefMut<'a, Option<JSPageInfo>> {
|
||||||
|
self.js_info.borrow_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn js_info<'a>(&'a self) -> Ref<'a, Option<JSPageInfo>> {
|
||||||
|
self.js_info.borrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn url<'a>(&'a self) -> Ref<'a, Option<(Url, bool)>> {
|
||||||
|
self.url.borrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mut_url<'a>(&'a self) -> RefMut<'a, Option<(Url, bool)>> {
|
||||||
|
self.url.borrow_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn frame<'a>(&'a self) -> Ref<'a, Option<Frame>> {
|
||||||
|
self.frame.borrow()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mut_frame<'a>(&'a self) -> RefMut<'a, Option<Frame>> {
|
||||||
|
self.frame.borrow_mut()
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds the given damage.
|
/// Adds the given damage.
|
||||||
pub fn damage(&mut self, level: DocumentDamageLevel) {
|
pub fn damage(&self, level: DocumentDamageLevel) {
|
||||||
let root = match self.frame {
|
let frame = self.frame();
|
||||||
|
let root = match *frame.get() {
|
||||||
None => return,
|
None => return,
|
||||||
Some(ref frame) => frame.document.get().GetDocumentElement()
|
Some(ref frame) => frame.document.get().GetDocumentElement()
|
||||||
};
|
};
|
||||||
|
@ -245,7 +288,8 @@ impl Page {
|
||||||
None => {},
|
None => {},
|
||||||
Some(root) => {
|
Some(root) => {
|
||||||
let root: JS<Node> = NodeCast::from(&root);
|
let root: JS<Node> = NodeCast::from(&root);
|
||||||
match self.damage {
|
let mut damage = self.damage.borrow_mut();
|
||||||
|
match *damage.get() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ref mut damage) => {
|
Some(ref mut damage) => {
|
||||||
// FIXME(pcwalton): This is wrong. We should trace up to the nearest ancestor.
|
// FIXME(pcwalton): This is wrong. We should trace up to the nearest ancestor.
|
||||||
|
@ -255,7 +299,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.damage = Some(DocumentDamage {
|
*damage.get() = Some(DocumentDamage {
|
||||||
root: root.to_trusted_node_address(),
|
root: root.to_trusted_node_address(),
|
||||||
level: level,
|
level: level,
|
||||||
})
|
})
|
||||||
|
@ -264,14 +308,16 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
self.url.get_ref().first().clone()
|
let url = self.url();
|
||||||
|
url.get().get_ref().first().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
/// Sends a ping to layout and waits for the response. The response will arrive when the
|
||||||
/// layout task has finished any pending request messages.
|
/// layout task has finished any pending request messages.
|
||||||
pub fn join_layout(&mut self) {
|
pub fn join_layout(&self) {
|
||||||
if self.layout_join_port.is_some() {
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
let join_port = replace(&mut self.layout_join_port, None);
|
if layout_join_port.get().is_some() {
|
||||||
|
let join_port = replace(layout_join_port.get(), None);
|
||||||
match join_port {
|
match join_port {
|
||||||
Some(ref join_port) => {
|
Some(ref join_port) => {
|
||||||
match join_port.try_recv() {
|
match join_port.try_recv() {
|
||||||
|
@ -290,7 +336,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends the given query to layout.
|
/// Sends the given query to layout.
|
||||||
pub fn query_layout<T: Send>(&mut self,
|
pub fn query_layout<T: Send>(&self,
|
||||||
query: LayoutQuery,
|
query: LayoutQuery,
|
||||||
response_port: Port<T>)
|
response_port: Port<T>)
|
||||||
-> T {
|
-> T {
|
||||||
|
@ -306,11 +352,12 @@ impl Page {
|
||||||
/// If there is no window size yet, the page is presumed invisible and no reflow is performed.
|
/// If there is no window size yet, the page is presumed invisible and no reflow is performed.
|
||||||
///
|
///
|
||||||
/// This function fails if there is no root frame.
|
/// This function fails if there is no root frame.
|
||||||
pub fn reflow(&mut self,
|
pub fn reflow(&self,
|
||||||
goal: ReflowGoal,
|
goal: ReflowGoal,
|
||||||
script_chan: ScriptChan,
|
script_chan: ScriptChan,
|
||||||
compositor: @ScriptListener) {
|
compositor: &ScriptListener) {
|
||||||
let root = match self.frame {
|
let frame = self.frame();
|
||||||
|
let root = match *frame.get() {
|
||||||
None => return,
|
None => return,
|
||||||
Some(ref frame) => {
|
Some(ref frame) => {
|
||||||
frame.document.get().GetDocumentElement()
|
frame.document.get().GetDocumentElement()
|
||||||
|
@ -330,21 +377,26 @@ impl Page {
|
||||||
|
|
||||||
// Layout will let us know when it's done.
|
// Layout will let us know when it's done.
|
||||||
let (join_port, join_chan) = Chan::new();
|
let (join_port, join_chan) = Chan::new();
|
||||||
self.layout_join_port = Some(join_port);
|
let mut layout_join_port = self.layout_join_port.borrow_mut();
|
||||||
|
*layout_join_port.get() = Some(join_port);
|
||||||
|
|
||||||
self.last_reflow_id += 1;
|
let mut last_reflow_id = self.last_reflow_id.borrow_mut();
|
||||||
|
*last_reflow_id.get() += 1;
|
||||||
|
|
||||||
|
let root: JS<Node> = NodeCast::from(&root);
|
||||||
|
let mut damage = self.damage.borrow_mut();
|
||||||
|
let window_size = self.window_size.borrow();
|
||||||
|
|
||||||
// Send new document and relevant styles to layout.
|
// Send new document and relevant styles to layout.
|
||||||
let root: JS<Node> = NodeCast::from(&root);
|
|
||||||
let reflow = ~Reflow {
|
let reflow = ~Reflow {
|
||||||
document_root: root.to_trusted_node_address(),
|
document_root: root.to_trusted_node_address(),
|
||||||
url: self.get_url(),
|
url: self.get_url(),
|
||||||
goal: goal,
|
goal: goal,
|
||||||
window_size: self.window_size,
|
window_size: *window_size.get(),
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
script_join_chan: join_chan,
|
script_join_chan: join_chan,
|
||||||
damage: replace(&mut self.damage, None).unwrap(),
|
damage: replace(damage.get(), None).unwrap(),
|
||||||
id: self.last_reflow_id,
|
id: *last_reflow_id.get(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.layout_chan.send(ReflowMsg(reflow));
|
self.layout_chan.send(ReflowMsg(reflow));
|
||||||
|
@ -354,14 +406,14 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initialize_js_info(&mut self, js_context: @Cx, global: *JSObject) {
|
pub fn initialize_js_info(&self, js_context: Rc<Cx>, global: *JSObject) {
|
||||||
assert!(global.is_not_null());
|
assert!(global.is_not_null());
|
||||||
|
|
||||||
// Note that the order that these variables are initialized is _not_ arbitrary. Switching
|
// Note that the order that these variables are initialized is _not_ arbitrary. Switching
|
||||||
// them around can -- and likely will -- lead to things breaking.
|
// them around can -- and likely will -- lead to things breaking.
|
||||||
|
|
||||||
js_context.set_default_options_and_version();
|
js_context.borrow().set_default_options_and_version();
|
||||||
js_context.set_logging_error_reporter();
|
js_context.borrow().set_logging_error_reporter();
|
||||||
|
|
||||||
let compartment = match js_context.new_compartment_with_global(global) {
|
let compartment = match js_context.new_compartment_with_global(global) {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
|
@ -370,17 +422,18 @@ impl Page {
|
||||||
|
|
||||||
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
|
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
|
||||||
let page_ptr = {
|
let page_ptr = {
|
||||||
let borrowed_page = &mut *self;
|
let borrowed_page = &*self;
|
||||||
borrowed_page as *mut Page
|
borrowed_page as *Page
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
js_context.set_cx_private(page_ptr as *());
|
js_context.borrow().set_cx_private(page_ptr as *());
|
||||||
|
|
||||||
JS_InhibitGC(js_context.ptr);
|
JS_InhibitGC(js_context.borrow().ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.js_info = Some(JSPageInfo {
|
let mut js_info = self.mut_js_info();
|
||||||
|
*js_info.get() = Some(JSPageInfo {
|
||||||
dom_static: GlobalStaticData(),
|
dom_static: GlobalStaticData(),
|
||||||
js_compartment: compartment,
|
js_compartment: compartment,
|
||||||
js_context: js_context,
|
js_context: js_context,
|
||||||
|
@ -402,9 +455,9 @@ pub struct JSPageInfo {
|
||||||
/// Global static data related to the DOM.
|
/// Global static data related to the DOM.
|
||||||
dom_static: GlobalStaticData,
|
dom_static: GlobalStaticData,
|
||||||
/// The JavaScript compartment for the origin associated with the script task.
|
/// The JavaScript compartment for the origin associated with the script task.
|
||||||
js_compartment: @mut Compartment,
|
js_compartment: Rc<Compartment>,
|
||||||
/// The JavaScript context.
|
/// The JavaScript context.
|
||||||
js_context: @Cx,
|
js_context: Rc<Cx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
|
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
|
||||||
|
@ -413,7 +466,7 @@ pub struct JSPageInfo {
|
||||||
/// FIXME: Rename to `Page`, following WebKit?
|
/// FIXME: Rename to `Page`, following WebKit?
|
||||||
pub struct ScriptTask {
|
pub struct ScriptTask {
|
||||||
/// A handle to the information pertaining to page layout
|
/// A handle to the information pertaining to page layout
|
||||||
page_tree: PageTree,
|
page_tree: RefCell<PageTree>,
|
||||||
/// A handle to the image cache task.
|
/// A handle to the image cache task.
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
/// A handle to the resource task.
|
/// A handle to the resource task.
|
||||||
|
@ -428,25 +481,25 @@ pub struct ScriptTask {
|
||||||
/// For communicating load url messages to the constellation
|
/// For communicating load url messages to the constellation
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
/// A handle to the compositor for communicating ready state messages.
|
/// A handle to the compositor for communicating ready state messages.
|
||||||
compositor: @ScriptListener,
|
compositor: ~ScriptListener,
|
||||||
|
|
||||||
/// The JavaScript runtime.
|
/// The JavaScript runtime.
|
||||||
js_runtime: js::rust::rt,
|
js_runtime: js::rust::rt,
|
||||||
|
|
||||||
mouse_over_targets: Option<~[JS<Node>]>
|
mouse_over_targets: RefCell<Option<~[JS<Node>]>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the relevant page from the associated JS Context.
|
/// Returns the relevant page from the associated JS Context.
|
||||||
pub fn page_from_context(js_context: *JSContext) -> *mut Page {
|
pub fn page_from_context(js_context: *JSContext) -> *Page {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_GetContextPrivate(js_context) as *mut Page
|
JS_GetContextPrivate(js_context) as *Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScriptTask {
|
impl ScriptTask {
|
||||||
/// Creates a new script task.
|
/// Creates a new script task.
|
||||||
pub fn new(id: PipelineId,
|
pub fn new(id: PipelineId,
|
||||||
compositor: @ScriptListener,
|
compositor: ~ScriptListener,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
port: Port<ScriptMsg>,
|
port: Port<ScriptMsg>,
|
||||||
chan: ScriptChan,
|
chan: ScriptChan,
|
||||||
|
@ -454,11 +507,12 @@ impl ScriptTask {
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
window_size: Size2D<uint>)
|
window_size: Size2D<uint>)
|
||||||
-> @mut ScriptTask {
|
-> Rc<ScriptTask> {
|
||||||
let js_runtime = js::rust::rt();
|
let js_runtime = js::rust::rt();
|
||||||
|
|
||||||
let script_task = @mut ScriptTask {
|
unsafe {
|
||||||
page_tree: PageTree::new(id, layout_chan, window_size),
|
Rc::new_unchecked(ScriptTask {
|
||||||
|
page_tree: RefCell::new(PageTree::new(id, layout_chan, window_size)),
|
||||||
|
|
||||||
image_cache_task: img_cache_task,
|
image_cache_task: img_cache_task,
|
||||||
resource_task: resource_task,
|
resource_task: resource_task,
|
||||||
|
@ -469,15 +523,14 @@ impl ScriptTask {
|
||||||
compositor: compositor,
|
compositor: compositor,
|
||||||
|
|
||||||
js_runtime: js_runtime,
|
js_runtime: js_runtime,
|
||||||
mouse_over_targets:None
|
mouse_over_targets: RefCell::new(None)
|
||||||
};
|
})
|
||||||
|
}
|
||||||
script_task
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Starts the script task. After calling this method, the script task will loop receiving
|
/// Starts the script task. After calling this method, the script task will loop receiving
|
||||||
/// messages on its port.
|
/// messages on its port.
|
||||||
pub fn start(&mut self) {
|
pub fn start(&self) {
|
||||||
while self.handle_msgs() {
|
while self.handle_msgs() {
|
||||||
// Go on...
|
// Go on...
|
||||||
}
|
}
|
||||||
|
@ -485,7 +538,7 @@ impl ScriptTask {
|
||||||
|
|
||||||
pub fn create<C:ScriptListener + Send>(
|
pub fn create<C:ScriptListener + Send>(
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
compositor: C,
|
compositor: ~C,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
port: Port<ScriptMsg>,
|
port: Port<ScriptMsg>,
|
||||||
chan: ScriptChan,
|
chan: ScriptChan,
|
||||||
|
@ -499,7 +552,7 @@ impl ScriptTask {
|
||||||
builder.name("ScriptTask");
|
builder.name("ScriptTask");
|
||||||
builder.spawn(proc() {
|
builder.spawn(proc() {
|
||||||
let script_task = ScriptTask::new(id,
|
let script_task = ScriptTask::new(id,
|
||||||
@compositor as @ScriptListener,
|
compositor as ~ScriptListener,
|
||||||
layout_chan,
|
layout_chan,
|
||||||
port,
|
port,
|
||||||
chan,
|
chan,
|
||||||
|
@ -507,24 +560,31 @@ impl ScriptTask {
|
||||||
resource_task,
|
resource_task,
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
window_size);
|
window_size);
|
||||||
script_task.start();
|
script_task.borrow().start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle incoming control messages.
|
/// Handle incoming control messages.
|
||||||
fn handle_msgs(&mut self) -> bool {
|
fn handle_msgs(&self) -> bool {
|
||||||
// Handle pending resize events.
|
// Handle pending resize events.
|
||||||
// Gather them first to avoid a double mut borrow on self.
|
// Gather them first to avoid a double mut borrow on self.
|
||||||
let mut resizes = ~[];
|
let mut resizes = ~[];
|
||||||
for page in self.page_tree.iter() {
|
|
||||||
|
{
|
||||||
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
|
for page in page_tree.get().iter() {
|
||||||
// Only process a resize if layout is idle.
|
// Only process a resize if layout is idle.
|
||||||
if page.layout_join_port.is_none() {
|
let page = page.borrow();
|
||||||
match page.resize_event.take() {
|
let layout_join_port = page.layout_join_port.borrow();
|
||||||
|
if layout_join_port.get().is_none() {
|
||||||
|
let mut resize_event = page.resize_event.borrow_mut();
|
||||||
|
match resize_event.get().take() {
|
||||||
Some(size) => resizes.push((page.id, size)),
|
Some(size) => resizes.push((page.id, size)),
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (id, Size2D { width, height }) in resizes.move_iter() {
|
for (id, Size2D { width, height }) in resizes.move_iter() {
|
||||||
self.handle_event(id, ResizeEvent(width, height));
|
self.handle_event(id, ResizeEvent(width, height));
|
||||||
|
@ -539,8 +599,10 @@ impl ScriptTask {
|
||||||
loop {
|
loop {
|
||||||
match event {
|
match event {
|
||||||
ResizeMsg(id, size) => {
|
ResizeMsg(id, size) => {
|
||||||
let page = self.page_tree.find(id).expect("resize sent to nonexistent pipeline").page;
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
page.resize_event = Some(size);
|
let page = page_tree.get().find(id).expect("resize sent to nonexistent pipeline").page();
|
||||||
|
let mut resize_event = page.resize_event.borrow_mut();
|
||||||
|
*resize_event.get() = Some(size);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
sequential.push(event);
|
sequential.push(event);
|
||||||
|
@ -573,7 +635,7 @@ impl ScriptTask {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_new_layout(&mut 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_id,
|
||||||
|
@ -581,33 +643,40 @@ impl ScriptTask {
|
||||||
layout_chan
|
layout_chan
|
||||||
} = new_layout_info;
|
} = new_layout_info;
|
||||||
|
|
||||||
let parent_page_tree = self.page_tree.find(old_id).expect("ScriptTask: received a layout
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
|
let parent_page_tree = page_tree.get().find(old_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_tree = PageTree::new(new_id, layout_chan, parent_page_tree.page.window_size);
|
let new_page_tree = {
|
||||||
|
let window_size = parent_page_tree.page().window_size.borrow();
|
||||||
|
PageTree::new(new_id, layout_chan, *window_size.get())
|
||||||
|
};
|
||||||
parent_page_tree.inner.push(new_page_tree);
|
parent_page_tree.inner.push(new_page_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a timer that fired.
|
/// Handles a timer that fired.
|
||||||
fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) {
|
fn handle_fire_timer_msg(&self, id: PipelineId, timer_data: ~TimerData) {
|
||||||
let page = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
pipeline ID not associated with this script task. This is a bug.").page;
|
let page = page_tree.get().find(id).expect("ScriptTask: received fire timer msg for a
|
||||||
let mut window = page.frame.get_ref().window.clone();
|
pipeline ID not associated with this script task. This is a bug.").page();
|
||||||
|
let frame = page.frame();
|
||||||
|
let mut window = frame.get().get_ref().window.clone();
|
||||||
if !window.get().active_timers.contains(&TimerHandle { handle: timer_data.handle, cancel_chan: None }) {
|
if !window.get().active_timers.contains(&TimerHandle { handle: timer_data.handle, cancel_chan: None }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.get_mut().active_timers.remove(&TimerHandle { handle: timer_data.handle, cancel_chan: None });
|
window.get_mut().active_timers.remove(&TimerHandle { handle: timer_data.handle, cancel_chan: None });
|
||||||
|
let js_info = page.js_info();
|
||||||
let this_value = if timer_data.args.len() > 0 {
|
let this_value = if timer_data.args.len() > 0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
RUST_JSVAL_TO_OBJECT(timer_data.args[0])
|
RUST_JSVAL_TO_OBJECT(timer_data.args[0])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
page.js_info.get_ref().js_compartment.global_obj.ptr
|
js_info.get().get_ref().js_compartment.borrow().global_obj.borrow().ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Support extra arguments. This requires passing a `*JSVal` array as `argv`.
|
// TODO: Support extra arguments. This requires passing a `*JSVal` array as `argv`.
|
||||||
let rval = JSVAL_NULL;
|
let rval = JSVAL_NULL;
|
||||||
let cx = page.js_info.get_ref().js_context.ptr;
|
let cx = js_info.get().get_ref().js_context.borrow().ptr;
|
||||||
with_gc_enabled(cx, || {
|
with_gc_enabled(cx, || {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_CallFunctionValue(cx, this_value, timer_data.funval, 0, ptr::null(), &rval);
|
JS_CallFunctionValue(cx, this_value, timer_data.funval, 0, ptr::null(), &rval);
|
||||||
|
@ -616,13 +685,16 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a notification that reflow completed.
|
/// Handles a notification that reflow completed.
|
||||||
fn handle_reflow_complete_msg(&mut self, pipeline_id: PipelineId, reflow_id: uint) {
|
fn handle_reflow_complete_msg(&self, pipeline_id: PipelineId, reflow_id: uint) {
|
||||||
debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id);
|
debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id);
|
||||||
let page_tree = self.page_tree.find(pipeline_id).expect(
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
|
let page = page_tree.get().find(pipeline_id).expect(
|
||||||
"ScriptTask: received a load message for a layout channel that is not associated \
|
"ScriptTask: received a load message for a layout channel that is not associated \
|
||||||
with this script task. This is a bug.");
|
with this script task. This is a bug.").page();
|
||||||
if page_tree.page.last_reflow_id == reflow_id {
|
let last_reflow_id = page.last_reflow_id.borrow();
|
||||||
page_tree.page.layout_join_port = None;
|
if *last_reflow_id.get() == reflow_id {
|
||||||
|
let mut layout_join_port = page.layout_join_port.borrow_mut();
|
||||||
|
*layout_join_port.get() = None;
|
||||||
}
|
}
|
||||||
self.compositor.set_ready_state(FinishedLoading);
|
self.compositor.set_ready_state(FinishedLoading);
|
||||||
}
|
}
|
||||||
|
@ -634,13 +706,16 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Window was resized, but this script was not active, so don't reflow yet
|
/// Window was resized, but this script was not active, so don't reflow yet
|
||||||
fn handle_resize_inactive_msg(&mut self, id: PipelineId, new_size: Size2D<uint>) {
|
fn handle_resize_inactive_msg(&self, id: PipelineId, new_size: Size2D<uint>) {
|
||||||
let page = self.page_tree.find(id).expect("Received resize message for PipelineId not associated
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
with a page in the page tree. This is a bug.").page;
|
let page = page_tree.get().find(id).expect("Received resize message for PipelineId not associated
|
||||||
page.window_size = new_size;
|
with a page in the page tree. This is a bug.").page();
|
||||||
let last_loaded_url = replace(&mut page.url, None);
|
let mut window_size = page.window_size.borrow_mut();
|
||||||
|
*window_size.get() = new_size;
|
||||||
|
let mut page_url = page.mut_url();
|
||||||
|
let last_loaded_url = replace(page_url.get(), None);
|
||||||
for url in last_loaded_url.iter() {
|
for url in last_loaded_url.iter() {
|
||||||
page.url = Some((url.first(), true));
|
*page_url.get() = Some((url.first(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +724,7 @@ impl ScriptTask {
|
||||||
/// constellation to shut down the pipeline, which will clean everything up
|
/// constellation to shut down the pipeline, which will clean everything up
|
||||||
/// normally. If we do exit, we will tear down the DOM nodes, possibly at a point
|
/// normally. If we do exit, we will tear down the DOM nodes, possibly at a point
|
||||||
/// where layout is still accessing them.
|
/// where layout is still accessing them.
|
||||||
fn handle_exit_window_msg(&mut self, _: PipelineId) {
|
fn handle_exit_window_msg(&self, _: PipelineId) {
|
||||||
debug!("script task handling exit window msg");
|
debug!("script task handling exit window msg");
|
||||||
|
|
||||||
// TODO(tkuehn): currently there is only one window,
|
// TODO(tkuehn): currently there is only one window,
|
||||||
|
@ -660,10 +735,12 @@ impl ScriptTask {
|
||||||
|
|
||||||
/// Handles a request to exit the script task and shut down layout.
|
/// Handles a request to exit the script task and shut down layout.
|
||||||
/// Returns true if the script task should shut down and false otherwise.
|
/// Returns true if the script task should shut down and false otherwise.
|
||||||
fn handle_exit_pipeline_msg(&mut self, id: PipelineId) -> bool {
|
fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool {
|
||||||
// If root is being exited, shut down all pages
|
// If root is being exited, shut down all pages
|
||||||
if self.page_tree.page.id == id {
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
for page in self.page_tree.iter() {
|
if page_tree.get().page().id == id {
|
||||||
|
for page in page_tree.get().iter() {
|
||||||
|
let page = page.borrow();
|
||||||
debug!("shutting down layout for root page {:?}", page.id);
|
debug!("shutting down layout for root page {:?}", page.id);
|
||||||
shut_down_layout(page)
|
shut_down_layout(page)
|
||||||
}
|
}
|
||||||
|
@ -671,9 +748,10 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise find just the matching page and exit all sub-pages
|
// otherwise find just the matching page and exit all sub-pages
|
||||||
match self.page_tree.remove(id) {
|
match page_tree.get().remove(id) {
|
||||||
Some(ref mut page_tree) => {
|
Some(ref mut page_tree) => {
|
||||||
for page in page_tree.iter() {
|
for page in page_tree.iter() {
|
||||||
|
let page = page.borrow();
|
||||||
debug!("shutting down layout for page {:?}", page.id);
|
debug!("shutting down layout for page {:?}", page.id);
|
||||||
shut_down_layout(page)
|
shut_down_layout(page)
|
||||||
}
|
}
|
||||||
|
@ -689,17 +767,22 @@ impl ScriptTask {
|
||||||
|
|
||||||
/// The entry point to document loading. Defines bindings, sets up the window and document
|
/// The entry point to document loading. Defines bindings, sets up the window and document
|
||||||
/// objects, parses HTML and CSS, and kicks off initial layout.
|
/// objects, parses HTML and CSS, and kicks off initial layout.
|
||||||
fn load(&mut self, pipeline_id: PipelineId, url: Url) {
|
fn load(&self, pipeline_id: PipelineId, url: Url) {
|
||||||
debug!("ScriptTask: loading {:?} on page {:?}", url, pipeline_id);
|
debug!("ScriptTask: loading {:?} on page {:?}", url, pipeline_id);
|
||||||
|
|
||||||
let page = self.page_tree.find(pipeline_id).expect("ScriptTask: received a load
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
|
let page_tree = page_tree.get().find(pipeline_id).expect("ScriptTask: received a load
|
||||||
message for a layout channel that is not associated with this script task. This
|
message for a layout channel that is not associated with this script task. This
|
||||||
is a bug.").page;
|
is a bug.");
|
||||||
let last_loaded_url = replace(&mut page.url, None);
|
let page = page_tree.page();
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut page_url = page.mut_url();
|
||||||
|
let last_loaded_url = replace(page_url.get(), None);
|
||||||
for loaded in last_loaded_url.iter() {
|
for loaded in last_loaded_url.iter() {
|
||||||
let (ref loaded, needs_reflow) = *loaded;
|
let (ref loaded, needs_reflow) = *loaded;
|
||||||
if *loaded == url {
|
if *loaded == url {
|
||||||
page.url = Some((loaded.clone(), false));
|
*page_url.get() = Some((loaded.clone(), false));
|
||||||
if needs_reflow {
|
if needs_reflow {
|
||||||
page.damage(ContentChangedDocumentDamage);
|
page.damage(ContentChangedDocumentDamage);
|
||||||
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
|
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
|
||||||
|
@ -707,38 +790,46 @@ impl ScriptTask {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let cx = self.js_runtime.cx();
|
let cx = self.js_runtime.cx();
|
||||||
// Create the window and document objects.
|
// Create the window and document objects.
|
||||||
let window = Window::new(cx.ptr,
|
let window = Window::new(cx.borrow().ptr,
|
||||||
page,
|
page_tree.page.clone(),
|
||||||
self.chan.clone(),
|
self.chan.clone(),
|
||||||
self.compositor,
|
self.compositor.dup(),
|
||||||
self.image_cache_task.clone());
|
self.image_cache_task.clone());
|
||||||
page.initialize_js_info(cx, window.reflector().get_jsobject());
|
page.initialize_js_info(cx.clone(), window.reflector().get_jsobject());
|
||||||
|
|
||||||
RegisterBindings::Register(page.js_info.get_ref().js_compartment);
|
{
|
||||||
|
let mut js_info = page.mut_js_info();
|
||||||
|
RegisterBindings::Register(js_info.get().get_mut_ref());
|
||||||
|
}
|
||||||
|
|
||||||
self.compositor.set_ready_state(Loading);
|
self.compositor.set_ready_state(Loading);
|
||||||
// Parse HTML.
|
// Parse HTML.
|
||||||
//
|
//
|
||||||
// Note: We can parse the next document in parallel with any previous documents.
|
// Note: We can parse the next document in parallel with any previous documents.
|
||||||
let mut document = Document::new(&window, Some(url.clone()), HTMLDocument, None);
|
let mut document = Document::new(&window, Some(url.clone()), HTMLDocument, None);
|
||||||
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
|
let next_subpage_id = page.next_subpage_id.borrow();
|
||||||
|
let html_parsing_result = hubbub_html_parser::parse_html(page,
|
||||||
&mut document,
|
&mut document,
|
||||||
url.clone(),
|
url.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
page.next_subpage_id.clone());
|
next_subpage_id.get().clone());
|
||||||
|
|
||||||
let HtmlParserResult {
|
let HtmlParserResult {
|
||||||
discovery_port
|
discovery_port
|
||||||
} = html_parsing_result;
|
} = html_parsing_result;
|
||||||
|
|
||||||
|
{
|
||||||
// Create the root frame.
|
// Create the root frame.
|
||||||
page.frame = Some(Frame {
|
let mut frame = page.mut_frame();
|
||||||
|
*frame.get() = Some(Frame {
|
||||||
document: document.clone(),
|
document: document.clone(),
|
||||||
window: window.clone(),
|
window: window.clone(),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Send style sheets over to layout.
|
// Send style sheets over to layout.
|
||||||
//
|
//
|
||||||
|
@ -756,7 +847,8 @@ impl ScriptTask {
|
||||||
page.layout_chan.send(AddStylesheetMsg(sheet));
|
page.layout_chan.send(AddStylesheetMsg(sheet));
|
||||||
}
|
}
|
||||||
Some(HtmlDiscoveredIFrame((iframe_url, subpage_id, sandboxed))) => {
|
Some(HtmlDiscoveredIFrame((iframe_url, subpage_id, sandboxed))) => {
|
||||||
page.next_subpage_id = SubpageId(*subpage_id + 1);
|
let mut next_subpage_id = page.next_subpage_id.borrow_mut();
|
||||||
|
*next_subpage_id.get() = SubpageId(*subpage_id + 1);
|
||||||
let sandboxed = if sandboxed {
|
let sandboxed = if sandboxed {
|
||||||
IFrameSandboxed
|
IFrameSandboxed
|
||||||
} else {
|
} else {
|
||||||
|
@ -776,8 +868,11 @@ impl ScriptTask {
|
||||||
|
|
||||||
let fragment = url.fragment.as_ref().map(|ref fragment| fragment.to_owned());
|
let fragment = url.fragment.as_ref().map(|ref fragment| fragment.to_owned());
|
||||||
|
|
||||||
|
{
|
||||||
// No more reflow required
|
// No more reflow required
|
||||||
page.url = Some((url.clone(), false));
|
let mut page_url = page.mut_url();
|
||||||
|
*page_url.get() = Some((url.clone(), false));
|
||||||
|
}
|
||||||
|
|
||||||
// Receive the JavaScript scripts.
|
// Receive the JavaScript scripts.
|
||||||
assert!(js_scripts.is_some());
|
assert!(js_scripts.is_some());
|
||||||
|
@ -785,14 +880,24 @@ impl ScriptTask {
|
||||||
debug!("js_scripts: {:?}", js_scripts);
|
debug!("js_scripts: {:?}", js_scripts);
|
||||||
|
|
||||||
// Define debug functions.
|
// Define debug functions.
|
||||||
let compartment = page.js_info.get_ref().js_compartment;
|
let cx = {
|
||||||
let cx = page.js_info.get_ref().js_context;
|
let js_info = page.js_info();
|
||||||
compartment.define_functions(debug_fns);
|
let js_info = js_info.get().get_ref();
|
||||||
|
let compartment = js_info.js_compartment.borrow();
|
||||||
|
compartment.define_functions(DEBUG_FNS);
|
||||||
|
|
||||||
|
js_info.js_context.borrow().ptr
|
||||||
|
};
|
||||||
|
|
||||||
// Evaluate every script in the document.
|
// Evaluate every script in the document.
|
||||||
for file in js_scripts.iter() {
|
for file in js_scripts.iter() {
|
||||||
with_gc_enabled(cx.ptr, || {
|
with_gc_enabled(cx, || {
|
||||||
cx.evaluate_script(compartment.global_obj,
|
let (cx, global_obj) = {
|
||||||
|
let js_info = page.js_info();
|
||||||
|
(js_info.get().get_ref().js_context.clone(),
|
||||||
|
js_info.get().get_ref().js_compartment.borrow().global_obj.clone())
|
||||||
|
};
|
||||||
|
cx.borrow().evaluate_script(global_obj,
|
||||||
file.data.clone(),
|
file.data.clone(),
|
||||||
file.url.to_str(),
|
file.url.to_str(),
|
||||||
1);
|
1);
|
||||||
|
@ -809,13 +914,15 @@ impl ScriptTask {
|
||||||
let winclone = wintarget.clone();
|
let winclone = wintarget.clone();
|
||||||
wintarget.get_mut().dispatch_event_with_target(&winclone, Some(doctarget), &mut event);
|
wintarget.get_mut().dispatch_event_with_target(&winclone, Some(doctarget), &mut event);
|
||||||
|
|
||||||
page.fragment_node = fragment.map_default(None, |fragid| self.find_fragment_node(page, fragid));
|
let mut fragment_node = page.fragment_node.borrow_mut();
|
||||||
|
*fragment_node.get() = fragment.map_default(None, |fragid| self.find_fragment_node(page, fragid));
|
||||||
|
|
||||||
self.constellation_chan.send(LoadCompleteMsg(page.id, url));
|
self.constellation_chan.send(LoadCompleteMsg(page.id, url));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_fragment_node(&self, page: &mut Page, fragid: ~str) -> Option<JS<Element>> {
|
fn find_fragment_node(&self, page: &Page, fragid: ~str) -> Option<JS<Element>> {
|
||||||
let document = page.frame.get_ref().document.clone();
|
let frame = page.frame();
|
||||||
|
let document = frame.get().get_ref().document.clone();
|
||||||
match document.get().GetElementById(fragid.to_owned()) {
|
match document.get().GetElementById(fragid.to_owned()) {
|
||||||
Some(node) => Some(node),
|
Some(node) => Some(node),
|
||||||
None => {
|
None => {
|
||||||
|
@ -831,7 +938,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_fragment_point(&self, pipeline_id: PipelineId, page: &mut Page, node: JS<Element>) {
|
fn scroll_fragment_point(&self, pipeline_id: PipelineId, page: &Page, node: JS<Element>) {
|
||||||
let (port, chan) = Chan::new();
|
let (port, chan) = Chan::new();
|
||||||
let node: JS<Node> = NodeCast::from(&node);
|
let node: JS<Node> = NodeCast::from(&node);
|
||||||
match page.query_layout(ContentBoxQuery(node.to_trusted_node_address(), chan), port) {
|
match page.query_layout(ContentBoxQuery(node.to_trusted_node_address(), chan), port) {
|
||||||
|
@ -846,27 +953,37 @@ impl ScriptTask {
|
||||||
/// This is the main entry point for receiving and dispatching DOM events.
|
/// This is the main entry point for receiving and dispatching DOM events.
|
||||||
///
|
///
|
||||||
/// TODO: Actually perform DOM event dispatch.
|
/// TODO: Actually perform DOM event dispatch.
|
||||||
fn handle_event(&mut self, pipeline_id: PipelineId, event: Event_) {
|
fn handle_event(&self, pipeline_id: PipelineId, event: Event_) {
|
||||||
let page = self.page_tree.find(pipeline_id).expect("ScriptTask: received an event
|
let mut page_tree = self.page_tree.borrow_mut();
|
||||||
|
let page = page_tree.get().find(pipeline_id).expect("ScriptTask: received an event
|
||||||
message for a layout channel that is not associated with this script task. This
|
message for a layout channel that is not associated with this script task. This
|
||||||
is a bug.").page;
|
is a bug.").page();
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
ResizeEvent(new_width, new_height) => {
|
ResizeEvent(new_width, new_height) => {
|
||||||
debug!("script got resize event: {:u}, {:u}", new_width, new_height);
|
debug!("script got resize event: {:u}, {:u}", new_width, new_height);
|
||||||
|
|
||||||
page.window_size = Size2D(new_width, new_height);
|
{
|
||||||
|
let mut window_size = page.window_size.borrow_mut();
|
||||||
|
*window_size.get() = Size2D(new_width, new_height);
|
||||||
|
}
|
||||||
|
|
||||||
if page.frame.is_some() {
|
{
|
||||||
|
let frame = page.frame();
|
||||||
|
if frame.get().is_some() {
|
||||||
page.damage(ReflowDocumentDamage);
|
page.damage(ReflowDocumentDamage);
|
||||||
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor)
|
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor)
|
||||||
}
|
}
|
||||||
match page.fragment_node.take() {
|
}
|
||||||
|
|
||||||
|
let mut fragment_node = page.fragment_node.borrow_mut();
|
||||||
|
match fragment_node.get().take() {
|
||||||
Some(node) => self.scroll_fragment_point(pipeline_id, page, node),
|
Some(node) => self.scroll_fragment_point(pipeline_id, page, node),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
match page.frame {
|
let frame = page.frame();
|
||||||
|
match *frame.get() {
|
||||||
Some(ref frame) => {
|
Some(ref frame) => {
|
||||||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
||||||
|
@ -888,7 +1005,8 @@ impl ScriptTask {
|
||||||
ReflowEvent => {
|
ReflowEvent => {
|
||||||
debug!("script got reflow event");
|
debug!("script got reflow event");
|
||||||
|
|
||||||
if page.frame.is_some() {
|
let frame = page.frame();
|
||||||
|
if frame.get().is_some() {
|
||||||
page.damage(MatchSelectorsDocumentDamage);
|
page.damage(MatchSelectorsDocumentDamage);
|
||||||
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor)
|
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor)
|
||||||
}
|
}
|
||||||
|
@ -897,7 +1015,8 @@ impl ScriptTask {
|
||||||
ClickEvent(_button, point) => {
|
ClickEvent(_button, point) => {
|
||||||
debug!("ClickEvent: clicked at {:?}", point);
|
debug!("ClickEvent: clicked at {:?}", point);
|
||||||
|
|
||||||
let document = page.frame.get_ref().document.clone();
|
let frame = page.frame();
|
||||||
|
let document = frame.get().get_ref().document.clone();
|
||||||
let root = document.get().GetDocumentElement();
|
let root = document.get().GetDocumentElement();
|
||||||
if root.is_none() {
|
if root.is_none() {
|
||||||
return;
|
return;
|
||||||
|
@ -908,7 +1027,7 @@ impl ScriptTask {
|
||||||
Ok(HitTestResponse(node_address)) => {
|
Ok(HitTestResponse(node_address)) => {
|
||||||
debug!("node address is {:?}", node_address);
|
debug!("node address is {:?}", node_address);
|
||||||
let mut node: JS<Node> =
|
let mut node: JS<Node> =
|
||||||
NodeHelpers::from_untrusted_node_address(self.js_runtime.ptr,
|
NodeHelpers::from_untrusted_node_address(self.js_runtime.borrow().ptr,
|
||||||
node_address);
|
node_address);
|
||||||
debug!("clicked on {:s}", node.debug_str());
|
debug!("clicked on {:s}", node.debug_str());
|
||||||
|
|
||||||
|
@ -934,7 +1053,8 @@ impl ScriptTask {
|
||||||
MouseDownEvent(..) => {}
|
MouseDownEvent(..) => {}
|
||||||
MouseUpEvent(..) => {}
|
MouseUpEvent(..) => {}
|
||||||
MouseMoveEvent(point) => {
|
MouseMoveEvent(point) => {
|
||||||
let document = page.frame.get_ref().document.clone();
|
let frame = page.frame();
|
||||||
|
let document = frame.get().get_ref().document.clone();
|
||||||
let root = document.get().GetDocumentElement();
|
let root = document.get().GetDocumentElement();
|
||||||
if root.is_none() {
|
if root.is_none() {
|
||||||
return;
|
return;
|
||||||
|
@ -947,7 +1067,8 @@ impl ScriptTask {
|
||||||
let mut target_list: ~[JS<Node>] = ~[];
|
let mut target_list: ~[JS<Node>] = ~[];
|
||||||
let mut target_compare = false;
|
let mut target_compare = false;
|
||||||
|
|
||||||
match self.mouse_over_targets {
|
let mut mouse_over_targets = self.mouse_over_targets.borrow_mut();
|
||||||
|
match *mouse_over_targets.get() {
|
||||||
Some(ref mut mouse_over_targets) => {
|
Some(ref mut mouse_over_targets) => {
|
||||||
for node in mouse_over_targets.mut_iter() {
|
for node in mouse_over_targets.mut_iter() {
|
||||||
node.set_hover_state(false);
|
node.set_hover_state(false);
|
||||||
|
@ -959,7 +1080,7 @@ impl ScriptTask {
|
||||||
for node_address in node_address.iter() {
|
for node_address in node_address.iter() {
|
||||||
let mut node: JS<Node> =
|
let mut node: JS<Node> =
|
||||||
NodeHelpers::from_untrusted_node_address(
|
NodeHelpers::from_untrusted_node_address(
|
||||||
self.js_runtime.ptr, *node_address);
|
self.js_runtime.borrow().ptr, *node_address);
|
||||||
// Traverse node generations until a node that is an element is
|
// Traverse node generations until a node that is an element is
|
||||||
// found.
|
// found.
|
||||||
while !node.is_element() {
|
while !node.is_element() {
|
||||||
|
@ -972,7 +1093,7 @@ impl ScriptTask {
|
||||||
if node.is_element() {
|
if node.is_element() {
|
||||||
node.set_hover_state(true);
|
node.set_hover_state(true);
|
||||||
|
|
||||||
match self.mouse_over_targets {
|
match *mouse_over_targets.get() {
|
||||||
Some(ref mouse_over_targets) => {
|
Some(ref mouse_over_targets) => {
|
||||||
if !target_compare {
|
if !target_compare {
|
||||||
target_compare = !mouse_over_targets.contains(&node);
|
target_compare = !mouse_over_targets.contains(&node);
|
||||||
|
@ -983,7 +1104,7 @@ impl ScriptTask {
|
||||||
target_list.push(node);
|
target_list.push(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match self.mouse_over_targets {
|
match *mouse_over_targets.get() {
|
||||||
Some(ref mouse_over_targets) => {
|
Some(ref mouse_over_targets) => {
|
||||||
if mouse_over_targets.len() != target_list.len() {
|
if mouse_over_targets.len() != target_list.len() {
|
||||||
target_compare = true;
|
target_compare = true;
|
||||||
|
@ -993,11 +1114,11 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
if target_compare {
|
if target_compare {
|
||||||
if self.mouse_over_targets.is_some() {
|
if mouse_over_targets.get().is_some() {
|
||||||
page.damage(MatchSelectorsDocumentDamage);
|
page.damage(MatchSelectorsDocumentDamage);
|
||||||
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
|
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
|
||||||
}
|
}
|
||||||
self.mouse_over_targets = Some(target_list);
|
*mouse_over_targets.get() = Some(target_list);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(()) => {},
|
Err(()) => {},
|
||||||
|
@ -1006,7 +1127,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_url_from_element(&self, page: @mut Page, element: &Element) {
|
fn load_url_from_element(&self, page: &Page, element: &Element) {
|
||||||
// if the node's element is "a," load url from href attr
|
// if the node's element is "a," load url from href attr
|
||||||
let attr = element.get_attribute(Null, "href");
|
let attr = element.get_attribute(Null, "href");
|
||||||
for href in attr.iter() {
|
for href in attr.iter() {
|
||||||
|
@ -1029,7 +1150,7 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shuts down layout for the given page.
|
/// Shuts down layout for the given page.
|
||||||
fn shut_down_layout(page: @mut Page) {
|
fn shut_down_layout(page: &Page) {
|
||||||
page.join_layout();
|
page.join_layout();
|
||||||
|
|
||||||
// Tell the layout task to begin shutting down.
|
// Tell the layout task to begin shutting down.
|
||||||
|
@ -1040,12 +1161,14 @@ fn shut_down_layout(page: @mut Page) {
|
||||||
// Destroy all nodes. Setting frame and js_info to None will trigger our
|
// Destroy all nodes. Setting frame and js_info to None will trigger our
|
||||||
// compartment to shutdown, run GC, etc.
|
// compartment to shutdown, run GC, etc.
|
||||||
|
|
||||||
|
let mut js_info = page.mut_js_info();
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_AllowGC(page.js_info.get_ref().js_context.ptr);
|
JS_AllowGC(js_info.get().get_ref().js_context.borrow().ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
page.frame = None;
|
let mut frame = page.mut_frame();
|
||||||
page.js_info = None;
|
*frame.get() = None;
|
||||||
|
*js_info.get() = None;
|
||||||
|
|
||||||
// Destroy the layout task. If there were node leaks, layout will now crash safely.
|
// Destroy the layout task. If there were node leaks, layout will now crash safely.
|
||||||
page.layout_chan.send(layout_interface::ExitNowMsg);
|
page.layout_chan.send(layout_interface::ExitNowMsg);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6a9db14da31271868090963067e1e689904e515d
|
Subproject commit b04df09b61a68ed47e4829045804173fc849f370
|
Loading…
Add table
Add a link
Reference in a new issue