Setting CSS props and timers from JavaScript

Koos Vriezen koos.vriezen at xs4all.nl
Sun Nov 3 15:47:10 GMT 2002


On Sun, 3 Nov 2002, David Faure wrote:

> On Sunday 03 November 2002 15:17, Koos Vriezen wrote:
>
> > KHTML ends with 12538 on my box while eating all CPU. Mozilla ends with
> > 185, probably has a limit of 16ms.
> > It's quite easy to set a limit in WindowQObject::installTimeout (2 times).
>
> Oh, I didn't think we could do this (it's effectively forbidding sites from using
> a setting < 16). But indeed it leads to much better useability, I'm all for it
> (seems to be the only fix against this "extreme polling" those sites do).

Ok, if no further comments, I'll commit this.

>
> > Another thing is that setting the top property. Now a property is first
> > removed and than added, marking it as changed trggering a recalcStyle.
> > Adding 'if (styleDecl.getPropertyValue(prop) == propvalue) return;'
> > in DOMCSSStyleDeclaration::tryPut does seem to prevent this (but may slow
> > down cases where propvalue != current value).
>
> Hmm, indeed. Which is why it might not be a good idea - in the common case
> it _is_ different. And if not, the recalc might be intentionnal. Websites which
> want to do this in a smarter way (for this case where the value is usually
> unchanged), can query the prop before setting it...

Yes maybe, but how do you judge the programming skills of an average web
developer :). I rather protect my CPU for this... If a developer wants to
trigger a recalc this way, it probably read the KHTML sources first :)
And what effect would a recalc have if nothing is changed?

> [ The real problem IMHO is that there is no DOM event for "scrollbars moved",
> which such sites could use to move the static thingie, instead of polling :} ]

IE has onScroll events, which are imo very suitable for this.

Koos






More information about the kfm-devel mailing list