Skip to content
Permalink
Browse files

Pass the javscript file url to the evaluate function

  • Loading branch information...
evilpie committed Sep 1, 2013
1 parent c532c73 commit a0d900e1f6b89a920a4b143f8dc3ef718cd27fb2
Showing with 16 additions and 7 deletions.
  1. +13 −4 src/components/script/html/hubbub_html_parser.rs
  2. +3 −3 src/components/script/script_task.rs
@@ -59,7 +59,12 @@ macro_rules! handle_htmlelement(
)
)

type JSResult = ~[~[u8]];
pub struct JSFile {
data: ~[u8],
url: Url
}

type JSResult = ~[JSFile];

enum CSSMessage {
CSSTaskNewFile(StylesheetProvenance),
@@ -145,6 +150,7 @@ fn js_script_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
JSTaskNewFile(url) => {
let (result_port, result_chan) = comm::stream();
let resource_task = resource_task.clone();
let url_clone = url.clone();
do task::spawn {
let (input_port, input_chan) = comm::stream();
// TODO: change copy to move once we can move into closures
@@ -168,16 +174,19 @@ fn js_script_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
}
}
}
result_vec.push(result_port);

let bytes = result_port.recv();
if bytes.is_some() {
result_vec.push(JSFile { data: bytes.unwrap(), url: url_clone });
}
}
JSTaskExit => {
break;
}
}
}

let js_scripts = result_vec.iter().filter_map(|result_port| result_port.recv()).collect();
to_parent.send(HtmlDiscoveredScript(js_scripts));
to_parent.send(HtmlDiscoveredScript(result_vec));
}

// Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized
@@ -682,10 +682,10 @@ impl ScriptTask {
js_info.js_compartment.define_functions(debug_fns);

// Evaluate every script in the document.
for bytes in js_scripts.iter() {
for file in js_scripts.iter() {
let _ = js_info.js_context.evaluate_script(js_info.js_compartment.global_obj,
bytes.clone(),
~"???",
file.data.clone(),
file.url.to_str(),
1);
}
}

5 comments on commit a0d900e

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Sep 1, 2013

saw approval from metajack
at evilpie@a0d900e

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Sep 1, 2013

merging evilpie/servo/file-url = a0d900e into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Sep 1, 2013

evilpie/servo/file-url = a0d900e merged ok, testing candidate = 7ea10ff

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Sep 1, 2013

fast-forwarding master to auto = 7ea10ff

Please sign in to comment.
You can’t perform that action at this time.