? 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 6 Jun 2007 12:56:37 -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. * @@ -730,18 +739,18 @@ 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 - * GetIDAttributeName(). This may be null if there is no ID. + * 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 * classes, but that's not guaranteed. 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 6 Jun 2007 12:56:38 -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.233 diff -u -8 -p -r3.233 nsGenericDOMDataNode.cpp --- content/base/src/nsGenericDOMDataNode.cpp 16 May 2007 01:13:47 -0000 3.233 +++ content/base/src/nsGenericDOMDataNode.cpp 6 Jun 2007 12:56:39 -0000 @@ -623,21 +623,29 @@ 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 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 6 Jun 2007 12:56:39 -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 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.568 diff -u -8 -p -r3.568 nsGenericElement.cpp --- content/base/src/nsGenericElement.cpp 30 May 2007 22:32:55 -0000 3.568 +++ content/base/src/nsGenericElement.cpp 6 Jun 2007 12:56:40 -0000 @@ -2203,19 +2203,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. @@ -2268,19 +2269,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; } @@ -3616,18 +3633,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.254 diff -u -8 -p -r3.254 nsGenericElement.h --- content/base/src/nsGenericElement.h 30 May 2007 22:32:55 -0000 3.254 +++ content/base/src/nsGenericElement.h 6 Jun 2007 12:56:41 -0000 @@ -378,17 +378,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 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 6 Jun 2007 12:56:41 -0000 @@ -41,38 +41,49 @@ #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 PRBool IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) 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 6 Jun 2007 12:56:41 -0000 @@ -371,17 +371,17 @@ nsXMLEventsManager::AttributeChanged(nsI } else { 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->IsIDAttributeName(aNameSpaceID, aAttribute)) { 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.714 diff -u -8 -p -r1.714 nsGenericHTMLElement.cpp --- content/html/content/src/nsGenericHTMLElement.cpp 30 May 2007 20:43:41 -0000 1.714 +++ content/html/content/src/nsGenericHTMLElement.cpp 6 Jun 2007 12:56:42 -0000 @@ -1416,19 +1416,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.267 diff -u -8 -p -r1.267 nsGenericHTMLElement.h --- content/html/content/src/nsGenericHTMLElement.h 24 May 2007 14:10:03 -0000 1.267 +++ content/html/content/src/nsGenericHTMLElement.h 6 Jun 2007 12:56:43 -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 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.722 diff -u -8 -p -r3.722 nsHTMLDocument.cpp --- content/html/document/src/nsHTMLDocument.cpp 23 May 2007 03:52:53 -0000 3.722 +++ content/html/document/src/nsHTMLDocument.cpp 6 Jun 2007 12:56:44 -0000 @@ -1359,18 +1359,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); @@ -1388,18 +1387,17 @@ nsHTMLDocument::AttributeChanged(nsIDocu 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 (aContent->IsIDAttributeName(aNameSpaceID, aAttribute)) { 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 6 Jun 2007 12:56:44 -0000 @@ -122,20 +122,31 @@ NS_INTERFACE_MAP_BEGIN(nsSVGElement) NS_INTERFACE_MAP_END_INHERITING(nsGenericElement) //---------------------------------------------------------------------- // Implementation //---------------------------------------------------------------------- // nsIContent methods -nsIAtom * -nsSVGElement::GetIDAttributeName() const +nsIAtom* +nsSVGElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +{ + aNameSpaceID = kNameSpaceID_None; + if (HasAttr(aNameSpaceID, nsGkAtoms::id)) { + return nsGkAtoms::id; + } + return nsGenericElement::GetIDAttributeName(aNameSpaceID); +} + +PRBool +nsSVGElement::IsIDAttributeName(PRInt32 aNameSpaceID, nsIAtom* aAtom) const { - return nsGkAtoms::id; + 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 6 Jun 2007 12:56:44 -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 6 Jun 2007 12:56:44 -0000 @@ -259,20 +259,31 @@ 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 6 Jun 2007 12:56:45 -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.711 diff -u -8 -p -r1.711 nsXULElement.cpp --- content/xul/content/src/nsXULElement.cpp 25 May 2007 00:28:21 -0000 1.711 +++ content/xul/content/src/nsXULElement.cpp 6 Jun 2007 12:56:45 -0000 @@ -1711,19 +1711,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.246 diff -u -8 -p -r1.246 nsXULElement.h --- content/xul/content/src/nsXULElement.h 24 May 2007 14:10:03 -0000 1.246 +++ content/xul/content/src/nsXULElement.h 6 Jun 2007 12:56:46 -0000 @@ -488,17 +488,18 @@ public: virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); // nsIContent virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent); 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.768 diff -u -8 -p -r1.768 nsXULDocument.cpp --- content/xul/document/src/nsXULDocument.cpp 23 May 2007 03:52:53 -0000 1.768 +++ content/xul/document/src/nsXULDocument.cpp 6 Jun 2007 12:56:47 -0000 @@ -923,17 +923,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 (aElement->IsIDAttributeName(aNameSpaceID, aAttribute) || + (aAttribute == nsGkAtoms::ref && aNameSpaceID == kNameSpaceID_None)) { 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; @@ -1793,48 +1794,64 @@ nsIAtom** nsXULDocument::kIdentityAttrs[ &nsGkAtoms::id, &nsGkAtoms::ref, nsnull }; nsresult nsXULDocument::AddElementToMap(nsIContent* aElement) { - // Look at the element's 'id' and 'ref' attributes, and if set, + // Look at the element's ID and 'ref' attributes, and if set, // add pointers in the resource-to-element map to the element. nsresult rv; - - for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) { - nsAutoString value; - aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); - if (!value.IsEmpty()) { - rv = mElementMap.Add(value, aElement); - if (NS_FAILED(rv)) return rv; + PRInt32 namespaceID; + nsIAtom* idAttr = aElement->GetIDAttributeName(namespaceID); + if (idAttr) { + nsAutoString idvalue; + aElement->GetAttr(namespaceID, idAttr, idvalue); + if (!idvalue.IsEmpty()) { + rv = mElementMap.Add(idvalue, aElement); + NS_ENSURE_SUCCESS(rv, rv); } } + nsAutoString refvalue; + aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, refvalue); + if (!refvalue.IsEmpty()) { + rv = mElementMap.Add(refvalue, aElement); + NS_ENSURE_SUCCESS(rv, rv); + } + return NS_OK; } nsresult nsXULDocument::RemoveElementFromMap(nsIContent* aElement) { // Remove the element from the resource-to-element map. nsresult rv; - - for (PRInt32 i = 0; kIdentityAttrs[i] != nsnull; ++i) { - nsAutoString value; - aElement->GetAttr(kNameSpaceID_None, *kIdentityAttrs[i], value); - if (!value.IsEmpty()) { - rv = mElementMap.Remove(value, aElement); - if (NS_FAILED(rv)) return rv; + PRInt32 namespaceID; + nsIAtom* idAttr = aElement->GetIDAttributeName(namespaceID); + if (idAttr) { + nsAutoString idvalue; + aElement->GetAttr(namespaceID, idAttr, idvalue); + if (!idvalue.IsEmpty()) { + rv = mElementMap.Remove(idvalue, aElement); + NS_ENSURE_SUCCESS(rv, rv); } } + nsAutoString refvalue; + aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, refvalue); + if (!refvalue.IsEmpty()) { + rv = mElementMap.Remove(refvalue, aElement); + NS_ENSURE_SUCCESS(rv, rv); + } + return NS_OK; } PRIntn nsXULDocument::RemoveElementsFromMapByContent(const PRUnichar* aID, nsIContent* aElement, void* aClosure) Index: layout/base/nsCSSFrameConstructor.cpp =================================================================== RCS file: /cvsroot/mozilla/layout/base/nsCSSFrameConstructor.cpp,v retrieving revision 1.1352 diff -u -8 -p -r1.1352 nsCSSFrameConstructor.cpp --- layout/base/nsCSSFrameConstructor.cpp 22 May 2007 20:34:00 -0000 1.1352 +++ layout/base/nsCSSFrameConstructor.cpp 6 Jun 2007 12:56:51 -0000 @@ -10084,17 +10084,18 @@ nsCSSFrameConstructor::AttributeChanged( #if 0 NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, ("HTMLStyleSheet::AttributeChanged: content=%p[%s] frame=%p", aContent, ContentTag(aContent, 0), frame)); #endif // the style tag has its own interpretation based on aHint - nsChangeHint hint = aContent->GetAttributeChangeHint(aAttribute, aModType); + nsChangeHint hint = (aNameSpaceID == kNameSpaceID_None) + ? aContent->GetAttributeChangeHint(aAttribute, aModType) : nsChangeHint(0); PRBool reframe = (hint & nsChangeHint_ReconstructFrame) != 0; #ifdef MOZ_XUL // The following listbox widget trap prevents offscreen listbox widget // content from being removed and re-inserted (which is what would // happen otherwise). if (!primaryFrame && !reframe) { @@ -10119,41 +10120,46 @@ nsCSSFrameConstructor::AttributeChanged( rootBox->AddTooltipSupport(aContent); } } #endif // MOZ_XUL if (primaryFrame) { // See if we have appearance information for a theme. - const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay(); - if (disp->mAppearance) { - nsPresContext* presContext = mPresShell->GetPresContext(); - nsITheme *theme = presContext->GetTheme(); - if (theme && theme->ThemeSupportsWidget(presContext, primaryFrame, disp->mAppearance)) { - PRBool repaint = PR_FALSE; - theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint); - if (repaint) - NS_UpdateHint(hint, nsChangeHint_RepaintFrame); + if (aNameSpaceID == kNameSpaceID_None) { + const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay(); + if (disp->mAppearance) { + nsPresContext* presContext = mPresShell->GetPresContext(); + nsITheme *theme = presContext->GetTheme(); + if (theme && theme->ThemeSupportsWidget(presContext, primaryFrame, + disp->mAppearance)) { + PRBool repaint = PR_FALSE; + theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, + &repaint); + if (repaint) + NS_UpdateHint(hint, nsChangeHint_RepaintFrame); + } } } // let the frame deal with it now, so we don't have to deal later result = primaryFrame->AttributeChanged(aNameSpaceID, aAttribute, aModType); // XXXwaterson should probably check for special IB siblings // here, and propagate the AttributeChanged notification to // them, as well. Currently, inline frames don't do anything on // this notification, so it's not that big a deal. } // See if we can optimize away the style re-resolution -- must be called after // the frame's AttributeChanged() in case it does something that affects the style nsFrameManager *frameManager = shell->FrameManager(); nsReStyleHint rshint = frameManager->HasAttributeDependentStyle(aContent, + aNameSpaceID, aAttribute, aModType); // Menus and such can't deal with asynchronous changes of display // when the menugenerated or menuactive attribute changes, so make // sure to process that immediately if (aNameSpaceID == kNameSpaceID_None && ((aAttribute == nsGkAtoms::menugenerated && Index: layout/base/nsFrameManager.cpp =================================================================== RCS file: /cvsroot/mozilla/layout/base/nsFrameManager.cpp,v retrieving revision 1.245 diff -u -8 -p -r1.245 nsFrameManager.cpp --- layout/base/nsFrameManager.cpp 27 Mar 2007 15:33:40 -0000 1.245 +++ layout/base/nsFrameManager.cpp 6 Jun 2007 12:56:52 -0000 @@ -84,17 +84,17 @@ #include "nsContentUtils.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" #include "nsPrintfCString.h" #include "nsLayoutErrors.h" #include "nsLayoutUtils.h" #include "nsAutoPtr.h" #include "imgIRequest.h" - +#include "nsIDOMMutationEvent.h" #include "nsFrameManager.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #include "nsIAccessibleEvent.h" #endif #ifdef DEBUG //#define NOISY_DEBUG @@ -1441,28 +1441,32 @@ nsFrameManager::ComputeStyleChangeFor(ns frame = frame2; } while (frame2); return topLevelChange; } nsReStyleHint nsFrameManager::HasAttributeDependentStyle(nsIContent *aContent, + PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType) { nsReStyleHint hint = mStyleSet->HasAttributeDependentStyle(GetPresContext(), aContent, + aNameSpaceID, aAttribute, aModType); - if (aAttribute == nsGkAtoms::style) { - // Perhaps should check that it's XUL, SVG, (or HTML) namespace, but - // it doesn't really matter. Or we could even let - // HTMLCSSStyleSheetImpl::HasAttributeDependentStyle handle it. + // Perhaps should check that it's XUL, SVG, (or HTML) namespace when + // handling style attribute. Or we could even let + // HTMLCSSStyleSheetImpl::HasAttributeDependentStyle handle it. + if (aAttribute == nsGkAtoms::style || + (aModType == nsIDOMMutationEvent::REMOVAL && + aContent->IsIDAttributeName(aNameSpaceID, aAttribute))) { hint = nsReStyleHint(hint | eReStyle_Self); } return hint; } // Capture state for a given frame. // Accept a content id here, in some cases we may not have content (scroll position) Index: layout/base/nsFrameManager.h =================================================================== RCS file: /cvsroot/mozilla/layout/base/nsFrameManager.h,v retrieving revision 1.21 diff -u -8 -p -r1.21 nsFrameManager.h --- layout/base/nsFrameManager.h 4 Dec 2006 20:35:54 -0000 1.21 +++ layout/base/nsFrameManager.h 6 Jun 2007 12:56:52 -0000 @@ -186,16 +186,17 @@ public: */ NS_HIDDEN_(nsChangeHint) ComputeStyleChangeFor(nsIFrame* aFrame, nsStyleChangeList* aChangeList, nsChangeHint aMinChange); // Determine whether an attribute affects style NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent, + PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType); /* * Capture/restore frame state for the frame subtree rooted at aFrame. * aState is the document state storage object onto which each frame * stores its state. */ 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 6 Jun 2007 12:56:55 -0000 @@ -996,16 +996,17 @@ static PRBool AttrMatchesValue(const nsA // |aDependence| has two functions: // * when non-null, it indicates that we're processing a negation, // which is done only when SelectorMatches calls itself recursively // * what it points to should be set to true whenever a test is skipped // because of aStateMask or aAttribute static PRBool SelectorMatches(RuleProcessorData &data, nsCSSSelector* aSelector, PRInt32 aStateMask, // states NOT to test + PRInt32 aNameSpaceID, // the namespace of the attribute nsIAtom* aAttribute, // attribute NOT to test PRBool* const aDependence = nsnull) { // namespace/tag match if ((kNameSpaceID_Unknown != aSelector->mNameSpace && data.mNameSpaceID != aSelector->mNameSpace) || (aSelector->mTag && aSelector->mTag != data.mContentTag)) { @@ -1317,19 +1318,17 @@ static PRBool SelectorMatches(RuleProces result = PR_FALSE; } else { NS_ASSERTION(data.mContent, "Must have content if either data.mHasAttributes or " "aAttribute is set!"); result = PR_TRUE; nsAttrSelector* attr = aSelector->mAttrList; do { - if (attr->mAttr == aAttribute) { - // XXX we should really have a namespace, not just an attr - // name, in HasAttributeDependentStyle! + if (attr->mAttr == aAttribute && attr->mNameSpace == aNameSpaceID) { result = PR_TRUE; if (aDependence) *aDependence = PR_TRUE; } else if (attr->mNameSpace == kNameSpaceID_Unknown) { // Attr selector with a wildcard namespace. We have to examine all // the attributes on our content node.... This sort of selector is // essentially a boolean OR, over all namespaces, of equivalent attr @@ -1391,18 +1390,20 @@ static PRBool SelectorMatches(RuleProces attr = attr->mNext; } while (attr && result); } } nsAtomList* IDList = aSelector->mIDList; if (result && IDList) { // test for ID match result = PR_FALSE; - - if (aAttribute && aAttribute == data.mContent->GetIDAttributeName()) { + PRInt32 namespaceID; + if (aAttribute && + aAttribute == data.mContent->GetIDAttributeName(namespaceID) && + aNameSpaceID == 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; @@ -1430,17 +1431,18 @@ static PRBool SelectorMatches(RuleProces IDList = IDList->mNext; } while (IDList); } } } if (result && aSelector->mClassList) { // test for class match - if (aAttribute && aAttribute == data.mContent->GetClassAttributeName()) { + if (aAttribute && aAttribute == data.mContent->GetClassAttributeName() && + aNameSpaceID == kNameSpaceID_None) { result = PR_TRUE; if (aDependence) *aDependence = PR_TRUE; } else { // case sensitivity: bug 93371 const PRBool isCaseSensitive = data.mCompatMode != eCompatibility_NavQuirks; @@ -1457,17 +1459,17 @@ static PRBool SelectorMatches(RuleProces } } // apply SelectorMatches to the negated selectors in the chain if (!isNegated) { for (nsCSSSelector *negation = aSelector->mNegations; result && negation; negation = negation->mNegations) { PRBool dependence = PR_FALSE; - result = !SelectorMatches(data, negation, aStateMask, + result = !SelectorMatches(data, negation, aStateMask, aNameSpaceID, aAttribute, &dependence); // If the selector does match due to the dependence on aStateMask // or aAttribute, then we want to keep result true so that the // final result of SelectorMatches is true. Doing so tells // StateEnumFunc or AttributeEnumFunc that there is a dependence // on the state or attribute. result = result || dependence; } @@ -1531,17 +1533,17 @@ static PRBool SelectorMatchesTree(RulePr &prevdata->mCompatMode); prevdata->mParentData = data; } } } if (! data) { return PR_FALSE; } - if (SelectorMatches(*data, selector, 0, nsnull)) { + if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) { // to avoid greedy matching, we need to recur if this is a // descendant combinator and the next combinator is not if ((NS_IS_GREEDY_OPERATOR(selector->mOperator)) && (selector->mNext) && (!NS_IS_GREEDY_OPERATOR(selector->mNext->mOperator))) { // pretend the selector didn't match, and step through content // while testing the same selector @@ -1568,17 +1570,17 @@ static PRBool SelectorMatchesTree(RulePr return PR_TRUE; // all the selectors matched. } static void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector, void* aData) { ElementRuleProcessorData* data = (ElementRuleProcessorData*)aData; - if (SelectorMatches(*data, aSelector, 0, nsnull)) { + if (SelectorMatches(*data, aSelector, 0, kNameSpaceID_Unknown, nsnull)) { nsCSSSelector *next = aSelector->mNext; if (!next || SelectorMatchesTree(*data, next)) { // for performance, require that every implementation of // nsICSSStyleRule return the same pointer for nsIStyleRule (why // would anything multiply inherit nsIStyleRule anyway?) #ifdef DEBUG nsCOMPtr iRule = do_QueryInterface(aRule); NS_ASSERTION(NS_STATIC_CAST(nsIStyleRule*, aRule) == iRule.get(), @@ -1621,17 +1623,17 @@ static void PseudoEnumFunc(nsICSSStyleRu if (matches) { nsCSSSelector *selector = aSelector->mNext; if (selector) { // test next selector specially if (PRUnichar('+') == selector->mOperator) { return; // not valid here, can't match } - if (SelectorMatches(*data, selector, 0, nsnull)) { + if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) { selector = selector->mNext; } else { if (PRUnichar('>') == selector->mOperator) { return; // immediate parent didn't match } } } @@ -1692,17 +1694,18 @@ PR_STATIC_CALLBACK(PRBool) StateEnumFunc nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ? eReStyle_LaterSiblings : eReStyle_Self; // If enumData->change already includes all the bits of possibleChange, don't // bother calling SelectorMatches, since even if it returns false // enumData->change won't change. if ((possibleChange & ~(enumData->change)) && - SelectorMatches(*data, selector, data->mStateMask, nsnull) && + SelectorMatches(*data, selector, data->mStateMask, kNameSpaceID_Unknown, + nsnull) && SelectorMatchesTree(*data, selector->mNext)) { enumData->change = nsReStyleHint(enumData->change | possibleChange); } return PR_TRUE; } NS_IMETHODIMP @@ -1746,17 +1749,17 @@ PR_STATIC_CALLBACK(PRBool) AttributeEnum nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ? eReStyle_LaterSiblings : eReStyle_Self; // If enumData->change already includes all the bits of possibleChange, don't // bother calling SelectorMatches, since even if it returns false // enumData->change won't change. if ((possibleChange & ~(enumData->change)) && - SelectorMatches(*data, selector, 0, data->mAttribute) && + SelectorMatches(*data, selector, 0, data->mNameSpaceID, data->mAttribute) && SelectorMatchesTree(*data, selector->mNext)) { enumData->change = nsReStyleHint(enumData->change | possibleChange); } return PR_TRUE; } NS_IMETHODIMP @@ -1766,17 +1769,18 @@ nsCSSRuleProcessor::HasAttributeDependen NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT), "content must be element"); AttributeEnumData data(aData); // Since we always have :-moz-any-link (and almost always have :link // and :visited rules from prefs), rather than hacking AddRule below // to add |href| to the hash, we'll just handle it here. - if (aData->mAttribute == nsGkAtoms::href && + if (aData->mNameSpaceID == kNameSpaceID_None && + aData->mAttribute == nsGkAtoms::href && aData->mIsHTMLContent && (aData->mContentTag == nsGkAtoms::a || aData->mContentTag == nsGkAtoms::area || aData->mContentTag == nsGkAtoms::link)) { data.change = nsReStyleHint(data.change | eReStyle_Self); } // XXX What about XLinks? // XXXbz now that :link and :visited are also states, do we need a @@ -1784,21 +1788,24 @@ 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) && + namespaceID == aData->mNameSpaceID) { cascade->mIDSelectors.EnumerateForwards(AttributeEnumFunc, &data); } - if (aData->mAttribute == aData->mContent->GetClassAttributeName()) { + if (aData->mNameSpaceID == kNameSpaceID_None && + aData->mAttribute == aData->mContent->GetClassAttributeName()) { cascade->mClassSelectors.EnumerateForwards(AttributeEnumFunc, &data); } AttributeSelectorEntry *entry = NS_STATIC_CAST(AttributeSelectorEntry*, PL_DHashTableOperate(&cascade->mAttributeSelectors, aData->mAttribute, PL_DHASH_LOOKUP)); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { entry->mSelectors->EnumerateForwards(AttributeEnumFunc, &data); Index: layout/style/nsIStyleRuleProcessor.h =================================================================== RCS file: /cvsroot/mozilla/layout/style/nsIStyleRuleProcessor.h,v retrieving revision 3.46 diff -u -8 -p -r3.46 nsIStyleRuleProcessor.h --- layout/style/nsIStyleRuleProcessor.h 23 Apr 2007 14:22:00 -0000 3.46 +++ layout/style/nsIStyleRuleProcessor.h 6 Jun 2007 12:56:55 -0000 @@ -147,27 +147,30 @@ struct StateRuleProcessorData : public R NS_PRECONDITION(aContent, "null pointer"); } const PRInt32 mStateMask; // |HasStateDependentStyle| for which state(s)? // Constants defined in nsIEventStateManager.h . }; struct AttributeRuleProcessorData : public RuleProcessorData { AttributeRuleProcessorData(nsPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute, - PRInt32 aModType) + nsIContent* aContent, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType) : RuleProcessorData(aPresContext, aContent, nsnull), + mNameSpaceID(aNameSpaceID), mAttribute(aAttribute), mModType(aModType) { NS_PRECONDITION(aContent, "null pointer"); } - nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute? - PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent). + PRInt32 mNameSpaceID; + nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute? + PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent). }; // IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b} #define NS_ISTYLE_RULE_PROCESSOR_IID \ {0x015575fe, 0x7b6c, 0x11d3, {0xba, 0x05, 0x00, 0x10, 0x83, 0x02, 0x3c, 0x2b}} /* The style rule processor interface is a mechanism to separate the matching Index: layout/style/nsStyleSet.cpp =================================================================== RCS file: /cvsroot/mozilla/layout/style/nsStyleSet.cpp,v retrieving revision 3.180 diff -u -8 -p -r3.180 nsStyleSet.cpp --- layout/style/nsStyleSet.cpp 16 May 2007 21:08:51 -0000 3.180 +++ layout/style/nsStyleSet.cpp 6 Jun 2007 12:56:55 -0000 @@ -896,19 +896,20 @@ nsStyleSet::HasStateDependentStyle(nsPre WalkRuleProcessors(SheetHasStatefulStyle, &data); result = data.mHint; } return result; } struct AttributeData : public AttributeRuleProcessorData { - AttributeData(nsPresContext* aPresContext, - nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType) - : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType), + AttributeData(nsPresContext* aPresContext, nsIContent* aContent, + PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) + : AttributeRuleProcessorData(aPresContext, aContent, aNameSpaceID, + aAttribute, aModType), mHint(nsReStyleHint(0)) {} nsReStyleHint mHint; }; static PRBool SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData) { @@ -918,28 +919,30 @@ SheetHasAttributeStyle(nsIStyleRuleProce data->mHint = nsReStyleHint(data->mHint | hint); return PR_TRUE; // continue } // Test if style is dependent on content state nsReStyleHint nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext, nsIContent* aContent, + PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { nsReStyleHint result = nsReStyleHint(0); if (aContent->IsNodeOfType(nsINode::eELEMENT) && (mRuleProcessors[eAgentSheet] || mRuleProcessors[ePresHintSheet] || mRuleProcessors[eUserSheet] || mRuleProcessors[eHTMLPresHintSheet] || mRuleProcessors[eDocSheet] || mRuleProcessors[eStyleAttrSheet] || mRuleProcessors[eOverrideSheet])) { - AttributeData data(aPresContext, aContent, aAttribute, aModType); + AttributeData data(aPresContext, aContent, aNameSpaceID, aAttribute, + aModType); WalkRuleProcessors(SheetHasAttributeStyle, &data); result = data.mHint; } return result; } Index: layout/style/nsStyleSet.h =================================================================== RCS file: /cvsroot/mozilla/layout/style/nsStyleSet.h,v retrieving revision 3.19 diff -u -8 -p -r3.19 nsStyleSet.h --- layout/style/nsStyleSet.h 16 May 2007 21:08:51 -0000 3.19 +++ layout/style/nsStyleSet.h 6 Jun 2007 12:56:56 -0000 @@ -131,19 +131,20 @@ class nsStyleSet // Test if style is dependent on content state nsReStyleHint HasStateDependentStyle(nsPresContext* aPresContext, nsIContent* aContent, PRInt32 aStateMask); // Test if style is dependent on the presence of an attribute. nsReStyleHint HasAttributeDependentStyle(nsPresContext* aPresContext, - nsIContent* aContent, - nsIAtom* aAttribute, - PRInt32 aModType); + nsIContent* aContent, + PRInt32 aNameSpaceID, + nsIAtom* aAttribute, + PRInt32 aModType); // APIs for registering objects that can supply additional // rules during processing. void SetBindingManager(nsBindingManager* aBindingManager) { mBindingManager = aBindingManager; }