[cssom] serializing <color>

Opera uses the algorithm specified for <canvas> everywhere. This means  
#rrggbb for when alpha is 1 and otherwise rgba().


Gecko uses different serialization algorithms. System colors and color  
keywords are preserved for e.g. the .style.color case but not for  
<canvas>. (The keywords are returned in lowercase, not in the case  
specified by the specification. I personally like this.) Also, instead of  
#rrggbb it uses rgb() for .style.color, though not for <canvas>.

Gecko also uses a slightly different parser for <canvas> it seems. E.g. I  
found it accepts "red garbage" and treats that the same as "red" whereas  
.style.color will not.


WebKit (I toyed with Chrome) seems to follow Gecko, though the <canvas>  
part was quite buggy (fillStyle accepts any string and just returns it?)  
and tests with system colors and .style.color failed.


I played in the "Live DOM Viewer" with these bits of code by the way:

<!DOCTYPE html>
...<script>
  var x =document.createElement("canvas").getContext("2d")
  x.fillStyle = "red garbage"
  w(x.fillStyle)
</script>


<!DOCTYPE html>
...<script>
  document.body.style.color = "#fff"
  w(document.body.style.color)
</script>


Any thoughts as to what direction we want this to go in?

Personally I quite prefer the way Opera handles this, though preserving  
system colors might be valuable. Not sure.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Monday, 15 February 2010 13:47:41 UTC