mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Infrastructure for synchronous script loading
This implements the parts of the "prepare a script element" algorithm that are required for synchronous scripts. It also adds some infrastructure for future support of the `async` and `defer` attributes.
This commit is contained in:
parent
5858fccf87
commit
65a0d1fe9a
4 changed files with 142 additions and 14 deletions
|
@ -318,15 +318,20 @@ pub trait WindowHelpers {
|
|||
fn load_url(self, href: DOMString);
|
||||
fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext);
|
||||
fn evaluate_js_with_result(self, code: &str) -> JSVal;
|
||||
fn evaluate_script_with_result(self, code: &str, filename: &str) -> JSVal;
|
||||
}
|
||||
|
||||
|
||||
impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||
fn evaluate_js_with_result(self, code: &str) -> JSVal {
|
||||
self.evaluate_script_with_result(code, "")
|
||||
}
|
||||
|
||||
fn evaluate_script_with_result(self, code: &str, filename: &str) -> JSVal {
|
||||
let global = self.reflector().get_jsobject();
|
||||
let code: Vec<u16> = code.as_slice().utf16_units().collect();
|
||||
let mut rval = UndefinedValue();
|
||||
let filename = "".to_c_str();
|
||||
let filename = filename.to_c_str();
|
||||
let cx = self.get_cx();
|
||||
|
||||
with_compartment(cx, global, || {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue