aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/script_task.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-08-11 16:41:16 +0200
committerMs2ger <ms2ger@gmail.com>2014-08-11 16:41:18 +0200
commit96aad42a5d219e8219b2f94047eba967bb7affe0 (patch)
tree71a875d3bb239d39c901ebc9b3533f696b36386b /src/components/script/script_task.rs
parent8e597069336d63914d8ab40d79c6f21ad21122bd (diff)
downloadservo-96aad42a5d219e8219b2f94047eba967bb7affe0.tar.gz
servo-96aad42a5d219e8219b2f94047eba967bb7affe0.zip
Give workers their own ScriptChan and use it for postMessage.
This ensures that XHR callbacks for XHR objects in workers are called on the worker thread rather than the main thread.
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r--src/components/script/script_task.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 2f7df8d6ddd..0d24eaccbba 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -31,12 +31,6 @@ use layout_interface::ContentChangedDocumentDamage;
use layout_interface;
use page::{Page, IterablePage, Frame};
-use geom::point::Point2D;
-use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC};
-use js::jsapi::{JSContext, JSRuntime};
-use js::rust::{Cx, RtUtils};
-use js::rust::with_compartment;
-use js;
use script_traits::{CompositorEvent, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent};
use script_traits::{MouseMoveEvent, MouseUpEvent, ConstellationControlMsg, ScriptTaskFactory};
use script_traits::{ResizeMsg, AttachLayoutMsg, LoadMsg, SendEventMsg, ResizeInactiveMsg};
@@ -50,15 +44,23 @@ use servo_msg::constellation_msg;
use servo_net::image_cache_task::ImageCacheTask;
use servo_net::resource_task::ResourceTask;
use servo_util::geometry::to_frac_px;
+use servo_util::str::DOMString;
use servo_util::task::spawn_named_with_send_on_failure;
+
+use geom::point::Point2D;
+use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC};
+use js::jsapi::{JSContext, JSRuntime};
+use js::rust::{Cx, RtUtils};
+use js::rust::with_compartment;
+use js;
+use url::Url;
+
+use serialize::{Encoder, Encodable};
use std::any::{Any, AnyRefExt};
use std::cell::RefCell;
use std::comm::{channel, Sender, Receiver, Select};
use std::mem::replace;
use std::rc::Rc;
-use url::Url;
-
-use serialize::{Encoder, Encodable};
local_data_key!(pub StackRoots: *const RootCollection)
@@ -75,7 +77,9 @@ pub enum ScriptMsg {
/// Notifies the script that a window associated with a particular pipeline should be closed.
ExitWindowMsg(PipelineId),
/// Notifies the script of progress on a fetch
- XHRProgressMsg(TrustedXHRAddress, XHRProgress)
+ XHRProgressMsg(TrustedXHRAddress, XHRProgress),
+ /// Message sent through postMessage
+ DOMMessage(DOMString),
}
/// Encapsulates internal communication within the script task.
@@ -430,6 +434,7 @@ impl ScriptTask {
FromScript(ExitWindowMsg(id)) => self.handle_exit_window_msg(id),
FromConstellation(ResizeMsg(..)) => fail!("should have handled ResizeMsg already"),
FromScript(XHRProgressMsg(addr, progress)) => XMLHttpRequest::handle_xhr_progress(addr, progress),
+ FromScript(DOMMessage(..)) => fail!("unexpected message"),
}
}