mirror of
https://github.com/servo/servo.git
synced 2025-06-18 22:34:30 +01:00
Pass scripts as ~str to support non-ASCII string literals etc.
Of course scripts on the Web are not always encoded as UTF-8 and we will have to deal with that at some point.
This commit is contained in:
parent
c539945401
commit
279ae53b7b
3 changed files with 7 additions and 5 deletions
|
@ -19,6 +19,7 @@ use std::cast;
|
|||
use std::cell::Cell;
|
||||
use std::comm;
|
||||
use std::comm::{Port, SharedChan};
|
||||
use std::str;
|
||||
use std::str::eq_slice;
|
||||
use std::task;
|
||||
use std::from_str::FromStr;
|
||||
|
@ -102,7 +103,7 @@ macro_rules! handle_element_base(
|
|||
|
||||
|
||||
pub struct JSFile {
|
||||
data: ~[u8],
|
||||
data: ~str,
|
||||
url: Url
|
||||
}
|
||||
|
||||
|
@ -222,11 +223,11 @@ fn js_script_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
|
|||
|
||||
let bytes = result_port.recv();
|
||||
if bytes.is_some() {
|
||||
result_vec.push(JSFile { data: bytes.unwrap(), url: url_clone });
|
||||
result_vec.push(JSFile { data: str::from_utf8(bytes.unwrap()), url: url_clone });
|
||||
}
|
||||
}
|
||||
JSTaskNewInlineScript(data, url) => {
|
||||
result_vec.push(JSFile { data: data.into_bytes(), url: url });
|
||||
result_vec.push(JSFile { data: data, url: url });
|
||||
}
|
||||
JSTaskExit => {
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@ use std::comm;
|
|||
use std::comm::{Port, SharedChan};
|
||||
use std::io::read_whole_file;
|
||||
use std::ptr;
|
||||
use std::str;
|
||||
use std::task::{spawn_sched, SingleThreaded};
|
||||
use std::util::replace;
|
||||
use dom::window::TimerData;
|
||||
|
@ -578,7 +579,7 @@ impl ScriptTask {
|
|||
Ok(bytes) => {
|
||||
compartment.define_functions(debug_fns);
|
||||
cx.evaluate_script(compartment.global_obj,
|
||||
bytes,
|
||||
str::from_utf8(bytes),
|
||||
url.path.clone(),
|
||||
1);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1a9a5c3c1462bd3b3e7905ee2834a5ba906f0214
|
||||
Subproject commit 7372f6b7ed1cfa66f0883667d4b08901487c9ab2
|
Loading…
Add table
Add a link
Reference in a new issue