Clean up use of QueryInterface in consoleBindings.xml b=179268 r=timeless sr=bz
git-svn-id: svn://10.0.0.236/trunk@168920 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</xul:vbox>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<implementation implements="nsIConsoleListener">
|
||||
<field name="limit" readonly="true">
|
||||
250
|
||||
</field>
|
||||
@@ -70,20 +70,15 @@
|
||||
<body><![CDATA[
|
||||
this.mCount = 0;
|
||||
|
||||
this.mConsoleListener = {
|
||||
console: this,
|
||||
observe : function(aObject) { this.console.appendItem(aObject); }
|
||||
};
|
||||
|
||||
this.mConsoleRowBox = document.getAnonymousElementByAttribute(this, "role", "console-rows");
|
||||
this.mStrBundle = document.getAnonymousElementByAttribute(this, "role", "string-bundle");
|
||||
|
||||
try {
|
||||
var isupports = Components.classes['@mozilla.org/consoleservice;1'].getService();
|
||||
this.mCService = isupports.QueryInterface(Components.interfaces.nsIConsoleService);
|
||||
this.mCService.registerListener(this.mConsoleListener);
|
||||
this.mCService = Components.classes['@mozilla.org/consoleservice;1']
|
||||
.getService(Components.interfaces.nsIConsoleService);
|
||||
this.mCService.registerListener(this);
|
||||
} catch (ex) {
|
||||
appendItem(
|
||||
appendMessage(
|
||||
"Unable to display errors - couldn't get Console Service component. " +
|
||||
"(Missing @mozilla.org/consoleservice;1)");
|
||||
return;
|
||||
@@ -97,7 +92,7 @@
|
||||
|
||||
<method name="destroy">
|
||||
<body><![CDATA[
|
||||
this.mCService.unregisterListener(this.mConsoleListener);
|
||||
this.mCService.unregisterListener(this);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@@ -121,33 +116,22 @@
|
||||
|
||||
// Populate with messages after latest "clear"
|
||||
while (++i < messages.length)
|
||||
this.appendItem(messages[i]);
|
||||
this.observe(messages[i]);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="appendItem">
|
||||
<parameter name="aObject"/>
|
||||
<!-- nsIConsoleListener -->
|
||||
<method name="observe">
|
||||
<parameter name="aConsoleMessage"/>
|
||||
<body><![CDATA[
|
||||
if (!aObject.message) return;
|
||||
|
||||
try {
|
||||
// Try to QI it to a script error to get more info
|
||||
var scriptError = aObject.QueryInterface(Components.interfaces.nsIScriptError);
|
||||
|
||||
if (aConsoleMessage instanceof Components.interfaces.nsIScriptError) {
|
||||
// filter chrome urls
|
||||
if (!this.showChromeErrors && scriptError.sourceName.substr(0, 9) == "chrome://")
|
||||
if (!this.showChromeErrors && /^chrome:/.test(aConsoleMessage.sourceName))
|
||||
return;
|
||||
|
||||
this.appendError(scriptError);
|
||||
} catch (ex) {
|
||||
try {
|
||||
// Try to QI it to a console message
|
||||
var msg = aObject.QueryInterface(Components.interfaces.nsIConsoleMessage);
|
||||
this.appendMessage(msg.message);
|
||||
} catch (ex2) {
|
||||
// Give up and append the object itself as a string
|
||||
this.appendMessage(aObject);
|
||||
}
|
||||
this.appendError(aConsoleMessage);
|
||||
} else {
|
||||
this.appendMessage(aConsoleMessage.message);
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
Reference in New Issue
Block a user