Re: [whatwg] Color attributes

2009-02-13 Thread Ian Hickson
On Wed, 11 Feb 2009, Simon Pieters wrote:
 On Wed, 11 Feb 2009 01:22:59 +0100, Ian Hickson i...@hixie.ch wrote:
  On Thu, 16 Oct 2008, Simon Pieters wrote:
   
   Color attributes in HTML have special processing. [...]
   
   It seems that some pages use three-digit notation and expect it to 
   work as in CSS. I've made the algorithm do that and I've drafted up 
   a spec for this:
   
  http://simon.html5.org/specs/html-color-attributes
  
  The spec now defines this.
 
 It seems the spec lacks the CSS2 system colors and 'transparent'.

Fixed.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


Re: [whatwg] Color attributes

2009-02-10 Thread Ian Hickson
On Thu, 16 Oct 2008, Simon Pieters wrote:

 Color attributes in HTML have special processing. [...]
 
 It seems that some pages use three-digit notation and expect it to work 
 as in CSS. I've made the algorithm do that and I've drafted up a spec 
 for this:
 
http://simon.html5.org/specs/html-color-attributes

The spec now defines this.

Thanks for your work on this. It was hugely helpful.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


Re: [whatwg] Color attributes

2009-02-10 Thread Simon Pieters

On Wed, 11 Feb 2009 01:22:59 +0100, Ian Hickson i...@hixie.ch wrote:


On Thu, 16 Oct 2008, Simon Pieters wrote:


Color attributes in HTML have special processing. [...]

It seems that some pages use three-digit notation and expect it to work
as in CSS. I've made the algorithm do that and I've drafted up a spec
for this:

   http://simon.html5.org/specs/html-color-attributes


The spec now defines this.


It seems the spec lacks the CSS2 system colors and 'transparent'.

--
Simon Pieters
Opera Software




Re: [whatwg] Color attributes

2008-10-17 Thread Simon Pieters

On Fri, 17 Oct 2008 00:01:02 +0200, Andy Lyttle [EMAIL PROTECTED] wrote:

While the first item's length in segments is greater than 2 and the  
first character in each item in segments is a U+0030 DIGIT ZERO  
character, remove the first character from each item in segments.


Does this mean, if the length of the first item in segments is greater  
than 2 then loop through each item in segments, and if the first  
character is 0 then remove it?


Or does it mean, if the length of the first item in segments is greater  
than 2 and the first character of every item in segments is 0, then loop  
through each item and delete the first character, but if the first  
character of any item is not 0 then leave the whole thing alone?


I'm assuming you meant #1, but your wording isn't perfectly clear.


I meant #2. Reworded.


Has it occurred to you that while your algorithm makes the string foo  
return an error, the string l33tsp34k is converted to a dark purple?


Yes. I thought it matched webkit. But further testing shows that it does  
not. :-(


999 - #000999
aaa - #aa
aax - #00
#999 - #99
#aax - #00

I've made the algorithm return input if it's correct #rgb and otherwise  
continue the algorithm (which will instead match IE).


So the above would instead be:

999 - #090909
aaa - #0a0a0a
aax - #0a0a00
#999 - #99
#aax - #0a0a00


Thanks!

--
Simon Pieters
Opera Software


Re: [whatwg] Color attributes

2008-10-16 Thread Simon Pieters
On Thu, 05 Jul 2007 23:43:55 +0200, Simon Pieters [EMAIL PROTECTED]  
wrote:



Color attributes in HTML have special processing.


It seems that some pages use three-digit notation and expect it to work as  
in CSS. I've made the algorithm do that and I've drafted up a spec for  
this:


   http://simon.html5.org/specs/html-color-attributes

--
Simon Pieters
Opera Software


Re: [whatwg] Color attributes

2008-10-16 Thread Andy Lyttle
While the first item's length in segments is greater than 2 and the  
first character in each item in segments is a U+0030 DIGIT ZERO  
character, remove the first character from each item in segments.


Does this mean, if the length of the first item in segments is  
greater than 2 then loop through each item in segments, and if the  
first character is 0 then remove it?


Or does it mean, if the length of the first item in segments is  
greater than 2 and the first character of every item in segments is  
0, then loop through each item and delete the first character, but if  
the first character of any item is not 0 then leave the whole thing  
alone?


I'm assuming you meant #1, but your wording isn't perfectly clear.

Has it occurred to you that while your algorithm makes the string  
foo return an error, the string l33tsp34k is converted to a dark  
purple?


--
Andy Lyttle
[EMAIL PROTECTED]



On Oct 16, 2008, at 4:46 AM, Simon Pieters wrote:

On Thu, 05 Jul 2007 23:43:55 +0200, Simon Pieters  
[EMAIL PROTECTED] wrote:



Color attributes in HTML have special processing.


It seems that some pages use three-digit notation and expect it to  
work as in CSS. I've made the algorithm do that and I've drafted up  
a spec for this:


   http://simon.html5.org/specs/html-color-attributes

--
Simon Pieters
Opera Software




Re: [whatwg] Color attributes

2007-10-01 Thread Simon Pieters
On Fri, 24 Aug 2007 19:05:06 +0200, Simon Pieters [EMAIL PROTECTED]  
wrote:



[...]


http://simon.html5.org/test/html/parsing/color-attributes/the-algorithm/


Do we want to do this for quirks mode only? IE7 does it for standards  
mode as well, but Opera, Firefox and Safari have different (stricter)  
processing rules for standards mode.


I'd suggest that we do the same thing for both quirks mode and standards  
mode.


It seems IE also supports CSS2 System Colors.

The algorithm (once again; hopefully this time it'll stick):

   1. If the string is the empty string, act as if the attribute was
  absent and abort these steps.
   2. If the string ASCII-case-insensitively matches a css3-color keyword
  or one of the CSS2 System Colors, or is transparent
  (ASCII-case-insensitively), use that and abort these steps.
   3. Trim all but the first 128 chars from the string.
   4. If it exists, strip the first leading #.
   5. Replace non-valid-hex chars with 0s.
   6. ASCII-lower-case the string.
   7. Make string length a multiple of 3 and a minimum of 3 by appending
  0s.
   8. Split the string into 3 equal segments.
   9. Trim all but the right-most 8 chars from each segment.
  10. If segment length is 1, left-pad each segment with a 0, else:
  11. While segment length is greater than 2 and the first char of each
  segment is equal to 0, trim the left-most char from each segment,
  then:
  12. Trim all but the first 2 chars from each segment.
  13. Join the segments and append them to a # char to create the final
  string.

--
Simon Pieters


Re: [whatwg] Color attributes

2007-08-24 Thread Simon Pieters
On Thu, 23 Aug 2007 19:18:41 +0200, Simon Pieters [EMAIL PROTECTED]  
wrote:



For reference, the complete algorithm would be:


Hmm, there needs to be a step before the first one, actually:

   1. If the value is the empty string, act as if the attribute was
  absent and abort these steps.


[...]


Test cases for the algorithm:

http://simon.html5.org/test/html/parsing/color-attributes/the-algorithm/


Do we want to do this for quirks mode only? IE7 does it for standards mode  
as well, but Opera, Firefox and Safari have different (stricter)  
processing rules for standards mode.


--
Simon Pieters


Re: [whatwg] Color attributes

2007-08-23 Thread Simon Pieters
On Fri, 27 Jul 2007 13:07:26 +0200, Simon Pieters [EMAIL PROTECTED]  
wrote:


On Thu, 05 Jul 2007 23:43:55 +0200, Simon Pieters [EMAIL PROTECTED]  
wrote:



Color attributes in HTML have special processing.

Some tests/demos:

 http://simon.html5.org/test/html/parsing/color-attributes/

https://bugzilla.mozilla.org/attachment.cgi?id=188040 contains further
tests and an algorithm that is supposed to match what IE does. The only
flaw in that algorithm AFAICT is that there is a step missing before the
first step: match the value against the list of supported color  
keywords.


For reference, the complete algorithm would be:

1. If the value case-insensitively matches a color keyword, use  
that and

   abort these steps. [CSS3COLOR]


ASCII-case-insensitively, even.

transparent is also to be treated as a keyword, meaning transparent.  
(It seems that IE treats transparent as black for text color, but that's  
a CSS thing.)



2. Trim all but the first 128 chars from the string.
3. If it exists, strip the first leading #.
4. Replace non-valid-hex chars with 0s.
5. Lower-case the string.


ASCII-lower-case.

6. Make string length a multiple of 3 and a minimum of 3 by  
appending 0s.

7. Split the string into 3 equal segments.
8. Trim all but the right-most 8 chars from each segment.
9. If segment length is 1, left-pad each segment with a 0, else:
   10. While segment length is greater than 2 and the first char of each
   segment is equal to 0, trim the left-most char from each segment,
   then:
   11. Trim all but the first 2 chars from each segment.
   12. Join the segments and append them to a # char to create the final
   string.


Test cases for the algorithm:

   http://simon.html5.org/test/html/parsing/color-attributes/the-algorithm/

--
Simon Pieters