[webkit-dev] Detecting a finished paint via JavaScript

David Hyatt hyatt at apple.com
Wed Jul 8 10:55:08 PDT 2009


On Jul 8, 2009, at 12:45 PM, RDC wrote:

>> Would you be willing elaborate on why you want this?
>
> Of course; I would like it for benchmarking page rendering times-- 
> something I believe would be possible with Web Inspector, but I'm  
> after a cross-browser way of achieving it.
>
> At the moment I have a benchmark that uses the onLoad event to move  
> onto the next page; on Firefox this sometimes results in pages being  
> "skipped" as the onLoad event is triggered before any painting is  
> done. We use the mozAfterPaint to control this somewhat (though not  
> completely effectively--any DOM manipulation via JS causes further  
> paint events, but by this time the onLoad has fired).
>
> Thinking more about it, perhaps it is the case that WebKit doesn't  
> behave in exactly the same way, and the afterPaint event is not  
> needed to guarantee that at least *some* of the page is painted  
> before moving on.

We behave about the same.  We fire onload before both layout and  
paint.  If you say document.body.offsetWidth inside an onload handler  
we end up more or less equivalent  to Gecko (we will only have the  
paint left to do).

As Robert O' Callahan wrote though, mozAfterPaint doesn't really fire  
after painting.  It's approximate.  So I'm not sure it's advisable to  
try to use it in a benchmarking tool.

dave
(hyatt at apple.com)



More information about the webkit-dev mailing list