Bug 221988 Replace doesQI function with built-in instanceof operator r=peterv sr=alecf moa=caillon
git-svn-id: svn://10.0.0.236/trunk@148087 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d81fdc2091
commit
188c3fa081
@ -110,7 +110,7 @@ ViewerRegistry.prototype =
|
||||
for (var i = 0; i < this.mViewerDS.length; ++i) {
|
||||
js = this.getEntryProperty(i, "filter");
|
||||
try {
|
||||
fn = new Function("doesQI", "object", js);
|
||||
fn = new Function("object", js);
|
||||
} catch (ex) {
|
||||
fn = new Function("return false");
|
||||
debug("### ERROR - Syntax error in filter for viewer \"" + this.getEntryProperty(i, "description") + "\"\n");
|
||||
@ -172,20 +172,7 @@ ViewerRegistry.prototype =
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
objectMatchesEntry: function(aObject, aIndex)
|
||||
{
|
||||
if (!aObject) return false;
|
||||
return this.mFilters[aIndex](this.doesQI, aObject);
|
||||
},
|
||||
|
||||
doesQI: function(aObject, aInterface)
|
||||
{
|
||||
if (!("QueryInterface" in aObject)) return false;
|
||||
|
||||
try {
|
||||
var result = aObject.QueryInterface(Components.interfaces[aInterface]);
|
||||
return true;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
return this.mFilters[aIndex](aObject);
|
||||
},
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -19,11 +19,11 @@
|
||||
|
||||
ins:icon This sets an icon for the viewer. Currently unused.
|
||||
|
||||
ins:filter This determines which nodes (or in the case of JavaScript Object viewer, values), the viewer
|
||||
referenced is valid for.
|
||||
For example, ins:filter="return doesQI(object, 'nsIDOMDocument');" is a JavaScript fragment
|
||||
ViewerRegistry.js uses to define a filter function if the panel's subject node is an instance
|
||||
of nsIDOMDocument.
|
||||
ins:filter This determines which nodes (or in the case of JavaScript Object
|
||||
viewer, values), the viewer referenced is valid for. For example,
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMDocument;"
|
||||
is a JavaScript fragment ViewerRegistry.js uses to define a filter
|
||||
function if the panel's subject node is an instance of nsIDOMDocument.
|
||||
-->
|
||||
|
||||
<rdf:Seq about="inspector:viewers">
|
||||
@ -32,49 +32,49 @@
|
||||
ins:panels="bxDocPanel"
|
||||
ins:description="DOM Nodes"
|
||||
ins:icon="chrome://inspector/content/viewers/dom/dom-icon.gif"
|
||||
ins:filter="return doesQI(object, 'nsIDOMDocument');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMDocument;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="stylesheets"
|
||||
ins:panels="bxDocPanel"
|
||||
ins:description="Stylesheets"
|
||||
ins:filter="return doesQI(object, 'nsIDOMDocument');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMDocument;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="domNode"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="DOM Node"
|
||||
ins:filter="return doesQI(object, 'nsIDOMNode')"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMNode;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="boxModel"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="Box Model"
|
||||
ins:filter="return doesQI(object, 'nsIDOMElement');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMElement;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="xblBindings"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="XBL Bindings"
|
||||
ins:filter="return doesQI(object, 'nsIDOMElement');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMElement;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="styleRules"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="CSS Style Rules"
|
||||
ins:filter="return doesQI(object, 'nsIDOMElement') || doesQI(object, 'nsIDOMCSSStyleSheet');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMElement || object instanceof Components.interfaces.nsIDOMCSSStyleSheet;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
ins:uid="computedStyle"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="Computed Style"
|
||||
ins:filter="return doesQI(object, 'nsIDOMElement');"/>
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMElement;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li><rdf:Description
|
||||
|
||||
@ -311,25 +311,13 @@ StyleRulesViewer.prototype =
|
||||
|
||||
};
|
||||
|
||||
function doesQI(aObject, aInterface)
|
||||
{
|
||||
if (!("QueryInterface" in aObject)) return false;
|
||||
|
||||
try {
|
||||
var result = aObject.QueryInterface(Components.interfaces[aInterface]);
|
||||
return true;
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// StyleRuleView
|
||||
|
||||
function StyleRuleView(aObject)
|
||||
{
|
||||
this.mDOMUtils = XPCU.getService("@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
|
||||
if (doesQI(aObject, "nsIDOMCSSStyleSheet")) {
|
||||
if (aObject instanceof Components.interfaces.nsIDOMCSSStyleSheet) {
|
||||
this.mSheetRules = aObject.cssRules;
|
||||
} else {
|
||||
this.mRules = this.mDOMUtils.getCSSStyleRules(aObject);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user