[CSS idea] Style sets

?As a celebration of first year anniversary of Style Sets use in my
implementation of CSS I wrote this article about them:
http://www.terrainformatica.com/2010/09/style-sets-in-h-smile-core/

In brief, style set is declared as:

@style-set TabsComponent
{
   :root { ... }
   :root > ul.ui-tabs-nav { ... }
   :root > div.ui-tabs-panel { ...; display:none; }
   :root > div.ui-tabs-panel.current { ... ; display:block; }
}

Such style set is applied to some DOM sub-tree using style-set property on
"style set root" element as:

div#my-tabs { style-set: TabsComponent; }

this will define styles of the element itself and its children.

In principle most of features of style sets (but not all) can be achieved by 
use of
CSS preprocessors like http://lesscss.org/ but the main purpose of SS is to 
reduce
computational complexity of CSS resolution process.
In my case style set mechanism reduces order of magnitude number of 
selectors
that need to be scanned for finding style of particular DOM element.
Default style sheet (of the UA) contains just tens of rules assigning style 
sets.
And the whole number of rules in all style sets is about 2 thousands.
I've got overall complexity of DOM style resolving close to O(N*log(S)).
Where N is a number of DOM elements and S is a number of style rules.
In case of flat (conventional CSS) style system the complexity will be over
than O(N*S).

Just an idea.

-- 
Andrew Fedoniouk

http://terrainformatica.com
 

Received on Tuesday, 28 September 2010 05:03:41 UTC