From 1d54a8e8572009b4fbeab7754f8951a3539b22c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 17 Aug 2017 21:41:37 +0200 Subject: [PATCH] style: Add a note about weirdness in serialization of computed calc(). --- components/style/values/computed/length.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index a8287fa9991..bf0938bd685 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -194,6 +194,18 @@ impl From for Option { impl ToCss for CalcLengthOrPercentage { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + // FIXME(emilio): This should be consistent with specified calc(). + // + // Also, serialisation here is kinda weird with negative percentages, + // for example, as of right now: + // + // calc(10px - 5%) + // + // would serialize as: + // + // calc(10px + -5%) + // + // Need to update and run through try. match (self.length, self.percentage) { (l, Some(p)) if l == Au(0) => p.to_css(dest), (l, Some(p)) => write!(dest, "calc({}px + {}%)", Au::to_px(l), p.0 * 100.),