Bug 1593642 - More compact debug output for CSS values.
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 04 Nov 2019 12:52:57 +0000
changeset 500349 05767a01cd42b5b04b5dafab4bface35480f3f4b
parent 500348 0c22ff31f55bf19fc93471ab57d9ce7c797f9781
child 500350 f42af586cb9b1e10c60c0888a49a45441f66cbcb
push id36763
push userrmaries@mozilla.com
push dateMon, 04 Nov 2019 21:44:06 +0000
treeherdermozilla-central@75a7a3400888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1593642
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593642 - More compact debug output for CSS values. ``` Rect { start_corner: Vec2 { i: 0.0 px, b: 0.0 px }, size: Vec2 { i: 1024.0 px, b: 20.0 px }, } ``` … instead of: ``` Rect { start_corner: Vec2 { inline: CSSPixelLength( 0.0, ), block: CSSPixelLength( 0.0, ), }, size: Vec2 { inline: CSSPixelLength( 1024.0, ), block: CSSPixelLength( 0.0, ), }, } ``` Differential Revision: https://phabricator.services.mozilla.com/D51590
servo/components/style/values/computed/length.rs
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -608,30 +608,36 @@ impl Size {
 
 /// The computed `<length>` value.
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[derive(
     Animate,
     Clone,
     ComputeSquaredDistance,
     Copy,
-    Debug,
     Deserialize,
     MallocSizeOf,
     PartialEq,
     PartialOrd,
     Serialize,
     ToAnimatedValue,
     ToAnimatedZero,
     ToResolvedValue,
     ToShmem,
 )]
 #[repr(C)]
 pub struct CSSPixelLength(CSSFloat);
 
+impl fmt::Debug for CSSPixelLength {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.0.fmt(f)?;
+        f.write_str(" px")
+    }
+}
+
 impl CSSPixelLength {
     /// Return a new CSSPixelLength.
     #[inline]
     pub fn new(px: CSSFloat) -> Self {
         CSSPixelLength(px)
     }
 
     /// Return the containing pixel value.