Re: WebKit now supports CSS Variables

Also, I think your spec leak a "CSS Variables Center".

 

Now, if we want to get, with the DOM (JS), all variables defined in the page, we must walk all stylesheets and style rules.

It should be great if we can have a "document.CSSVariables" object.

 

My original plan was this:

 

    /*
        DOM Implementation of constants
        --------------------------------
        document.CSSConstants : {
            /*
                Parse CSS-Value in regard to CSS-Type (2)
                If a constant already exists with the same name:
                    If old constant and new constant have the same type : update the old constant. (3)
                    Otherly : an error should be thrown (1).
                Otherly, add a new constant.
                
                Exceptions: "TYPE_IS_WRONG" (1), "WRONG_DATA" (2), "READONLY_CONSTANT" (3)
            */
            [function:void] add(constantName:DOMString, constantType:CSS-Type, constantValue:CSS-Value);
            
            /*
                Exceptions: "CONSTANT_DOES_NOT_EXISTS", "READONLY_CONSTANT"
            */
            [function:void] remove(constantName:DOMString);
            
            /*
                Read:
                    If constant doesn't exists, return undefined
                Write:
                    If constant doesn't exists, it should be added
                    Exceptions: "READONLY_CONSTANT", "WRONG_DATA"
            */
            [default/r/w]   item(constantIndex:Number):CSS-Constant;
            [default/r/w]   item(constantName:String):CSS-Constant;
            
            [r]             length:Number;
        }
        
        CSSConstant : {
            [constructor]   new(name:DOMString, type:CSS-Type, value:CSS-Value):CSSConstant
            [r]             name:DOMString;
            [r]             type:CSS-Type;
            /*
                Some browsers constants (@browser, ...) can be readonly.
            */
            [default/r/w]   value:CSS-Value;
        }

 

But the spec seems to tend to be different, so I suppose this is better:

> Remove any "type" idea, and placed a "media" concept in place.

> Rename "constant" into "variable"

> Add "get/setVariableValue" (my old spec was leaking here)

> Do some other minor changes

 

    /*
        DOM Implementation of variables
        --------------------------------
        [document.] CSSVariables : {
            /*
                If a variable already exists with the same name:
                    If old variable and new variable have the same media : update the old variable. (2)
                    Otherly : an error should be thrown (1).
                Otherly, add a new variable.
                
                Exceptions: "MEDIA_IS_WRONG" (1), "READONLY_VARIABLE" (2)
            */
            [function:void] add(variableName:DOMString, variableMedia:CSS-Media-Type, variableValue:CSS-Value);
            
            /*
                Exceptions: "VARIABLE_DOES_NOT_EXISTS", "READONLY_VARIABLE"
            */
            [function:void] remove(variableName:DOMString);

 

            /*
                If a variable already exists with the same name:
                    Return the variable's value
                Otherly, throw an error (1)
                
                Exceptions: "VARIABLE_DOES_NOT_EXISTS" (1)

            */
            [function:CSS-Value] getVariableValue(variableName:DOMString);

 

            /*
                If an old variable with the same name exists : update the old variable. (1)
                Otherly, an error should be thrown (2)
                
                Exceptions: "READONLY_VARIABLE" (1), "VARIABLE_DOES_NOT_EXISTS" (2)
            */
            [function:void] setVariableValue(variableName:DOMString, variableValue:CSS-Value);


            
            /*
                Read:
                    If variable doesn't exists, return undefined
                Write:
                    If variable doesn't exists, it should be added
                    Exceptions: "READONLY_VARIABLE", "WRONG_DATA"
            */
            [default/r/w]   item(variableIndex:Number):CSS-Variable;
            [default/r/w]   item(variableName:String):CSS-Variable;
            
            [r]             length:Number;
        }
        
        [window.] CSSVariable : {
            [constructor]   new(name:DOMString, media:CSS-Media-Type, value:CSS-Value):CSSVariable
            [r]             name:DOMString;
            [r]             media:CSS-Media-Type;
            /*
                Some browsers variables (@browser, ...) can be readonly.
            */
            [default/r/w]   value:CSS-Value;
        }

 


Fremy

 




--------------------------------------------------
From: "David Hyatt" <hyatt@apple.com>
Sent: Monday, June 23, 2008 9:07 PM
To: "www-style list" <www-style@w3.org>
Subject: WebKit now supports CSS Variables

> 
> WebKit now has an experimental implementation of CSS variables as  
> outlined here:
> 
> http://disruptive-innovations.com/zoo/cssvariables/
> 
> You can test this feature using a nightly from:
> 
> http://nightly.webkit.org/
> 
> Test cases can be found here:
> 
> http://trac.webkit.org/browser/trunk/LayoutTests/fast/css/variables
> 
> dave
> (hyatt@apple.com)
> 
>

Received on Tuesday, 24 June 2008 10:31:02 UTC