mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Implement nsIHTMLElementFactory
This commit is contained in:
parent
c37119c8c6
commit
c66cd43ff3
@ -35,6 +35,7 @@
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLElementFactory.h"
|
||||
#include "nsITextContent.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
@ -814,6 +815,57 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, const nsString& aTag)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLElementFactoryIID, NS_IHTML_ELEMENT_FACTORY_IID);
|
||||
|
||||
class nsHTMLElementFactory : public nsIHTMLElementFactory {
|
||||
public:
|
||||
nsHTMLElementFactory();
|
||||
virtual ~nsHTMLElementFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstanceByTag(const nsString& aTag,
|
||||
nsIHTMLContent** aResult);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(aInstancePtrResult, "null OUT ptr");
|
||||
if (!aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsHTMLElementFactory* it = new nsHTMLElementFactory();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLElementFactoryIID,
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsHTMLElementFactory::nsHTMLElementFactory()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsHTMLElementFactory::~nsHTMLElementFactory()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsHTMLElementFactory, kIHTMLElementFactoryIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLElementFactory::CreateInstanceByTag(const nsString& aTag,
|
||||
nsIHTMLContent** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_CreateHTMLElement(aResult, aTag);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SinkContext::SinkContext(HTMLContentSink* aSink)
|
||||
{
|
||||
mSink = aSink;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIHTMLElementFactory.h"
|
||||
#include "nsITextContent.h"
|
||||
|
||||
#include "nsIDOMText.h"
|
||||
@ -814,6 +815,57 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, const nsString& aTag)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIHTMLElementFactoryIID, NS_IHTML_ELEMENT_FACTORY_IID);
|
||||
|
||||
class nsHTMLElementFactory : public nsIHTMLElementFactory {
|
||||
public:
|
||||
nsHTMLElementFactory();
|
||||
virtual ~nsHTMLElementFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstanceByTag(const nsString& aTag,
|
||||
nsIHTMLContent** aResult);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(aInstancePtrResult, "null OUT ptr");
|
||||
if (!aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsHTMLElementFactory* it = new nsHTMLElementFactory();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLElementFactoryIID,
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
nsHTMLElementFactory::nsHTMLElementFactory()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsHTMLElementFactory::~nsHTMLElementFactory()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsHTMLElementFactory, kIHTMLElementFactoryIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLElementFactory::CreateInstanceByTag(const nsString& aTag,
|
||||
nsIHTMLContent** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_CreateHTMLElement(aResult, aTag);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SinkContext::SinkContext(HTMLContentSink* aSink)
|
||||
{
|
||||
mSink = aSink;
|
||||
|
Loading…
x
Reference in New Issue
Block a user