Bug 15460. Expose XML element creation via nsIXMLElementFactory interface. r=kipp.
git-svn-id: svn://10.0.0.236/trunk@49759 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
nsIXMLContentSink.h
|
||||
nsIXMLDocument.h
|
||||
nsIXMLElementFactory.h
|
||||
|
||||
@@ -27,6 +27,7 @@ MODULE = layout
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
nsIXMLElementFactory.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
@@ -20,6 +20,7 @@ DEPTH=..\..\..\..
|
||||
EXPORTS = \
|
||||
nsIXMLContentSink.h \
|
||||
nsIXMLDocument.h \
|
||||
nsIXMLElementFactory.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXMLContentSink.h"
|
||||
#include "nsIXMLElementFactory.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
@@ -1881,3 +1882,71 @@ nsXMLContentSink::RefreshIfEnabled(nsIViewManager* vm)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// XML Element Factory
|
||||
//
|
||||
|
||||
class XMLElementFactoryImpl : public nsIXMLElementFactory
|
||||
{
|
||||
protected:
|
||||
XMLElementFactoryImpl();
|
||||
virtual ~XMLElementFactoryImpl();
|
||||
|
||||
public:
|
||||
friend
|
||||
nsresult
|
||||
NS_NewXMLElementFactory(nsIXMLElementFactory** aResult);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIXMLElementFactory interface
|
||||
NS_IMETHOD CreateInstanceByTag(const nsString& aTag, nsIXMLContent** aResult);
|
||||
|
||||
};
|
||||
|
||||
|
||||
XMLElementFactoryImpl::XMLElementFactoryImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
XMLElementFactoryImpl::~XMLElementFactoryImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(XMLElementFactoryImpl, NS_GET_IID(nsIXMLElementFactory));
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewXMLElementFactory(nsIXMLElementFactory** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
XMLElementFactoryImpl* result = new XMLElementFactoryImpl();
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XMLElementFactoryImpl::CreateInstanceByTag(const nsString& aTag, nsIXMLContent** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag = dont_AddRef(NS_NewAtom(aTag));
|
||||
if (! tag)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_NewXMLElement(aResult, tag);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user