Do not copy the result of get_link()

This commit is contained in:
Simon Sapin 2014-01-25 09:48:21 -08:00
parent 5ae7aad6e2
commit 2782d1d07f
3 changed files with 3 additions and 4 deletions

View file

@ -413,7 +413,7 @@ impl<'le> TElement for LayoutElement<'le> {
unsafe { self.element.get_attr_val_for_layout(namespace, name) }
}
fn get_link(&self) -> Option<~str> {
fn get_link(&self) -> Option<&'static str> {
// FIXME: This is HTML only.
match self.element.node.type_id {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
@ -422,7 +422,6 @@ impl<'le> TElement for LayoutElement<'le> {
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId) => {
unsafe { self.element.get_attr_val_for_layout(&namespace::Null, "href") }
.map(|val| val.to_owned())
}
_ => None,
}

View file

@ -40,7 +40,7 @@ pub fn parse_namespace_rule(rule: AtRule, namespaces: &mut NamespaceMap) {
},
URL(value) | String(value) => {
if ns.is_some() { syntax_error!() }
ns = Some(Namespace::from_str(value.as_slice()));
ns = Some(Namespace::from_str(value));
break
},
_ => syntax_error!(),

View file

@ -25,7 +25,7 @@ pub trait TNode<E:TElement> : Clone {
pub trait TElement {
fn get_attr(&self, namespace: &Namespace, attr: &str) -> Option<&'static str>;
fn get_link(&self) -> Option<~str>;
fn get_link(&self) -> Option<&'static str>;
fn get_local_name<'a>(&'a self) -> &'a str;
fn get_namespace<'a>(&'a self) -> &'a Namespace;
}