style: Minor debugging improvements.

These were useful when implementing forwarding, and forgot to send them
earlier.

Differential Revision: https://phabricator.services.mozilla.com/D53767
This commit is contained in:
Emilio Cobos Álvarez 2019-11-19 06:47:12 +00:00
parent a7c50b57a1
commit d7167cec58
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
2 changed files with 10 additions and 3 deletions

View file

@ -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<ConcreteShadowRoot = Self>;

View file

@ -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, "<shadow-root> ({:#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, "<document> ({:#x})", self.opaque().0);
}
if self.is_shadow_root() {
return write!(f, "<shadow-root> ({:#x})", self.opaque().0);
if let Some(sr) = self.as_shadow_root() {
return sr.fmt(f);
}
write!(f, "<non-text node> ({:#x})", self.opaque().0)