Re: Computational complexity of CSS

----- Original Message ----- 
From: "Bjoern Hoehrmann" <derhoermi@gmx.net>


>* Andrew Fedoniouk wrote:
>>If let's say in style sheet we have something like this:
>>
>>  select > option { background-color: color1... }
>>  select:focus > option { background-color: color2 ... }
>>
>>(weird but happens)
>>
>>then on focus-out event UA must resolve (find and inherit)
>>styles for all 10,000 items-elements (and their children) of the list.
>>This is serious task for modern hardware.
>>
>>Is anybody looking in this direction or you think
>>this problem is a bit artificial?
>
> Well, what do you really want to know? It is unlikely that we change CSS
> in a fundamental way such that this problem does not occur, authors are
> not going to put less elements in documents or less rules in stylesheets
> and you are probably not concerned about making microprocessors faster,
> so are you looking for optimizations that could be applied here? Or are
> you concerned about how significant the cascade's performance impact is
> in this case (compared to for example drawing the 10000 items)?
> -- 
> Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
>

Purpose of my note is simple: CSS/selectors as system has fundamental
flaw or limitation as you wish -  it can handle small documents and small 
style sets only.

For example system of styles written as :

select
{
   option
   {
      background-color: color1
   }
   @:focus option
   {
      background-color: color2
   }
}

effectively reduces lookup complexity as inner style blocks
need to be scanned only for children of the <select> - not
for all N nodes in the document.

I mean that probably it makes sense:

1) to review current flat model of styles/selectors.
2) while designing new selectors inspect them first
    in respect of the problem.

Andrew Fedoniouk.
http://terrainformatica.com

Received on Wednesday, 16 November 2005 17:07:50 UTC