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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>15427</bug_id>
          
          <creation_ts>2007-10-08 09:59:31 -0700</creation_ts>
          <short_desc>much of the CSS system should be autogenerated</short_desc>
          <delta_ts>2007-10-08 10:40:58 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>12159</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>darin</cc>
    
    <cc>hyatt</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>58103</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2007-10-08 09:59:31 -0700</bug_when>
    <thetext>much of the CSS system should be autogenerated

CSSParser::parseValue
CSSStyleSelector::applyProperty
CSSComputedStyleDeclaration::getPropertyCSSValue

Could all be autogenerated.  Instead of using a switch, a function table keyed off the autogenerated CSS_VAL_ defines.  The actual main body for each parseValue, applyProperty, getPropertyCSSValue function would be completely autogenerated in each case.   Most sub-functions (for simple values, like enums) could be autogenrated, but this would provide an easy override point for more complicated value/property handling.  An example subfunction which could be autogenerated:

PassRefPtr&lt;CSSValue&gt; CSSComputedStyleDeclarationFunctions::getTextAnchor(RenderStyle* style, ...) {
    if (svgStyle-&gt;textAnchor() == TA_START)
        return new CSSPrimitiveValue(CSS_VAL_START);
    else if (svgStyle-&gt;textAnchor() == TA_MIDDLE)
        return new CSSPrimitiveValue(CSS_VAL_MIDDLE);
    else
        return new CSSPrimitiveValue(CSS_VAL_END);
}

Also, due to bug 15422, we no longer have very good compile-time checking (on SVG enabled builds) for all the necessary switch statements for CSS handling.  This would add that back by either auto-generating all the needed subfunctions, or leaving them empty (and thus causing a compile failure).

We could even make CSSValueKeywords.in autogenerated from some more complicated file.

One possible source file:

CSSPropertiesAndValues.in:
stroke-miter-limit: &lt;number&gt;
alignment-baseline: [prefix: AB_] auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | inherit
fill # custom
stroke # custom

That&apos;s obviously not a complete specification above, but some things to note:
1.  inherit could be explicit or assumed depending on what&apos;s more common
2.  some sort of custom value handling *by default*
3. automatic enum handling (note the use of a prefix for specifying how to convert enums for the Impl)
4. handles different value types (just like the CSS grammar does)
5. Note that CSS_VAL defines become automatic and implicit.  Only if your overriding behavior do you ever know they exist.  They become an implementation detail of the CSS system hidden from most coders.

I&apos;d be curious to hear others thoughts.  I think it&apos;d be relatively straightforward to break the existing switch statements into subfunctions and autogenerate the parent function today.  Then slowly we could add enum support, and other more advanced sub-function support.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58108</commentid>
    <comment_count>1</comment_count>
    <who name="">mitz</who>
    <bug_when>2007-10-08 10:40:58 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of 12159 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>