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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue