зеркало из https://github.com/mozilla/gecko-dev.git
Bug 592469 - Web Console cleanup: part 6 - HUDService - remove displaysIndex() and more; r=dcamp,gavin.sharp
This commit is contained in:
Родитель
15280d025b
Коммит
8248f63ec8
|
@ -1197,15 +1197,14 @@ NetworkPanel.prototype =
|
||||||
* Ensures that the number of message nodes of type aCategory don't exceed that
|
* Ensures that the number of message nodes of type aCategory don't exceed that
|
||||||
* category's line limit by removing old messages as needed.
|
* category's line limit by removing old messages as needed.
|
||||||
*
|
*
|
||||||
* @param nsIDOMNode aConsoleNode
|
* @param aHUDId aHUDId
|
||||||
* The DOM node (richlistbox aka outputNode) that holds the output of the
|
* The HeadsUpDisplay ID.
|
||||||
* console.
|
|
||||||
* @param integer aCategory
|
* @param integer aCategory
|
||||||
* The category of message nodes to limit.
|
* The category of message nodes to limit.
|
||||||
* @return number
|
* @return number
|
||||||
* The current user-selected log limit.
|
* The current user-selected log limit.
|
||||||
*/
|
*/
|
||||||
function pruneConsoleOutputIfNecessary(aConsoleNode, aCategory)
|
function pruneConsoleOutputIfNecessary(aHUDId, aCategory)
|
||||||
{
|
{
|
||||||
// Get the log limit, either from the pref or from the constant.
|
// Get the log limit, either from the pref or from the constant.
|
||||||
let logLimit;
|
let logLimit;
|
||||||
|
@ -1216,13 +1215,15 @@ function pruneConsoleOutputIfNecessary(aConsoleNode, aCategory)
|
||||||
logLimit = DEFAULT_LOG_LIMIT;
|
logLimit = DEFAULT_LOG_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
let scrollBox = aConsoleNode.scrollBoxObject.element;
|
let hudRef = HUDService.getHudReferenceById(aHUDId);
|
||||||
|
let outputNode = hudRef.outputNode;
|
||||||
|
|
||||||
|
let scrollBox = outputNode.scrollBoxObject.element;
|
||||||
let oldScrollHeight = scrollBox.scrollHeight;
|
let oldScrollHeight = scrollBox.scrollHeight;
|
||||||
let scrolledToBottom = ConsoleUtils.isOutputScrolledToBottom(aConsoleNode);
|
let scrolledToBottom = ConsoleUtils.isOutputScrolledToBottom(outputNode);
|
||||||
let hudRef = HUDService.getHudReferenceForOutputNode(aConsoleNode);
|
|
||||||
|
|
||||||
// Prune the nodes.
|
// Prune the nodes.
|
||||||
let messageNodes = aConsoleNode.querySelectorAll(".webconsole-msg-" +
|
let messageNodes = outputNode.querySelectorAll(".webconsole-msg-" +
|
||||||
CATEGORY_CLASS_FRAGMENTS[aCategory]);
|
CATEGORY_CLASS_FRAGMENTS[aCategory]);
|
||||||
let removeNodes = messageNodes.length - logLimit;
|
let removeNodes = messageNodes.length - logLimit;
|
||||||
for (let i = 0; i < removeNodes; i++) {
|
for (let i = 0; i < removeNodes; i++) {
|
||||||
|
@ -1837,6 +1838,18 @@ HUD_SERVICE.prototype =
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the HeadsUpDisplay object associated to a content window.
|
||||||
|
*
|
||||||
|
* @param nsIDOMWindow aContentWindow
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
getHudByWindow: function HS_getHudByWindow(aContentWindow)
|
||||||
|
{
|
||||||
|
let hudId = this.getHudIdByWindow(aContentWindow);
|
||||||
|
return hudId ? this.hudReferences[hudId] : null;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hudId that is corresponding to the hud activated for the
|
* Returns the hudId that is corresponding to the hud activated for the
|
||||||
* passed aContentWindow. If there is no matching hudId null is returned.
|
* passed aContentWindow. If there is no matching hudId null is returned.
|
||||||
|
@ -1850,27 +1863,6 @@ HUD_SERVICE.prototype =
|
||||||
return this.getHudIdByWindowId(windowId);
|
return this.getHudIdByWindowId(windowId);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the hudReference for a given output node.
|
|
||||||
*
|
|
||||||
* @param nsIDOMNode aNode currently either a xul:vbox, the HUDBox, or a
|
|
||||||
* richlistbox, the outputNode.
|
|
||||||
* @returns a HUD | null
|
|
||||||
*/
|
|
||||||
getHudReferenceForOutputNode: function HS_getHudReferenceForOutputNode(aNode)
|
|
||||||
{
|
|
||||||
let node = aNode;
|
|
||||||
// starting from richlistbox, need to find hudbox
|
|
||||||
while (!node.id && !node.classList.contains("hud-box")) {
|
|
||||||
if (node.parentNode) {
|
|
||||||
node = node.parentNode;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.getHudReferenceById(node.id);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hudReference for a given id.
|
* Returns the hudReference for a given id.
|
||||||
*
|
*
|
||||||
|
@ -1882,15 +1874,6 @@ HUD_SERVICE.prototype =
|
||||||
return aId in this.hudReferences ? this.hudReferences[aId] : null;
|
return aId in this.hudReferences ? this.hudReferences[aId] : null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an array that contains all the HUD IDs.
|
|
||||||
* @returns array
|
|
||||||
*/
|
|
||||||
displaysIndex: function HS_displaysIndex()
|
|
||||||
{
|
|
||||||
return Object.keys(this.hudReferences);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hudId that is corresponding to the given outer window ID.
|
* Returns the hudId that is corresponding to the given outer window ID.
|
||||||
*
|
*
|
||||||
|
@ -2589,29 +2572,6 @@ HUD_SERVICE.prototype =
|
||||||
// see bug 559748
|
// see bug 559748
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Passed a HUDId, the corresponding window is returned
|
|
||||||
*
|
|
||||||
* @param string aHUDId
|
|
||||||
* @returns nsIDOMWindow
|
|
||||||
*/
|
|
||||||
getContentWindowFromHUDId: function HS_getContentWindowFromHUDId(aHUDId)
|
|
||||||
{
|
|
||||||
var hud = this.getHudReferenceById(aHUDId).HUDBox;
|
|
||||||
var nodes = hud.parentNode.childNodes;
|
|
||||||
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
var node = nodes[i];
|
|
||||||
|
|
||||||
if (node.localName == "stack" &&
|
|
||||||
node.firstChild &&
|
|
||||||
node.firstChild.contentWindow) {
|
|
||||||
return node.firstChild.contentWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error("HS_getContentWindowFromHUD: Cannot get contentWindow");
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a generator that always returns a unique number for use in the
|
* Creates a generator that always returns a unique number for use in the
|
||||||
* indexes
|
* indexes
|
||||||
|
@ -5744,7 +5704,7 @@ ConsoleUtils = {
|
||||||
|
|
||||||
HUDService.regroupOutput(outputNode);
|
HUDService.regroupOutput(outputNode);
|
||||||
|
|
||||||
if (pruneConsoleOutputIfNecessary(outputNode, aNode.category) == 0) {
|
if (pruneConsoleOutputIfNecessary(aHUDId, aNode.category) == 0) {
|
||||||
// We can't very well scroll to make the message node visible if the log
|
// We can't very well scroll to make the message node visible if the log
|
||||||
// limit is zero and the node was destroyed in the first place.
|
// limit is zero and the node was destroyed in the first place.
|
||||||
return;
|
return;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче