Short URL: http://html5.org/r/2776
| SVN | Bug | Comment | Time (UTC) |
|---|---|---|---|
| 2776 | How to parse a color in an IE-compatible way. (credit: sp) | 2009-02-11 00:20 |
Index: source =================================================================== --- source (revision 2775) +++ source (revision 2776) @@ -3311,10 +3311,114 @@ the first step that returns a value. This algorithm will either return a <span>simple color</span> or an error.</p> - <ol class=XXX> + <ol> - <li>... + <li><p>Let <var title="">input</var> be the string being + parsed.</p></li> + <li><p>If <var title="">input</var> is the empty string, then + return an error.</p></li> + + <li><p>If <var title="">input</var> is an <span>ASCII + case-insensitive</span> match for one of the keywords listed in the + <a href="http://www.w3.org/TR/css3-color/#svg-color">SVG color + keywords</a> section of the CSS3 Color specification, the return + the <span>simple color</span> corresponding to that keyword. <a + href="#refsCSS3COLOR">[CSS3COLOR]</a></p></li> + + <li> + + <p>If <var title="">input</var> is four characters long, and the + first character in <var title="">input</var> is a U+0023 NUMBER + SIGN (#) character, and the the last three characters of <var + title="">input</var> are all in the range U+0030 DIGIT ZERO (0) + .. U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A .. U+0046 + LATIN CAPITAL LETTER F, and U+0061 LATIN SMALL LETTER A .. U+0066 + LATIN SMALL LETTER F, then run these substeps:</p> + + <ol> + + <li><p>Let <var title="">result</var> be a <span>simple + color</span>.</p> + + <li><p>Interpret the second character of <var + title="">input</var> as a hexadecimal digit; let the red + component of <var title="">result</var> be the resulting number + multiplied by 17.</p> + + <li><p>Interpret the third character of <var title="">input</var> + as a hexadecimal digit; let the green component of <var + title="">result</var> be the resulting number multiplied by + 17.</p> + + <li><p>Interpret the fourth character of <var + title="">input</var> as a hexadecimal digit; let the blue + component of <var title="">result</var> be the resulting number + multiplied by 17.</p> + + <li><p>Return <var title="">result</var>.</p> + + </ol> + + </li> + + <li><p>Replace any characters in <var title="">input</var> that + have a Unicode codepoint greater than U+FFFF (i.e. any characters + that are not in the basic multilingual plane) with the + two-character string "<code title="">00</code>".</p></li> + + <li><p>If <var title="">input</var> is longer than 128 characters, + truncate <var title="">input</var>, leaving only the first 128 + characters.</p></li> + + <li><p>If the first character in <var title="">input</var> is a + U+0023 NUMBER SIGN character (#), remove it.</p></li> + + <li><p>Replace any character in <var title="">input</var> that is + not in the range U+0030 DIGIT ZERO (0) .. U+0039 DIGIT NINE (9), + U+0041 LATIN CAPITAL LETTER A .. U+0046 LATIN CAPITAL LETTER F, and + U+0061 LATIN SMALL LETTER A .. U+0066 LATIN SMALL LETTER F with the + character U+0030 DIGIT ZERO (0).</p></li> + + <li><p>While <var title="">input</var>'s length is zero or not a + multiple of three, append a U+0030 DIGIT ZERO (0) character to <var + title="">input</var>.</p></li> + + <li><p>Split <var title="">input</var> into three strings of equal + length, to obtain three components. Let <var title="">length</var> + be the length of those components (one third the length of <var + title="">input</var>).</p></li> + + <li><p>If <var title="">length</var> is greater than 8, then remove + the leading <span><var title="">length</var>-8</span> characters in + each component, and let <var title="">length</var> be 8.</p></li> + + <li><p>While <var title="">length</var> is greater than two and the + first character in each component is a U+0030 DIGIT ZERO (0) + character, remove that character and reduce <var + title="">length</var> by one.</p></li> + + <li><p>If <var title="">length</var> is <em>still</em> greater than + two, truncate each component, leaving only the first two + characters in each.</p></li> + + <li><p>Let <var title="">result</var> be a <span>simple + color</span>.</p> + + <li><p>Interpret the first component as a hexadecimal number; let + the red component of <var title="">result</var> be the resulting + number.</p></li> + + <li><p>Interpret the second component as a hexadecimal number; let + the green component of <var title="">result</var> be the resulting + number.</p></li> + + <li><p>Interpret the third component as a hexadecimal number; let + the blue component of <var title="">result</var> be the resulting + number.</p></li> + + <li><p>Return <var title="">result</var>.</p> + </ol> <hr> @@ -13219,6 +13323,12 @@ <span>represents</span> a <span>hyperlink</span> (a hypertext anchor).</p> + <!-- v2: Eric Meyer requests the ability to nest links so that a big + hyperlink, e.g. representing a calendar event, can be clickable, + while within it there are subareas that represent links to distinct + areas, e.g. a link to see photos of the event, or to edit the event, + or some such. --> + <p>If the <code>a</code> element has no <code title="attr-hyperlink-href">href</code> attribute, then the element <span>represents</span> a placeholder for where a link might