servo: Merge #17791 - Bring back concise logging for ElementData (from bholley:less_verbose_cv); r=heycam

This was removed recently in the ComputedValues patch, and makes traversal
logging rather unusable.

Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1382357

Source-Repo: https://github.com/servo/servo
Source-Revision: 37d96f5ca9cf6df08dcb9a98455cbf297ec22cff

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : ed1e3f1a7d8600447fc6a7c446812399752aef60
This commit is contained in:
Bobby Holley 2017-07-19 21:02:28 -07:00
Родитель c371881b39
Коммит 2a5b9c20fb
1 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -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<Arc<EagerPseudoArray>>);
#[derive(Debug, Default)]
#[derive(Default)]
struct EagerPseudoArray(EagerPseudoArrayInner);
type EagerPseudoArrayInner = [Option<Arc<ComputedValues>>; 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<Arc<ComputedValues>>,
@ -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