diff --git a/servo/components/style/data.rs b/servo/components/style/data.rs index 0927edfc432d..47cf4c8a8af7 100644 --- a/servo/components/style/data.rs +++ b/servo/components/style/data.rs @@ -13,6 +13,7 @@ use rule_tree::StrongRuleNode; use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage}; use servo_arc::Arc; use shared_lock::StylesheetGuards; +use std::fmt; use std::ops::{Deref, DerefMut}; bitflags! { @@ -118,7 +119,7 @@ impl RestyleData { #[derive(Clone, Debug, Default)] pub struct EagerPseudoStyles(Option>); -#[derive(Debug, Default)] +#[derive(Default)] struct EagerPseudoArray(EagerPseudoArrayInner); type EagerPseudoArrayInner = [Option>; EAGER_PSEUDO_COUNT]; @@ -147,6 +148,20 @@ impl Clone for EagerPseudoArray { } } +// Override Debug to print which pseudos we have, and substitute the rule node +// for the much-more-verbose ComputedValues stringification. +impl fmt::Debug for EagerPseudoArray { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "EagerPseudoArray {{ ")?; + for i in 0..EAGER_PSEUDO_COUNT { + if let Some(ref values) = self[i] { + write!(f, "{:?}: {:?}, ", PseudoElement::from_eager_index(i), &values.rules)?; + } + } + write!(f, "}}") + } +} + impl EagerPseudoStyles { /// Returns whether there are any pseudo styles. pub fn is_empty(&self) -> bool { @@ -179,7 +194,7 @@ impl EagerPseudoStyles { /// The styles associated with a node, including the styles for any /// pseudo-elements. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Default)] pub struct ElementStyles { /// The element's style. pub primary: Option>, @@ -204,6 +219,16 @@ impl ElementStyles { } } +// We manually implement Debug for ElementStyles so that we can avoid the +// verbose stringification of every property in the ComputedValues. We +// substitute the rule node instead. +impl fmt::Debug for ElementStyles { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ElementStyles {{ primary: {:?}, pseudos: {:?} }}", + self.primary.as_ref().map(|x| &x.rules), self.pseudos) + } +} + /// Style system data associated with an Element. /// /// In Gecko, this hangs directly off the Element. Servo, this is embedded