mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #9201 - wenderen:8512-task-thread, r=jdm
task -> thread for #8512 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9201) <!-- Reviewable:end -->
This commit is contained in:
commit
d3e2f94f20
119 changed files with 1209 additions and 1207 deletions
|
@ -7,8 +7,8 @@
|
|||
use dom::bindings::trace::JSTraceable;
|
||||
use js::jsapi::JSTracer;
|
||||
use std::cell::{BorrowState, Ref, RefCell, RefMut};
|
||||
use util::task_state;
|
||||
use util::task_state::SCRIPT;
|
||||
use util::thread_state;
|
||||
use util::thread_state::SCRIPT;
|
||||
|
||||
/// A mutable field in the DOM.
|
||||
///
|
||||
|
@ -25,10 +25,10 @@ pub struct DOMRefCell<T> {
|
|||
impl<T> DOMRefCell<T> {
|
||||
/// Return a reference to the contents.
|
||||
///
|
||||
/// For use in the layout task only.
|
||||
/// For use in the layout thread only.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_layout(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl<T> DOMRefCell<T> {
|
|||
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
|
||||
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
|
||||
// https://github.com/servo/servo/issues/6389
|
||||
// debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
|
||||
// debug_assert!(thread_state::get().contains(SCRIPT | IN_GC));
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl<T> DOMRefCell<T> {
|
|||
///
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||
debug_assert!(task_state::get().contains(SCRIPT));
|
||||
debug_assert!(thread_state::get().contains(SCRIPT));
|
||||
&mut *self.value.as_unsafe_cell().get()
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ impl<T> DOMRefCell<T> {
|
|||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub fn try_borrow(&self) -> Option<Ref<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.value.borrow_state() {
|
||||
BorrowState::Writing => None,
|
||||
_ => Some(self.value.borrow()),
|
||||
|
@ -88,17 +88,17 @@ impl<T> DOMRefCell<T> {
|
|||
///
|
||||
/// Panics if this is called off the script thread.
|
||||
pub fn try_borrow_mut(&self) -> Option<RefMut<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.value.borrow_state() {
|
||||
BorrowState::Unused => Some(self.value.borrow_mut()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Version of the above that we use during restyle while the script task
|
||||
/// Version of the above that we use during restyle while the script thread
|
||||
/// is blocked.
|
||||
pub fn borrow_mut_for_layout(&self) -> RefMut<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
self.value.borrow_mut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ use js::jsapi::GetGlobalForObjectCrossCompartment;
|
|||
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
|
||||
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::ResourceThread;
|
||||
use profile_traits::mem;
|
||||
use script_task::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptTask};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
|
||||
use timers::{ScheduledCallback, TimerHandle};
|
||||
use url::Url;
|
||||
|
@ -65,7 +65,7 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Extract a `Window`, causing task failure if the global object is not
|
||||
/// Extract a `Window`, causing thread failure if the global object is not
|
||||
/// a `Window`.
|
||||
pub fn as_window(&self) -> &window::Window {
|
||||
match *self {
|
||||
|
@ -82,7 +82,7 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler task.
|
||||
/// Get a `mem::ProfilerChan` to send messages to the memory profiler thread.
|
||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.mem_profiler_chan(),
|
||||
|
@ -107,7 +107,7 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
|
||||
/// Get an `IpcSender<ScriptToDevtoolsControlMsg>` to send messages to Devtools
|
||||
/// task when available.
|
||||
/// thread when available.
|
||||
pub fn devtools_chan(&self) -> Option<IpcSender<ScriptToDevtoolsControlMsg>> {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.devtools_chan(),
|
||||
|
@ -115,16 +115,16 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the `ResourceTask` for this global scope.
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
/// Get the `ResourceThread` for this global scope.
|
||||
pub fn resource_thread(&self) -> ResourceThread {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => {
|
||||
let doc = window.Document();
|
||||
let doc = doc.r();
|
||||
let loader = doc.loader();
|
||||
(*loader.resource_task).clone()
|
||||
(*loader.resource_thread).clone()
|
||||
}
|
||||
GlobalRef::Worker(ref worker) => worker.resource_task().clone(),
|
||||
GlobalRef::Worker(ref worker) => worker.resource_thread().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,45 +154,45 @@ impl<'a> GlobalRef<'a> {
|
|||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn dom_manipulation_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn dom_manipulation_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.dom_manipulation_task_source(),
|
||||
GlobalRef::Window(ref window) => window.dom_manipulation_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn user_interaction_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn user_interaction_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.user_interaction_task_source(),
|
||||
GlobalRef::Window(ref window) => window.user_interaction_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn networking_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.networking_task_source(),
|
||||
GlobalRef::Window(ref window) => window.networking_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn history_traversal_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.history_traversal_task_source(),
|
||||
GlobalRef::Window(ref window) => window.history_traversal_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `ScriptChan` used to send messages to the event loop of this global's
|
||||
/// thread.
|
||||
pub fn file_reading_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
pub fn file_reading_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.file_reading_task_source(),
|
||||
GlobalRef::Window(ref window) => window.file_reading_thread_source(),
|
||||
GlobalRef::Worker(ref worker) => worker.script_chan(),
|
||||
}
|
||||
}
|
||||
|
@ -207,11 +207,11 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Process a single event as if it were the next event in the task queue for
|
||||
/// Process a single event as if it were the next event in the thread queue for
|
||||
/// this global.
|
||||
pub fn process_event(&self, msg: CommonScriptMsg) {
|
||||
match *self {
|
||||
GlobalRef::Window(_) => ScriptTask::process_event(msg),
|
||||
GlobalRef::Window(_) => ScriptThread::process_event(msg),
|
||||
GlobalRef::Worker(ref worker) => worker.process_event(msg),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ use dom::node::Node;
|
|||
use js::jsapi::{Heap, JSObject, JSTracer};
|
||||
use js::jsval::JSVal;
|
||||
use layout_interface::TrustedNodeAddress;
|
||||
use script_task::STACK_ROOTS;
|
||||
use script_thread::STACK_ROOTS;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::default::Default;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -41,7 +41,7 @@ use std::mem;
|
|||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use util::mem::HeapSizeOf;
|
||||
use util::task_state;
|
||||
use util::thread_state;
|
||||
|
||||
/// A traced reference to a DOM object
|
||||
///
|
||||
|
@ -66,7 +66,7 @@ impl<T> HeapSizeOf for JS<T> {
|
|||
impl<T> JS<T> {
|
||||
/// Returns `LayoutJS<T>` containing the same pointer.
|
||||
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ impl<T: Reflectable> JS<T> {
|
|||
/// XXX Not a great API. Should be a call on Root<T> instead
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn from_rooted(root: &Root<T>) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: unsafe { NonZero::new(&**root) },
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl<T: Reflectable> JS<T> {
|
|||
/// Create a JS<T> from a &T
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn from_ref(obj: &T) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: unsafe { NonZero::new(&*obj) },
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl<T: Reflectable> Deref for JS<T> {
|
|||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
// We can only have &JS<T> from a rooted thing, so it's safe to deref
|
||||
// it to &T.
|
||||
unsafe { &**self.ptr }
|
||||
|
@ -123,7 +123,7 @@ impl<T: Castable> LayoutJS<T> {
|
|||
where U: Castable,
|
||||
T: DerivedFrom<U>
|
||||
{
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe { mem::transmute_copy(self) }
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ impl<T: Castable> LayoutJS<T> {
|
|||
pub fn downcast<U>(&self) -> Option<LayoutJS<U>>
|
||||
where U: DerivedFrom<T>
|
||||
{
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
unsafe {
|
||||
if (*self.unsafe_get()).is::<U>() {
|
||||
Some(mem::transmute_copy(self))
|
||||
|
@ -145,7 +145,7 @@ impl<T: Castable> LayoutJS<T> {
|
|||
impl<T: Reflectable> LayoutJS<T> {
|
||||
/// Get the reflector.
|
||||
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
(**self.ptr).reflector().get_jsobject().get()
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ impl <T> Clone for JS<T> {
|
|||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
fn clone(&self) -> JS<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
JS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ impl <T> Clone for JS<T> {
|
|||
impl <T> Clone for LayoutJS<T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> LayoutJS<T> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
LayoutJS {
|
||||
ptr: self.ptr.clone(),
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ impl LayoutJS<Node> {
|
|||
/// Create a new JS-owned value wrapped from an address known to be a
|
||||
/// `Node` pointer.
|
||||
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
let TrustedNodeAddress(addr) = inner;
|
||||
LayoutJS {
|
||||
ptr: NonZero::new(addr as *const Node),
|
||||
|
@ -240,7 +240,7 @@ pub struct MutHeapJSVal {
|
|||
impl MutHeapJSVal {
|
||||
/// Create a new `MutHeapJSVal`.
|
||||
pub fn new() -> MutHeapJSVal {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutHeapJSVal {
|
||||
val: UnsafeCell::new(Heap::default()),
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ impl MutHeapJSVal {
|
|||
/// Set this `MutHeapJSVal` to the given value, calling write barriers as
|
||||
/// appropriate.
|
||||
pub fn set(&self, val: JSVal) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let cell = self.val.get();
|
||||
(*cell).set(val);
|
||||
|
@ -258,7 +258,7 @@ impl MutHeapJSVal {
|
|||
|
||||
/// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate.
|
||||
pub fn get(&self) -> JSVal {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { (*self.val.get()).get() }
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ pub struct MutHeap<T: HeapGCValue> {
|
|||
impl<T: Reflectable> MutHeap<JS<T>> {
|
||||
/// Create a new `MutHeap`.
|
||||
pub fn new(initial: &T) -> MutHeap<JS<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutHeap {
|
||||
val: UnsafeCell::new(JS::from_ref(initial)),
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
|||
|
||||
/// Set this `MutHeap` to the given value.
|
||||
pub fn set(&self, val: &T) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
*self.val.get() = JS::from_ref(val);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
|||
|
||||
/// Get the value in this `MutHeap`.
|
||||
pub fn get(&self) -> Root<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
Root::from_ref(&*ptr::read(self.val.get()))
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ pub struct MutNullableHeap<T: HeapGCValue> {
|
|||
impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
||||
/// Create a new `MutNullableHeap`.
|
||||
pub fn new(initial: Option<&T>) -> MutNullableHeap<JS<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutNullableHeap {
|
||||
ptr: UnsafeCell::new(initial.map(JS::from_ref)),
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
|||
pub fn or_init<F>(&self, cb: F) -> Root<T>
|
||||
where F: FnOnce() -> Root<T>
|
||||
{
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
match self.get() {
|
||||
Some(inner) => inner,
|
||||
None => {
|
||||
|
@ -365,14 +365,14 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
|||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn get(&self) -> Option<Root<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o))
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
|||
|
||||
/// Set this `MutNullableHeap` to the given value.
|
||||
pub fn set(&self, val: Option<&T>) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
*self.ptr.get() = val.map(|p| JS::from_ref(p));
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ impl<'a, T: Reflectable> PartialEq<Option<&'a T>> for MutNullableHeap<JS<T>> {
|
|||
impl<T: HeapGCValue> Default for MutNullableHeap<T> {
|
||||
#[allow(unrooted_must_root)]
|
||||
fn default() -> MutNullableHeap<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutNullableHeap {
|
||||
ptr: UnsafeCell::new(None),
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ impl<T: Reflectable> LayoutJS<T> {
|
|||
/// the only method that be safely accessed from layout. (The fact that
|
||||
/// this is unsafe is what necessitates the layout wrappers.)
|
||||
pub unsafe fn unsafe_get(&self) -> *const T {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
*self.ptr
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ impl Clone for RootCollectionPtr {
|
|||
impl RootCollection {
|
||||
/// Create an empty collection of roots
|
||||
pub fn new() -> RootCollection {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
RootCollection {
|
||||
roots: UnsafeCell::new(vec![]),
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ impl RootCollection {
|
|||
|
||||
/// Start tracking a stack-based root
|
||||
fn root(&self, untracked_reflector: *const Reflector) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
roots.push(untracked_reflector);
|
||||
|
@ -497,7 +497,7 @@ impl RootCollection {
|
|||
|
||||
/// Stop tracking a stack-based root, asserting if the reflector isn't found
|
||||
fn unroot<T: Reflectable>(&self, rooted: &Root<T>) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let mut roots = &mut *self.roots.get();
|
||||
let old_reflector = &*rooted.reflector();
|
||||
|
@ -562,7 +562,7 @@ impl<T: Reflectable> Root<T> {
|
|||
/// It cannot not outlive its associated `RootCollection`, and it gives
|
||||
/// out references which cannot outlive this new `Root`.
|
||||
pub fn new(unrooted: NonZero<*const T>) -> Root<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
STACK_ROOTS.with(|ref collection| {
|
||||
let RootCollectionPtr(collection) = collection.get().unwrap();
|
||||
unsafe { (*collection).root(&*(**unrooted).reflector()) }
|
||||
|
@ -588,7 +588,7 @@ impl<T: Reflectable> Root<T> {
|
|||
impl<T: Reflectable> Deref for Root<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { &**self.ptr.deref() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A generic, safe mechanism by which DOM objects can be pinned and transferred
|
||||
//! between tasks (or intra-task for asynchronous events). Akin to Gecko's
|
||||
//! between threads (or intra-thread for asynchronous events). Akin to Gecko's
|
||||
//! nsMainThreadPtrHandle, this uses thread-safe reference counting and ensures
|
||||
//! that the actual SpiderMonkey GC integration occurs on the script task via
|
||||
//! that the actual SpiderMonkey GC integration occurs on the script thread via
|
||||
//! message passing. Ownership of a `Trusted<T>` object means the DOM object of
|
||||
//! type T to which it points remains alive. Any other behaviour is undefined.
|
||||
//! To guarantee the lifetime of a DOM object when performing asynchronous operations,
|
||||
//! obtain a `Trusted<T>` from that object and pass it along with each operation.
|
||||
//! A usable pointer to the original DOM object can be obtained on the script task
|
||||
//! A usable pointer to the original DOM object can be obtained on the script thread
|
||||
//! from a `Trusted<T>` via the `to_temporary` method.
|
||||
//!
|
||||
//! The implementation of Trusted<T> is as follows:
|
||||
//! A hashtable resides in the script task, keyed on the pointer to the Rust DOM object.
|
||||
//! A hashtable resides in the script thread, keyed on the pointer to the Rust DOM object.
|
||||
//! The values in this hashtable are atomic reference counts. When a Trusted<T> object is
|
||||
//! created or cloned, this count is increased. When a Trusted<T> is dropped, the count
|
||||
//! decreases. If the count hits zero, a message is dispatched to the script task to remove
|
||||
//! decreases. If the count hits zero, a message is dispatched to the script thread to remove
|
||||
//! the entry from the hashmap if the count is still zero. The JS reflector for the DOM object
|
||||
//! is rooted when a hashmap entry is first created, and unrooted when the hashmap entry
|
||||
//! is removed.
|
||||
|
@ -28,7 +28,7 @@ use dom::bindings::reflector::{Reflectable, Reflector};
|
|||
use dom::bindings::trace::trace_reflector;
|
||||
use js::jsapi::JSTracer;
|
||||
use libc;
|
||||
use script_task::{CommonScriptMsg, ScriptChan};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::collections::hash_map::HashMap;
|
||||
|
@ -52,13 +52,13 @@ pub struct TrustedReference(*const libc::c_void);
|
|||
unsafe impl Send for TrustedReference {}
|
||||
|
||||
/// A safe wrapper around a raw pointer to a DOM object that can be
|
||||
/// shared among tasks for use in asynchronous operations. The underlying
|
||||
/// shared among threads for use in asynchronous operations. The underlying
|
||||
/// DOM object is guaranteed to live at least as long as the last outstanding
|
||||
/// `Trusted<T>` instance.
|
||||
#[allow_unrooted_interior]
|
||||
pub struct Trusted<T: Reflectable> {
|
||||
/// A pointer to the Rust DOM object of type T, but void to allow
|
||||
/// sending `Trusted<T>` between tasks, regardless of T's sendability.
|
||||
/// sending `Trusted<T>` between threads, regardless of T's sendability.
|
||||
ptr: *const libc::c_void,
|
||||
refcount: Arc<Mutex<usize>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
|
@ -125,7 +125,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
|
|||
assert!(*refcount > 0);
|
||||
*refcount -= 1;
|
||||
if *refcount == 0 {
|
||||
// It's possible this send will fail if the script task
|
||||
// It's possible this send will fail if the script thread
|
||||
// has already exited. There's not much we can do at this
|
||||
// point though.
|
||||
let msg = CommonScriptMsg::RefcountCleanup(TrustedReference(self.ptr));
|
||||
|
@ -142,7 +142,7 @@ pub struct LiveDOMReferences {
|
|||
}
|
||||
|
||||
impl LiveDOMReferences {
|
||||
/// Set up the task-local data required for storing the outstanding DOM references.
|
||||
/// Set up the thread-local data required for storing the outstanding DOM references.
|
||||
pub fn initialize() {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
*r.borrow_mut() = Some(LiveDOMReferences {
|
||||
|
|
|
@ -58,11 +58,11 @@ use msg::constellation_msg::ConstellationChan;
|
|||
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
|
||||
use net_traits::Metadata;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||
use net_traits::storage_task::StorageType;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::storage_thread::StorageType;
|
||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||
use script_task::ScriptChan;
|
||||
use script_thread::ScriptChan;
|
||||
use script_traits::{LayoutMsg, ScriptMsg, TimerEventId, TimerSource, UntrustedNodeAddress};
|
||||
use selectors::parser::PseudoElement;
|
||||
use selectors::states::*;
|
||||
|
@ -262,7 +262,7 @@ no_jsmanaged_fields!(Receiver<T>);
|
|||
no_jsmanaged_fields!(Rect<T>);
|
||||
no_jsmanaged_fields!(Size2D<T>);
|
||||
no_jsmanaged_fields!(Arc<T>);
|
||||
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask);
|
||||
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheThread);
|
||||
no_jsmanaged_fields!(Metadata);
|
||||
no_jsmanaged_fields!(Atom, Namespace, QualName);
|
||||
no_jsmanaged_fields!(Trusted<T: Reflectable>);
|
||||
|
|
|
@ -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 canvas::canvas_paint_task::RectToi32;
|
||||
use canvas::canvas_paint_thread::RectToi32;
|
||||
use canvas_traits::{Canvas2dMsg, CanvasCommonMsg, CanvasMsg};
|
||||
use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle};
|
||||
use canvas_traits::{FillOrStrokeStyle, FillRule, LinearGradientStyle, RadialGradientStyle, RepetitionStyle};
|
||||
|
@ -36,7 +36,7 @@ use euclid::rect::Rect;
|
|||
use euclid::size::Size2D;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache_task::ImageResponse;
|
||||
use net_traits::image_cache_thread::ImageResponse;
|
||||
use num::{Float, ToPrimitive};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use std::cell::Cell;
|
||||
|
@ -124,7 +124,7 @@ impl CanvasRenderingContext2D {
|
|||
-> CanvasRenderingContext2D {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintTask(size, sender)).unwrap();
|
||||
constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap();
|
||||
let (ipc_renderer, renderer_id) = receiver.recv().unwrap();
|
||||
CanvasRenderingContext2D {
|
||||
reflector_: Reflector::new(),
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::bindings::inheritance::Castable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use script_task::ScriptChan;
|
||||
use script_thread::ScriptChan;
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
||||
|
|
|
@ -28,17 +28,17 @@ use js::rust::Runtime;
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{LoadContext, load_whole_resource};
|
||||
use rand::random;
|
||||
use script_task::ScriptTaskEventCategory::WorkerEvent;
|
||||
use script_task::{ScriptTask, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg};
|
||||
use script_thread::ScriptThreadEventCategory::WorkerEvent;
|
||||
use script_thread::{ScriptThread, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg};
|
||||
use script_traits::{TimerEvent, TimerSource};
|
||||
use std::mem::replace;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
||||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
use util::task::spawn_named;
|
||||
use util::task_state;
|
||||
use util::task_state::{IN_WORKER, SCRIPT};
|
||||
use util::thread::spawn_named;
|
||||
use util::thread_state;
|
||||
use util::thread_state::{IN_WORKER, SCRIPT};
|
||||
|
||||
/// Messages used to control the worker event loops
|
||||
pub enum WorkerScriptMsg {
|
||||
|
@ -215,12 +215,15 @@ impl DedicatedWorkerGlobalScope {
|
|||
receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>) {
|
||||
let serialized_worker_url = worker_url.serialize();
|
||||
spawn_named(format!("WebWorker for {}", serialized_worker_url), move || {
|
||||
task_state::initialize(SCRIPT | IN_WORKER);
|
||||
thread_state::initialize(SCRIPT | IN_WORKER);
|
||||
|
||||
let roots = RootCollection::new();
|
||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &init.resource_task, worker_url, None) {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script,
|
||||
&init.resource_thread,
|
||||
worker_url,
|
||||
None) {
|
||||
Err(_) => {
|
||||
println!("error loading script {}", serialized_worker_url);
|
||||
parent_sender.send(CommonScriptMsg::RunnableMsg(WorkerEvent,
|
||||
|
@ -232,7 +235,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
}
|
||||
};
|
||||
|
||||
let runtime = Rc::new(ScriptTask::new_rt_and_cx());
|
||||
let runtime = Rc::new(ScriptThread::new_rt_and_cx());
|
||||
|
||||
let (devtools_mpsc_chan, devtools_mpsc_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan);
|
||||
|
@ -343,7 +346,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
let scope = self.upcast::<WorkerGlobalScope>();
|
||||
let cx = scope.get_cx();
|
||||
let path_seg = format!("url({})", scope.get_url());
|
||||
let reports = ScriptTask::get_reports(cx, path_seg);
|
||||
let reports = ScriptThread::get_reports(cx, path_seg);
|
||||
reports_chan.send(reports);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
|||
use net_traits::CookieSource::NonHTTP;
|
||||
use net_traits::{AsyncResponseTarget, PendingAsyncLoad};
|
||||
use num::ToPrimitive;
|
||||
use script_task::CSSError;
|
||||
use script_task::{MainThreadScriptMsg, Runnable};
|
||||
use script_thread::CSSError;
|
||||
use script_thread::{MainThreadScriptMsg, Runnable};
|
||||
use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg};
|
||||
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress};
|
||||
use std::ascii::AsciiExt;
|
||||
|
@ -2318,7 +2318,7 @@ impl DocumentMethods for Document {
|
|||
return Err(Error::Security);
|
||||
}
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||
let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||
let cookies = rx.recv().unwrap();
|
||||
Ok(cookies.map_or(DOMString::new(), DOMString::from))
|
||||
}
|
||||
|
@ -2331,7 +2331,7 @@ impl DocumentMethods for Document {
|
|||
return Err(Error::Security);
|
||||
}
|
||||
let _ = self.window
|
||||
.resource_task()
|
||||
.resource_thread()
|
||||
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ use encoding::label::encoding_from_whatwg_label;
|
|||
use encoding::types::{DecoderTrap, EncodingRef};
|
||||
use hyper::mime::{Attr, Mime};
|
||||
use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64};
|
||||
use script_task::ScriptTaskEventCategory::FileRead;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use script_thread::ScriptThreadEventCategory::FileRead;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
|
||||
#[derive(PartialEq, Clone, Copy, JSTraceable, HeapSizeOf)]
|
||||
pub enum FileReaderFunction {
|
||||
|
@ -360,10 +360,10 @@ impl FileReader {
|
|||
|
||||
let load_data = ReadMetaData::new(String::from(type_), label.map(String::from), function);
|
||||
|
||||
let fr = Trusted::new(self, global.file_reading_task_source());
|
||||
let fr = Trusted::new(self, global.file_reading_thread_source());
|
||||
let gen_id = self.generation_id.get();
|
||||
|
||||
let script_chan = global.file_reading_task_source();
|
||||
let script_chan = global.file_reading_thread_source();
|
||||
|
||||
spawn_named("file reader async operation".to_owned(), move || {
|
||||
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, script_chan)
|
||||
|
@ -404,17 +404,17 @@ impl Runnable for FileReaderEvent {
|
|||
}
|
||||
}
|
||||
|
||||
// https://w3c.github.io/FileAPI/#task-read-operation
|
||||
// https://w3c.github.io/FileAPI/#thread-read-operation
|
||||
fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, blob_contents: DataSlice,
|
||||
filereader: TrustedFileReader, script_chan: Box<ScriptChan + Send>) {
|
||||
let chan = &script_chan;
|
||||
// Step 4
|
||||
let task = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
|
||||
let task = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
|
||||
let task = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap();
|
||||
let thread = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents);
|
||||
chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap();
|
||||
}
|
||||
|
|
|
@ -332,11 +332,11 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
|
|||
pub mod utils {
|
||||
use dom::window::Window;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageResponse};
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageResponse};
|
||||
use url::Url;
|
||||
|
||||
pub fn request_image_from_cache(window: &Window, url: Url) -> ImageResponse {
|
||||
let image_cache = window.image_cache_task();
|
||||
let image_cache = window.image_cache_thread();
|
||||
let (response_chan, response_port) = ipc::channel().unwrap();
|
||||
image_cache.request_image(url, ImageCacheChan(response_chan), None);
|
||||
let result = response_port.recv().unwrap();
|
||||
|
|
|
@ -32,7 +32,7 @@ use hyper::header::ContentType;
|
|||
use hyper::method::Method;
|
||||
use hyper::mime;
|
||||
use msg::constellation_msg::LoadData;
|
||||
use script_task::{MainThreadScriptMsg, ScriptChan};
|
||||
use script_thread::{MainThreadScriptMsg, ScriptChan};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use string_cache::Atom;
|
||||
|
|
|
@ -22,9 +22,9 @@ use dom::virtualmethods::VirtualMethods;
|
|||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use net_traits::image::base::Image;
|
||||
use net_traits::image_cache_task::{ImageResponder, ImageResponse};
|
||||
use script_task::ScriptTaskEventCategory::UpdateReplacedElement;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use net_traits::image_cache_thread::{ImageResponder, ImageResponse};
|
||||
use script_thread::ScriptThreadEventCategory::UpdateReplacedElement;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::sync::Arc;
|
||||
use string_cache::Atom;
|
||||
use url::Url;
|
||||
|
@ -89,7 +89,7 @@ impl HTMLImageElement {
|
|||
fn update_image(&self, value: Option<(DOMString, Url)>) {
|
||||
let document = document_from_node(self);
|
||||
let window = document.window();
|
||||
let image_cache = window.image_cache_task();
|
||||
let image_cache = window.image_cache_thread();
|
||||
match value {
|
||||
None => {
|
||||
*self.url.borrow_mut() = None;
|
||||
|
@ -101,12 +101,12 @@ impl HTMLImageElement {
|
|||
let img_url = img_url.unwrap();
|
||||
*self.url.borrow_mut() = Some(img_url.clone());
|
||||
|
||||
let trusted_node = Trusted::new(self, window.networking_task_source());
|
||||
let trusted_node = Trusted::new(self, window.networking_thread_source());
|
||||
let (responder_sender, responder_receiver) = ipc::channel().unwrap();
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let wrapper = window.get_runnable_wrapper();
|
||||
ROUTER.add_route(responder_receiver.to_opaque(), box move |message| {
|
||||
// Return the image via a message to the script task, which marks the element
|
||||
// Return the image via a message to the script thread, which marks the element
|
||||
// as dirty and triggers a reflow.
|
||||
let image_response = message.to().unwrap();
|
||||
let runnable = ImageResponseHandlerRunnable::new(
|
||||
|
|
|
@ -29,8 +29,8 @@ use dom::node::{document_from_node, window_from_node};
|
|||
use dom::nodelist::NodeList;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
use msg::constellation_msg::ConstellationChan;
|
||||
use script_task::ScriptTaskEventCategory::InputEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable};
|
||||
use script_thread::ScriptThreadEventCategory::InputEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use selectors::states::*;
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -937,7 +937,7 @@ impl ChangeEventRunnable {
|
|||
pub fn send(node: &Node) {
|
||||
let window = window_from_node(node);
|
||||
let window = window.r();
|
||||
let chan = window.user_interaction_task_source();
|
||||
let chan = window.user_interaction_thread_source();
|
||||
let handler = Trusted::new(node, chan.clone());
|
||||
let dispatcher = ChangeEventRunnable {
|
||||
element: handler,
|
||||
|
|
|
@ -197,7 +197,7 @@ impl HTMLLinkElement {
|
|||
|
||||
// TODO: #8085 - Don't load external stylesheets if the node's mq doesn't match.
|
||||
let doc = window.Document();
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let elem = Trusted::new(self, script_chan.clone());
|
||||
|
||||
let context = Arc::new(Mutex::new(StylesheetContext {
|
||||
|
|
|
@ -34,8 +34,8 @@ use js::jsapi::RootedValue;
|
|||
use js::jsval::UndefinedValue;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use script_task::ScriptTaskEventCategory::ScriptEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use script_thread::ScriptThreadEventCategory::ScriptEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable, ScriptChan};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
|
@ -272,7 +272,7 @@ impl HTMLScriptElement {
|
|||
Ok(url) => {
|
||||
// Step 14.5-7.
|
||||
// TODO(#9186): use the fetch infrastructure.
|
||||
let script_chan = window.networking_task_source();
|
||||
let script_chan = window.networking_thread_source();
|
||||
let elem = Trusted::new(self, script_chan.clone());
|
||||
|
||||
let context = Arc::new(Mutex::new(ScriptContext {
|
||||
|
@ -432,7 +432,7 @@ impl HTMLScriptElement {
|
|||
if external {
|
||||
self.dispatch_load_event();
|
||||
} else {
|
||||
let chan = window.dom_manipulation_task_source();
|
||||
let chan = window.dom_manipulation_thread_source();
|
||||
let handler = Trusted::new(self, chan.clone());
|
||||
let dispatcher = box EventDispatcher {
|
||||
element: handler,
|
||||
|
@ -445,7 +445,7 @@ impl HTMLScriptElement {
|
|||
pub fn queue_error_event(&self) {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let chan = window.dom_manipulation_task_source();
|
||||
let chan = window.dom_manipulation_thread_source();
|
||||
let handler = Trusted::new(self, chan.clone());
|
||||
let dispatcher = box EventDispatcher {
|
||||
element: handler,
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
//! [`MutNullableJS`](bindings/js/struct.MutNullableJS.html) and
|
||||
//! [`MutHeap`](bindings/js/struct.MutHeap.html) smart pointers and
|
||||
//! [the tracing implementation](bindings/trace/index.html);
|
||||
//! * rooting pointers from across task boundaries or in channels: the
|
||||
//! * rooting pointers from across thread boundaries or in channels: the
|
||||
//! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer;
|
||||
//! * extracting pointers to DOM objects from their reflectors: the
|
||||
//! [`Unrooted`](bindings/js/struct.Unrooted.html) smart pointer.
|
||||
|
@ -196,7 +196,7 @@
|
|||
//! Layout code can access the DOM through the
|
||||
//! [`LayoutJS`](bindings/js/struct.LayoutJS.html) smart pointer. This does not
|
||||
//! keep the DOM object alive; we ensure that no DOM code (Garbage Collection
|
||||
//! in particular) runs while the layout task is accessing the DOM.
|
||||
//! in particular) runs while the layout thread is accessing the DOM.
|
||||
//!
|
||||
//! Methods accessible to layout are implemented on `LayoutJS<Foo>` using
|
||||
//! `LayoutFooHelpers` traits.
|
||||
|
|
|
@ -64,7 +64,7 @@ use std::iter::{self, FilterMap, Peekable};
|
|||
use std::mem;
|
||||
use string_cache::{Atom, Namespace, QualName};
|
||||
use util::str::DOMString;
|
||||
use util::task_state;
|
||||
use util::thread_state;
|
||||
use uuid::Uuid;
|
||||
|
||||
//
|
||||
|
@ -113,9 +113,9 @@ pub struct Node {
|
|||
/// are this node.
|
||||
ranges: WeakRangeVec,
|
||||
|
||||
/// Style+Layout information. Only the layout task may touch this data.
|
||||
/// Style+Layout information. Only the layout thread may touch this data.
|
||||
///
|
||||
/// Must be sent back to the layout task to be destroyed when this
|
||||
/// Must be sent back to the layout thread to be destroyed when this
|
||||
/// node is finalized.
|
||||
style_and_layout_data: Cell<Option<OpaqueStyleAndLayoutData>>,
|
||||
|
||||
|
@ -183,9 +183,9 @@ no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
|||
|
||||
|
||||
impl OpaqueStyleAndLayoutData {
|
||||
/// Sends the style and layout data, if any, back to the layout task to be destroyed.
|
||||
/// Sends the style and layout data, if any, back to the layout thread to be destroyed.
|
||||
pub fn dispose(self, node: &Node) {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
let win = window_from_node(node);
|
||||
let LayoutChan(chan) = win.layout_chan();
|
||||
node.style_and_layout_data.set(None);
|
||||
|
|
|
@ -29,7 +29,7 @@ use msg::constellation_msg::{PipelineId, SubpageId};
|
|||
use net_traits::{AsyncResponseListener, Metadata};
|
||||
use network_listener::PreInvoke;
|
||||
use parse::Parser;
|
||||
use script_task::{ScriptChan, ScriptTask};
|
||||
use script_thread::{ScriptChan, ScriptThread};
|
||||
use std::cell::Cell;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::default::Default;
|
||||
|
@ -241,7 +241,7 @@ impl AsyncResponseListener for ParserContext {
|
|||
fn headers_available(&mut self, metadata: Metadata) {
|
||||
let content_type = metadata.content_type.clone();
|
||||
|
||||
let parser = ScriptTask::page_fetch_complete(self.id.clone(), self.subpage.clone(),
|
||||
let parser = ScriptThread::page_fetch_complete(self.id.clone(), self.subpage.clone(),
|
||||
metadata);
|
||||
let parser = match parser {
|
||||
Some(parser) => parser,
|
||||
|
@ -366,7 +366,7 @@ impl<'a> Parser for &'a ServoHTMLParser {
|
|||
self.document.set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
ScriptTask::parsing_complete(pipeline);
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::window::Window;
|
|||
use js::jsapi::JSTracer;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use parse::Parser;
|
||||
use script_task::ScriptTask;
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
use url::Url;
|
||||
use xml5ever::tokenizer;
|
||||
|
@ -68,7 +68,7 @@ impl<'a> Parser for &'a ServoXMLParser {
|
|||
self.document.set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
ScriptTask::parsing_complete(pipeline);
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ use dom::event::{Event, EventBubbles, EventCancelable};
|
|||
use dom::storageevent::StorageEvent;
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType};
|
||||
use net_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType};
|
||||
use page::IterablePage;
|
||||
use script_task::{MainThreadRunnable, MainThreadScriptMsg, ScriptTask};
|
||||
use script_thread::{MainThreadRunnable, MainThreadScriptMsg, ScriptThread};
|
||||
use std::sync::mpsc::channel;
|
||||
use url::Url;
|
||||
use util::str::DOMString;
|
||||
|
@ -47,10 +47,10 @@ impl Storage {
|
|||
global_ref.get_url()
|
||||
}
|
||||
|
||||
fn get_storage_task(&self) -> StorageTask {
|
||||
fn get_storage_thread(&self) -> StorageThread {
|
||||
let global_root = self.global.root();
|
||||
let global_ref = global_root.r();
|
||||
global_ref.as_window().storage_task()
|
||||
global_ref.as_window().storage_thread()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl StorageMethods for Storage {
|
|||
fn Length(&self) -> u32 {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Length(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
receiver.recv().unwrap() as u32
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,9 @@ impl StorageMethods for Storage {
|
|||
fn Key(&self, index: u32) -> Option<DOMString> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap();
|
||||
self.get_storage_thread()
|
||||
.send(StorageThreadMsg::Key(sender, self.get_url(), self.storage_type, index))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap().map(DOMString::from)
|
||||
}
|
||||
|
||||
|
@ -77,8 +79,8 @@ impl StorageMethods for Storage {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let name = String::from(name);
|
||||
|
||||
let msg = StorageTaskMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::GetItem(sender, self.get_url(), self.storage_type, name);
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
receiver.recv().unwrap().map(DOMString::from)
|
||||
}
|
||||
|
||||
|
@ -88,8 +90,8 @@ impl StorageMethods for Storage {
|
|||
let name = String::from(name);
|
||||
let value = String::from(value);
|
||||
|
||||
let msg = StorageTaskMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone());
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
match receiver.recv().unwrap() {
|
||||
Err(_) => Err(Error::QuotaExceeded),
|
||||
Ok((changed, old_value)) => {
|
||||
|
@ -106,8 +108,8 @@ impl StorageMethods for Storage {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let name = String::from(name);
|
||||
|
||||
let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
||||
self.get_storage_task().send(msg).unwrap();
|
||||
let msg = StorageThreadMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone());
|
||||
self.get_storage_thread().send(msg).unwrap();
|
||||
if let Some(old_value) = receiver.recv().unwrap() {
|
||||
self.broadcast_change_notification(Some(name), Some(old_value), None);
|
||||
}
|
||||
|
@ -117,7 +119,7 @@ impl StorageMethods for Storage {
|
|||
fn Clear(&self) {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
if receiver.recv().unwrap() {
|
||||
self.broadcast_change_notification(None, None, None);
|
||||
}
|
||||
|
@ -127,7 +129,7 @@ impl StorageMethods for Storage {
|
|||
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
self.get_storage_task().send(StorageTaskMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
self.get_storage_thread().send(StorageThreadMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap();
|
||||
receiver.recv().unwrap().iter().cloned().map(DOMString::from).collect() // FIXME: inefficient?
|
||||
}
|
||||
|
||||
|
@ -155,7 +157,7 @@ impl Storage {
|
|||
let global_root = self.global.root();
|
||||
let global_ref = global_root.r();
|
||||
let main_script_chan = global_ref.as_window().main_thread_script_chan();
|
||||
let script_chan = global_ref.dom_manipulation_task_source();
|
||||
let script_chan = global_ref.dom_manipulation_thread_source();
|
||||
let trusted_storage = Trusted::new(self, script_chan);
|
||||
main_script_chan.send(MainThreadScriptMsg::MainThreadRunnableMsg(
|
||||
box StorageEventRunnable::new(trusted_storage, key, old_value, new_value))).unwrap();
|
||||
|
@ -177,7 +179,7 @@ impl StorageEventRunnable {
|
|||
}
|
||||
|
||||
impl MainThreadRunnable for StorageEventRunnable {
|
||||
fn handler(self: Box<StorageEventRunnable>, script_task: &ScriptTask) {
|
||||
fn handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
|
||||
let this = *self;
|
||||
let storage_root = this.element.root();
|
||||
let storage = storage_root.r();
|
||||
|
@ -195,7 +197,7 @@ impl MainThreadRunnable for StorageEventRunnable {
|
|||
Some(storage)
|
||||
);
|
||||
|
||||
let root_page = script_task.root_page();
|
||||
let root_page = script_thread.root_page();
|
||||
for it_page in root_page.iter() {
|
||||
let it_window_root = it_page.window();
|
||||
let it_window = it_window_root.r();
|
||||
|
|
|
@ -31,7 +31,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
|||
use js::jsapi::{JSContext, JSObject, RootedValue};
|
||||
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use net_traits::image_cache_task::ImageResponse;
|
||||
use net_traits::image_cache_thread::ImageResponse;
|
||||
use offscreen_gl_context::GLContextAttributes;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use std::cell::Cell;
|
||||
|
@ -91,7 +91,7 @@ impl WebGLRenderingContext {
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
constellation_chan.0
|
||||
.send(ConstellationMsg::CreateWebGLPaintTask(size, attrs, sender))
|
||||
.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender))
|
||||
.unwrap();
|
||||
let result = receiver.recv().unwrap();
|
||||
|
||||
|
@ -614,7 +614,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
}
|
||||
|
||||
// TODO(ecoal95): Probably in the future we should keep track of the
|
||||
// generated objects, either here or in the webgl task
|
||||
// generated objects, either here or in the webgl thread
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||
fn CreateBuffer(&self) -> Option<Root<WebGLBuffer>> {
|
||||
WebGLBuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone())
|
||||
|
|
|
@ -100,9 +100,9 @@ impl WebGLShader {
|
|||
&BuiltInResources::default()).unwrap();
|
||||
match validator.compile_and_translate(&[source.as_bytes()]) {
|
||||
Ok(translated_source) => {
|
||||
// NOTE: At this point we should be pretty sure that the compilation in the paint task
|
||||
// NOTE: At this point we should be pretty sure that the compilation in the paint thread
|
||||
// will succeed.
|
||||
// It could be interesting to retrieve the info log from the paint task though
|
||||
// It could be interesting to retrieve the info log from the paint thread though
|
||||
let msg = CanvasWebGLMsg::CompileShader(self.id, translated_source);
|
||||
self.renderer.send(CanvasMsg::WebGL(msg)).unwrap();
|
||||
self.compilation_status.set(ShaderCompilationStatus::Succeeded);
|
||||
|
|
|
@ -32,8 +32,8 @@ use net_traits::hosts::replace_hosts;
|
|||
use net_traits::unwrap_websocket_protocol;
|
||||
use net_traits::{WebSocketCommunicate, WebSocketConnectData, WebSocketDomAction, WebSocketNetworkEvent};
|
||||
use ref_slice::ref_slice;
|
||||
use script_task::ScriptTaskEventCategory::WebSocketEvent;
|
||||
use script_task::{CommonScriptMsg, Runnable};
|
||||
use script_thread::ScriptThreadEventCategory::WebSocketEvent;
|
||||
use script_thread::{CommonScriptMsg, Runnable};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
|
@ -139,7 +139,7 @@ pub struct WebSocket {
|
|||
global: GlobalField,
|
||||
ready_state: Cell<WebSocketRequestState>,
|
||||
buffered_amount: Cell<u64>,
|
||||
clearing_buffer: Cell<bool>, //Flag to tell if there is a running task to clear buffered_amount
|
||||
clearing_buffer: Cell<bool>, //Flag to tell if there is a running thread to clear buffered_amount
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
sender: DOMRefCell<Option<IpcSender<WebSocketDomAction>>>,
|
||||
failed: Cell<bool>, //Flag to tell if websocket was closed due to failure
|
||||
|
@ -183,7 +183,7 @@ impl WebSocket {
|
|||
-> Fallible<Root<WebSocket>> {
|
||||
// Step 1.
|
||||
let resource_url = try!(Url::parse(&url).map_err(|_| Error::Syntax));
|
||||
// Although we do this replace and parse operation again in the resource task,
|
||||
// Although we do this replace and parse operation again in the resource thread,
|
||||
// we try here to be able to immediately throw a syntax error on failure.
|
||||
let _ = try!(parse_url(&replace_hosts(&resource_url)).map_err(|_| Error::Syntax));
|
||||
// Step 2: Disallow https -> ws connections.
|
||||
|
@ -223,7 +223,7 @@ impl WebSocket {
|
|||
|
||||
// Step 7.
|
||||
let ws = WebSocket::new(global, resource_url.clone());
|
||||
let address = Trusted::new(ws.r(), global.networking_task_source());
|
||||
let address = Trusted::new(ws.r(), global.networking_thread_source());
|
||||
|
||||
let origin = global.get_url().serialize();
|
||||
let protocols: Vec<String> = protocols.iter().map(|x| String::from(x.clone())).collect();
|
||||
|
@ -234,7 +234,7 @@ impl WebSocket {
|
|||
protocols: protocols,
|
||||
};
|
||||
|
||||
// Create the interface for communication with the resource task
|
||||
// Create the interface for communication with the resource thread
|
||||
let (dom_action_sender, resource_action_receiver):
|
||||
(IpcSender<WebSocketDomAction>,
|
||||
IpcReceiver<WebSocketDomAction>) = ipc::channel().unwrap();
|
||||
|
@ -247,36 +247,36 @@ impl WebSocket {
|
|||
action_receiver: resource_action_receiver,
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let _ = resource_task.send(WebsocketConnect(connect, connect_data));
|
||||
let resource_thread = global.resource_thread();
|
||||
let _ = resource_thread.send(WebsocketConnect(connect, connect_data));
|
||||
|
||||
*ws.sender.borrow_mut() = Some(dom_action_sender);
|
||||
|
||||
let moved_address = address.clone();
|
||||
let sender = global.networking_task_source();
|
||||
let sender = global.networking_thread_source();
|
||||
thread::spawn(move || {
|
||||
while let Ok(event) = dom_event_receiver.recv() {
|
||||
match event {
|
||||
WebSocketNetworkEvent::ConnectionEstablished(headers, protocols) => {
|
||||
let open_task = box ConnectionEstablishedTask {
|
||||
let open_thread = box ConnectionEstablishedTask {
|
||||
addr: moved_address.clone(),
|
||||
headers: headers,
|
||||
protocols: protocols,
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_thread)).unwrap();
|
||||
},
|
||||
WebSocketNetworkEvent::MessageReceived(message) => {
|
||||
let message_task = box MessageReceivedTask {
|
||||
let message_thread = box MessageReceivedTask {
|
||||
address: moved_address.clone(),
|
||||
message: message,
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_thread)).unwrap();
|
||||
},
|
||||
WebSocketNetworkEvent::Close => {
|
||||
let task = box CloseTask {
|
||||
let thread = box CloseTask {
|
||||
addr: moved_address.clone(),
|
||||
};
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap();
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ impl WebSocket {
|
|||
};
|
||||
|
||||
let global = self.global.root();
|
||||
let chan = global.r().networking_task_source();
|
||||
let chan = global.r().networking_thread_source();
|
||||
let address = Trusted::new(self, chan.clone());
|
||||
|
||||
match data_byte_len.checked_add(self.buffered_amount.get()) {
|
||||
|
@ -469,11 +469,11 @@ impl Runnable for ConnectionEstablishedTask {
|
|||
if !self.protocols.is_empty() && self.headers.get::<WebSocketProtocol>().is_none() {
|
||||
ws.failed.set(true);
|
||||
ws.ready_state.set(WebSocketRequestState::Closing);
|
||||
let task = box CloseTask {
|
||||
let thread = box CloseTask {
|
||||
addr: self.addr,
|
||||
};
|
||||
let sender = global.r().networking_task_source();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap();
|
||||
let sender = global.r().networking_thread_source();
|
||||
sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ use msg::ParseErrorReporter;
|
|||
use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData};
|
||||
use msg::constellation_msg::{MozBrowserEvent, PipelineId, SubpageId, WindowSizeData};
|
||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||
use net_traits::ResourceTask;
|
||||
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
|
||||
use net_traits::storage_task::{StorageTask, StorageType};
|
||||
use net_traits::ResourceThread;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::storage_thread::{StorageThread, StorageType};
|
||||
use num::traits::ToPrimitive;
|
||||
use page::Page;
|
||||
use profile_traits::mem;
|
||||
use reporter::CSSErrorReporter;
|
||||
use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
|
||||
use script_task::{DOMManipulationTaskSource, UserInteractionTaskSource, NetworkingTaskSource};
|
||||
use script_task::{HistoryTraversalTaskSource, FileReadingTaskSource, SendableMainThreadScriptChan};
|
||||
use script_task::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
|
||||
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
|
||||
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::{MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use selectors::parser::PseudoElement;
|
||||
|
@ -116,21 +116,21 @@ pub struct Window {
|
|||
eventtarget: EventTarget,
|
||||
#[ignore_heap_size_of = "trait objects are hard"]
|
||||
script_chan: MainThreadScriptChan,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
dom_manipulation_task_source: DOMManipulationTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
user_interaction_task_source: UserInteractionTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
networking_task_source: NetworkingTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
history_traversal_task_source: HistoryTraversalTaskSource,
|
||||
#[ignore_heap_size_of = "task sources are hard"]
|
||||
file_reading_task_source: FileReadingTaskSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
dom_manipulation_thread_source: DOMManipulationThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
user_interaction_thread_source: UserInteractionThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
networking_thread_source: NetworkingThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
history_traversal_thread_source: HistoryTraversalThreadSource,
|
||||
#[ignore_heap_size_of = "thread sources are hard"]
|
||||
file_reading_thread_source: FileReadingThreadSource,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
crypto: MutNullableHeap<JS<Crypto>>,
|
||||
navigator: MutNullableHeap<JS<Navigator>>,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_task: ImageCacheTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_chan: ImageCacheChan,
|
||||
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
|
||||
|
@ -185,7 +185,7 @@ pub struct Window {
|
|||
#[ignore_heap_size_of = "Rc<T> is hard"]
|
||||
js_runtime: DOMRefCell<Option<Rc<Runtime>>>,
|
||||
|
||||
/// A handle for communicating messages to the layout task.
|
||||
/// A handle for communicating messages to the layout thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
layout_chan: LayoutChan,
|
||||
|
||||
|
@ -196,15 +196,15 @@ pub struct Window {
|
|||
/// The current size of the window, in pixels.
|
||||
window_size: Cell<Option<WindowSizeData>>,
|
||||
|
||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||
/// Associated resource thread for use by DOM objects like XMLHttpRequest
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
resource_task: Arc<ResourceTask>,
|
||||
resource_thread: Arc<ResourceThread>,
|
||||
|
||||
/// A handle for communicating messages to the storage task.
|
||||
/// A handle for communicating messages to the storage thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
storage_task: StorageTask,
|
||||
storage_thread: StorageThread,
|
||||
|
||||
/// A handle for communicating messages to the constellation task.
|
||||
/// A handle for communicating messages to the constellation thread.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
||||
|
@ -249,24 +249,24 @@ impl Window {
|
|||
self.js_runtime.borrow().as_ref().unwrap().cx()
|
||||
}
|
||||
|
||||
pub fn dom_manipulation_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.dom_manipulation_task_source.clone()
|
||||
pub fn dom_manipulation_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.dom_manipulation_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn user_interaction_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.user_interaction_task_source.clone()
|
||||
pub fn user_interaction_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.user_interaction_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn networking_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.networking_task_source.clone()
|
||||
pub fn networking_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.networking_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn history_traversal_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.history_traversal_task_source.clone()
|
||||
pub fn history_traversal_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.history_traversal_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn file_reading_task_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.file_reading_task_source.clone()
|
||||
pub fn file_reading_thread_source(&self) -> Box<ScriptChan + Send> {
|
||||
self.file_reading_thread_source.clone()
|
||||
}
|
||||
|
||||
pub fn main_thread_script_chan(&self) -> &Sender<MainThreadScriptMsg> {
|
||||
|
@ -302,8 +302,8 @@ impl Window {
|
|||
(box SendableMainThreadScriptChan(tx), box rx)
|
||||
}
|
||||
|
||||
pub fn image_cache_task(&self) -> &ImageCacheTask {
|
||||
&self.image_cache_task
|
||||
pub fn image_cache_thread(&self) -> &ImageCacheThread {
|
||||
&self.image_cache_thread
|
||||
}
|
||||
|
||||
pub fn compositor(&self) -> &IpcSender<ScriptToCompositorMsg> {
|
||||
|
@ -318,8 +318,8 @@ impl Window {
|
|||
&*self.page
|
||||
}
|
||||
|
||||
pub fn storage_task(&self) -> StorageTask {
|
||||
self.storage_task.clone()
|
||||
pub fn storage_thread(&self) -> StorageThread {
|
||||
self.storage_thread.clone()
|
||||
}
|
||||
|
||||
pub fn css_error_reporter(&self) -> Box<ParseErrorReporter + Send> {
|
||||
|
@ -837,10 +837,10 @@ impl Window {
|
|||
// (e.g. DOM objects removed from the tree that haven't
|
||||
// been collected yet). Forcing a GC here means that
|
||||
// those DOM objects will be able to call dispose()
|
||||
// to free their layout data before the layout task
|
||||
// to free their layout data before the layout thread
|
||||
// exits. Without this, those remaining objects try to
|
||||
// send a message to free their layout data to the
|
||||
// layout task when the script task is dropped,
|
||||
// layout thread when the script thread is dropped,
|
||||
// which causes a panic!
|
||||
self.Gc();
|
||||
|
||||
|
@ -981,7 +981,7 @@ impl Window {
|
|||
}
|
||||
Ok(_) => {}
|
||||
Err(Disconnected) => {
|
||||
panic!("Layout task failed while script was waiting for a result.");
|
||||
panic!("Layout thread failed while script was waiting for a result.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1018,7 @@ impl Window {
|
|||
// 2) The html element doesn't contain the 'reftest-wait' class
|
||||
// 3) The load event has fired.
|
||||
// When all these conditions are met, notify the constellation
|
||||
// that this pipeline is ready to write the image (from the script task
|
||||
// that this pipeline is ready to write the image (from the script thread
|
||||
// perspective at least).
|
||||
if opts::get().output_file.is_some() && for_display {
|
||||
let document = self.Document();
|
||||
|
@ -1126,8 +1126,8 @@ impl Window {
|
|||
(*self.Document().url()).clone()
|
||||
}
|
||||
|
||||
pub fn resource_task(&self) -> ResourceTask {
|
||||
(*self.resource_task).clone()
|
||||
pub fn resource_thread(&self) -> ResourceThread {
|
||||
(*self.resource_thread).clone()
|
||||
}
|
||||
|
||||
pub fn mem_profiler_chan(&self) -> mem::ProfilerChan {
|
||||
|
@ -1288,16 +1288,16 @@ impl Window {
|
|||
pub fn new(runtime: Rc<Runtime>,
|
||||
page: Rc<Page>,
|
||||
script_chan: MainThreadScriptChan,
|
||||
dom_task_source: DOMManipulationTaskSource,
|
||||
user_task_source: UserInteractionTaskSource,
|
||||
network_task_source: NetworkingTaskSource,
|
||||
history_task_source: HistoryTraversalTaskSource,
|
||||
file_task_source: FileReadingTaskSource,
|
||||
dom_thread_source: DOMManipulationThreadSource,
|
||||
user_thread_source: UserInteractionThreadSource,
|
||||
network_thread_source: NetworkingThreadSource,
|
||||
history_thread_source: HistoryTraversalThreadSource,
|
||||
file_thread_source: FileReadingThreadSource,
|
||||
image_cache_chan: ImageCacheChan,
|
||||
compositor: IpcSender<ScriptToCompositorMsg>,
|
||||
image_cache_task: ImageCacheTask,
|
||||
resource_task: Arc<ResourceTask>,
|
||||
storage_task: StorageTask,
|
||||
image_cache_thread: ImageCacheThread,
|
||||
resource_thread: Arc<ResourceThread>,
|
||||
storage_thread: StorageThread,
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||
|
@ -1318,18 +1318,18 @@ impl Window {
|
|||
let win = box Window {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
script_chan: script_chan,
|
||||
dom_manipulation_task_source: dom_task_source,
|
||||
user_interaction_task_source: user_task_source,
|
||||
networking_task_source: network_task_source,
|
||||
history_traversal_task_source: history_task_source,
|
||||
file_reading_task_source: file_task_source,
|
||||
dom_manipulation_thread_source: dom_thread_source,
|
||||
user_interaction_thread_source: user_thread_source,
|
||||
networking_thread_source: network_thread_source,
|
||||
history_traversal_thread_source: history_thread_source,
|
||||
file_reading_thread_source: file_thread_source,
|
||||
image_cache_chan: image_cache_chan,
|
||||
console: Default::default(),
|
||||
crypto: Default::default(),
|
||||
compositor: compositor,
|
||||
page: page,
|
||||
navigator: Default::default(),
|
||||
image_cache_task: image_cache_task,
|
||||
image_cache_thread: image_cache_thread,
|
||||
mem_profiler_chan: mem_profiler_chan,
|
||||
devtools_chan: devtools_chan,
|
||||
browsing_context: Default::default(),
|
||||
|
@ -1346,8 +1346,8 @@ impl Window {
|
|||
parent_info: parent_info,
|
||||
dom_static: GlobalStaticData::new(),
|
||||
js_runtime: DOMRefCell::new(Some(runtime.clone())),
|
||||
resource_task: resource_task,
|
||||
storage_task: storage_task,
|
||||
resource_thread: resource_thread,
|
||||
storage_thread: storage_thread,
|
||||
constellation_chan: constellation_chan,
|
||||
page_clip_rect: Cell::new(MAX_RECT),
|
||||
fragment_name: DOMRefCell::new(None),
|
||||
|
|
|
@ -24,7 +24,7 @@ use ipc_channel::ipc;
|
|||
use js::jsapi::{HandleValue, JSContext, RootedValue};
|
||||
use js::jsapi::{JSAutoCompartment, JSAutoRequest};
|
||||
use js::jsval::UndefinedValue;
|
||||
use script_task::{Runnable, ScriptChan};
|
||||
use script_thread::{Runnable, ScriptChan};
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::str::DOMString;
|
||||
|
||||
|
@ -68,13 +68,13 @@ impl Worker {
|
|||
Err(_) => return Err(Error::Syntax),
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let resource_thread = global.resource_thread();
|
||||
let constellation_chan = global.constellation_chan();
|
||||
let scheduler_chan = global.scheduler_chan();
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
let worker = Worker::new(global, sender.clone());
|
||||
let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_task_source());
|
||||
let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_thread_source());
|
||||
let worker_id = global.get_next_worker_id();
|
||||
|
||||
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
|
||||
|
@ -95,7 +95,7 @@ impl Worker {
|
|||
};
|
||||
|
||||
let init = WorkerGlobalScopeInit {
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
mem_profiler_chan: global.mem_profiler_chan(),
|
||||
to_devtools_sender: global.devtools_chan(),
|
||||
from_devtools_sender: optional_sender,
|
||||
|
@ -105,7 +105,7 @@ impl Worker {
|
|||
};
|
||||
DedicatedWorkerGlobalScope::run_worker_scope(
|
||||
init, worker_url, global.pipeline(), devtools_receiver, worker_ref,
|
||||
global.dom_manipulation_task_source(), sender, receiver);
|
||||
global.dom_manipulation_thread_source(), sender, receiver);
|
||||
|
||||
Ok(worker)
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ impl WorkerMethods for Worker {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage
|
||||
fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult {
|
||||
let data = try!(StructuredCloneData::write(cx, message));
|
||||
let address = Trusted::new(self, self.global.root().r().dom_manipulation_task_source());
|
||||
let address = Trusted::new(self, self.global.root().r().dom_manipulation_thread_source());
|
||||
self.sender.send((address, WorkerScriptMsg::DOMMessage(data))).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ use ipc_channel::ipc::IpcSender;
|
|||
use js::jsapi::{HandleValue, JSAutoRequest, JSContext};
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use net_traits::{LoadContext, ResourceTask, load_whole_resource};
|
||||
use net_traits::{LoadContext, ResourceThread, load_whole_resource};
|
||||
use profile_traits::mem;
|
||||
use script_task::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
|
||||
use std::cell::Cell;
|
||||
|
@ -40,7 +40,7 @@ pub enum WorkerGlobalScopeTypeId {
|
|||
}
|
||||
|
||||
pub struct WorkerGlobalScopeInit {
|
||||
pub resource_task: ResourceTask,
|
||||
pub resource_thread: ResourceThread,
|
||||
pub mem_profiler_chan: mem::ProfilerChan,
|
||||
pub to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||
|
@ -59,7 +59,7 @@ pub struct WorkerGlobalScope {
|
|||
runtime: Rc<Runtime>,
|
||||
next_worker_id: Cell<WorkerId>,
|
||||
#[ignore_heap_size_of = "Defined in std"]
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
location: MutNullableHeap<JS<WorkerLocation>>,
|
||||
navigator: MutNullableHeap<JS<WorkerNavigator>>,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
|
@ -104,7 +104,7 @@ impl WorkerGlobalScope {
|
|||
worker_id: init.worker_id,
|
||||
worker_url: worker_url,
|
||||
runtime: runtime,
|
||||
resource_task: init.resource_task,
|
||||
resource_thread: init.resource_thread,
|
||||
location: Default::default(),
|
||||
navigator: Default::default(),
|
||||
console: Default::default(),
|
||||
|
@ -158,8 +158,8 @@ impl WorkerGlobalScope {
|
|||
self.runtime.cx()
|
||||
}
|
||||
|
||||
pub fn resource_task(&self) -> &ResourceTask {
|
||||
&self.resource_task
|
||||
pub fn resource_thread(&self) -> &ResourceThread {
|
||||
&self.resource_thread
|
||||
}
|
||||
|
||||
pub fn get_url(&self) -> &Url {
|
||||
|
@ -203,7 +203,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
}
|
||||
|
||||
for url in urls {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_task, url, None) {
|
||||
let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_thread, url, None) {
|
||||
Err(_) => return Err(Error::Network),
|
||||
Ok((metadata, bytes)) => {
|
||||
(metadata.final_url, String::from_utf8(bytes).unwrap())
|
||||
|
|
|
@ -46,11 +46,11 @@ use js::jsapi::{JSContext, JS_ParseJSON, RootedValue};
|
|||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::ControlMsg::Load;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceTask};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceThread};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
use parse::html::{ParseContext, parse_html};
|
||||
use parse::xml::{self, parse_xml};
|
||||
use script_task::{ScriptChan, ScriptPort};
|
||||
use script_thread::{ScriptChan, ScriptPort};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -197,13 +197,13 @@ impl XMLHttpRequest {
|
|||
load_data: LoadData,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask) {
|
||||
resource_thread: ResourceThread) {
|
||||
struct CORSContext {
|
||||
xhr: Arc<Mutex<XHRContext>>,
|
||||
load_data: RefCell<Option<LoadData>>,
|
||||
req: CORSRequest,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
}
|
||||
|
||||
impl AsyncCORSResponseListener for CORSContext {
|
||||
|
@ -223,7 +223,7 @@ impl XMLHttpRequest {
|
|||
});
|
||||
|
||||
XMLHttpRequest::initiate_async_xhr(self.xhr.clone(), self.script_chan.clone(),
|
||||
self.resource_task.clone(), load_data);
|
||||
self.resource_thread.clone(), load_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ impl XMLHttpRequest {
|
|||
load_data: RefCell::new(Some(load_data)),
|
||||
req: req.clone(),
|
||||
script_chan: script_chan.clone(),
|
||||
resource_task: resource_task,
|
||||
resource_thread: resource_thread,
|
||||
};
|
||||
|
||||
req.http_fetch_async(box cors_context, script_chan);
|
||||
|
@ -240,7 +240,7 @@ impl XMLHttpRequest {
|
|||
|
||||
fn initiate_async_xhr(context: Arc<Mutex<XHRContext>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
resource_task: ResourceTask,
|
||||
resource_thread: ResourceThread,
|
||||
load_data: LoadData) {
|
||||
impl AsyncResponseListener for XHRContext {
|
||||
fn headers_available(&mut self, metadata: Metadata) {
|
||||
|
@ -281,7 +281,7 @@ impl XMLHttpRequest {
|
|||
ROUTER.add_route(action_receiver.to_opaque(), box move |message| {
|
||||
listener.notify(message.to().unwrap());
|
||||
});
|
||||
resource_task.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
resource_thread.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1026,7 +1026,7 @@ impl XMLHttpRequest {
|
|||
// This will cancel all previous timeouts
|
||||
let global = self.global.root();
|
||||
let callback = ScheduledXHRTimeout {
|
||||
xhr: Trusted::new(self, global.r().networking_task_source()),
|
||||
xhr: Trusted::new(self, global.r().networking_thread_source()),
|
||||
generation_id: self.generation_id.get(),
|
||||
};
|
||||
let duration = Length::new(duration_ms as u64);
|
||||
|
@ -1178,7 +1178,7 @@ impl XMLHttpRequest {
|
|||
Ok(req) => req,
|
||||
};
|
||||
|
||||
let xhr = Trusted::new(self, global.networking_task_source());
|
||||
let xhr = Trusted::new(self, global.networking_thread_source());
|
||||
|
||||
let context = Arc::new(Mutex::new(XHRContext {
|
||||
xhr: xhr,
|
||||
|
@ -1192,16 +1192,16 @@ impl XMLHttpRequest {
|
|||
let (tx, rx) = global.new_script_pair();
|
||||
(tx, Some(rx))
|
||||
} else {
|
||||
(global.networking_task_source(), None)
|
||||
(global.networking_thread_source(), None)
|
||||
};
|
||||
|
||||
let resource_task = global.resource_task();
|
||||
let resource_thread = global.resource_thread();
|
||||
if let Some(req) = cors_request {
|
||||
XMLHttpRequest::check_cors(context.clone(), load_data, req.clone(),
|
||||
script_chan.clone(), resource_task);
|
||||
script_chan.clone(), resource_thread);
|
||||
} else {
|
||||
XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan,
|
||||
resource_task, load_data);
|
||||
resource_thread, load_data);
|
||||
}
|
||||
|
||||
if let Some(script_port) = script_port {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue