<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26208</bug_id>
          
          <creation_ts>2014-06-26 20:45:17 +0000</creation_ts>
          <short_desc>For parsing CSS &lt;color&gt; values, this should explicitly ref the CSS Syntax spec, and use the &quot;parse a component value&quot; algorithm defined there.</short_desc>
          <delta_ts>2014-09-22 16:26:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#dependencies</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>jackalmage</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>108393</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-06-26 20:45:17 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html
Multipage: http://www.whatwg.org/C#dependencies
Complete: http://www.whatwg.org/c#dependencies
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html

Comment:
For parsing CSS &lt;color&gt; values, this should explicitly ref the CSS Syntax
spec, and use the &quot;parse a component value&quot; algorithm defined there.

Posted from: 2620:0:1000:1b01:a2b3:ccff:fefb:42ac
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.32 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108395</commentid>
    <comment_count>1</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-06-26 20:46:35 +0000</bug_when>
    <thetext>See, for example, https://github.com/whatwg/meta-brand-color#finding-the-brand-color:

&gt; For each element in candidate elements:
&gt;   1. Parse a component value from element&apos;s content attribute value. [[css-syntax]]
&gt;   2. Attempt to parse the result as a CSS color. If it succeeds, return the parsed color.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108531</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-30 23:44:29 +0000</bug_when>
    <thetext>Why does this have to be two steps instead of one? I&apos;m not sure I follow. I&apos;ll look into it more closely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108540</commentid>
    <comment_count>3</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-07-01 02:08:52 +0000</bug_when>
    <thetext>You could combine them, but it&apos;s still essentially two steps - one to turn codepoints into some structure of CSS tokens, then another to run a grammar against those tokens.

This matters, for example, due to whitespace - if you just check if an attribute&apos;s value parses as a CSS color, it&apos;ll fail due to whitespace if there&apos;s any at the beginning/end.  If you first get a component value, that discards whitespace at the beginning/end.  Right now you explicitly discard the whitespace, but that&apos;s not necessary if you ref Syntax properly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110945</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-03 22:49:02 +0000</bug_when>
    <thetext>Well I just mean that in most other cases, the tokenisation and parsing stages are wrapped into a single call site. For example, if you want to parse HTML, you just run the HTML parser, you don&apos;t have to manage the handoff of tokens from the tokeniser to the tree builder.

Presumably, the output of &quot;parse a component value&quot;, and thus the input of &quot;parse the result as a CSS color&quot;, is not a string, but a sequence of tokens or some such. In which case, &quot;parse the element&apos;s content attribute value as a CSS color&quot; should be meaningless (a type mismatch error).

So what I would suggest, is that we define &quot;parse [a string] as [some CSS value]&quot; as doing the tokenisation and any other processing that it needs, so that I can then say &quot;parse [a string] as a CSS &lt;color&gt; value&quot; and it does the right thing. Seems like that would make other specs integrating with CSS less verbose and more maintainable in the face of changes on the CSS side. The fact that there&apos;s a separate tokenisation step seems like an implementation detail of the CSS syntax specifications.

Anyway, if you disagree, just let me know, happy to do it however you want.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110971</commentid>
    <comment_count>5</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-09-04 02:26:00 +0000</bug_when>
    <thetext>Yeah, I&apos;m fine with adding a hook like &quot;parse as [[css grammar thing]]&quot;, which, like the other parsing functions, accepts either a list of codepoints, a list of tokens, or a list of component values.  It would do a &quot;parse a list of component values&quot; first, then attempt to match it against the specified grammar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111025</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-04 18:38:15 +0000</bug_when>
    <thetext>Cool. I&apos;ll update HTML to use that wording and link to the relevant part of CSS Syntax. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111108</commentid>
    <comment_count>7</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-09-05 21:57:11 +0000</bug_when>
    <thetext>Here you go: http://dev.w3.org/csswg/css-syntax/#parse-grammar</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111829</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-19 19:21:20 +0000</bug_when>
    <thetext>Please take a look at the HTML prose and see if it&apos;s ok. In particular, note the problem with the &apos;font&apos; property, not sure how to handle that, and check the example that starts &quot;For example, user agents are required to close all open constructs...&quot; and make sure that that matches reality on your end. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111830</commentid>
    <comment_count>9</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-19 19:21:32 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8793.
Check-in comment: Better reference CSS for parsing according to CSS.
https://html5.org/tools/web-apps-tracker?from=8792&amp;to=8793</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111850</commentid>
    <comment_count>10</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2014-09-19 21:28:50 +0000</bug_when>
    <thetext>(In reply to contributor from comment #9)
&gt; Checked in as WHATWG revision r8793.
&gt; Check-in comment: Better reference CSS for parsing according to CSS.
&gt; https://html5.org/tools/web-apps-tracker?from=8792&amp;to=8793

Per IRC discussion, the &lt;&apos;font&apos;&gt; nonterminal is what you want. It means &quot;the grammar of the &apos;font&apos; property&quot;, and excludes the global keywords.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>