HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2776How to parse a color in an IE-compatible way. (credit: sp)2009-02-11 00:20
@@ -3304,23 +3304,127 @@
 
   <hr>
 
   <p>Some obsolete legacy attributes parse colors in a more
   complicated manner, using the <dfn>rules for parsing a legacy color
   value</dfn>, which are given in the following algorithm. When
   invoked, the steps must be followed in the order given, aborting at
   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><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>...
+   <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>
 
   <p class="note">The <span title="canvas-context-2d">2D graphics
   context</span> has a separate color syntax that also handles
   opacity.</p>
 
 
@@ -13212,20 +13316,26 @@ first matching case):&lt;/p&gt;
     <p>The <code title="command-ro">Command</code> interface must also be implemented by
     this element.</p>
    </dd>
   </dl>
 
   <p>If the <code>a</code> element has an <code
   title="attr-hyperlink-href">href</code> attribute, then it
   <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
   otherwise have been placed, if it had been relevant.</p>
 
   <p>The <code title="attr-hyperlink-target">target</code>, <code
   title="attr-hyperlink-ping">ping</code>, <code
   title="attr-hyperlink-rel">rel</code>, <code
   title="attr-hyperlink-media">media</code>, <code
   title="attr-hyperlink-hreflang">hreflang</code>, and <code

|