From 8175bfd60bf3964139fe6add9be2a69646abe708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 27 Mar 2017 02:07:51 +0200 Subject: [PATCH] style: Add a note regarding why we don't need to handle percentages here. --- components/style/values/specified/length.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 8bdf6f40ef60..6a5baa19eb44 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -910,12 +910,24 @@ impl ToCss for CalcLengthOrPercentage { /// A percentage value. /// /// [0 .. 100%] maps to [0.0 .. 1.0] +/// +/// FIXME(emilio): There's no standard property that requires a `` +/// without requiring also a ``. If such a property existed, we'd need +/// to add special handling for `calc()` and percentages in here in the same way +/// as for `Angle` and `Time`, but the lack of this this is otherwise +/// undistinguishable (we handle it correctly from `CalcLengthOrPercentage`). +/// +/// As of today, only `-moz-image-rect` supports percentages without length. +/// This is not a regression, and that's a non-standard extension anyway, so I'm +/// not implementing it for now. #[derive(Clone, PartialEq, Copy, Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Percentage(pub CSSFloat); impl ToCss for Percentage { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + fn to_css(&self, dest: &mut W) -> fmt::Result + where W: fmt::Write, + { write!(dest, "{}%", self.0 * 100.) } }