зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #6004 - Replace TElement::get_link() by specific methods (from Ms2ger:get_link); r=SimonSapin
Source-Repo: https://github.com/servo/servo Source-Revision: be8539af885b5d668222bbbdd677922eb75be65f
This commit is contained in:
Родитель
f5449ac36a
Коммит
48d01c7d0c
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<Node> = 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.
|
||||
|
|
|
@ -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)",
|
||||
|
|
|
@ -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)",
|
||||
|
|
|
@ -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)",
|
||||
|
|
Загрузка…
Ссылка в новой задаче