Fix bug 393802 for HTML links: remove them from the link map when they stop being links due to removeAttribute. r+sr=bz
authorJesse Ruderman <jruderman@gmail.com>
Wed, 10 Sep 2008 15:12:43 -0700
changeset 19120 58699b3800baf65bc394257d609620fb32e13a6e
parent 19119 820b8844b5b6b78dc0ac45bdf2605d1c03766821
child 19121 428c66910e661d81acdccfe3cc98e264f51f6834
push id1949
push userjruderman@mozilla.com
push dateWed, 10 Sep 2008 22:13:30 +0000
treeherderautoland@58699b3800ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs393802
milestone1.9.1b1pre
Fix bug 393802 for HTML links: remove them from the link map when they stop being links due to removeAttribute. r+sr=bz
content/html/content/src/nsHTMLAnchorElement.cpp
content/html/content/src/nsHTMLAreaElement.cpp
content/html/content/src/nsHTMLLinkElement.cpp
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -659,16 +659,20 @@ nsHTMLAnchorElement::SetAttr(PRInt32 aNa
   return rv;
 }
 
 nsresult
 nsHTMLAnchorElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                                PRBool aNotify)
 {
   if (aAttribute == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
+    nsIDocument* doc = GetCurrentDoc();
+    if (doc) {
+      doc->ForgetLink(this);
+    }
     SetLinkState(eLinkState_Unknown);
   }
 
   if (aAttribute == nsGkAtoms::accesskey &&
       kNameSpaceID_None == aNameSpaceID) {
     RegUnRegAccessKey(PR_FALSE);
   }
 
--- a/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/content/html/content/src/nsHTMLAreaElement.cpp
@@ -274,16 +274,24 @@ nsHTMLAreaElement::SetAttr(PRInt32 aName
 
   return rv;
 }
 
 nsresult
 nsHTMLAreaElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                              PRBool aNotify)
 {
+  if (aAttribute == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
+    nsIDocument* doc = GetCurrentDoc();
+    if (doc) {
+      doc->ForgetLink(this);
+    }
+    SetLinkState(eLinkState_Unknown);
+  }
+
   if (aAttribute == nsGkAtoms::accesskey &&
       aNameSpaceID == kNameSpaceID_None) {
     RegUnRegAccessKey(PR_FALSE);
   }
 
   return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
 }
 
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -317,16 +317,24 @@ nsHTMLLinkElement::SetAttr(PRInt32 aName
 
   return rv;
 }
 
 nsresult
 nsHTMLLinkElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                              PRBool aNotify)
 {
+  if (aAttribute == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
+    nsIDocument* doc = GetCurrentDoc();
+    if (doc) {
+      doc->ForgetLink(this);
+    }
+    SetLinkState(eLinkState_Unknown);
+  }
+
   nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,
                                                 aNotify);
   if (NS_SUCCEEDED(rv)) {
     UpdateStyleSheetInternal(nsnull,
                              aNameSpaceID == kNameSpaceID_None &&
                              (aAttribute == nsGkAtoms::rel ||
                               aAttribute == nsGkAtoms::title ||
                               aAttribute == nsGkAtoms::media ||