Float values in rgb() colour values

So it turns out that Adobe InDesign - before SVG export was removed
post-CS3 - generated files with rgb() component values that are floats
rather than integers.  I discovered this after a user of my rendering
library reported a rendering "bug".

After experimenting, I see that all three of Chrome, FF and IE allow float
values in percentage components, but not normal components.  In the
following test file, the first rect is displayed, but not the second.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
   width="100%" height="100%"
   viewBox="0 0 200 200">

  <!-- Test float values in rgb() colour declarations.
       The Adobe InDesign SVG export filter (present in CS3 and earlier)
generated
       these erroneous type of values. -->
  <rect x="50" y="50" width="50" height="80" fill="rgb(100.5%,-4%, 33.3%)"
/>
  <rect x="100" y="50" width="50" height="80" fill="rgb(255, 0, 85.3)" />

  <text x="100" y="160" text-anchor="middle" font-size="8">Accept bad Adobe
InDesign colour declarations</text>
</svg>

How did it come about that the browsers all support floats in percentages?
 All versions of the spec, including SVG2, specify that they should be
integers.  Is it just a case of choosing to be permissive?  If so, why do
non-percent components not get the same treatment?

Cheers

Paul

Received on Monday, 27 January 2014 05:04:04 UTC