diff --git a/components/style/dom.rs b/components/style/dom.rs index c70a8fd26be..c85ff1edaff 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -151,7 +151,7 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq { /// Get this node's first child. fn first_child(&self) -> Option; - /// Get this node's first child. + /// Get this node's last child. fn last_child(&self) -> Option; /// Get this node's previous sibling. diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 3f23981a823..476e710795d 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -409,9 +409,11 @@ impl<'ln> TNode for GeckoNode<'ln> { #[inline] fn prev_sibling(&self) -> Option { unsafe { - bindings::Gecko_GetPreviousSibling(self.0) - .as_ref() - .map(GeckoNode) + let prev_or_last = GeckoNode::from_content(self.0.mPreviousOrLastSibling.as_ref()?); + if prev_or_last.0.mNextSibling.raw::().is_null() { + return None; + } + Some(prev_or_last) } }