Clean up the cast calls

This commit is contained in:
Anthony Ramine 2015-10-07 14:55:02 +02:00
parent 13ea3ac413
commit 68014af78e
66 changed files with 412 additions and 718 deletions

View file

@ -82,8 +82,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
// https://html.spec.whatwg.org/multipage/#dom-button-type
fn Type(&self) -> DOMString {
let elem = self.upcast::<Element>();
let mut ty = elem.get_string_attribute(&atom!("type"));
let mut ty = self.upcast::<Element>().get_string_attribute(&atom!("type"));
ty.make_ascii_lowercase();
// https://html.spec.whatwg.org/multipage/#attr-button-type
match &*ty {
@ -135,8 +134,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
impl VirtualMethods for HTMLButtonElement {
fn super_type(&self) -> Option<&VirtualMethods> {
let htmlelement: &HTMLElement = self.upcast::<HTMLElement>();
Some(htmlelement as &VirtualMethods)
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
}
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
@ -166,8 +164,7 @@ impl VirtualMethods for HTMLButtonElement {
s.bind_to_tree(tree_in_doc);
}
let el = self.upcast::<Element>();
el.check_ancestors_disabled_state_for_form_control();
self.upcast::<Element>().check_ancestors_disabled_state_for_form_control();
}
fn unbind_from_tree(&self, tree_in_doc: bool) {
@ -189,13 +186,12 @@ impl FormControl for HTMLButtonElement {}
impl<'a> Activatable for &'a HTMLButtonElement {
fn as_element(&self) -> &Element {
self.upcast::<Element>()
self.upcast()
}
fn is_instance_activatable(&self) -> bool {
//https://html.spec.whatwg.org/multipage/#the-button-element
let el = self.upcast::<Element>();
!(el.get_disabled_state())
!self.upcast::<Element>().get_disabled_state()
}
// https://html.spec.whatwg.org/multipage/#run-pre-click-activation-steps
@ -228,8 +224,7 @@ impl<'a> Activatable for &'a HTMLButtonElement {
let doc = document_from_node(*self);
let node = doc.upcast::<Node>();
let owner = self.form_owner();
let elem = self.upcast::<Element>();
if owner.is_none() || elem.click_in_progress() {
if owner.is_none() || self.upcast::<Element>().click_in_progress() {
return;
}
node.query_selector_iter("button[type=submit]".to_owned()).unwrap()