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

This commit is contained in:
hyatt%netscape.com 2001-02-22 23:46:19 +00:00
Родитель 439e45f563
Коммит 9509498ac9
4 изменённых файлов: 51 добавлений и 269 удалений

Просмотреть файл

@ -1,248 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
*/
/******
This file contains the list of all XUL nsIAtoms and their values
It is designed to be used as inline input to nsXULAtoms.cpp *only*
through the magic of C preprocessing.
All entires must be enclosed in the macro XUL_ATOM which will have cruel
and unusual things done to it
It is recommended (but not strictly necessary) to keep all entries
in alphabetical order
The first argument to XUL_ATOM is the C++ identifier of the atom
The second argument is the string value of the atom
******/
XUL_ATOM(button, "button")
XUL_ATOM(spinner, "spinner")
XUL_ATOM(scrollbar, "scrollbar")
XUL_ATOM(slider, "slider")
XUL_ATOM(palettename, "palettename")
XUL_ATOM(fontpicker, "fontpicker")
XUL_ATOM(text, "text")
XUL_ATOM(toolbar, "toolbar")
XUL_ATOM(toolbaritem, "toolbaritem")
XUL_ATOM(toolbox, "toolbox")
XUL_ATOM(image, "image")
// The tree atoms
XUL_ATOM(tree, "tree") // The start of a tree view
XUL_ATOM(treecaption, "treecaption") // The caption of a tree view
XUL_ATOM(treehead, "treehead") // The header of the tree view
XUL_ATOM(treerow, "treerow") // A row in the tree view
XUL_ATOM(treerows, "treerows") // A row in the tree view
XUL_ATOM(treecell, "treecell") // An item in the tree view
XUL_ATOM(treeitem, "treeitem") // A cell in the tree view
XUL_ATOM(treechildren, "treechildren") // The children of an item in the tree view
XUL_ATOM(treeindentation, "treeindentation") // Specifies that the indentation for the level should occur here.
XUL_ATOM(allowevents, "allowevents") // Lets events be handled on the cell contents or in menus.
XUL_ATOM(treecol, "treecol") // A column in the tree view
XUL_ATOM(treecolgroup, "treecolgroup") // A column group in the tree view
XUL_ATOM(treecols, "treecols") // A column group in the tree view
XUL_ATOM(treefoot, "treefoot") // The footer of the tree view
XUL_ATOM(scrollbarlist, "scrollbarlist") // An atom for internal use by the tree view
XUL_ATOM(indent, "indent") // indicates that a cell should be indented
XUL_ATOM(outer, "outer") // indicates that a treechildren is the outermost rowgroup
XUL_ATOM(sizemode, "sizemode") // when set, measure strings to determine preferred width
XUL_ATOM(open, "open") // Whether or not a menu, tree, etc. is open
XUL_ATOM(outliner, "outliner")
XUL_ATOM(outlinerbody, "outlinerbody")
XUL_ATOM(outlinercol, "outlinercol")
XUL_ATOM(cycler, "cycler")
XUL_ATOM(primary, "primary")
XUL_ATOM(current, "current")
XUL_ATOM(mozoutlinerrow, ":-moz-outliner-row")
XUL_ATOM(mozoutlinercell, ":-moz-outliner-cell")
XUL_ATOM(mozoutlinercolumn, ":-moz-outliner-column")
XUL_ATOM(mozoutlinercelltext, ":-moz-outliner-cell-text")
XUL_ATOM(mozoutlinertwisty, ":-moz-outliner-twisty")
XUL_ATOM(mozoutlinerindentation, ":-moz-outliner-indentation")
XUL_ATOM(menubar, "menubar") // An XP menu bar.
XUL_ATOM(menu, "menu") // Represents an XP menu
XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item
XUL_ATOM(menupopup, "menupopup") // The XP menu's children.
XUL_ATOM(menutobedisplayed, "menutobedisplayed") // The menu is about to be displayed at the next sync w/ frame
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
XUL_ATOM(popupset, "popupset") // Contains popup menus, context menus, and tooltips
XUL_ATOM(popup, "popup") // The popup for a context menu, popup menu, or tooltip
XUL_ATOM(menugenerated, "menugenerated") // Internal
XUL_ATOM(popupanchor, "popupanchor") // Anchor for popups
XUL_ATOM(popupalign, "popupalign") // Alignment for popups
XUL_ATOM(ignorekeys, "ignorekeys") // Alignment for popups
XUL_ATOM(sizetopopup, "sizetopopup") // Whether or not menus size to their popup children (used by menulists)
XUL_ATOM(key, "key") // The key element / attribute
XUL_ATOM(keycode, "keycode") // The keycode attribute
XUL_ATOM(keytext, "keytext") // The keytext attribute
XUL_ATOM(modifiers, "modifiers") // The modifiers attribute
XUL_ATOM(broadcaster, "broadcaster") // A broadcaster
XUL_ATOM(observes, "observes") // The observes element
XUL_ATOM(templateAtom, "template") // A XUL template
XUL_ATOM(progressbar, "progressbar")
XUL_ATOM(crop, "crop")
XUL_ATOM(mode, "mode")
XUL_ATOM(equalsize, "equalsize")
XUL_ATOM(box, "box")
XUL_ATOM(hbox, "hbox")
XUL_ATOM(vbox, "vbox")
XUL_ATOM(scrollbox, "scrollbox")
XUL_ATOM(mousethrough, "mousethrough")
XUL_ATOM(flex, "flex")
XUL_ATOM(spring, "spring")
XUL_ATOM(orient, "orient")
XUL_ATOM(autostretch, "autostretch")
XUL_ATOM(minwidth, "min-width")
XUL_ATOM(minheight, "min-height")
XUL_ATOM(autorepeatbutton, "autorepeatbutton")
XUL_ATOM(bulletinboard, "bulletinboard")
XUL_ATOM(titledbox, "titledbox")
XUL_ATOM(title, "title")
XUL_ATOM(titledboxContentPseudo, ":titledbox-content")
XUL_ATOM(stack, "stack")
XUL_ATOM(deck, "deck")
XUL_ATOM(tabcontrol, "tabcontrol")
XUL_ATOM(tab, "tab")
XUL_ATOM(tabpanel, "tabpanel")
XUL_ATOM(tabpage, "tabpage")
XUL_ATOM(tabbox, "tabbox")
XUL_ATOM(index, "index")
XUL_ATOM(maxpos, "maxpos")
XUL_ATOM(curpos, "curpos")
XUL_ATOM(scrollbarbutton, "scrollbarbutton")
XUL_ATOM(increment, "increment")
XUL_ATOM(pageincrement, "pageincrement")
XUL_ATOM(thumb, "thumb")
XUL_ATOM(toggled, "toggled")
XUL_ATOM(grippy, "grippy")
XUL_ATOM(splitter, "splitter")
XUL_ATOM(collapse, "collapse")
XUL_ATOM(collapsed, "collapsed")
XUL_ATOM(resizebefore, "resizebefore")
XUL_ATOM(resizeafter, "resizeafter")
XUL_ATOM(state, "state")
XUL_ATOM(debug, "debug")
XUL_ATOM(fixed, "fixed")
// grid
XUL_ATOM(grid, "grid")
XUL_ATOM(rows, "rows")
XUL_ATOM(columns, "columns")
XUL_ATOM(row, "row")
XUL_ATOM(column, "column")
// toolbar & toolbar d&d atoms
XUL_ATOM(ddDropLocation, "dd-droplocation")
XUL_ATOM(ddDropLocationCoord, "dd-droplocationcoord")
XUL_ATOM(ddDropOn, "dd-dropon")
XUL_ATOM(ddTriggerRepaintSorted, "dd-triggerrepaintsorted")
XUL_ATOM(ddTriggerRepaintRestore, "dd-triggerrepaintrestore")
XUL_ATOM(ddTriggerRepaint, "dd-triggerrepaint")
XUL_ATOM(ddNoDropBetweenRows, "dd-nodropbetweenrows")
XUL_ATOM(container, "container")
XUL_ATOM(ddDragDropArea, "dragdroparea")
XUL_ATOM(ddDropMarker, ":-moz-drop-marker")
XUL_ATOM(widget, "widget")
XUL_ATOM(window, "window")
XUL_ATOM(iframe, "iframe")
XUL_ATOM(browser, "browser")
XUL_ATOM(editor, "editor")
//
XUL_ATOM(checkbox, "checkbox")
XUL_ATOM(radio, "radio")
XUL_ATOM(radiogroup, "radiogroup")
XUL_ATOM(menulist, "menulist")
XUL_ATOM(menubutton, "menubutton")
XUL_ATOM(textfield, "textfield")
XUL_ATOM(textarea, "textarea")
XUL_ATOM(listbox, "listbox")
XUL_ATOM(tooltip, "tooltip")
XUL_ATOM(context, "context")
XUL_ATOM(style, "style")
XUL_ATOM(selected, "selected")
XUL_ATOM(clazz, "class")
XUL_ATOM(id, "id")
XUL_ATOM(persist, "persist")
XUL_ATOM(ref, "ref")
XUL_ATOM(command, "command")
XUL_ATOM(value, "value")
XUL_ATOM(width, "width")
XUL_ATOM(height, "height")
XUL_ATOM(left, "left")
XUL_ATOM(top, "top")
XUL_ATOM(events, "events")
XUL_ATOM(targets, "targets")
XUL_ATOM(uri, "uri")
XUL_ATOM(empty, "empty")
XUL_ATOM(textnode, "textnode")
XUL_ATOM(rule, "rule")
XUL_ATOM(action, "action")
XUL_ATOM(containment, "containment")
XUL_ATOM(flags, "flags")
XUL_ATOM(Template, "template")
XUL_ATOM(member, "member")
XUL_ATOM(conditions, "conditions")
XUL_ATOM(property, "property")
XUL_ATOM(instanceOf, "instanceOf")
XUL_ATOM(xulcontentsgenerated, "xulcontentsgenerated")
XUL_ATOM(parent, "parent")
XUL_ATOM(iscontainer, "iscontainer")
XUL_ATOM(isempty, "isempty")
XUL_ATOM(bindings, "bindings")
XUL_ATOM(binding, "binding")
XUL_ATOM(triple, "triple")
XUL_ATOM(subject, "subject")
XUL_ATOM(predicate, "predicate")
XUL_ATOM(child, "child")
XUL_ATOM(object, "object")
XUL_ATOM(tag, "tag")
XUL_ATOM(content, "content")
XUL_ATOM(blankrow, "blankrow")
XUL_ATOM(titlebar, "titlebar")
XUL_ATOM(resizer, "resizer")
XUL_ATOM(dir, "dir")

Просмотреть файл

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

Просмотреть файл

@ -133,6 +133,11 @@ function nsXULBrowserWindow()
this.defaultStatus = gNavigatorBundle.getString("defaultStatus"); this.defaultStatus = gNavigatorBundle.getString("defaultStatus");
} }
function updateOverLink() {
window.XULBrowserWindow.updateStatusField();
window.XULBrowserWindow.statusTimeoutInEffect = false;
}
nsXULBrowserWindow.prototype = nsXULBrowserWindow.prototype =
{ {
useRealProgressFlag : false, useRealProgressFlag : false,
@ -146,6 +151,8 @@ nsXULBrowserWindow.prototype =
overLink : "", overLink : "",
startTime : 0, startTime : 0,
statusTimeoutInEffect : false,
hideAboutBlank : true, hideAboutBlank : true,
QueryInterface : function(iid) QueryInterface : function(iid)
@ -177,7 +184,7 @@ nsXULBrowserWindow.prototype =
this.updateStatusField(); this.updateStatusField();
}, },
setOverLink : function(link) setOverLink : function(link, b)
{ {
this.overLink = link; this.overLink = link;
this.updateStatusField(); this.updateStatusField();
@ -190,7 +197,9 @@ nsXULBrowserWindow.prototype =
if (!statusTextFld) if (!statusTextFld)
statusTextFld = document.getElementById("statusbar-display"); statusTextFld = document.getElementById("statusbar-display");
if (statusTextFld.getAttribute("value") != text) {
statusTextFld.setAttribute("value", text); statusTextFld.setAttribute("value", text);
}
}, },
onProgress : function (request, current, max) onProgress : function (request, current, max)
@ -202,15 +211,15 @@ nsXULBrowserWindow.prototype =
statusMeter = document.getElementById("statusbar-icon"); statusMeter = document.getElementById("statusbar-icon");
if (max > 0) { if (max > 0) {
if (statusMeter.getAttribute("mode") != "normal") statusMeter.mode = "normal";
statusMeter.setAttribute("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 ; var percentage = (current * 100) / max ;
statusMeter.value = percentage; statusMeter.value = percentage;
statusMeter.progresstext = Math.round(percentage) + "%";
} else { } else {
if (statusMeter.getAttribute("mode") != "undetermined") statusMeter.mode = "undetermined";
statusMeter.setAttribute("mode","undetermined");
} }
}, },
@ -235,7 +244,7 @@ nsXULBrowserWindow.prototype =
this.startTime = (new Date()).getTime(); this.startTime = (new Date()).getTime();
// Turn progress meter on. // Turn progress meter on.
statusMeter.setAttribute("mode","undetermined"); statusMeter.mode = "undetermined";
throbberElement.setAttribute("busy", true); throbberElement.setAttribute("busy", true);
// XXX: These need to be based on window activity... // XXX: These need to be based on window activity...
@ -244,7 +253,6 @@ nsXULBrowserWindow.prototype =
stopContext.setAttribute("disabled", false); stopContext.setAttribute("disabled", false);
// Initialize the progress stuff... // Initialize the progress stuff...
statusMeter.setAttribute("mode","undetermined");
this.useRealProgressFlag = false; this.useRealProgressFlag = false;
this.totalRequests = 0; this.totalRequests = 0;
this.finishedRequests = 0; this.finishedRequests = 0;
@ -273,9 +281,8 @@ nsXULBrowserWindow.prototype =
this.setDefaultStatus(msg); this.setDefaultStatus(msg);
// Turn progress meter off. // Turn progress meter off.
statusMeter.setAttribute("mode","normal"); statusMeter.mode = "normal";
statusMeter.value = 0; // be sure to clear the progress bar statusMeter.value = 0; // be sure to clear the progress bar
statusMeter.progresstext = "";
throbberElement.removeAttribute("busy"); throbberElement.removeAttribute("busy");
// XXX: These need to be based on window activity... // XXX: These need to be based on window activity...
@ -293,7 +300,7 @@ nsXULBrowserWindow.prototype =
if (ctype != "text/html") if (ctype != "text/html")
this.useRealProgressFlag = true; this.useRealProgressFlag = true;
statusMeter.setAttribute("mode", "normal"); statusMeter.mode = "normal";
} }
if (state & nsIWebProgressListener.STATE_IS_REQUEST) { if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
@ -320,8 +327,11 @@ nsXULBrowserWindow.prototype =
onStatus : function(request, status, msg) onStatus : function(request, status, msg)
{ {
this.setOverLink(msg); this.overLink = msg;
//this.setDefaultStatus(msg); if (!this.statusTimeoutInEffect) {
this.statusTimeoutInEffect = true;
setTimeout(updateOverLink, 400);
}
} }
} }

Просмотреть файл

@ -226,11 +226,25 @@
</xul:box> </xul:box>
</content> </content>
<implementation> <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');"/> onget="return this.getAttribute('progresstext');"/>
<property name="value" onset="this.setAttribute('value',val); return val;" <property name="value" onget="return this.getAttribute('value');">
onget="return this.getAttribute('value');"/> <setter>
<property name="mode" onset="this.setAttribute('mode', val); return val;" <![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');"/> onget="return this.getAttribute('mode');"/>
</implementation> </implementation>
</binding> </binding>