aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmloptionelement.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-10-07 14:55:02 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2015-10-21 11:40:34 +0200
commit68014af78e8e3f5de4df0f6cc4d63b99c77478f5 (patch)
treef65b1a66ad8d7ce65042e37cf654da75e1766939 /components/script/dom/htmloptionelement.rs
parent13ea3ac413c511872784ccde416956217746553c (diff)
downloadservo-68014af78e8e3f5de4df0f6cc4d63b99c77478f5.tar.gz
servo-68014af78e8e3f5de4df0f6cc4d63b99c77478f5.zip
Clean up the cast calls
Diffstat (limited to 'components/script/dom/htmloptionelement.rs')
-rw-r--r--components/script/dom/htmloptionelement.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index d60ae457203..60af71b6c2e 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -64,7 +64,7 @@ fn collect_text(element: &Element, value: &mut DOMString) {
if child.is::<Text>() {
let characterdata = child.downcast::<CharacterData>().unwrap();
value.push_str(&characterdata.Data());
- } else if let Some(element_child) = child.downcast::<Element>() {
+ } else if let Some(element_child) = child.downcast() {
collect_text(element_child, value);
}
}
@@ -76,22 +76,19 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
// https://html.spec.whatwg.org/multipage/#dom-option-disabled
fn SetDisabled(&self, disabled: bool) {
- let elem = self.upcast::<Element>();
- elem.set_bool_attribute(&atom!("disabled"), disabled)
+ self.upcast::<Element>().set_bool_attribute(&atom!("disabled"), disabled)
}
// https://html.spec.whatwg.org/multipage/#dom-option-text
fn Text(&self) -> DOMString {
- let element = self.upcast::<Element>();
let mut content = String::new();
- collect_text(element, &mut content);
+ collect_text(self.upcast(), &mut content);
str_join(split_html_space_chars(&content), " ")
}
// https://html.spec.whatwg.org/multipage/#dom-option-text
fn SetText(&self, value: DOMString) {
- let node = self.upcast::<Node>();
- node.SetTextContent(Some(value))
+ self.upcast::<Node>().SetTextContent(Some(value))
}
// https://html.spec.whatwg.org/multipage/#attr-option-value
@@ -144,8 +141,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
impl VirtualMethods for HTMLOptionElement {
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) {
@@ -190,8 +186,7 @@ impl VirtualMethods for HTMLOptionElement {
s.bind_to_tree(tree_in_doc);
}
- let el = self.upcast::<Element>();
- el.check_parent_disabled_state_for_option();
+ self.upcast::<Element>().check_parent_disabled_state_for_option();
}
fn unbind_from_tree(&self, tree_in_doc: bool) {