Rename the content task to the script task

This commit is contained in:
Patrick Walton 2013-05-15 16:50:20 -07:00
parent 7caa209039
commit ad5bfd5297
21 changed files with 223 additions and 229 deletions

View file

@ -112,7 +112,7 @@ fn mainloop(po: Port<Msg>, dom_event_chan: SharedChan<Event>, opts: &Opts) {
let done = @mut false;
let resize_rate_limiter = @mut ResizeRateLimiter(dom_event_chan);
let check_for_messages: @fn() = || {
// Periodically check if content responded to our last resize event
// Periodically check if the script task responded to our last resize event
resize_rate_limiter.check_resize_response();
// Handle messages

View file

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*!
A little class that rate limits the number of resize events sent to the content task
based on how fast content dispatches those events. It waits until each event is handled
A little class that rate limits the number of resize events sent to the script task
based on how fast script dispatches those events. It waits until each event is handled
before sending the next. If the window is resized multiple times before an event is handled
then some events will never be sent.
*/
@ -41,7 +41,7 @@ pub impl ResizeRateLimiter {
self.next_resize_event = None;
} else {
if self.next_resize_event.is_some() {
warn!("osmain: content can't keep up. skipping resize event");
warn!("osmain: script task can't keep up. skipping resize event");
}
self.next_resize_event = Some((width, height));
}

View file

@ -1,7 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
type name_pool = {
};

View file

@ -2,18 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{task_from_context, global_content};
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::bindings::codegen::ClientRectBinding;
use dom::clientrect::ClientRect;
use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
use scripting::script_task::{task_from_context, global_script_context};
pub impl ClientRect {
pub fn init_wrapper(@mut self) {
let content = global_content();
let cx = content.compartment.get().cx.ptr;
let owner = content.window.get();
let script_context = global_script_context();
let cx = script_context.compartment.get().cx.ptr;
let owner = script_context.window.get();
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
self.wrap_object_shared(cx, scope);
@ -22,7 +22,9 @@ pub impl ClientRect {
impl CacheableWrapper for ClientRect {
fn get_wrappercache(&mut self) -> &mut WrapperCache {
unsafe { cast::transmute(&self.wrapper) }
unsafe {
cast::transmute(&self.wrapper)
}
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
@ -33,8 +35,10 @@ impl CacheableWrapper for ClientRect {
impl BindingObject for ClientRect {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { (*content).window.get() as @mut CacheableWrapper }
let script_context = task_from_context(cx);
unsafe {
(*script_context).window.get() as @mut CacheableWrapper
}
}
}

View file

@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{task_from_context, global_content};
use dom::bindings::codegen::ClientRectListBinding;
use dom::bindings::utils::{WrapperCache, CacheableWrapper, BindingObject};
use dom::clientrectlist::ClientRectList;
use js::jsapi::{JSObject, JSContext};
use scripting::script_task::{task_from_context, global_script_context};
pub impl ClientRectList {
fn init_wrapper(@mut self) {
let content = global_content();
let cx = content.compartment.get().cx.ptr;
let owner = content.window.get();
let script_context = global_script_context();
let cx = script_context.compartment.get().cx.ptr;
let owner = script_context.window.get();
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
self.wrap_object_shared(cx, scope);
@ -32,7 +32,7 @@ impl CacheableWrapper for ClientRectList {
impl BindingObject for ClientRectList {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { (*content).window.get() as @mut CacheableWrapper }
let script_context = task_from_context(cx);
unsafe { (*script_context).window.get() as @mut CacheableWrapper }
}
}

View file

@ -2435,8 +2435,8 @@ def CreateBindingJSObject(descriptor, parent):
if descriptor.proxy:
handler = """ //let cache = ptr::to_unsafe_ptr(aObject.get_wrappercache());
let content = task_from_context(aCx);
let handler = (*content).dom_static.proxy_handlers.get(&(prototypes::id::%s as uint));
let script_context = task_from_context(aCx);
let handler = (*script_context).dom_static.proxy_handlers.get(&(prototypes::id::%s as uint));
""" % descriptor.name
create = handler + """ let obj = NewProxyObject(aCx, *handler,
ptr::to_unsafe_ptr(&RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void)),
@ -2606,8 +2606,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
elif props.hasNonChromeOnly():
idsToInit.append(props.variableName(False))
if len(idsToInit) > 0:
setup = CGList([CGGeneric("let content = task_from_context(aCx);"),
CGList([CGGeneric("let %s_ids_mut = (*content).dom_static.attribute_ids.get(&(prototypes::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
setup = CGList([CGGeneric("let script_context = task_from_context(aCx);"),
CGList([CGGeneric("let %s_ids_mut = (*script_context).dom_static.attribute_ids.get(&(prototypes::id::%s as uint));" % (varname, self.descriptor.name)) for varname in idsToInit], '\n')], '\n')
initIds = CGList(
[CGGeneric("!InitIds(aCx, %s, *%s_ids_mut)" % (varname, varname)) for
varname in idsToInit], ' ||\n')
@ -2795,7 +2795,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
else:
getter = "GetConstructorObject"
body = " let content = task_from_context(aCx);\n"
body = " let script_context = task_from_context(aCx);\n"
#XXXjdm This self.descriptor.concrete check shouldn't be necessary
if not self.descriptor.concrete or self.descriptor.proxy:
body += """ let traps = ProxyTraps {
@ -2828,12 +2828,12 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
getElementIfPresent: ptr::null(),
getPrototypeOf: ptr::null()
};
(*content).dom_static.proxy_handlers.insert(prototypes::id::%s as uint,
(*script_context).dom_static.proxy_handlers.insert(prototypes::id::%s as uint,
CreateProxyHandler(ptr::to_unsafe_ptr(&traps)));
""" % self.descriptor.name
else:
body += """ (*content).dom_static.attribute_ids.insert(prototypes::id::%s as uint,
body += """ (*script_context).dom_static.attribute_ids.insert(prototypes::id::%s as uint,
vec::cast_to_mut(vec::from_slice(sAttributes_ids)));
""" % self.descriptor.name
body = "" #XXXjdm xray stuff isn't necessary yet
@ -3308,12 +3308,12 @@ class CGXrayHelper(CGAbstractExternMethod):
def definition_body(self):
varNames = self.properties.variableNames(True)
setup = "let content = task_from_context(cx);\n"
setup = "let script_context = task_from_context(cx);\n"
methods = self.properties.methods
if methods.hasNonChromeOnly() or methods.hasChromeOnly():
methodArgs = "Some(vec::zip_slice(%(methods)s, *method_ids))" % varNames
setup += "let method_ids = (*content).dom_static.method_ids.get(&(prototypes::id::ClientRect as uint));\n"
setup += "let method_ids = (*script_context).dom_static.method_ids.get(&(prototypes::id::ClientRect as uint));\n"
else:
methodArgs = "None"
methodArgs = CGGeneric(methodArgs)
@ -3321,7 +3321,7 @@ class CGXrayHelper(CGAbstractExternMethod):
attrs = self.properties.attrs
if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
attrArgs = "Some(vec::zip_slice(%(attrs)s, *attr_ids))" % varNames
setup += "let attr_ids = (*content).dom_static.attribute_ids.get(&(prototypes::id::ClientRect as uint));\n"
setup += "let attr_ids = (*script_context).dom_static.attribute_ids.get(&(prototypes::id::ClientRect as uint));\n"
else:
attrArgs = "None"
attrArgs = CGGeneric(attrArgs)
@ -3329,7 +3329,7 @@ class CGXrayHelper(CGAbstractExternMethod):
consts = self.properties.consts
if consts.hasNonChromeOnly() or consts.hasChromeOnly():
constArgs = "Some(vec::zip_slice(%(consts)s, *const_ids))" % varNames
setup += "let const_ids = (*content).dom_static.constant_ids.get(&(prototypes::id::ClientRect as uint));\n"
setup += "let const_ids = (*script_context).dom_static.constant_ids.get(&(prototypes::id::ClientRect as uint));\n"
else:
constArgs = "None"
constArgs = CGGeneric(constArgs)
@ -3614,8 +3614,8 @@ class CGClassConstructHook(CGAbstractExternMethod):
//XXXjdm Gecko obtains a GlobalObject from the global (maybe from the private value,
// or through unwrapping a slot or something). We'll punt and get the Window
// from the context for now.
let content = task_from_context(cx);
let global = (*content).window.get();
let script_context = task_from_context(cx);
let global = (*script_context).window.get();
let obj = global.get_wrappercache().get_wrapper();
"""
preArgs = ["global"]
@ -4147,7 +4147,7 @@ class CGBindingRoot(CGThing):
'dom::domparser::*', #XXXjdm
'dom::event::*', #XXXjdm
'dom::eventtarget::*', #XXXjdm
'content::content_task::task_from_context',
'scripting::script_task::task_from_context',
'dom::bindings::utils::EnumEntry',
],
[],

View file

@ -2,26 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use js::rust::{Compartment, jsobj};
use js::{JS_ARGV, JSPROP_ENUMERATE, JSPROP_SHARED,
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp,
JSPropertySpec, JSPropertyOpWrapper, JSStrictPropertyOpWrapper,
JSNativeWrapper, JSFunctionSpec};
use js::jsapi::bindgen::{JS_GetReservedSlot, JS_SetReservedSlot,
JS_DefineFunctions, JS_DefineProperties};
use js::glue::bindgen::*;
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
use core::ptr::null;
use core::libc::c_uint;
use content::content_task::task_from_context;
use dom::bindings::utils::{DOMString, rust_box, squirrel_away, str};
use dom::bindings::utils::{jsval_to_str, WrapNewBindingObject, CacheableWrapper};
use dom::bindings::utils::{WrapperCache, DerivedWrapper};
use dom::bindings::utils::{jsval_to_str, WrapNewBindingObject, CacheableWrapper};
use dom::bindings::utils;
use dom::document::Document;
use dom::htmlcollection::HTMLCollection;
use dom::bindings::utils;
use js::glue::bindgen::*;
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB};
use js::jsapi::bindgen::{JS_DefineProperties};
use js::jsapi::bindgen::{JS_GetReservedSlot, JS_SetReservedSlot, JS_DefineFunctions};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec, JSPropertyOpWrapper};
use js::jsapi::{JSStrictPropertyOpWrapper, JSNativeWrapper, JSFunctionSpec};
use js::rust::{Compartment, jsobj};
use js::{JSPROP_NATIVE_ACCESSORS};
use js::{JS_ARGV, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL};
use scripting::script_task::task_from_context;
use core::libc::c_uint;
use core::ptr::null;
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe {
@ -146,7 +145,7 @@ impl CacheableWrapper for Document {
}
fn wrap_object_shared(@mut self, cx: *JSContext, _scope: *JSObject) -> *JSObject {
let content = task_from_context(cx);
unsafe { create((*content).compartment.get(), self) }
let script_context = task_from_context(cx);
unsafe { create((*script_context).compartment.get(), self) }
}
}

View file

@ -2,14 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::task_from_context;
use dom::bindings::node::unwrap;
use dom::bindings::utils::jsval_to_str;
use dom::bindings::utils::{domstring_to_jsval, WrapNewBindingObject};
use dom::bindings::utils::{str, CacheableWrapper, DOM_OBJECT_SLOT, DOMString};
use dom::bindings::utils::jsval_to_str;
use dom::element::*;
use dom::node::{AbstractNode, Element, ElementNodeTypeId};
use layout::layout_task;
use scripting::script_task::task_from_context;
use super::utils;
use core::libc::c_uint;
@ -17,8 +17,8 @@ use core::ptr::null;
use js::glue::bindgen::*;
use js::jsapi::bindgen::*;
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec};
use js::jsapi::{JSPropertyOpWrapper, JSStrictPropertyOpWrapper, JSFunctionSpec};
use js::jsapi::{JSNativeWrapper, JSTracer, JSTRACE_OBJECT};
use js::jsapi::{JSPropertyOpWrapper, JSStrictPropertyOpWrapper, JSFunctionSpec};
use js::rust::{Compartment, jsobj};
use js::{JS_ARGV, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL};
use js::{JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
@ -215,8 +215,8 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
let node = unwrap(obj);
let width = match node.type_id() {
ElementNodeTypeId(HTMLImageElementTypeId) => {
let content = task_from_context(cx);
match (*content).query_layout(layout_task::ContentBox(node)) {
let script_context = task_from_context(cx);
match (*script_context).query_layout(layout_task::ContentBox(node)) {
Ok(rect) => {
match rect {
layout_task::ContentRect(rect) => rect.size.width.to_px(),

View file

@ -2,18 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{task_from_context, global_content};
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::bindings::codegen::EventBinding;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::event::Event_;
use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
use js::jsapi::{JSObject, JSContext, JSVal};
use scripting::script_task::{task_from_context, global_script_context};
pub impl Event_ {
pub fn init_wrapper(@mut self) {
let content = global_content();
let cx = content.compartment.get().cx.ptr;
let owner = content.window.get();
let script_context = global_script_context();
let cx = script_context.compartment.get().cx.ptr;
let owner = script_context.window.get();
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
self.wrap_object_shared(cx, scope);
@ -33,8 +33,8 @@ impl CacheableWrapper for Event_ {
impl BindingObject for Event_ {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { (*content).window.get() as @mut CacheableWrapper }
let script_context = task_from_context(cx);
unsafe { (*script_context).window.get() as @mut CacheableWrapper }
}
}

View file

@ -2,18 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{task_from_context, global_content};
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::bindings::codegen::EventTargetBinding;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, BindingObject, DerivedWrapper};
use dom::eventtarget::EventTarget;
use js::jsapi::{JSObject, JSContext, JSVal};
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
use js::jsapi::{JSObject, JSContext, JSVal};
use scripting::script_task::{task_from_context, global_script_context};
pub impl EventTarget {
pub fn init_wrapper(@mut self) {
let content = global_content();
let cx = content.compartment.get().cx.ptr;
let owner = content.window.get();
let script_context = global_script_context();
let cx = script_context.compartment.get().cx.ptr;
let owner = script_context.window.get();
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
self.wrap_object_shared(cx, scope);
@ -33,8 +33,8 @@ impl CacheableWrapper for EventTarget {
impl BindingObject for EventTarget {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { (*content).window.get() as @mut CacheableWrapper }
let script_context = task_from_context(cx);
unsafe { (*script_context).window.get() as @mut CacheableWrapper }
}
}

View file

@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{task_from_context, global_content};
use dom::bindings::codegen::HTMLCollectionBinding;
use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
use dom::htmlcollection::HTMLCollection;
use js::jsapi::{JSObject, JSContext};
use scripting::script_task::{task_from_context, global_script_context};
pub impl HTMLCollection {
fn init_wrapper(@mut self) {
let content = global_content();
let cx = content.compartment.get().cx.ptr;
let owner = content.window.get();
let script_context = global_script_context();
let cx = script_context.compartment.get().cx.ptr;
let owner = script_context.window.get();
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
self.wrap_object_shared(cx, scope);
@ -21,8 +21,8 @@ pub impl HTMLCollection {
impl BindingObject for HTMLCollection {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
let content = task_from_context(cx);
unsafe { (*content).window.get() as @mut CacheableWrapper }
let script_context = task_from_context(cx);
unsafe { (*script_context).window.get() as @mut CacheableWrapper }
}
}

View file

@ -2,38 +2,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use js;
use js::rust::Compartment;
use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL,
JS_THIS_OBJECT, JSFUN_CONSTRUCTOR, JS_CALLEE, JSPROP_READONLY,
JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER,
JSPROP_SETTER, JSVAL_VOID, JSVAL_TRUE, JSVAL_FALSE};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSNative,
JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
use js::jsapi::bindgen::{JS_ValueToString,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty,
JS_GetClass, JS_GetPrototype, JS_LinkConstructorAndPrototype,
JS_AlreadyHasOwnProperty, JS_NewObject, JS_NewFunction,
JS_GetFunctionPrototype, JS_InternString, JS_GetFunctionObject,
JS_DefineProperties,
JS_WrapValue, JS_ForwardGetPropertyTo,
JS_HasPropertyById, JS_GetPrototype, JS_GetGlobalForObject,
JS_EncodeString, JS_free, JS_GetStringCharsAndLength};
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
use js::glue::bindgen::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB,
RESOLVE_STUB};
use js::glue::bindgen::*;
use core::ptr::null;
use core::cast;
use content::content_task::task_from_context;
use core::hashmap::HashMap;
use core::ptr::to_unsafe_ptr;
use dom::bindings::node;
use dom::node::AbstractNode;
use js::glue::bindgen::*;
use js::glue::bindgen::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB, RESOLVE_STUB};
use js::jsapi::bindgen::{JS_AlreadyHasOwnProperty, JS_NewObject, JS_NewFunction};
use js::jsapi::bindgen::{JS_DefineProperties, JS_WrapValue, JS_ForwardGetPropertyTo};
use js::jsapi::bindgen::{JS_EncodeString, JS_free, JS_GetStringCharsAndLength};
use js::jsapi::bindgen::{JS_GetClass, JS_GetPrototype, JS_LinkConstructorAndPrototype};
use js::jsapi::bindgen::{JS_GetFunctionPrototype, JS_InternString, JS_GetFunctionObject};
use js::jsapi::bindgen::{JS_HasPropertyById, JS_GetPrototype, JS_GetGlobalForObject};
use js::jsapi::bindgen::{JS_NewStringCopyN, JS_DefineFunctions, JS_DefineProperty};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSNative};
use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
use js::rust::Compartment;
use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL};
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
use js::{JSPROP_SETTER, JSVAL_VOID, JSVAL_TRUE, JSVAL_FALSE};
use js::{JS_THIS_OBJECT, JSFUN_CONSTRUCTOR, JS_CALLEE, JSPROP_READONLY};
use js;
use scripting::script_task::task_from_context;
use core::cast;
use core::hashmap::HashMap;
use core::ptr::{null, to_unsafe_ptr};
static TOSTRING_CLASS_RESERVED_SLOT: u64 = 0;
static TOSTRING_NAME_RESERVED_SLOT: u64 = 1;
@ -168,9 +163,9 @@ pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
pub fn get_compartment(cx: *JSContext) -> @mut Compartment {
unsafe {
let content = task_from_context(cx);
let compartment = (*content).compartment.expect(~"Should always have compartment when \
executing JS code");
let script_context = task_from_context(cx);
let compartment = (*script_context).compartment.expect(~"Should always have compartment \
when executing JS code");
assert!(cx == compartment.cx.ptr);
compartment
}

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::global_content;
use dom::bindings::document;
use dom::bindings::utils::{DOMString, WrapperCache};
use dom::event::ReflowEvent;
use dom::htmlcollection::HTMLCollection;
use dom::node::AbstractNode;
use dom::window::Window;
use scripting::script_task::global_script_context;
use js::jsapi::bindgen::{JS_AddObjectRoot, JS_RemoveObjectRoot};
use servo_util::tree::{TreeNodeRef, TreeUtils};
@ -19,14 +19,13 @@ pub struct Document {
window: Option<@mut Window>,
}
pub fn Document(root: AbstractNode,
window: Option<@mut Window>) -> @mut Document {
pub fn Document(root: AbstractNode, window: Option<@mut Window>) -> @mut Document {
let doc = @mut Document {
root: root,
wrapper: WrapperCache::new(),
window: window
};
let compartment = global_content().compartment.get();
let compartment = global_script_context().compartment.get();
do root.with_base |base| {
assert!(base.wrapper.get_wrapper().is_not_null());
let rootable = base.wrapper.get_rootable();
@ -39,7 +38,7 @@ pub fn Document(root: AbstractNode,
#[unsafe_destructor]
impl Drop for Document {
fn finalize(&self) {
let compartment = global_content().compartment.get();
let compartment = global_script_context().compartment.get();
do self.root.with_base |base| {
assert!(base.wrapper.get_wrapper().is_not_null());
let rootable = base.wrapper.get_rootable();

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::global_content;
use dom::bindings::codegen::DOMParserBinding;
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
use dom::document::Document;
use dom::element::{Element, HTMLHtmlElement, HTMLHtmlElementTypeId};
use dom::node::Node;
use dom::window::Window;
use scripting::script_task::global_script_context;
pub struct DOMParser {
owner: @mut Window, //XXXjdm Document instead?
@ -22,7 +22,7 @@ impl DOMParser {
wrapper: WrapperCache::new()
};
let cx = global_content().compartment.get().cx.ptr;
let cx = global_script_context().compartment.get().cx.ptr;
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
parser.wrap_object_shared(cx, scope);

View file

@ -166,8 +166,10 @@ pub impl<'self> Element {
Some(win) => {
let node = self.parent.abstract.get();
assert!(node.is_element());
let content = unsafe { &mut *win.content_task };
match content.query_layout(layout_task::ContentBoxes(node)) {
let script_context = unsafe {
&mut *win.script_context
};
match script_context.query_layout(layout_task::ContentBoxes(node)) {
Ok(rects) => match rects {
layout_task::ContentRects(rects) =>
do rects.map |r| {
@ -206,8 +208,8 @@ pub impl<'self> Element {
Some(win) => {
let node = self.parent.abstract.get();
assert!(node.is_element());
let content = unsafe { &mut *win.content_task };
match content.query_layout(layout_task::ContentBox(node)) {
let script_context = unsafe { &mut *win.script_context };
match script_context.query_layout(layout_task::ContentBox(node)) {
Ok(rect) => match rect {
layout_task::ContentRect(rect) =>
Some(ClientRect::new(

View file

@ -4,7 +4,6 @@
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
use content::content_task::global_content;
use dom::bindings::codegen;
use dom::bindings::node;
use dom::bindings::utils::WrapperCache;
@ -13,12 +12,13 @@ use dom::characterdata::CharacterData;
use dom::document::Document;
use dom::element::{Element, ElementTypeId, HTMLImageElement, HTMLImageElementTypeId};
use dom::element::{HTMLStyleElementTypeId};
use js::rust::Compartment;
use layout::debug::DebugMethods;
use layout::flow::FlowContext;
use newcss::complete::CompleteSelectResults;
use scripting::script_task::global_script_context;
use core::cast::transmute;
use js::rust::Compartment;
use newcss::complete::CompleteSelectResults;
use servo_util::tree::{TreeNode, TreeNodeRef, TreeUtils};
//
@ -391,7 +391,7 @@ impl Node {
let mut node = AbstractNode {
obj: transmute(node),
};
let cx = global_content().compartment.get().cx.ptr;
let cx = global_script_context().compartment.get().cx.ptr;
node::create(cx, &mut node);
node
}

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content::content_task::{ControlMsg, Timer, ExitMsg, global_content, Content};
use scripting::script_task::{ControlMsg, ExitMsg, ScriptContext, Timer, global_script_context};
use dom::bindings::utils::WrapperCache;
use dom::bindings::window;
use dom::event::Event;
@ -16,15 +16,15 @@ use std::uv_global_loop;
pub enum TimerControlMsg {
TimerMessage_Fire(~TimerData),
TimerMessage_Close,
TimerMessage_TriggerExit //XXXjdm this is just a quick hack to talk to the content task
TimerMessage_TriggerExit //XXXjdm this is just a quick hack to talk to the script task
}
//FIXME If we're going to store the content task, find a way to do so safely. Currently it's
// only used for querying layout from arbitrary content.
//FIXME If we're going to store the script task, find a way to do so safely. Currently it's
// only used for querying layout from arbitrary script.
pub struct Window {
timer_chan: Chan<TimerControlMsg>,
dom_event_chan: SharedChan<Event>,
content_task: *mut Content,
script_context: *mut ScriptContext,
wrapper: WrapperCache
}
@ -75,7 +75,7 @@ pub impl Window {
let timeout = int::max(0, timeout) as uint;
// Post a delayed message to the per-window timer task; it will dispatch it
// to the relevant content handler that will deal with it.
// to the relevant script handler that will deal with it.
timer::delayed_send(&uv_global_loop::get(),
timeout,
&self.timer_chan,
@ -83,10 +83,10 @@ pub impl Window {
}
}
pub fn Window(content_chan: comm::SharedChan<ControlMsg>,
pub fn Window(script_chan: comm::SharedChan<ControlMsg>,
dom_event_chan: comm::SharedChan<Event>,
content_task: *mut Content) -> @mut Window {
script_context: *mut ScriptContext)
-> @mut Window {
let win = @mut Window {
wrapper: WrapperCache::new(),
dom_event_chan: dom_event_chan,
@ -95,15 +95,15 @@ pub fn Window(content_chan: comm::SharedChan<ControlMsg>,
match timer_port.recv() {
TimerMessage_Close => break,
TimerMessage_Fire(td) => {
content_chan.send(Timer(td));
script_chan.send(Timer(td));
}
TimerMessage_TriggerExit => content_chan.send(ExitMsg)
TimerMessage_TriggerExit => script_chan.send(ExitMsg)
}
}
},
content_task: content_task
script_context: script_context
};
let compartment = global_content().compartment.get();
let compartment = global_script_context().compartment.get();
window::create(compartment, win);
win
}

View file

@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositing::CompositorImpl;
use content::content_task::{ContentTask, ExecuteMsg, ParseMsg};
use content::content_task;
use dom::event::Event;
use layout::layout_task;
use layout::layout_task::LayoutTask;
use layout::layout_task;
use scripting::script_task::{ExecuteMsg, ParseMsg, ScriptTask};
use scripting::script_task;
use util::task::spawn_listener;
use core::cell::Cell;
@ -34,7 +34,7 @@ pub struct Engine {
resource_task: ResourceTask,
image_cache_task: ImageCacheTask,
layout_task: LayoutTask,
content_task: ContentTask
script_task: ScriptTask,
}
impl Engine {
@ -55,7 +55,7 @@ impl Engine {
let opts = opts.take();
let layout_task = LayoutTask(render_task.clone(), image_cache_task.clone(), opts);
let content_task = ContentTask(layout_task.clone(),
let script_task = ScriptTask(layout_task.clone(),
dom_event_port.take(),
dom_event_chan.take(),
resource_task.clone(),
@ -68,7 +68,7 @@ impl Engine {
resource_task: resource_task.clone(),
image_cache_task: image_cache_task.clone(),
layout_task: layout_task,
content_task: content_task,
script_task: script_task,
}.run()
}
}
@ -83,15 +83,15 @@ impl Engine {
match request {
LoadUrlMsg(url) => {
if url.path.ends_with(".js") {
self.content_task.send(ExecuteMsg(url))
self.script_task.send(ExecuteMsg(url))
} else {
self.content_task.send(ParseMsg(url))
self.script_task.send(ParseMsg(url))
}
return true
}
ExitMsg(sender) => {
self.content_task.send(content_task::ExitMsg);
self.script_task.send(script_task::ExitMsg);
self.layout_task.send(layout_task::ExitMsg);
let (response_port, response_chan) = comm::stream();

View file

@ -81,15 +81,15 @@ pub struct BuildData {
url: Url,
dom_event_chan: comm::SharedChan<Event>,
window_size: Size2D<uint>,
content_join_chan: comm::Chan<()>,
script_join_chan: comm::Chan<()>,
damage: Damage,
}
pub fn LayoutTask(render_task: RenderTask,
img_cache_task: ImageCacheTask,
opts: Opts) -> LayoutTask {
SharedChan::new(spawn_listener::<Msg>(|from_content| {
let mut layout = Layout(render_task.clone(), img_cache_task.clone(), from_content, &opts);
SharedChan::new(spawn_listener::<Msg>(|from_script| {
let mut layout = Layout(render_task.clone(), img_cache_task.clone(), from_script, &opts);
layout.start();
}))
}
@ -98,7 +98,7 @@ struct Layout {
render_task: RenderTask,
image_cache_task: ImageCacheTask,
local_image_cache: @mut LocalImageCache,
from_content: Port<Msg>,
from_script: Port<Msg>,
font_ctx: @mut FontContext,
// This is used to root reader data
layout_refs: ~[@mut LayoutData],
@ -107,7 +107,7 @@ struct Layout {
fn Layout(render_task: RenderTask,
image_cache_task: ImageCacheTask,
from_content: Port<Msg>,
from_script: Port<Msg>,
opts: &Opts)
-> Layout {
let fctx = @mut FontContext::new(opts.render_backend, true);
@ -116,7 +116,7 @@ fn Layout(render_task: RenderTask,
render_task: render_task,
image_cache_task: image_cache_task.clone(),
local_image_cache: @mut LocalImageCache(image_cache_task),
from_content: from_content,
from_script: from_script,
font_ctx: fctx,
layout_refs: ~[],
css_select_ctx: @mut new_css_select_ctx()
@ -133,7 +133,7 @@ impl Layout {
fn handle_request(&mut self) -> bool {
match self.from_content.recv() {
match self.from_script.recv() {
AddStylesheet(sheet) => {
self.handle_add_stylesheet(sheet);
}
@ -257,8 +257,8 @@ impl Layout {
self.render_task.send(RenderMsg(render_layer));
} // time(layout: display list building)
// Tell content that we're done.
data.content_join_chan.send(());
// Tell script that we're done.
data.script_join_chan.send(());
}
/// Handles a query from the script task. This is the main routine that DOM functions like
@ -312,9 +312,9 @@ impl Layout {
// When images can't be loaded in time to display they trigger
// this callback in some task somewhere. This will send a message
// to the content task, and ultimately cause the image to be
// to the script task, and ultimately cause the image to be
// re-requested. We probably don't need to go all the way back to
// the content task for this.
// the script task for this.
fn make_on_image_available_cb(&self, dom_event_chan: comm::SharedChan<Event>) -> @fn() -> ~fn(ImageResponseMsg) {
// This has a crazy signature because the image cache needs to
// make multiple copies of the callback, and the dom event

View file

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// The content task (also called the script task) is the main task that owns the DOM in memory,
/// runs JavaScript, and spawns parsing and layout tasks.
/// The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing
/// and layout tasks.
use dom::bindings::utils::GlobalStaticData;
use dom::document::Document;
@ -18,10 +18,10 @@ use core::cell::Cell;
use core::comm::{Port, SharedChan};
use core::either;
use core::io::read_whole_file;
use core::local_data;
use core::pipes::select2i;
use core::ptr::null;
use core::task::{SingleThreaded, task};
use core::local_data;
use core::util::replace;
use dom;
use geom::size::Size2D;
@ -50,14 +50,14 @@ pub enum PingMsg {
PongMsg
}
pub type ContentTask = SharedChan<ControlMsg>;
pub type ScriptTask = SharedChan<ControlMsg>;
pub fn ContentTask(layout_task: LayoutTask,
pub fn ScriptTask(layout_task: LayoutTask,
dom_event_port: Port<Event>,
dom_event_chan: SharedChan<Event>,
resource_task: ResourceTask,
img_cache_task: ImageCacheTask)
-> ContentTask {
-> ScriptTask {
let (control_port, control_chan) = comm::stream();
let control_chan = SharedChan::new(control_chan);
@ -70,20 +70,20 @@ pub fn ContentTask(layout_task: LayoutTask,
let mut the_task = task();
the_task.sched_mode(SingleThreaded);
do the_task.spawn {
let content = Content(layout_task.clone(),
let script_context = ScriptContext(layout_task.clone(),
control_port.take(),
control_chan_copy.clone(),
resource_task.clone(),
img_cache_task.clone(),
dom_event_port.take(),
dom_event_chan.take());
content.start();
script_context.start();
}
return control_chan;
}
pub struct Content {
pub struct ScriptContext {
layout_task: LayoutTask,
layout_join_port: Option<comm::Port<()>>,
@ -110,14 +110,14 @@ pub struct Content {
damage: Damage,
}
pub fn Content(layout_task: LayoutTask,
pub fn ScriptContext(layout_task: LayoutTask,
control_port: comm::Port<ControlMsg>,
control_chan: comm::SharedChan<ControlMsg>,
resource_task: ResourceTask,
img_cache_task: ImageCacheTask,
event_port: comm::Port<Event>,
event_chan: comm::SharedChan<Event>)
-> @mut Content {
-> @mut ScriptContext {
let jsrt = jsrt();
let cx = jsrt.cx();
@ -129,7 +129,7 @@ pub fn Content(layout_task: LayoutTask,
Err(()) => None
};
let content = @mut Content {
let script_context = @mut ScriptContext {
layout_task: layout_task,
layout_join_port: None,
image_cache_task: img_cache_task,
@ -138,53 +138,55 @@ pub fn Content(layout_task: LayoutTask,
event_port: event_port,
event_chan: event_chan,
jsrt : jsrt,
cx : cx,
jsrt: jsrt,
cx: cx,
dom_static: GlobalStaticData(),
document : None,
window : None,
doc_url : None,
window_size : Size2D(800u, 600u),
document: None,
window: None,
doc_url: None,
window_size: Size2D(800u, 600u),
resource_task : resource_task,
compartment : compartment,
resource_task: resource_task,
compartment: compartment,
damage : MatchSelectorsDamage,
damage: MatchSelectorsDamage,
};
cx.set_cx_private(ptr::to_unsafe_ptr(&*content) as *());
cx.set_cx_private(ptr::to_unsafe_ptr(&*script_context) as *());
unsafe {
local_data::local_data_set(global_content_key, cast::transmute(content));
local_data::local_data_set(global_script_context_key, cast::transmute(script_context));
}
content
script_context
}
fn global_content_key(_: @Content) {}
fn global_script_context_key(_: @ScriptContext) {}
pub fn global_content() -> @Content {
pub fn global_script_context() -> @ScriptContext {
unsafe {
return local_data::local_data_get(global_content_key).get();
return local_data::local_data_get(global_script_context_key).get();
}
}
pub fn task_from_context(cx: *JSContext) -> *mut Content {
JS_GetContextPrivate(cx) as *mut Content
pub fn task_from_context(cx: *JSContext) -> *mut ScriptContext {
JS_GetContextPrivate(cx) as *mut ScriptContext
}
#[unsafe_destructor]
impl Drop for Content {
impl Drop for ScriptContext {
fn finalize(&self) {
unsafe { local_data::local_data_pop(global_content_key) };
unsafe {
let _ = local_data::local_data_pop(global_script_context_key);
}
}
}
#[allow(non_implicitly_copyable_typarams)]
pub impl Content {
pub impl ScriptContext {
fn start(&mut self) {
while self.handle_msg() {
// Go on ...
// Go on...
}
}
@ -204,7 +206,7 @@ pub impl Content {
fn handle_control_msg(&mut self, control_msg: ControlMsg) -> bool {
match control_msg {
ParseMsg(url) => {
debug!("content: Received url `%s` to parse", url_to_str(&url));
debug!("script: Received url `%s` to parse", url_to_str(&url));
define_bindings(self.compartment.get());
@ -219,7 +221,7 @@ pub impl Content {
// Send stylesheets over to layout
// FIXME: Need these should be streamed to layout as they are parsed
// and do not need to stop here in the content task
// and do not need to stop here in the script task
loop {
match result.style_port.recv() {
Some(sheet) => {
@ -275,7 +277,7 @@ pub impl Content {
ExecuteMsg(url) => {
debug!("content: Received url `%s` to execute", url_to_str(&url));
debug!("script: Received url `%s` to execute", url_to_str(&url));
match read_whole_file(&Path(url.path)) {
Err(msg) => {
@ -307,10 +309,10 @@ pub impl Content {
match join_port {
Some(ref join_port) => {
if !join_port.peek() {
warn!("content: waiting on layout");
warn!("script: waiting on layout");
}
join_port.recv();
debug!("content: layout joined");
debug!("script: layout joined");
}
None => fail!(~"reader forked but no join port?")
}
@ -321,7 +323,7 @@ pub impl Content {
/// layout task, and then request a new layout run. It won't wait for the new layout
/// computation to finish.
fn relayout(&mut self, document: &Document, doc_url: &Url) {
debug!("content: performing relayout");
debug!("script: performing relayout");
// Now, join the layout so that they will see the latest changes we have made.
self.join_layout();
@ -336,13 +338,13 @@ pub impl Content {
url: copy *doc_url,
dom_event_chan: self.event_chan.clone(),
window_size: self.window_size,
content_join_chan: join_chan,
script_join_chan: join_chan,
damage: replace(&mut self.damage, NoDamage),
};
self.layout_task.send(BuildMsg(data));
debug!("content: layout forked");
debug!("script: layout forked");
}
fn query_layout(&mut self, query: layout_task::LayoutQuery)
@ -362,7 +364,7 @@ pub impl Content {
fn handle_event(&mut self, event: Event) -> bool {
match event {
ResizeEvent(new_width, new_height, response_chan) => {
debug!("content got resize event: %u, %u", new_width, new_height);
debug!("script got resize event: %u, %u", new_width, new_height);
self.damage.add(ReflowDamage);
self.window_size = Size2D(new_width, new_height);
match copy self.document {
@ -378,7 +380,7 @@ pub impl Content {
return true;
}
ReflowEvent => {
debug!("content got reflow event");
debug!("script got reflow event");
self.damage.add(MatchSelectorsDamage);
match /*bad*/ copy self.document {
None => {

View file

@ -47,8 +47,8 @@ pub use servo_util::url::make_url;
#[path="compositing/mod.rs"]
pub mod compositing;
pub mod content {
pub mod content_task;
pub mod scripting {
pub mod script_task;
}
pub mod css {