Implement GetAreas; cleanup some whitespace; removed some out of date comments

This commit is contained in:
kipp%netscape.com 1999-01-09 00:17:07 +00:00
Родитель 00cbea9c70
Коммит ef74e3273a
2 изменённых файлов: 72 добавлений и 38 удалений

Просмотреть файл

@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "GenericElementCollection.h"
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
@ -69,6 +70,7 @@ public:
protected:
nsGenericHTMLContainerElement mInner;
GenericElementCollection* mAreas;
};
nsresult
@ -89,10 +91,15 @@ nsHTMLMapElement::nsHTMLMapElement(nsIAtom* aTag)
{
NS_INIT_REFCNT();
mInner.Init(this, aTag);
mAreas = nsnull;
}
nsHTMLMapElement::~nsHTMLMapElement()
{
if (nsnull != mAreas) {
mAreas->ParentDestroyed();
NS_RELEASE(mAreas);
}
}
NS_IMPL_ADDREF(nsHTMLMapElement)
@ -126,8 +133,20 @@ nsHTMLMapElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
NS_IMETHODIMP
nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas)
{
*aAreas = nsnull;
return NS_ERROR_OUT_OF_MEMORY;/* XXX */
if (nsnull == aAreas) {
return NS_ERROR_NULL_POINTER;
}
if (nsnull == mAreas) {
mAreas = new GenericElementCollection(NS_STATIC_CAST(nsIContent*, this),
nsHTMLAtoms::area);
if (nsnull == mAreas) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mAreas);
}
*aAreas = NS_STATIC_CAST(nsIDOMHTMLCollection*, mAreas);
NS_ADDREF(mAreas);
return NS_OK;
}
@ -138,7 +157,6 @@ nsHTMLMapElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
// XXX write me
return NS_CONTENT_ATTR_NOT_THERE;
}
@ -147,7 +165,6 @@ nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@ -156,8 +173,8 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext,
aPresContext);
}
NS_IMETHODIMP

Просмотреть файл

@ -26,6 +26,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "GenericElementCollection.h"
static NS_DEFINE_IID(kIDOMHTMLMapElementIID, NS_IDOMHTMLMAPELEMENT_IID);
@ -69,6 +70,7 @@ public:
protected:
nsGenericHTMLContainerElement mInner;
GenericElementCollection* mAreas;
};
nsresult
@ -89,10 +91,15 @@ nsHTMLMapElement::nsHTMLMapElement(nsIAtom* aTag)
{
NS_INIT_REFCNT();
mInner.Init(this, aTag);
mAreas = nsnull;
}
nsHTMLMapElement::~nsHTMLMapElement()
{
if (nsnull != mAreas) {
mAreas->ParentDestroyed();
NS_RELEASE(mAreas);
}
}
NS_IMPL_ADDREF(nsHTMLMapElement)
@ -126,8 +133,20 @@ nsHTMLMapElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
NS_IMETHODIMP
nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas)
{
*aAreas = nsnull;
return NS_ERROR_OUT_OF_MEMORY;/* XXX */
if (nsnull == aAreas) {
return NS_ERROR_NULL_POINTER;
}
if (nsnull == mAreas) {
mAreas = new GenericElementCollection(NS_STATIC_CAST(nsIContent*, this),
nsHTMLAtoms::area);
if (nsnull == mAreas) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mAreas);
}
*aAreas = NS_STATIC_CAST(nsIDOMHTMLCollection*, mAreas);
NS_ADDREF(mAreas);
return NS_OK;
}
@ -138,7 +157,6 @@ nsHTMLMapElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,
nsHTMLValue& aResult)
{
// XXX write me
return NS_CONTENT_ATTR_NOT_THERE;
}
@ -147,7 +165,6 @@ nsHTMLMapElement::AttributeToString(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsString& aResult) const
{
// XXX write me
return mInner.AttributeToString(aAttribute, aValue, aResult);
}
@ -156,8 +173,8 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
// XXX write me
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext,
aPresContext);
}
NS_IMETHODIMP