Patch to further reduce the time of progress meter and status updates. r=pchen, sr=alecf

git-svn-id: svn://10.0.0.236/trunk@87716 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hyatt%netscape.com 2001-02-22 23:46:19 +00:00
parent 38967ee649
commit 1d9c05fae0
4 changed files with 52 additions and 21 deletions

View File

@ -113,6 +113,7 @@ XUL_ATOM(observes, "observes") // The observes element
XUL_ATOM(templateAtom, "template") // A XUL template
XUL_ATOM(progressbar, "progressbar")
XUL_ATOM(progresstext, "progresstext")
XUL_ATOM(crop, "crop")
XUL_ATOM(mode, "mode")

View File

@ -3858,6 +3858,11 @@ nsXULElement::ExecuteOnBroadcastHandler(nsIDOMElement* anElement, const nsAReada
// Now we execute the onchange handler in the context of the
// observer. We need to find the observer in order to
// execute the handler.
nsAutoString obs;
anElement->GetAttribute(NS_LITERAL_STRING("observes"), obs);
if (obs.Length() > 0)
return NS_OK;
nsCOMPtr<nsIDOMNodeList> nodeList;
if (NS_SUCCEEDED(anElement->GetElementsByTagName(NS_LITERAL_STRING("observes"),
getter_AddRefs(nodeList)))) {
@ -4159,7 +4164,8 @@ nsXULElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
{
aHint = NS_STYLE_HINT_CONTENT; // by default, never map attributes to style
if (aAttribute == nsXULAtoms::value) {
if (aAttribute == nsXULAtoms::value || aAttribute == nsXULAtoms::flex ||
aAttribute == nsXULAtoms::progresstext) {
// VERY IMPORTANT! This has a huge positive performance impact!
aHint = NS_STYLE_HINT_ATTRCHANGE;
}

View File

@ -133,6 +133,11 @@ function nsXULBrowserWindow()
this.defaultStatus = gNavigatorBundle.getString("defaultStatus");
}
function updateOverLink() {
window.XULBrowserWindow.updateStatusField();
window.XULBrowserWindow.statusTimeoutInEffect = false;
}
nsXULBrowserWindow.prototype =
{
useRealProgressFlag : false,
@ -146,6 +151,8 @@ nsXULBrowserWindow.prototype =
overLink : "",
startTime : 0,
statusTimeoutInEffect : false,
hideAboutBlank : true,
QueryInterface : function(iid)
@ -158,7 +165,7 @@ nsXULBrowserWindow.prototype =
setJSStatus : function(status)
{
this.jsStatus = status;
this.updateStatusField();
this.updateStatusField();
// Status is now on status bar; don't use it next time.
// This will cause us to revert to defaultStatus/jsDefaultStatus when the
// user leaves the link (e.g., if the script set window.status in onmouseover).
@ -177,7 +184,7 @@ nsXULBrowserWindow.prototype =
this.updateStatusField();
},
setOverLink : function(link)
setOverLink : function(link, b)
{
this.overLink = link;
this.updateStatusField();
@ -190,7 +197,9 @@ nsXULBrowserWindow.prototype =
if (!statusTextFld)
statusTextFld = document.getElementById("statusbar-display");
statusTextFld.setAttribute("value", text);
if (statusTextFld.getAttribute("value") != text) {
statusTextFld.setAttribute("value", text);
}
},
onProgress : function (request, current, max)
@ -202,15 +211,15 @@ nsXULBrowserWindow.prototype =
statusMeter = document.getElementById("statusbar-icon");
if (max > 0) {
if (statusMeter.getAttribute("mode") != "normal")
statusMeter.setAttribute("mode", "normal");
statusMeter.mode = "normal";
// This is highly optimized. Don't touch this code unless
// you are intimately familiar with the cost of setting
// attrs on XUL elements. -- hyatt
var percentage = (current * 100) / max ;
statusMeter.value = percentage;
statusMeter.progresstext = Math.round(percentage) + "%";
statusMeter.value = percentage;
} else {
if (statusMeter.getAttribute("mode") != "undetermined")
statusMeter.setAttribute("mode","undetermined");
statusMeter.mode = "undetermined";
}
},
@ -235,7 +244,7 @@ nsXULBrowserWindow.prototype =
this.startTime = (new Date()).getTime();
// Turn progress meter on.
statusMeter.setAttribute("mode","undetermined");
statusMeter.mode = "undetermined";
throbberElement.setAttribute("busy", true);
// XXX: These need to be based on window activity...
@ -244,7 +253,6 @@ nsXULBrowserWindow.prototype =
stopContext.setAttribute("disabled", false);
// Initialize the progress stuff...
statusMeter.setAttribute("mode","undetermined");
this.useRealProgressFlag = false;
this.totalRequests = 0;
this.finishedRequests = 0;
@ -273,9 +281,8 @@ nsXULBrowserWindow.prototype =
this.setDefaultStatus(msg);
// Turn progress meter off.
statusMeter.setAttribute("mode","normal");
statusMeter.mode = "normal";
statusMeter.value = 0; // be sure to clear the progress bar
statusMeter.progresstext = "";
throbberElement.removeAttribute("busy");
// XXX: These need to be based on window activity...
@ -293,7 +300,7 @@ nsXULBrowserWindow.prototype =
if (ctype != "text/html")
this.useRealProgressFlag = true;
statusMeter.setAttribute("mode", "normal");
statusMeter.mode = "normal";
}
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
@ -320,8 +327,11 @@ nsXULBrowserWindow.prototype =
onStatus : function(request, status, msg)
{
this.setOverLink(msg);
//this.setDefaultStatus(msg);
this.overLink = msg;
if (!this.statusTimeoutInEffect) {
this.statusTimeoutInEffect = true;
setTimeout(updateOverLink, 400);
}
}
}

View File

@ -226,11 +226,25 @@
</xul:box>
</content>
<implementation>
<property name="progresstext" onset="this.setAttribute('progresstext',val); return val;"
<property name="progresstext" onset="if (this.progresstext != val) this.setAttribute('progresstext',val); return val;"
onget="return this.getAttribute('progresstext');"/>
<property name="value" onset="this.setAttribute('value',val); return val;"
onget="return this.getAttribute('value');"/>
<property name="mode" onset="this.setAttribute('mode', val); return val;"
<property name="value" onget="return this.getAttribute('value');">
<setter>
<![CDATA[
var p = Math.round(val);
var c = this.value;
if (p != c) {
var delta = p - c;
if (delta < 0) delta = -delta;
if (delta > 3 || p == 0 || p == 100) {
this.setAttribute('value',p);
}
}
return p;
]]>
</setter>
</property>
<property name="mode" onset="if (this.mode != val) this.setAttribute('mode', val); return val;"
onget="return this.getAttribute('mode');"/>
</implementation>
</binding>