Bug 1368240: Also print the class name when logging elements. r?heycam
MozReview-Commit-ID: 1MSn4rty5RL
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -402,16 +402,34 @@ impl<'lb> GeckoXBLBinding<'lb> {
pub struct GeckoElement<'le>(pub &'le RawGeckoElement);
impl<'le> fmt::Debug for GeckoElement<'le> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "<{}", self.get_local_name()));
if let Some(id) = self.get_id() {
try!(write!(f, " id={}", id));
}
+
+ let mut first = true;
+ let mut any = false;
+ self.each_class(|c| {
+ if first {
+ first = false;
+ any = true;
+ let _ = f.write_str(" class=\"");
+ } else {
+ let _ = f.write_str(" ");
+ }
+ let _ = write!(f, "{}", c);
+ });
+
+ if any {
+ f.write_str("\"")?;
+ }
+
write!(f, "> ({:#x})", self.as_node().opaque().0)
}
}
impl<'le> GeckoElement<'le> {
/// Parse the style attribute of an element.
pub fn parse_style_attribute(value: &str,
url_data: &UrlExtraData,