Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Any way to force a repaint during script execution?

2 views
Skip to first unread message

dolphinling

unread,
Sep 23, 2007, 9:29:44 PM9/23/07
to
I'm trying to write a testcase for something and I need a way to force a repaint
of something while a script executes. I tried the document.body.offsetHeight
trick, but it seems to only work for relayout cases, not repainting cases.

Is there anything like that to force a repaint?
--
dolphinling
<http://dolphinling.net/>

Boris Zbarsky

unread,
Sep 23, 2007, 9:49:38 PM9/23/07
to
dolphinling wrote:
> I'm trying to write a testcase for something and I need a way to force a
> repaint of something while a script executes. I tried the
> document.body.offsetHeight trick, but it seems to only work for relayout
> cases, not repainting cases.
>
> Is there anything like that to force a repaint?

The only way to do that, really, is to set a timeout and run the rest of your
script off that timeout.

-Boris


Bob Clary

unread,
Sep 25, 2007, 1:32:39 PM9/25/07
to
dolphinling wrote:
> I'm trying to write a testcase for something and I need a way to force a
> repaint of something while a script executes. I tried the
> document.body.offsetHeight trick, but it seems to only work for relayout
> cases, not repainting cases.
>
> Is there anything like that to force a repaint?

create another window of the same size and position, then use blur+focus?

Martijn

unread,
Sep 25, 2007, 4:06:31 PM9/25/07
to dolphinling, dev-q...@lists.mozilla.org
Maybe you could use part of the code from the "Time Render"
bookmarklet from Vlad?
http://blog.vlad1.com/archives/2005/10/28/74/
Only works on trunk.

Regards,
Martijn

2007/9/24, dolphinling <li...@dolphinling.net>:

> _______________________________________________
> dev-quality mailing list
> dev-q...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-quality
>


--
Martijn Wargers - Help Mozilla!
http://weblogs.mozillazine.org/qa/
http://wiki.mozilla.org/Mozilla_QA_Community
irc://irc.mozilla.org/qa - /nick mw22

dolphinling

unread,
Sep 25, 2007, 5:17:14 PM9/25/07
to

Thanks everyone. I ended up using setInterval (rather than setTimeout in a
loop), and it worked.

Vlad's bookmarklet uses
var wu =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
wu.redraw();

Which looks like it's specifically designed to repaint the page, but probably
not accessible to web pages. Is that right?

--
dolphinling
<http://dolphinling.net/>

Boris Zbarsky

unread,
Sep 25, 2007, 5:23:27 PM9/25/07
to
dolphinling wrote:
> Which looks like it's specifically designed to repaint the page, but
> probably not accessible to web pages. Is that right?

Correct.

-Boris

Martijn

unread,
Sep 25, 2007, 5:23:50 PM9/25/07
to dolphinling, dev-q...@lists.mozilla.org
2007/9/25, dolphinling <li...@dolphinling.net>:

> Vlad's bookmarklet uses
> var wu =
> window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
> wu.redraw();
>
> Which looks like it's specifically designed to repaint the page, but probably
> not accessible to web pages. Is that right?

You get the alert, no?
If you get the alert, then it's working (it works for me, here)
So I think it's accessible to web pages.

Regards,
Martijn

Martijn

unread,
Sep 25, 2007, 5:41:46 PM9/25/07
to Boris Zbarsky, dev-q...@lists.mozilla.org
2007/9/25, Boris Zbarsky <bzba...@mit.edu>:

Are you sure?
Something like this also seems to work for instance:
http://martijn.martijn.googlepages.com/focus.htm

Regards,
Martijn

> -Boris

Boris Zbarsky

unread,
Sep 25, 2007, 5:44:08 PM9/25/07
to
Martijn wrote:
> So I think it's accessible to web pages.

If it is, that's a bug we need to fix.

-Boris

Martijn

unread,
Sep 25, 2007, 7:08:30 PM9/25/07
to Boris Zbarsky, dev-q...@lists.mozilla.org
2007/9/25, Boris Zbarsky <bzba...@mit.edu>:

> Martijn wrote:
> > So I think it's accessible to web pages.
>
> If it is, that's a bug we need to fix.

Ok, I filed https://bugzilla.mozilla.org/show_bug.cgi?id=397571 for it.
(but to be honest, I kinda like it that you can use this stuff on web pages)

0 new messages