aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-03-05 09:22:58 -0500
committerJosh Matthews <josh@joshmatthews.net>2015-04-16 11:46:40 -0400
commit01e66035ffb621e57466f0a2ff73d0cbd795eb1c (patch)
tree72f135418a030770a5a8ed067a8947a623d36490 /components/script/script_task.rs
parent2ee21ddbe79fa3a3b01f446ad1e6d23e67c68e46 (diff)
downloadservo-01e66035ffb621e57466f0a2ff73d0cbd795eb1c.tar.gz
servo-01e66035ffb621e57466f0a2ff73d0cbd795eb1c.zip
Implement sync XHR by creating and spinning on-demand event loops.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index b304a15afda..e43ca69a981 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -38,6 +38,7 @@ use dom::uievent::UIEvent;
use dom::eventtarget::EventTarget;
use dom::node::{self, Node, NodeHelpers, NodeDamage, window_from_node};
use dom::window::{Window, WindowHelpers, ScriptHelpers, ReflowReason};
+use dom::worker::TrustedWorkerAddress;
use parse::html::{HTMLInput, parse_html};
use layout_interface::{ScriptLayoutChan, LayoutChan, ReflowGoal, ReflowQueryType};
use layout_interface;
@@ -200,6 +201,22 @@ pub trait ScriptChan {
fn clone(&self) -> Box<ScriptChan+Send>;
}
+pub trait ScriptPort {
+ fn recv(&self) -> ScriptMsg;
+}
+
+impl ScriptPort for Receiver<ScriptMsg> {
+ fn recv(&self) -> ScriptMsg {
+ self.recv().unwrap()
+ }
+}
+
+impl ScriptPort for Receiver<(TrustedWorkerAddress, ScriptMsg)> {
+ fn recv(&self) -> ScriptMsg {
+ self.recv().unwrap().1
+ }
+}
+
/// Encapsulates internal communication within the script task.
#[jstraceable]
pub struct NonWorkerScriptChan(pub Sender<ScriptMsg>);
@@ -403,6 +420,15 @@ unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus)
}
impl ScriptTask {
+ pub fn process_event(msg: ScriptMsg) {
+ SCRIPT_TASK_ROOT.with(|root| {
+ if let Some(script_task) = *root.borrow() {
+ let script_task = unsafe { &*script_task };
+ script_task.handle_msg_from_script(msg);
+ }
+ });
+ }
+
/// Creates a new script task.
pub fn new(compositor: Box<ScriptListener+'static>,
port: Receiver<ScriptMsg>,