Add repaint() method equivalent in Javascript

RESOLVED DUPLICATE of bug 21081

Status

()

Core
DOM
--
enhancement
RESOLVED DUPLICATE of bug 21081
11 years ago
11 years ago

People

(Reporter: VK, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: 

Firefox - as nearly all existing browsers - do not update graphics context until after the current script execution is finished. Until it's finished the DOM changes are being accumulated but not reflected on the screen. The most commonly used way to overcome this problem is by using micro-breaks over setTimeout.

/* repaint delay vulnerable coding : */
function someLongProcess() {
 document.getElementById('LoadingMessage').style.visibility = 'visible';
 doLongProcess();
 document.getElementById('LoadingMessage').style.visibility = 'hidden';
}

In the sample above nothing will work as the coder would expect.
LoadingMessage DOM element will remain invisible on the screen until after someLongProcess function is fully executed. Only after that all graphics context changes will be applied in one bulk, so LoadingMessage element will be changed to visible and to hidden right after that, so for the viewer it will not appear at all.


/* repaint delay aware coding : */
function someLongProcess() {
 document.getElementById('LoadingMessage').style.visibility = 'visible';
 window.setTimeout(doLongProcess, 60);
}

function doLongProcess() {
 // long process;
 document.getElementById('LoadingMessage').style.visibility = 'hidden';
}

IE allows to overcome this graphics weakness by some non-trivial use of showModalDialog method but nothing similar is found yet for Gecko. I consider this as an annoyance as it is imposes code modularity not dictated by the programming logic but by a graphics engine default.

I propose to add window.repaint() method to be able to refresh the screen without breaking the sub on parts for setTimeout workaround.
By its internal implementation that could be as simple(?) as window.alert "virtually" displayed and OK clicked in it in in say 10ms. Maybe there are more simple ways to implement it.

Reproducible: Always
Assignee: general → nobody
Component: JavaScript Engine → DOM
QA Contact: general → general
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 21081
You need to log in before you can comment on or make changes to this bug.