tweaks to attribute change notification

Checkin during red tree approved by sar
This commit is contained in:
peterl%netscape.com 1999-01-15 01:56:18 +00:00
Родитель ebdfaaa40b
Коммит 7623bb0e4e
4 изменённых файлов: 20 добавлений и 32 удалений

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

@ -1050,7 +1050,7 @@ nsGenericElement::Release()
void
nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
nsLinkVerb aVerb,
const nsString& aBase,
nsIURL* aBaseURL,
const nsString& aURLSpec,
const nsString& aTargetSpec,
PRBool aClick)
@ -1059,24 +1059,15 @@ nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
nsresult rv = aPresContext.GetLinkHandler(&handler);
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
// Resolve url to an absolute url
nsIURL* docURL = nsnull;
nsIDocument* doc;
rv = GetDocument(doc);
if (NS_SUCCEEDED(rv) && (nsnull != doc)) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
nsAutoString absURLSpec;
if (aURLSpec.Length() > 0) {
nsresult rv = NS_MakeAbsoluteURL(docURL, aBase, aURLSpec, absURLSpec);
if (nsnull != aBaseURL) {
nsString empty;
NS_MakeAbsoluteURL(aBaseURL, empty, aURLSpec, absURLSpec);
}
else {
absURLSpec = aURLSpec;
}
NS_IF_RELEASE(docURL);
// Now pass on absolute url to the click handler
if (aClick) {
handler->OnLinkClick(mContent, aVerb, absURLSpec, aTargetSpec);
@ -1640,16 +1631,18 @@ nsGenericContainerElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
if (nsnull != mAttributes) {
PRInt32 count = mAttributes->Count();
PRInt32 index;
PRBool found = PR_FALSE;
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
mAttributes->RemoveElementAt(index);
delete attr;
found = PR_TRUE;
break;
}
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
if (NS_SUCCEEDED(rv) && found && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
}

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

@ -46,6 +46,7 @@ class nsIDOMScriptObjectFactory;
class nsDOMCSSDeclaration;
class nsIDOMCSSStyleDeclaration;
class nsDOMAttributeMap;
class nsIURL;
// Class that holds the child list of a content element and also
@ -173,8 +174,8 @@ public:
REFNSIID aIID);
void TriggerLink(nsIPresContext& aPresContext,
nsLinkVerb aVerb,
const nsString& aBase,
nsLinkVerb aVerb,
nsIURL* aBaseURL,
const nsString& aURLSpec,
const nsString& aTargetSpec,
PRBool aClick);

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

@ -1050,7 +1050,7 @@ nsGenericElement::Release()
void
nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
nsLinkVerb aVerb,
const nsString& aBase,
nsIURL* aBaseURL,
const nsString& aURLSpec,
const nsString& aTargetSpec,
PRBool aClick)
@ -1059,24 +1059,15 @@ nsGenericElement::TriggerLink(nsIPresContext& aPresContext,
nsresult rv = aPresContext.GetLinkHandler(&handler);
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
// Resolve url to an absolute url
nsIURL* docURL = nsnull;
nsIDocument* doc;
rv = GetDocument(doc);
if (NS_SUCCEEDED(rv) && (nsnull != doc)) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
nsAutoString absURLSpec;
if (aURLSpec.Length() > 0) {
nsresult rv = NS_MakeAbsoluteURL(docURL, aBase, aURLSpec, absURLSpec);
if (nsnull != aBaseURL) {
nsString empty;
NS_MakeAbsoluteURL(aBaseURL, empty, aURLSpec, absURLSpec);
}
else {
absURLSpec = aURLSpec;
}
NS_IF_RELEASE(docURL);
// Now pass on absolute url to the click handler
if (aClick) {
handler->OnLinkClick(mContent, aVerb, absURLSpec, aTargetSpec);
@ -1640,16 +1631,18 @@ nsGenericContainerElement::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
if (nsnull != mAttributes) {
PRInt32 count = mAttributes->Count();
PRInt32 index;
PRBool found = PR_FALSE;
for (index = 0; index < count; index++) {
nsGenericAttribute* attr = (nsGenericAttribute*)mAttributes->ElementAt(index);
if ((attr->mNameSpaceID == aNameSpaceID) && (attr->mName == aName)) {
mAttributes->RemoveElementAt(index);
delete attr;
found = PR_TRUE;
break;
}
}
if (NS_SUCCEEDED(rv) && aNotify && (nsnull != mDocument)) {
if (NS_SUCCEEDED(rv) && found && aNotify && (nsnull != mDocument)) {
mDocument->AttributeChanged(mContent, aName, NS_STYLE_HINT_UNKNOWN);
}
}

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

@ -46,6 +46,7 @@ class nsIDOMScriptObjectFactory;
class nsDOMCSSDeclaration;
class nsIDOMCSSStyleDeclaration;
class nsDOMAttributeMap;
class nsIURL;
// Class that holds the child list of a content element and also
@ -173,8 +174,8 @@ public:
REFNSIID aIID);
void TriggerLink(nsIPresContext& aPresContext,
nsLinkVerb aVerb,
const nsString& aBase,
nsLinkVerb aVerb,
nsIURL* aBaseURL,
const nsString& aURLSpec,
const nsString& aTargetSpec,
PRBool aClick);