aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/script_task.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2014-04-17 23:13:34 -0400
committerJosh Matthews <josh@joshmatthews.net>2014-05-03 14:18:31 -0400
commitaaf0a6119414072b34e3ef2109827eaf2f2a3156 (patch)
tree2bae4de6f3fc306b8721858ed37ad98e09a7215c /src/components/script/script_task.rs
parenta09a4bd297d48c2702e1e15a901b1fdec32dda83 (diff)
downloadservo-aaf0a6119414072b34e3ef2109827eaf2f2a3156.tar.gz
servo-aaf0a6119414072b34e3ef2109827eaf2f2a3156.zip
Store per-ScriptTask RootCollection in TLS and use that in favour of per-frame collections.
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r--src/components/script/script_task.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index c945f8c3451..2bfe058cc65 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -55,6 +55,7 @@ use servo_util::namespace::Null;
use std::cast;
use std::cell::{RefCell, Ref, RefMut};
use std::comm::{channel, Sender, Receiver, Empty, Disconnected, Data};
+use std::local_data;
use std::mem::replace;
use std::ptr;
use std::rc::Rc;
@@ -63,6 +64,8 @@ use url::Url;
use serialize::{Encoder, Encodable};
+local_data_key!(pub StackRoots: *RootCollection)
+
/// Messages used to control the script task.
pub enum ScriptMsg {
/// Loads a new URL on the specified pipeline.
@@ -510,6 +513,21 @@ pub struct JSPageInfo {
pub js_context: Untraceable<Rc<Cx>>,
}
+struct StackRootTLS;
+
+impl StackRootTLS {
+ fn new(roots: &RootCollection) -> StackRootTLS {
+ local_data::set(StackRoots, roots as *RootCollection);
+ StackRootTLS
+ }
+}
+
+impl Drop for StackRootTLS {
+ fn drop(&mut self) {
+ let _ = local_data::pop(StackRoots);
+ }
+}
+
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
/// frames.
///
@@ -653,6 +671,9 @@ impl ScriptTask {
/// Handle incoming control messages.
fn handle_msgs(&self) -> bool {
+ let roots = RootCollection::new();
+ let _stack_roots_tls = StackRootTLS::new(&roots);
+
// Handle pending resize events.
// Gather them first to avoid a double mut borrow on self.
let mut resizes = vec!();