diff --git a/components/style/dom.rs b/components/style/dom.rs index 2ea64bbb3dc..ef571b8df0a 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -331,7 +331,7 @@ where } /// The ShadowRoot trait. -pub trait TShadowRoot: Sized + Copy + Clone + PartialEq { +pub trait TShadowRoot: Sized + Copy + Clone + Debug + PartialEq { /// The concrete node type. type ConcreteNode: TNode; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index ffa6855736e..bd110801c05 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -144,6 +144,13 @@ impl<'ld> TDocument for GeckoDocument<'ld> { #[derive(Clone, Copy)] pub struct GeckoShadowRoot<'lr>(pub &'lr structs::ShadowRoot); +impl<'ln> fmt::Debug for GeckoShadowRoot<'ln> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // TODO(emilio): Maybe print the host or something? + write!(f, " ({:#x})", self.as_node().opaque().0) + } +} + impl<'lr> PartialEq for GeckoShadowRoot<'lr> { #[inline] fn eq(&self, other: &Self) -> bool { @@ -232,8 +239,8 @@ impl<'ln> fmt::Debug for GeckoNode<'ln> { return write!(f, " ({:#x})", self.opaque().0); } - if self.is_shadow_root() { - return write!(f, " ({:#x})", self.opaque().0); + if let Some(sr) = self.as_shadow_root() { + return sr.fmt(f); } write!(f, " ({:#x})", self.opaque().0)