Bug 1368240: Also print the class name when logging elements. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 09 Jun 2017 17:19:50 +0200
changeset 592544 7339e70bc8da18585067ca0b001bce6e6e4808ca
parent 592543 84d97987e40e6b4b1b2b30e5dd3365514020b8e3
child 592545 fd08a1090ff431e39b8c8dcf302f3c3a1742c9c3
push id63430
push userbmo:emilio+bugs@crisal.io
push dateMon, 12 Jun 2017 12:30:48 +0000
reviewersheycam
bugs1368240
milestone55.0a1
Bug 1368240: Also print the class name when logging elements. r?heycam MozReview-Commit-ID: 1MSn4rty5RL
servo/components/style/gecko/wrapper.rs
--- 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,