Skip to content
Permalink
Browse files

style: Minor debugging improvements.

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

Differential Revision: https://phabricator.services.mozilla.com/D53767
  • Loading branch information
emilio committed Nov 19, 2019
1 parent a7c50b5 commit d7167cec58ee2dc336d1037bc6ae0f8490bfa580
Showing with 10 additions and 3 deletions.
  1. +1 −1 components/style/dom.rs
  2. +9 −2 components/style/gecko/wrapper.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<ConcreteShadowRoot = Self>;

@@ -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)

0 comments on commit d7167ce

Please sign in to comment.
You can’t perform that action at this time.