Adding an interface for the creation of elements. Converting the HTML

element factory so that it implements this generic interface. r=waterson
This commit is contained in:
hyatt%netscape.com 2000-01-19 03:10:06 +00:00
parent cd53596229
commit 0684563f95
9 changed files with 24 additions and 76 deletions

View File

@ -1,4 +1,3 @@
#
# This is a list of local files which get copied to the mozilla:dist:layout directory
#
nsIHTMLElementFactory.h

View File

@ -28,8 +28,5 @@ include $(DEPTH)/config/autoconf.mk
MODULE = layout
EXPORTS = nsIHTMLElementFactory.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

View File

@ -22,7 +22,6 @@
DEPTH=..\..\..\..
EXPORTS = \
nsIHTMLElementFactory.h \
$(NULL)
MODULE=raptor

View File

@ -43,7 +43,7 @@
#include "prlog.h"
#include "nsHTMLParts.h"
#include "nsIHTMLElementFactory.h"
#include "nsIElementFactory.h"
#include "nsITextContent.h"
#include "nsIDOMText.h"
@ -958,9 +958,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, PRInt32 aID)
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIHTMLElementFactoryIID, NS_IHTML_ELEMENT_FACTORY_IID);
class nsHTMLElementFactory : public nsIHTMLElementFactory {
class nsHTMLElementFactory : public nsIElementFactory {
public:
nsHTMLElementFactory();
virtual ~nsHTMLElementFactory();
@ -968,11 +966,11 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstanceByTag(const nsString& aTag,
nsIHTMLContent** aResult);
nsIContent** aResult);
};
nsresult
NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
NS_NewHTMLElementFactory(nsIElementFactory** aInstancePtrResult)
{
NS_PRECONDITION(aInstancePtrResult, "null OUT ptr");
if (!aInstancePtrResult) {
@ -982,7 +980,7 @@ NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLElementFactoryIID,
return it->QueryInterface(nsIElementFactory::GetIID(),
(void**)aInstancePtrResult);
}
@ -995,14 +993,18 @@ nsHTMLElementFactory::~nsHTMLElementFactory()
{
}
NS_IMPL_ISUPPORTS(nsHTMLElementFactory, kIHTMLElementFactoryIID);
NS_IMPL_ISUPPORTS1(nsHTMLElementFactory, nsIElementFactory);
NS_IMETHODIMP
nsHTMLElementFactory::CreateInstanceByTag(const nsString& aTag,
nsIHTMLContent** aResult)
nsIContent** aResult)
{
nsresult rv;
rv = NS_CreateHTMLElement(aResult, aTag);
nsCOMPtr<nsIHTMLContent> htmlContent;
rv = NS_CreateHTMLElement(getter_AddRefs(htmlContent), aTag);
nsCOMPtr<nsIContent> content = do_QueryInterface(htmlContent);
*aResult = content;
NS_IF_ADDREF(*aResult);
return rv;
}

View File

@ -1,4 +1,3 @@
#
# This is a list of local files which get copied to the mozilla:dist:layout directory
#
nsIHTMLElementFactory.h

View File

@ -28,8 +28,5 @@ include $(DEPTH)/config/autoconf.mk
MODULE = layout
EXPORTS = nsIHTMLElementFactory.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

View File

@ -22,7 +22,6 @@
DEPTH=..\..\..\..
EXPORTS = \
nsIHTMLElementFactory.h \
$(NULL)
MODULE=raptor

View File

@ -1,46 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIHTMLElementFactory_h___
#define nsIHTMLElementFactory_h___
#include "nslayout.h"
#include "nsISupports.h"
class nsIHTMLContent;
class nsString;
/* a6cf90fb-15b3-11d2-932e-00805f8add32 */
#define NS_IHTML_ELEMENT_FACTORY_IID \
{ 0xa6cf90fb, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
/**
* An API for creating html content objects
*/
class nsIHTMLElementFactory : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IHTML_ELEMENT_FACTORY_IID; return iid; }
NS_IMETHOD CreateInstanceByTag(const nsString& aTag,
nsIHTMLContent** aResult) = 0;
};
#endif /* nsIHTMLElementFactory_h___ */

View File

@ -43,7 +43,7 @@
#include "prlog.h"
#include "nsHTMLParts.h"
#include "nsIHTMLElementFactory.h"
#include "nsIElementFactory.h"
#include "nsITextContent.h"
#include "nsIDOMText.h"
@ -958,9 +958,7 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, PRInt32 aID)
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIHTMLElementFactoryIID, NS_IHTML_ELEMENT_FACTORY_IID);
class nsHTMLElementFactory : public nsIHTMLElementFactory {
class nsHTMLElementFactory : public nsIElementFactory {
public:
nsHTMLElementFactory();
virtual ~nsHTMLElementFactory();
@ -968,11 +966,11 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstanceByTag(const nsString& aTag,
nsIHTMLContent** aResult);
nsIContent** aResult);
};
nsresult
NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
NS_NewHTMLElementFactory(nsIElementFactory** aInstancePtrResult)
{
NS_PRECONDITION(aInstancePtrResult, "null OUT ptr");
if (!aInstancePtrResult) {
@ -982,7 +980,7 @@ NS_NewHTMLElementFactory(nsIHTMLElementFactory** aInstancePtrResult)
if (!it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLElementFactoryIID,
return it->QueryInterface(nsIElementFactory::GetIID(),
(void**)aInstancePtrResult);
}
@ -995,14 +993,18 @@ nsHTMLElementFactory::~nsHTMLElementFactory()
{
}
NS_IMPL_ISUPPORTS(nsHTMLElementFactory, kIHTMLElementFactoryIID);
NS_IMPL_ISUPPORTS1(nsHTMLElementFactory, nsIElementFactory);
NS_IMETHODIMP
nsHTMLElementFactory::CreateInstanceByTag(const nsString& aTag,
nsIHTMLContent** aResult)
nsIContent** aResult)
{
nsresult rv;
rv = NS_CreateHTMLElement(aResult, aTag);
nsCOMPtr<nsIHTMLContent> htmlContent;
rv = NS_CreateHTMLElement(getter_AddRefs(htmlContent), aTag);
nsCOMPtr<nsIContent> content = do_QueryInterface(htmlContent);
*aResult = content;
NS_IF_ADDREF(*aResult);
return rv;
}