XTF factories
Factory interface
[scriptable, uuid(27c10dca-2efc-416b-ae36-9794380a661e)]
interface nsIXTFElementFactory : nsISupports
{
nsIXTFElement createElement(in AString tagName);
};
Sample implementation in JS module:
//----------------------------------------------------------------------
// xtfShapesFactory
const XTF_SHAPE_FACTORY_CID = Components.ID("{42575fd0-256d-42e5-abe7-cc0b9464503f}");
const XTF_SHAPE_FACTORY_PROGID = "@mozilla.org/xtf/element-factory;1?namespace=urn:mozilla:xtf:tests:shapes";
function xtfShapeFactory() { }
xtfShapeFactory.prototype = {
// nsISupports implementation:
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsIXTFElementFactory) &&
!iid.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
},
// nsIXTFElementFactory implementation:
createElement: function (tagName) {
if (tagName=="canvas")
return new xtfCanvas();
if (tagName=="shape")
return new xtfShape();
else if (tagName=="smiley")
return new xtfSmiley();
else
throw Components.results.NS_ERROR_FAILURE;
}
};
Alex Fritze
Last modified: Sun Feb 22 06:14:25 GMTST 2004