Eliminate SetAttr/UnsetAttr; use standard 3arg version now; leave the attribute impl macros alone for now; pass on attribute changes to the document when aNotify is PR_TRUE

This commit is contained in:
kipp%netscape.com 1998-09-24 21:35:52 +00:00
Родитель a53b4e8abb
Коммит a7c647f26c
4 изменённых файлов: 154 добавлений и 314 удалений

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

@ -517,7 +517,7 @@ DOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr);
mContent->UnsetAttribute(attr, PR_TRUE);
}
return res;
@ -793,7 +793,7 @@ nsGenericHTMLElement::RemoveAttribute(const nsString& aName)
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
UnsetAttribute(attr);
UnsetAttribute(attr, PR_TRUE);
NS_RELEASE(attr);
return NS_OK;
}
@ -843,7 +843,7 @@ nsGenericHTMLElement::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
nsAutoString upper;
name.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
UnsetAttribute(attr);
UnsetAttribute(attr, PR_TRUE);
}
}
@ -873,7 +873,7 @@ nsGenericHTMLElement::GetId(nsString& aId)
nsresult
nsGenericHTMLElement::SetId(const nsString& aId)
{
SetAttr(nsHTMLAtoms::id, aId, eSetAttrNotify_Restart);
SetAttribute(nsHTMLAtoms::id, aId, PR_TRUE);
return NS_OK;
}
@ -887,7 +887,7 @@ nsGenericHTMLElement::GetTitle(nsString& aTitle)
nsresult
nsGenericHTMLElement::SetTitle(const nsString& aTitle)
{
SetAttr(nsHTMLAtoms::title, aTitle, eSetAttrNotify_None);
SetAttribute(nsHTMLAtoms::title, aTitle, PR_TRUE);
return NS_OK;
}
@ -901,7 +901,7 @@ nsGenericHTMLElement::GetLang(nsString& aLang)
nsresult
nsGenericHTMLElement::SetLang(const nsString& aLang)
{
SetAttr(nsHTMLAtoms::lang, aLang, eSetAttrNotify_Reflow);
SetAttribute(nsHTMLAtoms::lang, aLang, PR_TRUE);
return NS_OK;
}
@ -915,7 +915,7 @@ nsGenericHTMLElement::GetDir(nsString& aDir)
nsresult
nsGenericHTMLElement::SetDir(const nsString& aDir)
{
SetAttr(nsHTMLAtoms::dir, aDir, eSetAttrNotify_Reflow);
SetAttribute(nsHTMLAtoms::dir, aDir, PR_TRUE);
return NS_OK;
}
@ -929,7 +929,7 @@ nsGenericHTMLElement::GetClassName(nsString& aClassName)
nsresult
nsGenericHTMLElement::SetClassName(const nsString& aClassName)
{
SetAttr(nsHTMLAtoms::kClass, aClassName, eSetAttrNotify_Restart);
SetAttribute(nsHTMLAtoms::kClass, aClassName, PR_TRUE);
return NS_OK;
}
@ -1184,6 +1184,10 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
}
}
}
if (aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
return result;
}
@ -1197,9 +1201,13 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
if (nsnull != sheet) {
result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
result = sheet->SetAttributeFor(aAttribute, aValue, mContent,
mAttributes);
NS_RELEASE(sheet);
}
if (aNotify) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
else { // manage this ourselves and re-sync when we connect to doc
result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
@ -1234,7 +1242,7 @@ nsGenericHTMLElement::MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
}
nsresult
nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@ -1243,6 +1251,9 @@ nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
result = sheet->UnsetAttributeFor(aAttribute, mContent, mAttributes);
NS_RELEASE(sheet);
}
if (aNotify) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
else { // manage this ourselves and re-sync when we connect to doc
result = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
@ -1593,77 +1604,6 @@ nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
//----------------------------------------------------------------------
nsresult
nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsString& aValue,
nsSetAttrNotify aNotify)
{
nsresult rv = SetAttribute(aAttribute, aValue, PR_FALSE);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
if (nsnull != mDocument) {
mDocument->ContentChanged(mContent, nsnull);
}
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsSetAttrNotify aNotify)
{
nsresult rv = SetAttribute(aAttribute, aValue, PR_FALSE);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::UnsetAttr(nsIAtom* aAttribute,
nsSetAttrNotify aNotify)
{
nsresult rv = UnsetAttribute(aAttribute);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::RenderFrame()
{
@ -3264,15 +3204,10 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
nsIContent* oldKid = mChildren->ElementAt(aIndex);
if (nsnull != oldKid ) {
nsIDocument* doc = mDocument;
if (aNotify) {
if (nsnull != doc) {
doc->ContentWillBeRemoved(mContent, oldKid, aIndex);
}
}
PRBool rv = mChildren->RemoveElementAt(aIndex);
if (aNotify) {
if (nsnull != doc) {
doc->ContentHasBeenRemoved(mContent, oldKid, aIndex);
doc->ContentRemoved(mContent, oldKid, aIndex);
}
}
oldKid->SetDocument(nsnull);

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

@ -48,13 +48,6 @@ class nsISupportsArray;
class nsIDOMScriptObjectFactory;
class nsChildContentList;
enum nsSetAttrNotify {
eSetAttrNotify_None = 0,
eSetAttrNotify_Render = 1,
eSetAttrNotify_Reflow = 2,
eSetAttrNotify_Restart = 3
};
class nsGenericHTMLElement : public nsIJSScriptObject {
public:
nsGenericHTMLElement();
@ -134,7 +127,7 @@ public:
PRBool aNotify);
nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRBool aNotify);
nsresult UnsetAttribute(nsIAtom* aAttribute);
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const;
nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
@ -163,14 +156,6 @@ public:
//----------------------------------------
nsresult SetAttr(nsIAtom* aAttribute, const nsString& aValue,
nsSetAttrNotify aNotify);
nsresult SetAttr(nsIAtom* aAttribute, const nsHTMLValue& aValue,
nsSetAttrNotify aNotify);
nsresult UnsetAttr(nsIAtom* aAttribute, nsSetAttrNotify aNotify);
nsresult RenderFrame();
nsresult AddScriptEventListener(nsIAtom* aAttribute,
@ -700,8 +685,8 @@ public:
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
return _g.UnsetAttribute(aAttribute); \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
@ -759,8 +744,8 @@ public:
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
return _g.UnsetAttribute(aAttribute); \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
@ -870,17 +855,17 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_STRING_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(nsString& aValue) \
{ \
mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(const nsString& aValue) \
{ \
return mInner.SetAttr(nsHTMLAtoms::_atom, aValue, _notify); \
#define NS_IMPL_STRING_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(nsString& aValue) \
{ \
mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(const nsString& aValue) \
{ \
return mInner.SetAttribute(nsHTMLAtoms::_atom, aValue, PR_TRUE); \
}
/**
@ -888,26 +873,26 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRBool* aValue) \
{ \
nsHTMLValue val; \
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsAutoString empty; \
if (aValue) { \
return mInner.SetAttr(nsHTMLAtoms::_atom, empty, _notify); \
} \
else { \
mInner.UnsetAttr(nsHTMLAtoms::_atom, _notify); \
return NS_OK; \
} \
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRBool* aValue) \
{ \
nsHTMLValue val; \
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsAutoString empty; \
if (aValue) { \
return mInner.SetAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
} \
else { \
mInner.UnsetAttribute(nsHTMLAtoms::_atom, PR_TRUE); \
return NS_OK; \
} \
}
/**
@ -915,25 +900,25 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_INT_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRInt32* aValue) \
{ \
nsHTMLValue value; \
*aValue = -1; \
if (NS_CONTENT_ATTR_HAS_VALUE == \
mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \
if (value.GetUnit() == eHTMLUnit_Integer) { \
*aValue = value.GetIntValue(); \
} \
} \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRInt32 aValue) \
{ \
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
return mInner.SetAttr(nsHTMLAtoms::_atom, value, _notify); \
#define NS_IMPL_INT_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRInt32* aValue) \
{ \
nsHTMLValue value; \
*aValue = -1; \
if (NS_CONTENT_ATTR_HAS_VALUE == \
mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \
if (value.GetUnit() == eHTMLUnit_Integer) { \
*aValue = value.GetIntValue(); \
} \
} \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRInt32 aValue) \
{ \
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
return mInner.SetAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
}
#endif /* nsGenericHTMLElement_h___ */

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

@ -517,7 +517,7 @@ DOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
mContent->UnsetAttribute(attr);
mContent->UnsetAttribute(attr, PR_TRUE);
}
return res;
@ -793,7 +793,7 @@ nsGenericHTMLElement::RemoveAttribute(const nsString& aName)
nsAutoString upper;
aName.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
UnsetAttribute(attr);
UnsetAttribute(attr, PR_TRUE);
NS_RELEASE(attr);
return NS_OK;
}
@ -843,7 +843,7 @@ nsGenericHTMLElement::RemoveAttributeNode(nsIDOMAttribute* aAttribute)
nsAutoString upper;
name.ToUpperCase(upper);
nsIAtom* attr = NS_NewAtom(upper);
UnsetAttribute(attr);
UnsetAttribute(attr, PR_TRUE);
}
}
@ -873,7 +873,7 @@ nsGenericHTMLElement::GetId(nsString& aId)
nsresult
nsGenericHTMLElement::SetId(const nsString& aId)
{
SetAttr(nsHTMLAtoms::id, aId, eSetAttrNotify_Restart);
SetAttribute(nsHTMLAtoms::id, aId, PR_TRUE);
return NS_OK;
}
@ -887,7 +887,7 @@ nsGenericHTMLElement::GetTitle(nsString& aTitle)
nsresult
nsGenericHTMLElement::SetTitle(const nsString& aTitle)
{
SetAttr(nsHTMLAtoms::title, aTitle, eSetAttrNotify_None);
SetAttribute(nsHTMLAtoms::title, aTitle, PR_TRUE);
return NS_OK;
}
@ -901,7 +901,7 @@ nsGenericHTMLElement::GetLang(nsString& aLang)
nsresult
nsGenericHTMLElement::SetLang(const nsString& aLang)
{
SetAttr(nsHTMLAtoms::lang, aLang, eSetAttrNotify_Reflow);
SetAttribute(nsHTMLAtoms::lang, aLang, PR_TRUE);
return NS_OK;
}
@ -915,7 +915,7 @@ nsGenericHTMLElement::GetDir(nsString& aDir)
nsresult
nsGenericHTMLElement::SetDir(const nsString& aDir)
{
SetAttr(nsHTMLAtoms::dir, aDir, eSetAttrNotify_Reflow);
SetAttribute(nsHTMLAtoms::dir, aDir, PR_TRUE);
return NS_OK;
}
@ -929,7 +929,7 @@ nsGenericHTMLElement::GetClassName(nsString& aClassName)
nsresult
nsGenericHTMLElement::SetClassName(const nsString& aClassName)
{
SetAttr(nsHTMLAtoms::kClass, aClassName, eSetAttrNotify_Restart);
SetAttribute(nsHTMLAtoms::kClass, aClassName, PR_TRUE);
return NS_OK;
}
@ -1184,6 +1184,10 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
}
}
}
if (aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
return result;
}
@ -1197,9 +1201,13 @@ nsGenericHTMLElement::SetAttribute(nsIAtom* aAttribute,
if (nsnull != mDocument) { // set attr via style sheet
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
if (nsnull != sheet) {
result = sheet->SetAttributeFor(aAttribute, aValue, mContent, mAttributes);
result = sheet->SetAttributeFor(aAttribute, aValue, mContent,
mAttributes);
NS_RELEASE(sheet);
}
if (aNotify) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
else { // manage this ourselves and re-sync when we connect to doc
result = EnsureWritableAttributes(mContent, mAttributes, PR_TRUE);
@ -1234,7 +1242,7 @@ nsGenericHTMLElement::MapCommonAttributesInto(nsIHTMLAttributes* aAttributes,
}
nsresult
nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify)
{
nsresult result = NS_OK;
if (nsnull != mDocument) { // set attr via style sheet
@ -1243,6 +1251,9 @@ nsGenericHTMLElement::UnsetAttribute(nsIAtom* aAttribute)
result = sheet->UnsetAttributeFor(aAttribute, mContent, mAttributes);
NS_RELEASE(sheet);
}
if (aNotify) {
mDocument->AttributeChanged(mContent, aAttribute);
}
}
else { // manage this ourselves and re-sync when we connect to doc
result = EnsureWritableAttributes(mContent, mAttributes, PR_FALSE);
@ -1593,77 +1604,6 @@ nsGenericHTMLElement::ToHTMLString(nsString& aBuf) const
//----------------------------------------------------------------------
nsresult
nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsString& aValue,
nsSetAttrNotify aNotify)
{
nsresult rv = SetAttribute(aAttribute, aValue, PR_FALSE);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
if (nsnull != mDocument) {
mDocument->ContentChanged(mContent, nsnull);
}
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::SetAttr(nsIAtom* aAttribute,
const nsHTMLValue& aValue,
nsSetAttrNotify aNotify)
{
nsresult rv = SetAttribute(aAttribute, aValue, PR_FALSE);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::UnsetAttr(nsIAtom* aAttribute,
nsSetAttrNotify aNotify)
{
nsresult rv = UnsetAttribute(aAttribute);
if (NS_OK != rv) {
return rv;
}
switch (aNotify) {
case eSetAttrNotify_None:
break;
case eSetAttrNotify_Reflow:
break;
case eSetAttrNotify_Render:
RenderFrame();
break;
case eSetAttrNotify_Restart:
break;
}
return rv;
}
nsresult
nsGenericHTMLElement::RenderFrame()
{
@ -3264,15 +3204,10 @@ nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
nsIContent* oldKid = mChildren->ElementAt(aIndex);
if (nsnull != oldKid ) {
nsIDocument* doc = mDocument;
if (aNotify) {
if (nsnull != doc) {
doc->ContentWillBeRemoved(mContent, oldKid, aIndex);
}
}
PRBool rv = mChildren->RemoveElementAt(aIndex);
if (aNotify) {
if (nsnull != doc) {
doc->ContentHasBeenRemoved(mContent, oldKid, aIndex);
doc->ContentRemoved(mContent, oldKid, aIndex);
}
}
oldKid->SetDocument(nsnull);

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

@ -48,13 +48,6 @@ class nsISupportsArray;
class nsIDOMScriptObjectFactory;
class nsChildContentList;
enum nsSetAttrNotify {
eSetAttrNotify_None = 0,
eSetAttrNotify_Render = 1,
eSetAttrNotify_Reflow = 2,
eSetAttrNotify_Restart = 3
};
class nsGenericHTMLElement : public nsIJSScriptObject {
public:
nsGenericHTMLElement();
@ -134,7 +127,7 @@ public:
PRBool aNotify);
nsresult SetAttribute(nsIAtom* aAttribute, const nsHTMLValue& aValue,
PRBool aNotify);
nsresult UnsetAttribute(nsIAtom* aAttribute);
nsresult UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify);
nsresult GetAttribute(nsIAtom *aAttribute, nsString &aResult) const;
nsresult GetAttribute(nsIAtom* aAttribute, nsHTMLValue& aValue) const;
nsresult GetAllAttributeNames(nsISupportsArray* aArray,
@ -163,14 +156,6 @@ public:
//----------------------------------------
nsresult SetAttr(nsIAtom* aAttribute, const nsString& aValue,
nsSetAttrNotify aNotify);
nsresult SetAttr(nsIAtom* aAttribute, const nsHTMLValue& aValue,
nsSetAttrNotify aNotify);
nsresult UnsetAttr(nsIAtom* aAttribute, nsSetAttrNotify aNotify);
nsresult RenderFrame();
nsresult AddScriptEventListener(nsIAtom* aAttribute,
@ -700,8 +685,8 @@ public:
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
return _g.UnsetAttribute(aAttribute); \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
@ -759,8 +744,8 @@ public:
const nsHTMLValue& aValue, PRBool aNotify) { \
return _g.SetAttribute(aAttribute, aValue, aNotify); \
} \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute) { \
return _g.UnsetAttribute(aAttribute); \
NS_IMETHOD UnsetAttribute(nsIAtom* aAttribute, PRBool aNotify) { \
return _g.UnsetAttribute(aAttribute, aNotify); \
} \
NS_IMETHOD GetAttribute(nsIAtom *aAttribute, \
nsString &aResult) const { \
@ -870,17 +855,17 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_STRING_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(nsString& aValue) \
{ \
mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(const nsString& aValue) \
{ \
return mInner.SetAttr(nsHTMLAtoms::_atom, aValue, _notify); \
#define NS_IMPL_STRING_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(nsString& aValue) \
{ \
mInner.GetAttribute(nsHTMLAtoms::_atom, aValue); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(const nsString& aValue) \
{ \
return mInner.SetAttribute(nsHTMLAtoms::_atom, aValue, PR_TRUE); \
}
/**
@ -888,26 +873,26 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRBool* aValue) \
{ \
nsHTMLValue val; \
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsAutoString empty; \
if (aValue) { \
return mInner.SetAttr(nsHTMLAtoms::_atom, empty, _notify); \
} \
else { \
mInner.UnsetAttr(nsHTMLAtoms::_atom, _notify); \
return NS_OK; \
} \
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRBool* aValue) \
{ \
nsHTMLValue val; \
nsresult rv = mInner.GetAttribute(nsHTMLAtoms::_atom, val); \
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv; \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \
{ \
nsAutoString empty; \
if (aValue) { \
return mInner.SetAttribute(nsHTMLAtoms::_atom, empty, PR_TRUE); \
} \
else { \
mInner.UnsetAttribute(nsHTMLAtoms::_atom, PR_TRUE); \
return NS_OK; \
} \
}
/**
@ -915,25 +900,25 @@ public:
* valued content property. The method uses the generic SetAttr and
* GetAttribute methods.
*/
#define NS_IMPL_INT_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRInt32* aValue) \
{ \
nsHTMLValue value; \
*aValue = -1; \
if (NS_CONTENT_ATTR_HAS_VALUE == \
mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \
if (value.GetUnit() == eHTMLUnit_Integer) { \
*aValue = value.GetIntValue(); \
} \
} \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRInt32 aValue) \
{ \
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
return mInner.SetAttr(nsHTMLAtoms::_atom, value, _notify); \
#define NS_IMPL_INT_ATTR(_class, _method, _atom, _notify) \
NS_IMETHODIMP \
_class::Get##_method(PRInt32* aValue) \
{ \
nsHTMLValue value; \
*aValue = -1; \
if (NS_CONTENT_ATTR_HAS_VALUE == \
mInner.GetAttribute(nsHTMLAtoms::_atom, value)) { \
if (value.GetUnit() == eHTMLUnit_Integer) { \
*aValue = value.GetIntValue(); \
} \
} \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(PRInt32 aValue) \
{ \
nsHTMLValue value(aValue, eHTMLUnit_Integer); \
return mInner.SetAttribute(nsHTMLAtoms::_atom, value, PR_TRUE); \
}
#endif /* nsGenericHTMLElement_h___ */