mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Upgrade rust-selectors, pass ':empty' tests
https://github.com/servo/rust-selectors/pull/36
This commit is contained in:
parent
406be7accf
commit
b1b03a32db
10 changed files with 110 additions and 10 deletions
|
@ -211,7 +211,9 @@ impl<'ln> LayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ln> ::selectors::Node<LayoutElement<'ln>> for LayoutNode<'ln> {
|
||||
impl<'ln> ::selectors::Node for LayoutNode<'ln> {
|
||||
type Element = LayoutElement<'ln>;
|
||||
|
||||
fn parent_node(&self) -> Option<LayoutNode<'ln>> {
|
||||
unsafe {
|
||||
self.node.parent_node_ref().map(|node| self.new_with_this_lifetime(&node))
|
||||
|
@ -244,7 +246,7 @@ impl<'ln> ::selectors::Node<LayoutElement<'ln>> for LayoutNode<'ln> {
|
|||
|
||||
/// If this is an element, accesses the element data.
|
||||
#[inline]
|
||||
fn as_element(&self) -> Option<LayoutElement<'ln>> {
|
||||
fn as_element(&self) -> Option<Self::Element> {
|
||||
ElementCast::to_layout_js(&self.node).map(|element| {
|
||||
LayoutElement {
|
||||
element: element,
|
||||
|
@ -259,6 +261,16 @@ impl<'ln> ::selectors::Node<LayoutElement<'ln>> for LayoutNode<'ln> {
|
|||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_element_or_non_empty_text(&self) -> bool {
|
||||
if let Some(text) = TextCast::to_layout_js(&self.node) {
|
||||
unsafe {
|
||||
!CharacterDataCast::from_layout_js(&text).data_for_layout().is_empty()
|
||||
}
|
||||
} else {
|
||||
ElementCast::to_layout_js(&self.node).is_some()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> LayoutNode<'ln> {
|
||||
|
|
|
@ -2579,7 +2579,9 @@ impl<'a> VirtualMethods for &'a Node {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> ::selectors::Node<&'a Element> for &'a Node {
|
||||
impl<'a> ::selectors::Node for &'a Node {
|
||||
type Element = &'a Element;
|
||||
|
||||
fn parent_node(&self) -> Option<&'a Node> {
|
||||
(*self).parent_node.get()
|
||||
.map(|node| node.root().get_unsound_ref_forever())
|
||||
|
@ -2609,9 +2611,17 @@ impl<'a> ::selectors::Node<&'a Element> for &'a Node {
|
|||
DocumentDerived::is_document(*self)
|
||||
}
|
||||
|
||||
fn as_element(&self) -> Option<&'a Element> {
|
||||
fn as_element(&self) -> Option<Self::Element> {
|
||||
ElementCast::to_ref(*self)
|
||||
}
|
||||
|
||||
fn is_element_or_non_empty_text(&self) -> bool {
|
||||
if self.is_text() {
|
||||
self.GetTextContent().map_or(false, |s| !s.is_empty())
|
||||
} else {
|
||||
self.is_element()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DisabledStateHelpers {
|
||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -1192,7 +1192,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-selectors#a16e32540845548d46857f2896248c382ef34393"
|
||||
source = "git+https://github.com/servo/rust-selectors#a6cf1fba8f31960254aa62434ab8aeee13aff080"
|
||||
dependencies = [
|
||||
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cssparser 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue