diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index f3f29d1b2e7..0fbe60645bd 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -265,7 +265,7 @@ impl StyleSharingCandidate { local_name: element.get_local_name().clone(), class: element.get_attr(&ns!(""), &atom!("class")) .map(|string| string.to_owned()), - link: element.get_link().is_some(), + link: element.is_link(), namespace: (*element.get_namespace()).clone(), common_style_affecting_attributes: create_common_style_affecting_attributes_from_element(&element) @@ -333,7 +333,7 @@ impl StyleSharingCandidate { } } - if element.get_link().is_some() != self.link { + if element.is_link() != self.link { return false } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 0e8aa88e6bc..33e343df99f 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -536,7 +536,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> { self.element.namespace() } - fn get_link(self) -> Option<&'le str> { + fn is_link(self) -> bool { // FIXME: This is HTML only. let node: &Node = NodeCast::from_actual(self.element); match node.type_id_for_layout() { @@ -545,13 +545,23 @@ impl<'le> TElement<'le> for LayoutElement<'le> { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { unsafe { - self.element.get_attr_val_for_layout(&ns!(""), &atom!("href")) + self.element.get_attr_val_for_layout(&ns!(""), &atom!("href")).is_some() } } - _ => None, + _ => false, } } + #[inline] + fn is_unvisited_link(self) -> bool { + self.is_link() + } + + #[inline] + fn is_visited_link(self) -> bool { + false + } + #[inline] fn get_hover_state(self) -> bool { unsafe { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 3b4eaebd2b7..4989039802d 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1494,8 +1494,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> { } impl<'a> style::node::TElement<'a> for JSRef<'a, Element> { - #[allow(unsafe_code)] - fn get_link(self) -> Option<&'a str> { + fn is_link(self) -> bool { // FIXME: This is HTML only. let node: JSRef = NodeCast::from_ref(self); match node.type_id() { @@ -1503,17 +1502,22 @@ impl<'a> style::node::TElement<'a> for JSRef<'a, Element> { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) | NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { - self.get_attribute(&ns!(""), &atom!("href")).root().map(|attr| { - // This transmute is used to cheat the lifetime restriction. - // FIXME(https://github.com/rust-lang/rust/issues/23338) - let attr = attr.r(); - let value: &str = &**attr.value(); - unsafe { mem::transmute(value) } - }) + self.has_attribute(&atom!("href")) }, - _ => None, + _ => false, } } + + #[inline] + fn is_unvisited_link(self) -> bool { + self.is_link() + } + + #[inline] + fn is_visited_link(self) -> bool { + false + } + fn get_local_name(self) -> &'a Atom { // FIXME(zwarich): Remove this when UFCS lands and there is a better way // of disambiguating methods. diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index f15d968bb54..0e2190b6d31 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1055,7 +1055,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.1.0" -source = "git+https://github.com/servo/rust-selectors#31e13ceb0e4128e0782490cf683443f93a2289be" +source = "git+https://github.com/servo/rust-selectors#66e21c10cd1feff49e0d934c1861701bc7cd9c44" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 831f26c9756..e6ed7ee68ce 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -1037,7 +1037,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.1.0" -source = "git+https://github.com/servo/rust-selectors#31e13ceb0e4128e0782490cf683443f93a2289be" +source = "git+https://github.com/servo/rust-selectors#66e21c10cd1feff49e0d934c1861701bc7cd9c44" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index f6728e87ef3..7132d323a23 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -908,7 +908,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.1.0" -source = "git+https://github.com/servo/rust-selectors#31e13ceb0e4128e0782490cf683443f93a2289be" +source = "git+https://github.com/servo/rust-selectors#66e21c10cd1feff49e0d934c1861701bc7cd9c44" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",