? dom/public/coreEvents/orig_nsIDOMEventReceiver.h
? dom/tests/mochitest/bugs/test_bug373998.html
? layout/forms/nsTextControlFrame.stack.txt
? layout/generic/nsGfxScrollFrame.cpp.stack.txt
Index: content/base/public/nsIContent.h
===================================================================
RCS file: /cvsroot/mozilla/content/base/public/nsIContent.h,v
retrieving revision 3.165
diff -u -8 -p -r3.165 nsIContent.h
--- content/base/public/nsIContent.h	12 May 2007 15:36:28 -0000	3.165
+++ content/base/public/nsIContent.h	15 May 2007 14:14:11 -0000
@@ -58,18 +58,18 @@ class nsICSSStyleRule;
 class nsRuleWalker;
 class nsAttrValue;
 class nsAttrName;
 class nsTextFragment;
 class nsIDocShell;
 
 // IID for the nsIContent interface
 #define NS_ICONTENT_IID       \
-{ 0xb6408b0, 0x20c6, 0x4d60, \
-  { 0xb7, 0x2f, 0x90, 0xb7, 0x7a, 0x9d, 0xb9, 0xb6 } }
+{ 0x609baee8, 0x3c0a, 0x4122, \
+  { 0x9c, 0xc6, 0xe4, 0xc9, 0x83, 0x53, 0xff, 0x9c } }
 
 
 // hack to make egcs / gcc 2.95.2 happy
 class nsIContent_base : public nsINode {
 public:
 #ifdef MOZILLA_INTERNAL_API
   // If you're using the external API, the only thing you can know about
   // nsIContent is that it exists with an IID
@@ -210,17 +210,26 @@ public:
     return mNodeInfo;
   }
 
   /**
    * Returns an atom holding the name of the attribute of type ID on
    * this content node (if applicable).  Returns null for non-element
    * content nodes.
    */
-  virtual nsIAtom *GetIDAttributeName() const = 0;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const = 0;
+
+  /**
+   * Returns true if the attribute can be
+   * used as an ID attribute of the element.
+   * Note this may return true with many attributes, but only one
+   * is used as an ID at the time.
+   */
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID,
+                                   nsIAtom* aAtom) const = 0;
 
   /**
    * Normalizes an attribute name and returns it as a nodeinfo if an attribute
    * with that name exists. This method is intended for character case
    * conversion if the content object is case insensitive (e.g. HTML). Returns
    * the nodeinfo of the attribute with the specified name if one exists or
    * null otherwise.
    *
@@ -275,17 +284,17 @@ public:
    * @param aResult the value (may legitimately be the empty string) [OUT]
    * @returns PR_TRUE if the attribute was set (even when set to empty string)
    *          PR_FALSE when not set.
    */
   virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, 
                          nsAString& aResult) const = 0;
 
   /**
-   * Determine if an attribute has been set (empty string or otherwise).
+   * Determine if an attribute hasmutt been set (empty string or otherwise).
    *
    * @param aNameSpaceId the namespace id of the attribute
    * @param aAttr the attribute name
    * @return whether an attribute exists
    */
   virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const = 0;
 
   /**
@@ -730,17 +739,17 @@ public:
   virtual nsresult SetScriptTypeID(PRUint32 aLang)
   {
     NS_NOTREACHED("SetScriptTypeID not implemented");
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   /**
    * Get the ID of this content node (the atom corresponding to the
-   * value of the null-namespace attribute whose name is given by
+   * value of the attribute whose name is given by
    * GetIDAttributeName().  This may be null if there is no ID.
    */
   virtual nsIAtom* GetID() const = 0;
 
   /**
    * Get the class list of this content node (this corresponds to the
    * value of the null-namespace attribute whose name is given by
    * GetClassAttributeName().  This may be null if there are no
Index: content/base/src/nsDOMAttribute.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/base/src/nsDOMAttribute.cpp,v
retrieving revision 1.104
diff -u -8 -p -r1.104 nsDOMAttribute.cpp
--- content/base/src/nsDOMAttribute.cpp	14 May 2007 09:11:37 -0000	1.104
+++ content/base/src/nsDOMAttribute.cpp	15 May 2007 14:14:12 -0000
@@ -595,24 +595,25 @@ nsDOMAttribute::GetIsId(PRBool* aReturn)
 {
   nsIContent* content = GetContentInternal();
   if (!content)
   {
     *aReturn = PR_FALSE;
     return NS_OK;
   }
 
-  nsIAtom* idAtom = content->GetIDAttributeName();
+  PRInt32 namespaceID;
+  nsIAtom* idAtom = content->GetIDAttributeName(namespaceID);
   if (!idAtom)
   {
     *aReturn = PR_FALSE;
     return NS_OK;
   }
 
-  *aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);
+  *aReturn = mNodeInfo->Equals(idAtom, namespaceID);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::GetSchemaTypeInfo(nsIDOM3TypeInfo** aReturn)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
Index: content/base/src/nsGenericDOMDataNode.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/base/src/nsGenericDOMDataNode.cpp,v
retrieving revision 3.232
diff -u -8 -p -r3.232 nsGenericDOMDataNode.cpp
--- content/base/src/nsGenericDOMDataNode.cpp	14 May 2007 09:11:38 -0000	3.232
+++ content/base/src/nsGenericDOMDataNode.cpp	15 May 2007 14:14:12 -0000
@@ -630,21 +630,28 @@ nsGenericDOMDataNode::UnbindFromTree(PRB
   if (slots) {
     slots->mBindingParent = nsnull;
   }
 
   nsNodeUtils::ParentChainChanged(this);
 }
 
 nsIAtom *
-nsGenericDOMDataNode::GetIDAttributeName() const
+nsGenericDOMDataNode::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
+  aNameSpaceID = kNameSpaceID_Unknown;
   return nsnull;
 }
 
+PRBool
+nsGenericDOMDataNode::IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const
+{
+  return PR_FALSE;
+}
+
 already_AddRefed<nsINodeInfo>
 nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const
 {
   return nsnull;
 }
 
 nsresult
 nsGenericDOMDataNode::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
Index: content/base/src/nsGenericDOMDataNode.h
===================================================================
RCS file: /cvsroot/mozilla/content/base/src/nsGenericDOMDataNode.h,v
retrieving revision 3.138
diff -u -8 -p -r3.138 nsGenericDOMDataNode.h
--- content/base/src/nsGenericDOMDataNode.h	14 May 2007 09:11:38 -0000	3.138
+++ content/base/src/nsGenericDOMDataNode.h	15 May 2007 14:14:12 -0000
@@ -190,17 +190,18 @@ public:
 
   // Implementation for nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               PRBool aCompileEventHandlers);
   virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
                               PRBool aNullParent = PR_TRUE);
 
-  virtual nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNamespaceId) const;
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
   virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
   nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, PRBool aNotify)
   {
     return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
   }
   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                            nsIAtom* aPrefix, const nsAString& aValue,
Index: content/base/src/nsGenericElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/base/src/nsGenericElement.cpp,v
retrieving revision 3.561
diff -u -8 -p -r3.561 nsGenericElement.cpp
--- content/base/src/nsGenericElement.cpp	14 May 2007 09:11:38 -0000	3.561
+++ content/base/src/nsGenericElement.cpp	15 May 2007 14:14:13 -0000
@@ -1946,19 +1946,20 @@ nsGenericElement::DispatchDOMEvent(nsEve
   return nsEventDispatcher::DispatchDOMEvent(NS_STATIC_CAST(nsIContent*, this),
                                              aEvent, aDOMEvent,
                                              aPresContext, aEventStatus);
 }
 
 nsIAtom*
 nsGenericElement::GetID() const
 {
-  nsIAtom* IDName = GetIDAttributeName();
+  PRInt32 namespaceID;
+  nsIAtom* IDName = GetIDAttributeName(namespaceID);
   if (IDName) {
-    const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName);
+    const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName, namespaceID);
     if (attrVal){
       if (attrVal->Type() == nsAttrValue::eAtom) {
         return attrVal->GetAtomValue();
       }
       if(attrVal->IsEmptyString()){
         return nsnull;
       }
       // Check if the ID has been stored as a string.
@@ -2011,19 +2012,35 @@ nsGenericElement::IsAttributeMapped(cons
 nsChangeHint
 nsGenericElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
                                          PRInt32 aModType) const
 {
   return nsChangeHint(0);
 }
 
 nsIAtom *
-nsGenericElement::GetIDAttributeName() const
+nsGenericElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
-  return mNodeInfo->GetIDAttributeAtom();
+  aNameSpaceID = kNameSpaceID_None;
+  nsIAtom* idAtom = mNodeInfo->GetIDAttributeAtom();
+  if (idAtom && HasAttr(aNameSpaceID, idAtom)) {
+    return idAtom;
+  }
+
+  aNameSpaceID = kNameSpaceID_XML;
+  return nsGkAtoms::id;
+}
+
+PRBool
+nsGenericElement::IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None &&
+          aAtom == mNodeInfo->GetIDAttributeAtom()) ||
+         (aNameSpaceID == kNameSpaceID_XML &&
+          aAtom == nsGkAtoms::id);
 }
 
 nsIAtom *
 nsGenericElement::GetClassAttributeName() const
 {
   return nsnull;
 }
 
@@ -3361,18 +3378,17 @@ nsGenericElement::SetAttrAndNotify(PRInt
 }
 
 PRBool
 nsGenericElement::ParseAttribute(PRInt32 aNamespaceID,
                                  nsIAtom* aAttribute,
                                  const nsAString& aValue,
                                  nsAttrValue& aResult)
 {
-  if (aNamespaceID == kNameSpaceID_None &&
-      aAttribute == GetIDAttributeName() && !aValue.IsEmpty()) {
+  if (IsIDAttributeName(aNamespaceID, aAttribute) && !aValue.IsEmpty()) {
     // Store id as an atom.  id="" means that the element has no id,
     // not that it has an emptystring as the id.
     aResult.ParseAtom(aValue);
     return PR_TRUE;
   }
 
   return PR_FALSE;
 }
Index: content/base/src/nsGenericElement.h
===================================================================
RCS file: /cvsroot/mozilla/content/base/src/nsGenericElement.h,v
retrieving revision 3.253
diff -u -8 -p -r3.253 nsGenericElement.h
--- content/base/src/nsGenericElement.h	15 May 2007 08:50:36 -0000	3.253
+++ content/base/src/nsGenericElement.h	15 May 2007 14:14:14 -0000
@@ -398,17 +398,18 @@ public:
   virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup);
 
   // nsIContent interface methods
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               PRBool aCompileEventHandlers);
   virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
                               PRBool aNullParent = PR_TRUE);
-  virtual nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
   virtual nsIAtom *GetClassAttributeName() const;
   virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
   nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                    const nsAString& aValue, PRBool aNotify)
   {
     return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
   }
   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
Index: content/events/src/nsXMLEventsElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/events/src/nsXMLEventsElement.cpp,v
retrieving revision 1.6
diff -u -8 -p -r1.6 nsXMLEventsElement.cpp
--- content/events/src/nsXMLEventsElement.cpp	26 Dec 2006 17:47:47 -0000	1.6
+++ content/events/src/nsXMLEventsElement.cpp	15 May 2007 14:14:14 -0000
@@ -41,38 +41,48 @@
 #include "nsIDocument.h"
 
 class nsXMLEventsElement : public nsXMLElement {
 public:
   nsXMLEventsElement(nsINodeInfo *aNodeInfo);
   virtual ~nsXMLEventsElement();
   NS_FORWARD_NSIDOMNODE(nsXMLElement::)
 
-  virtual nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
   virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, 
                            nsIAtom* aPrefix, const nsAString& aValue,
                            PRBool aNotify);
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
 
 nsXMLEventsElement::nsXMLEventsElement(nsINodeInfo *aNodeInfo)
   : nsXMLElement(aNodeInfo)
 {
 }
 
 nsXMLEventsElement::~nsXMLEventsElement()
 {
 }
 
 nsIAtom *
-nsXMLEventsElement::GetIDAttributeName() const
+nsXMLEventsElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
-  if (mNodeInfo->Equals(nsGkAtoms::listener))
+  aNameSpaceID = kNameSpaceID_None;
+  if (HasAttr(aNameSpaceID, nsGkAtoms::id)) {
     return nsGkAtoms::id;
-  return nsXMLElement::GetIDAttributeName();
+  }
+  return nsGenericElement::GetIDAttributeName(aNameSpaceID);
+}
+
+PRBool
+nsXMLEventsElement::IsIDAttributeName(PRInt32 aNameSpaceID,
+                                      nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
+    nsGenericElement::IsIDAttributeName(aNameSpaceID, aAtom);
 }
 
 nsresult
 nsXMLEventsElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
                             const nsAString& aValue, PRBool aNotify)
 {
   if (mNodeInfo->Equals(nsGkAtoms::listener) && 
       mNodeInfo->GetDocument() && aNameSpaceID == kNameSpaceID_None && 
Index: content/events/src/nsXMLEventsManager.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/events/src/nsXMLEventsManager.cpp,v
retrieving revision 1.17
diff -u -8 -p -r1.17 nsXMLEventsManager.cpp
--- content/events/src/nsXMLEventsManager.cpp	14 May 2007 09:11:39 -0000	1.17
+++ content/events/src/nsXMLEventsManager.cpp	15 May 2007 14:14:14 -0000
@@ -365,23 +365,25 @@ nsXMLEventsManager::AttributeChanged(nsI
        aAttribute == nsGkAtoms::observer ||
        aAttribute == nsGkAtoms::phase ||
        aAttribute == nsGkAtoms::propagate)) {
     RemoveListener(aContent);
     AddXMLEventsContent(aContent);
     nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent);
   }
   else {
+    PRInt32 namespaceID;
     if (aContent->NodeInfo()->Equals(nsGkAtoms::listener,
                                      kNameSpaceID_XMLEvents)) {
       RemoveListener(aContent);
       AddXMLEventsContent(aContent);
       nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent);
     }
-    else if (aContent->GetIDAttributeName() == aAttribute) {
+    else if (aContent->GetIDAttributeName(namespaceID) == aAttribute &&
+             namespaceID == aNameSpaceID) {
       if (aModType == nsIDOMMutationEvent::REMOVAL)
         mListeners.Enumerate(EnumAndSetIncomplete, aContent);
       else if (aModType == nsIDOMMutationEvent::MODIFICATION) {
         //Remove possible listener
         mListeners.Enumerate(EnumAndSetIncomplete, aContent);
         //Add new listeners
         AddListeners(aDocument);
       }
Index: content/html/content/src/nsGenericHTMLElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/src/nsGenericHTMLElement.cpp,v
retrieving revision 1.713
diff -u -8 -p -r1.713 nsGenericHTMLElement.cpp
--- content/html/content/src/nsGenericHTMLElement.cpp	14 May 2007 09:11:39 -0000	1.713
+++ content/html/content/src/nsGenericHTMLElement.cpp	15 May 2007 14:14:15 -0000
@@ -1418,19 +1418,31 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 
 
 const nsAttrValue*
 nsGenericHTMLElement::GetClasses() const
 {
   return mAttrsAndChildren.GetAttr(nsGkAtoms::_class);
 }
 
 nsIAtom *
-nsGenericHTMLElement::GetIDAttributeName() const
+nsGenericHTMLElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
-  return nsGkAtoms::id;
+  aNameSpaceID = kNameSpaceID_None;
+  if (HasAttr(aNameSpaceID, nsGkAtoms::id)) {
+    return nsGkAtoms::id;
+  }
+  return nsGenericElement::GetIDAttributeName(aNameSpaceID);
+}
+
+PRBool
+nsGenericHTMLElement::IsIDAttributeName(PRInt32 aNameSpaceID,
+                                        nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
+    nsGenericElement::IsIDAttributeName(aNameSpaceID, aAtom);
 }
 
 nsIAtom *
 nsGenericHTMLElement::GetClassAttributeName() const
 {
   return nsGkAtoms::_class;
 }
 
Index: content/html/content/src/nsGenericHTMLElement.h
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/src/nsGenericHTMLElement.h,v
retrieving revision 1.266
diff -u -8 -p -r1.266 nsGenericHTMLElement.h
--- content/html/content/src/nsGenericHTMLElement.h	23 Apr 2007 07:31:20 -0000	1.266
+++ content/html/content/src/nsGenericHTMLElement.h	15 May 2007 14:14:15 -0000
@@ -219,17 +219,18 @@ public:
   void Compact() { mAttrsAndChildren.Compact(); }
   const nsAttrValue* GetParsedAttr(nsIAtom* aAttr) const
   {
     return mAttrsAndChildren.GetAttr(aAttr);
   }
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
 
   virtual const nsAttrValue* GetClasses() const;
-  virtual nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
   virtual nsIAtom *GetClassAttributeName() const;
   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
   virtual nsICSSStyleRule* GetInlineStyleRule();
   NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
   already_AddRefed<nsIURI> GetBaseURI() const;
 
   virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
                                 nsIAtom* aAttribute,
Index: content/html/document/src/nsHTMLDocument.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/html/document/src/nsHTMLDocument.cpp,v
retrieving revision 3.720
diff -u -8 -p -r3.720 nsHTMLDocument.cpp
--- content/html/document/src/nsHTMLDocument.cpp	9 May 2007 02:47:58 -0000	3.720
+++ content/html/document/src/nsHTMLDocument.cpp	15 May 2007 14:14:17 -0000
@@ -1361,18 +1361,17 @@ nsHTMLDocument::AttributeWillChange(nsIC
     nsIAtom* name = IsNamedItem(aContent);
     if (name) {
       nsresult rv = RemoveFromNameTable(name, aContent);
 
       if (NS_FAILED(rv)) {
         return;
       }
     }
-  } else if (aAttribute == aContent->GetIDAttributeName() &&
-             aNameSpaceID == kNameSpaceID_None) {
+  } else if (aContent->IsIDAttributeName(aNameSpaceID, aAttribute)) {
     nsresult rv = RemoveFromIdTable(aContent);
 
     if (NS_FAILED(rv)) {
       return;
     }
   }
 
   nsDocument::AttributeWillChange(aContent, aNameSpaceID, aAttribute);
@@ -1383,25 +1382,26 @@ nsHTMLDocument::AttributeChanged(nsIDocu
                                  nsIContent* aContent, PRInt32 aNameSpaceID,
                                  nsIAtom* aAttribute, PRInt32 aModType)
 {
   NS_ASSERTION(aDocument == this, "unexpected doc");
 
   NS_ABORT_IF_FALSE(aContent, "Null content!");
   NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
 
+  PRInt32 nameSpaceID;
   if (!IsXHTML() && aAttribute == nsGkAtoms::name &&
       aNameSpaceID == kNameSpaceID_None) {
 
     nsIAtom* name = IsNamedItem(aContent);
     if (name) {
       UpdateNameTableEntry(name, aContent);
     }
-  } else if (aAttribute == aContent->GetIDAttributeName() &&
-             aNameSpaceID == kNameSpaceID_None) {
+  } else if (aAttribute == aContent->GetIDAttributeName(namespaceID) &&
+             aNameSpaceID == nameSpaceID) {
     nsIAtom* id = aContent->GetID();
     if (id) {
       UpdateIdTableEntry(id, aContent);
     }
   }
 }
 
 PRBool
Index: content/svg/content/src/nsSVGElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/svg/content/src/nsSVGElement.cpp,v
retrieving revision 1.120
diff -u -8 -p -r1.120 nsSVGElement.cpp
--- content/svg/content/src/nsSVGElement.cpp	14 May 2007 09:11:44 -0000	1.120
+++ content/svg/content/src/nsSVGElement.cpp	15 May 2007 14:14:17 -0000
@@ -123,19 +123,30 @@ NS_INTERFACE_MAP_END_INHERITING(nsGeneri
 
 //----------------------------------------------------------------------
 // Implementation
   
 //----------------------------------------------------------------------
 // nsIContent methods
 
 nsIAtom *
-nsSVGElement::GetIDAttributeName() const
+nsSVGElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
-  return nsGkAtoms::id;
+  aNameSpaceID = kNameSpaceID_None;
+  if (HasAttr(aNameSpaceID, nsGkAtoms::id)) {
+    return nsGkAtoms::id;
+  }
+  return nsGenericElement::GetIDAttributeName(aNameSpaceID);
+}
+
+PRBool
+nsSVGElement::IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
+    nsGenericElement::IsIDAttributeName(aNameSpaceID, aAtom);
 }
 
 nsIAtom *
 nsSVGElement::GetClassAttributeName() const
 {
   return nsGkAtoms::_class;
 }
 
Index: content/svg/content/src/nsSVGElement.h
===================================================================
RCS file: /cvsroot/mozilla/content/svg/content/src/nsSVGElement.h,v
retrieving revision 1.67
diff -u -8 -p -r1.67 nsSVGElement.h
--- content/svg/content/src/nsSVGElement.h	2 Apr 2007 17:17:36 -0000	1.67
+++ content/svg/content/src/nsSVGElement.h	15 May 2007 14:14:17 -0000
@@ -66,17 +66,18 @@ protected:
   virtual ~nsSVGElement();
 
 public:
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIContent interface methods
 
-  virtual nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
   virtual nsIAtom *GetClassAttributeName() const;
   virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                              PRBool aNotify);
 
   virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
 
   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
   NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
Index: content/xtf/src/nsXTFElementWrapper.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/xtf/src/nsXTFElementWrapper.cpp,v
retrieving revision 1.45
diff -u -8 -p -r1.45 nsXTFElementWrapper.cpp
--- content/xtf/src/nsXTFElementWrapper.cpp	1 May 2007 22:24:21 -0000	1.45
+++ content/xtf/src/nsXTFElementWrapper.cpp	15 May 2007 14:14:18 -0000
@@ -259,20 +259,32 @@ nsXTFElementWrapper::RemoveChildAt(PRUin
     GetXTFElement()->WillRemoveChild(aIndex);
   rv = nsXTFElementWrapperBase::RemoveChildAt(aIndex, aNotify);
   if (mNotificationMask & nsIXTFElement::NOTIFY_CHILD_REMOVED)
     GetXTFElement()->ChildRemoved(aIndex);
   return rv;
 }
 
 nsIAtom *
-nsXTFElementWrapper::GetIDAttributeName() const
+nsXTFElementWrapper::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
   // XXX:
-  return nsGkAtoms::id;
+  aNameSpaceID = kNameSpaceID_None;
+  if (HasAttr(aNameSpaceID, nsGkAtoms::id)) {
+    return nsGkAtoms::id;
+  }
+  return nsXTFElementWrapperBase::GetIDAttributeName(aNameSpaceID);
+}
+
+PRBool
+nsXTFElementWrapper::IsIDAttributeName(PRInt32 aNameSpaceID,
+                                       nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
+    nsXTFElementWrapperBase::IsIDAttributeName(aNameSpaceID, aAtom);
 }
 
 nsresult
 nsXTFElementWrapper::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                              nsIAtom* aPrefix, const nsAString& aValue,
                              PRBool aNotify)
 {
   nsresult rv;
Index: content/xtf/src/nsXTFElementWrapper.h
===================================================================
RCS file: /cvsroot/mozilla/content/xtf/src/nsXTFElementWrapper.h,v
retrieving revision 1.31
diff -u -8 -p -r1.31 nsXTFElementWrapper.h
--- content/xtf/src/nsXTFElementWrapper.h	23 Apr 2007 14:21:55 -0000	1.31
+++ content/xtf/src/nsXTFElementWrapper.h	15 May 2007 14:14:18 -0000
@@ -73,17 +73,18 @@ public:
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               PRBool aCompileEventHandlers);
   virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
                               PRBool aNullParent = PR_TRUE);
   nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
                          PRBool aNotify);
   nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
-  nsIAtom *GetIDAttributeName() const;
+  virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
+  virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
   nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                    nsIAtom* aPrefix, const nsAString& aValue,
                    PRBool aNotify);
   PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, 
                  nsAString& aResult) const;
   PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
   virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
                              const nsAString& aValue,
Index: content/xul/content/src/nsXULElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/xul/content/src/nsXULElement.cpp,v
retrieving revision 1.706
diff -u -8 -p -r1.706 nsXULElement.cpp
--- content/xul/content/src/nsXULElement.cpp	14 May 2007 09:11:45 -0000	1.706
+++ content/xul/content/src/nsXULElement.cpp	15 May 2007 14:14:19 -0000
@@ -1849,19 +1849,30 @@ nsXULElement::GetAttributeChangeHint(con
 
 NS_IMETHODIMP_(PRBool)
 nsXULElement::IsAttributeMapped(const nsIAtom* aAttribute) const
 {
     return PR_FALSE;
 }
 
 nsIAtom *
-nsXULElement::GetIDAttributeName() const
+nsXULElement::GetIDAttributeName(PRInt32& aNameSpaceID) const
 {
+  aNameSpaceID = kNameSpaceID_None;
+  if (HasAttr(aNameSpaceID, nsGkAtoms::id)) {
     return nsGkAtoms::id;
+  }
+  return nsGenericElement::GetIDAttributeName(aNameSpaceID);
+}
+
+PRBool
+nsXULElement::IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const
+{
+  return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) ||
+    nsGenericElement::IsIDAttributeName(aNameSpaceID, aAtom);
 }
 
 nsIAtom *
 nsXULElement::GetClassAttributeName() const
 {
     return nsGkAtoms::_class;
 }
 
Index: content/xul/content/src/nsXULElement.h
===================================================================
RCS file: /cvsroot/mozilla/content/xul/content/src/nsXULElement.h,v
retrieving revision 1.243
diff -u -8 -p -r1.243 nsXULElement.h
--- content/xul/content/src/nsXULElement.h	14 May 2007 09:11:45 -0000	1.243
+++ content/xul/content/src/nsXULElement.h	15 May 2007 14:14:19 -0000
@@ -488,17 +488,18 @@ public:
     // nsIContent
     virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                                 nsIContent* aBindingParent,
                                 PRBool aCompileEventHandlers);
     virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
                                 PRBool aNullParent = PR_TRUE);
     virtual void SetNativeAnonymous(PRBool aAnonymous);
     virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
-    virtual nsIAtom *GetIDAttributeName() const;
+    virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const;
+    virtual PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const;
     virtual nsIAtom *GetClassAttributeName() const;
     virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
                            nsAString& aResult) const;
     virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
     virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
                                const nsAString& aValue,
                                nsCaseTreatment aCaseSensitive) const;
     virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
Index: content/xul/document/src/nsXULDocument.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/xul/document/src/nsXULDocument.cpp,v
retrieving revision 1.766
diff -u -8 -p -r1.766 nsXULDocument.cpp
--- content/xul/document/src/nsXULDocument.cpp	14 May 2007 09:11:45 -0000	1.766
+++ content/xul/document/src/nsXULDocument.cpp	15 May 2007 14:14:20 -0000
@@ -876,17 +876,20 @@ nsXULDocument::ExecuteOnBroadcastHandler
         if (!child->NodeInfo()->Equals(nsGkAtoms::observes, kNameSpaceID_XUL))
             continue;
 
         // Is this the element that was listening to us?
         nsAutoString listeningToID;
         child->GetAttr(kNameSpaceID_None, nsGkAtoms::element, listeningToID);
 
         nsAutoString broadcasterID;
-        aBroadcaster->GetAttr(kNameSpaceID_None, nsGkAtoms::id, broadcasterID);
+        nsCOMPtr<nsIAtom> idAtom = aBroadcaster->GetID();
+        if (idAtom) {
+          idAtom->ToString(broadcasterID);
+        }
 
         if (listeningToID != broadcasterID)
             continue;
 
         // We are observing the broadcaster, but is this the right
         // attribute?
         nsAutoString listeningToAttribute;
         child->GetAttr(kNameSpaceID_None, nsGkAtoms::attribute,
@@ -923,17 +926,18 @@ nsXULDocument::AttributeChanged(nsIDocum
                                 nsIAtom* aAttribute, PRInt32 aModType)
 {
     NS_ASSERTION(aDocument == this, "unexpected doc");
 
     nsresult rv;
 
     // XXXbz check aNameSpaceID, dammit!
     // First see if we need to update our element map.
-    if ((aAttribute == nsGkAtoms::id) || (aAttribute == nsGkAtoms::ref)) {
+    if (IsIDAttributeName(aNameSpaceID, aAttribute) ||
+        (aAttribute == nsGkAtoms::ref)) {
 
         rv = mElementMap.Enumerate(RemoveElementsFromMapByContent, aElement);
         if (NS_FAILED(rv)) return;
 
         // That'll have removed _both_ the 'ref' and 'id' entries from
         // the map. So add 'em back now.
         rv = AddElementToMap(aElement);
         if (NS_FAILED(rv)) return;
@@ -3806,17 +3810,20 @@ nsXULDocument::OverlayForwardReference::
     nsCOMPtr<nsIContent> target;
 
     PRBool notify = PR_FALSE;
     nsIPresShell *shell = mDocument->GetPrimaryShell();
     if (shell)
         shell->GetDidInitialReflow(&notify);
 
     nsAutoString id;
-    mOverlay->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
+    nsCOMPtr<nsIAtom> idAtom = mOverlay->GetID();
+    if (idAtom) {
+      idAtom->ToString(id);
+    }
     if (id.IsEmpty()) {
         // mOverlay is a direct child of <overlay> and has no id.
         // Insert it under the root element in the base document.
         if (!mDocument->mRootContent) {
             return eResolve_Error;
         }
 
         rv = mDocument->InsertElement(mDocument->mRootContent, mOverlay, notify);
@@ -3897,17 +3904,17 @@ nsXULDocument::OverlayForwardReference::
     nsresult rv;
 
     // Merge attributes from the overlay content node to that of the
     // actual document.
     PRUint32 i;
     const nsAttrName* name;
     for (i = 0; (name = aOverlayNode->GetAttrNameAt(i)); ++i) {
         // We don't want to swap IDs, they should be the same.
-        if (name->Equals(nsGkAtoms::id))
+        if (aOverlayNode->IsIDAttributeName(name->NamespaceID(), name->Atom()))
             continue;
 
         PRInt32 nameSpaceID = name->NamespaceID();
         nsIAtom* attr = name->LocalName();
         nsIAtom* prefix = name->GetPrefix();
 
         nsAutoString value;
         aOverlayNode->GetAttr(nameSpaceID, attr, value);
@@ -3940,17 +3947,20 @@ nsXULDocument::OverlayForwardReference::
     // This must be a strong reference since it will be the only
     // reference to a content object during part of this loop.
     nsCOMPtr<nsIContent> currContent;
 
     for (i = 0; i < childCount; ++i) {
         currContent = aOverlayNode->GetChildAt(0);
 
         nsAutoString id;
-        currContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
+        nsCOMPtr<nsIAtom> idAtom = currContent->GetID();
+        if (idAtom) {
+          idAtom->ToString(idAtom);
+        }
 
         nsCOMPtr<nsIDOMElement> nodeInDocument;
         if (!id.IsEmpty()) {
             nsCOMPtr<nsIDOMDocument> domDocument(
                         do_QueryInterface(aTargetNode->GetDocument()));
             if (!domDocument) return NS_ERROR_FAILURE;
 
             rv = domDocument->GetElementById(id, getter_AddRefs(nodeInDocument));
@@ -3966,22 +3976,27 @@ nsXULDocument::OverlayForwardReference::
             // Given two parents, aTargetNode and aOverlayNode, we want
             // to call merge on currContent if we find an associated
             // node in the document with the same id as currContent that
             // also has aTargetNode as its parent.
 
             nsCOMPtr<nsIDOMNode> nodeParent;
             rv = nodeInDocument->GetParentNode(getter_AddRefs(nodeParent));
             if (NS_FAILED(rv)) return rv;
-            nsCOMPtr<nsIDOMElement> elementParent(do_QueryInterface(nodeParent));
+            nsCOMPtr<nsIContent> elementParent(do_QueryInterface(nodeParent));
 
             nsAutoString parentID;
-            elementParent->GetAttribute(NS_LITERAL_STRING("id"), parentID);
-            if (aTargetNode->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id,
-                                         parentID, eCaseMatters)) {
+            nsCOMPtr<nsIAtom> idAtom = elementParent->GetID();
+            if (idAtom) {
+              idAtom->ToString(parentID);
+            }
+            PRint32 namespaceID;
+            nsIAtom* IDName = aTargetNode->GetIDAttributeName(namespaceID);
+            if (IDName && aTargetNode->AttrValueIs(namespaceID, IDName,
+                                                   parentID, eCaseMatters)) {
                 // The element matches. "Go Deep!"
                 nsCOMPtr<nsIContent> childDocumentContent(do_QueryInterface(nodeInDocument));
                 rv = Merge(childDocumentContent, currContent, aNotify);
                 if (NS_FAILED(rv)) return rv;
                 rv = aOverlayNode->RemoveChildAt(0, PR_FALSE);
                 if (NS_FAILED(rv)) return rv;
 
                 continue;
Index: layout/style/nsCSSRuleProcessor.cpp
===================================================================
RCS file: /cvsroot/mozilla/layout/style/nsCSSRuleProcessor.cpp,v
retrieving revision 1.11
diff -u -8 -p -r1.11 nsCSSRuleProcessor.cpp
--- layout/style/nsCSSRuleProcessor.cpp	27 Mar 2007 15:33:40 -0000	1.11
+++ layout/style/nsCSSRuleProcessor.cpp	15 May 2007 14:14:24 -0000
@@ -1392,17 +1392,20 @@ static PRBool SelectorMatches(RuleProces
       } while (attr && result);
     }
   }
   nsAtomList* IDList = aSelector->mIDList;
   if (result && IDList) {
     // test for ID match
     result = PR_FALSE;
 
-    if (aAttribute && aAttribute == data.mContent->GetIDAttributeName()) {
+    //XXX We need the namespace of the aAttribute.
+    PRInt32 namespaceID;
+    if (aAttribute &&
+        aAttribute == data.mContent->GetIDAttributeName(namespaceID)) {
       result = PR_TRUE;
       if (aDependence)
         *aDependence = PR_TRUE;
     }
     else if (nsnull != data.mContentID) {
       // case sensitivity: bug 93371
       const PRBool isCaseSensitive =
         data.mCompatMode != eCompatibility_NavQuirks;
@@ -1784,17 +1787,18 @@ nsCSSRuleProcessor::HasAttributeDependen
 
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // We do the same thing for attributes that we do for state selectors
   // (see HasStateDependentStyle), except that instead of one big list
   // we have a hashtable with a per-attribute list.
 
   if (cascade) {
-    if (aData->mAttribute == aData->mContent->GetIDAttributeName()) {
+    PRInt32 namespaceID;
+    if (aData->mAttribute == aData->mContent->GetIDAttributeName(namespaceID)) {
       cascade->mIDSelectors.EnumerateForwards(AttributeEnumFunc, &data);
     }
     
     if (aData->mAttribute == aData->mContent->GetClassAttributeName()) {
       cascade->mClassSelectors.EnumerateForwards(AttributeEnumFunc, &data);
     }
 
     AttributeSelectorEntry *entry = NS_STATIC_CAST(AttributeSelectorEntry*,
Index: extensions/xforms/nsXFormsUtils.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/xforms/nsXFormsUtils.cpp,v
retrieving revision 1.96
diff -u -8 -p -r1.96 nsXFormsUtils.cpp
--- extensions/xforms/nsXFormsUtils.cpp	27 Mar 2007 20:09:39 -0000	1.96
+++ extensions/xforms/nsXFormsUtils.cpp	15 May 2007 14:14:25 -0000
@@ -1958,18 +1958,20 @@ nsXFormsUtils::GetElementById(const nsAS
   PRUint16 type;
   nsCOMPtr<nsIDOMNode> childNode;
   for (i = 0; i < elements; ++i) {
     descendants->Item(i, getter_AddRefs(childNode));
     childNode->GetNodeType(&type);
     if (type == nsIDOMNode::ELEMENT_NODE) {
       nsCOMPtr<nsIContent> content(do_QueryInterface(childNode));
       NS_ASSERTION(content, "An ELEMENT_NODE not implementing nsIContent?!");
-      if (content->AttrValueIs(kNameSpaceID_None, content->GetIDAttributeName(),
-                               aId, eCaseMatters)) {
+      PRint32 namespaceID;
+      nsIAtom* idAtom = content->GetIDAttributeName(namespaceID);
+      if (idAtom &&
+          content->AttrValueIs(namespaceID, idAtom, aId, eCaseMatters)) {
         element = do_QueryInterface(childNode);
         break;
       }
     }
   }
 
   if (i == elements) {
     return NS_OK;
