Replace TElement::get_link() by specific methods.

This commit is contained in:
Ms2ger 2015-05-11 10:52:58 +02:00
parent c76d73d124
commit fa31d7d909
6 changed files with 32 additions and 18 deletions

View file

@ -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
}

View file

@ -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 {