From 2e89228cd5d19ca55c8eaaf60e082f072bc5eb0c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 3 Jul 2015 13:27:23 +0200 Subject: [PATCH 1/3] Remove HTMLAnchorElement::handle_event. It is equivalent to the default implementation. --- components/script/dom/htmlanchorelement.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 4e749ff6306..c96b13099cf 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -69,15 +69,6 @@ impl<'a> VirtualMethods for &'a HTMLAnchorElement { Some(htmlelement as &VirtualMethods) } - fn handle_event(&self, event: &Event) { - match self.super_type() { - Some(s) => { - s.handle_event(event); - } - None => {} - } - } - fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { &atom!("rel") => AttrValue::from_serialized_tokenlist(value), From 59ea4dbd212c0dc7fd36f5cee3a9d278138503ae Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 3 Jul 2015 13:30:31 +0200 Subject: [PATCH 2/3] Remove an avoidable null-check from HTMLAnchorElement::activation_behavior. --- components/script/dom/htmlanchorelement.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index c96b13099cf..8fc76ced75f 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -129,7 +129,7 @@ impl<'a> Activatable for &'a HTMLAnchorElement { if let Some(element) = ElementCast::to_ref(target) { if target.is_htmlimageelement() && element.has_attribute(&atom!("ismap")) { - let target_node = NodeCast::to_ref(target).unwrap(); + let target_node = NodeCast::from_ref(element); let rect = window_from_node(target_node).r().content_box_query( target_node.to_trusted_node_address()); ismap_suffix = Some( From 9f52ab11aa4beefa072de95ab612b7fe67c56631 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 3 Jul 2015 13:31:00 +0200 Subject: [PATCH 3/3] Simplify the string handling in HTMLAnchorElement::activation_behavior. --- components/script/dom/htmlanchorelement.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 8fc76ced75f..9f1f57a0baf 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -141,14 +141,13 @@ impl<'a> Activatable for &'a HTMLAnchorElement { //TODO: Step 4. Download the link is `download` attribute is set. - let attr = element.get_attribute(&ns!(""), &atom!("href")); - match attr { - Some(ref href) => { - let value = href.r().Value() + ismap_suffix.as_ref().map(|s| &**s).unwrap_or(""); - debug!("clicked on link to {}", value); - doc.r().load_anchor_href(value); + if let Some(ref href) = element.get_attribute(&ns!(""), &atom!("href")) { + let mut value = href.r().Value(); + if let Some(suffix) = ismap_suffix { + value.push_str(&suffix); } - None => () + debug!("clicked on link to {}", value); + doc.r().load_anchor_href(value); } }