Re: Suggestion for CSS3 selectors (fwd)

Andrei Polushin wrote:
> Andrew Fedoniouk wrote:
>> People, are you serious about all this?
>>
>> What CPU would you use to process this:
>>
>> :root < a:hover { color:sisyphean; font:boulder; }
>>
>> ?
>>
>> This simply means recalculation of styles and layout of all DOM 
>> elements on simple a:hover. So is my question above.
>
> How your example differs from the example below:
>
>   :root:hover { color:sisyphean; font:boulder; }
>
> ?
>
:root:hover {} does not require whole tree scan for match/not-match answer.
Complexity of :root:hover is O(1). And  selector :root < a:hover has 
complexity O(n).
> This example is valid in present CSS, and it will hang your browser in 
> an equivalent manner. So the "recalculation" is the problem, but it is 
> a completely *different* problem.
>
>> Complexity of style resolution for *single* element using
>> containment selector is O(n), where n is a number of DOM elements in 
>> the whole tree. So resolving the whole DOM against single containment 
>> rule is O(n*n). This will not fly.
>
> Yes, in certain computation models, style *resolution* would be an 
> obvious problem. But the proposal is about how to change the 
> computation model, isn't it? In particular, it was proposed not to 
> match the ancestor node, and not to scan the tree into depth, but to 
> match the most descendant node, and update the certain properties of 
> the ancestor node.
Such reformulation is not changing anything in principle.

  parent < child { color:red; }
  child { font: cool; }

To resolve final style of the element (child) you need (resolved) parent 
style and list of rules matching the child.
To find parent style you need to scan all children first. That is still 
O(n).
>
> This model would require us to store something in each node on the 
> path from ancestor to descendant, thus I'm still not sure whether it's 
> viable, but the model is completely different from the present model 
> you describe.
I cannot see how is it different, sorry.
It could be different only if you will drop inheritance from CSS. 
Completely.

---
Gentlemen, do we have real life samples of where this feature is required?

--
Andrew Fedoniouk.
http://terrainformatica.com

Received on Thursday, 1 May 2008 17:49:22 UTC