Get rid of a bunch of explicit derefs

This commit is contained in:
David Zbarsky 2015-11-02 22:26:50 -08:00
parent ca56ebbb09
commit 722aa86c89
49 changed files with 340 additions and 360 deletions

View file

@ -154,11 +154,11 @@ impl AsyncResponseListener for ScriptContext {
});
let elem = self.elem.root();
// TODO: maybe set this to None again after script execution to save memory.
*elem.r().load.borrow_mut() = Some(ScriptOrigin::External(load));
*elem.load.borrow_mut() = Some(ScriptOrigin::External(load));
elem.ready_to_be_parser_executed.set(true);
let document = document_from_node(elem.r());
document.r().finish_load(LoadType::Script(self.url.clone()));
document.finish_load(LoadType::Script(self.url.clone()));
}
}
@ -237,7 +237,7 @@ impl HTMLScriptElement {
// Step 13.
if let Some(ref charset) = element.get_attribute(&ns!(""), &atom!("charset")) {
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.r().Value()) {
if let Some(encodingRef) = encoding_from_whatwg_label(&charset.Value()) {
*self.block_character_encoding.borrow_mut() = encodingRef;
}
}
@ -296,7 +296,7 @@ impl HTMLScriptElement {
listener.notify(message.to().unwrap());
});
doc.r().load_async(LoadType::Script(url), response_target);
doc.load_async(LoadType::Script(url), response_target);
}
}
true
@ -310,32 +310,32 @@ impl HTMLScriptElement {
deferred &&
was_parser_inserted &&
!async {
doc.r().add_deferred_script(self);
doc.add_deferred_script(self);
// Second part implemented in Document::process_deferred_scripts.
return NextParserState::Continue;
// Step 15.b, has src, was parser-inserted, is not async.
} else if is_external &&
was_parser_inserted &&
!async {
doc.r().set_pending_parsing_blocking_script(Some(self));
doc.set_pending_parsing_blocking_script(Some(self));
// Second part implemented in the load result handler.
// Step 15.c, doesn't have src, was parser-inserted, is blocked on stylesheet.
} else if !is_external &&
was_parser_inserted &&
// TODO: check for script nesting levels.
doc.r().get_script_blocking_stylesheets_count() > 0 {
doc.r().set_pending_parsing_blocking_script(Some(self));
doc.get_script_blocking_stylesheets_count() > 0 {
doc.set_pending_parsing_blocking_script(Some(self));
*self.load.borrow_mut() = Some(ScriptOrigin::Internal(text, base_url));
self.ready_to_be_parser_executed.set(true);
// Step 15.d, has src, isn't async, isn't non-blocking.
} else if is_external &&
!async &&
!self.non_blocking.get() {
doc.r().push_asap_in_order_script(self);
doc.push_asap_in_order_script(self);
// Second part implemented in Document::process_asap_scripts.
// Step 15.e, has src.
} else if is_external {
doc.r().add_asap_script(self);
doc.add_asap_script(self);
// Second part implemented in Document::process_asap_scripts.
// Step 15.f, otherwise.
} else {
@ -347,8 +347,8 @@ impl HTMLScriptElement {
}
// TODO: make this suspension happen automatically.
if was_parser_inserted {
if let Some(parser) = doc.r().get_current_parser() {
parser.r().suspend();
if let Some(parser) = doc.get_current_parser() {
parser.suspend();
}
}
return NextParserState::Suspend;
@ -432,8 +432,8 @@ impl HTMLScriptElement {
// Step 2.b.6.
// TODO: Create a script...
let window = window_from_node(self);
let mut rval = RootedValue::new(window.r().get_cx(), UndefinedValue());
window.r().evaluate_script_on_global_with_result(&*source,
let mut rval = RootedValue::new(window.get_cx(), UndefinedValue());
window.evaluate_script_on_global_with_result(&*source,
&*url.serialize(),
rval.handle_mut());
@ -451,8 +451,8 @@ impl HTMLScriptElement {
if external {
self.dispatch_load_event();
} else {
let chan = window.r().script_chan();
let handler = Trusted::new(window.r().get_cx(), self, chan.clone());
let chan = window.script_chan();
let handler = Trusted::new(window.get_cx(), self, chan.clone());
let dispatcher = box EventDispatcher {
element: handler,
is_error: false,
@ -632,9 +632,9 @@ impl Runnable for EventDispatcher {
fn handler(self: Box<EventDispatcher>) {
let target = self.element.root();
if self.is_error {
target.r().dispatch_error_event();
target.dispatch_error_event();
} else {
target.r().dispatch_load_event();
target.dispatch_load_event();
}
}
}