From bd9a96d5b99ec0b015bc4ffbb295baf3830e0c74 Mon Sep 17 00:00:00 2001 From: "Olli.Pettay%helsinki.fi" Date: Thu, 26 Jul 2007 14:16:21 +0000 Subject: [PATCH] Backing out bug 275196, xml:id, to fix tp regression git-svn-id: svn://10.0.0.236/trunk@231054 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIContent.h | 25 +-- mozilla/content/base/src/nsDOMAttribute.cpp | 5 +- .../content/base/src/nsGenericDOMDataNode.cpp | 10 +- .../content/base/src/nsGenericDOMDataNode.h | 4 +- mozilla/content/base/src/nsGenericElement.cpp | 30 +--- mozilla/content/base/src/nsGenericElement.h | 4 +- .../content/events/src/nsXMLEventsElement.cpp | 20 +-- .../content/events/src/nsXMLEventsManager.cpp | 19 ++- .../html/content/src/nsGenericHTMLElement.cpp | 16 +- .../html/content/src/nsGenericHTMLElement.h | 4 +- .../html/document/src/nsHTMLDocument.cpp | 6 +- .../content/svg/content/src/nsSVGElement.cpp | 18 +-- .../content/svg/content/src/nsSVGElement.h | 4 +- .../content/xtf/src/nsXTFElementWrapper.cpp | 17 +- mozilla/content/xtf/src/nsXTFElementWrapper.h | 4 +- .../content/xul/content/src/nsXULElement.cpp | 18 +-- .../content/xul/content/src/nsXULElement.h | 4 +- .../xul/document/src/nsXULDocument.cpp | 56 +++---- mozilla/extensions/xforms/nsXFormsUtils.cpp | 6 +- mozilla/layout/base/nsCSSFrameConstructor.cpp | 26 ++- mozilla/layout/base/nsFrameManager.cpp | 2 - mozilla/layout/base/nsFrameManager.h | 1 - mozilla/layout/style/nsCSSRuleProcessor.cpp | 37 ++--- mozilla/layout/style/nsIStyleRuleProcessor.h | 11 +- mozilla/layout/style/nsStyleSet.cpp | 13 +- mozilla/layout/style/nsStyleSet.h | 1 - mozilla/layout/style/test/Makefile.in | 1 - .../layout/style/test/test_bug275196.xhtml | 149 ------------------ 28 files changed, 114 insertions(+), 397 deletions(-) delete mode 100644 mozilla/layout/style/test/test_bug275196.xhtml diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 8dae699bbb7..105be819376 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -63,8 +63,8 @@ class nsIDocShell; // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x609baee8, 0x3c0a, 0x4122, \ - { 0x9c, 0xc6, 0xe4, 0xc9, 0x83, 0x53, 0xff, 0x9c } } +{ 0x36b375cb, 0xf01e, 0x4c18, \ + { 0xbf, 0x9e, 0xba, 0xad, 0x77, 0x1d, 0xce, 0x22 } } // hack to make egcs / gcc 2.95.2 happy class nsIContent_base : public nsINode { @@ -211,21 +211,10 @@ public: /** * Returns an atom holding the name of the attribute of type ID on - * this content node (if applicable). - * Language specific ID attribute has the highest priority, then - * ID attribute defined in DTD, and finally xml:id. - * Returns null for non-element content nodes. + * this content node (if applicable). Returns null for non-element + * content nodes. */ - 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 a time. - */ - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const = 0; + virtual nsIAtom *GetIDAttributeName() const = 0; /** * Normalizes an attribute name and returns it as a nodeinfo if an attribute @@ -742,8 +731,8 @@ public: /** * Get the ID of this content node (the atom corresponding to the - * value of the attribute whose name is given by GetIDAttributeName(). - * This may be null if there is no ID. + * value of the null-namespace attribute whose name is given by + * GetIDAttributeName(). This may be null if there is no ID. */ virtual nsIAtom* GetID() const = 0; diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index fd31bbfbe09..d01023df035 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -600,15 +600,14 @@ nsDOMAttribute::GetIsId(PRBool* aReturn) return NS_OK; } - PRInt32 namespaceID; - nsIAtom* idAtom = content->GetIDAttributeName(namespaceID); + nsIAtom* idAtom = content->GetIDAttributeName(); if (!idAtom) { *aReturn = PR_FALSE; return NS_OK; } - *aReturn = mNodeInfo->Equals(idAtom, namespaceID); + *aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None); return NS_OK; } diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 4ea0c2bd2e7..5f436eae71b 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -631,19 +631,11 @@ nsGenericDOMDataNode::UnbindFromTree(PRBool aDeep, PRBool aNullParent) } nsIAtom * -nsGenericDOMDataNode::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsGenericDOMDataNode::GetIDAttributeName() const { - aNameSpaceID = kNameSpaceID_Unknown; return nsnull; } -PRBool -nsGenericDOMDataNode::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return PR_FALSE; -} - already_AddRefed nsGenericDOMDataNode::GetExistingAttrNameFromQName(const nsAString& aStr) const { diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index e076d48b1ed..dedcbcd51c9 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -195,9 +195,7 @@ public: virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, PRBool aNullParent = PR_TRUE); - virtual nsIAtom *GetIDAttributeName(PRInt32& aNamespaceId) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const; nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, const nsAString& aValue, PRBool aNotify) diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index d6b8b9f3d4c..92044c5a8df 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2260,10 +2260,9 @@ nsGenericElement::DispatchDOMEvent(nsEvent* aEvent, nsIAtom* nsGenericElement::GetID() const { - PRInt32 namespaceID; - nsIAtom* IDName = GetIDAttributeName(namespaceID); + nsIAtom* IDName = GetIDAttributeName(); if (IDName) { - const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName, namespaceID); + const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(IDName); if (attrVal){ if (attrVal->Type() == nsAttrValue::eAtom) { return attrVal->GetAtomValue(); @@ -2326,26 +2325,9 @@ nsGenericElement::GetAttributeChangeHint(const nsIAtom* aAttribute, } nsIAtom * -nsGenericElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsGenericElement::GetIDAttributeName() const { - aNameSpaceID = kNameSpaceID_None; - nsIAtom* idAtom = mNodeInfo->GetIDAttributeAtom(); - if (idAtom && HasAttr(aNameSpaceID, idAtom)) { - return idAtom; - } - - aNameSpaceID = kNameSpaceID_XML; - return nsGkAtoms::id; -} - -PRBool -nsGenericElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && - aAtom == mNodeInfo->GetIDAttributeAtom()) || - (aNameSpaceID == kNameSpaceID_XML && - aAtom == nsGkAtoms::id); + return mNodeInfo->GetIDAttributeAtom(); } nsIAtom * @@ -3670,8 +3652,8 @@ nsGenericElement::ParseAttribute(PRInt32 aNamespaceID, const nsAString& aValue, nsAttrValue& aResult) { - if (IsPotentialIDAttributeName(aNamespaceID, aAttribute) && - !aValue.IsEmpty()) { + if (aNamespaceID == kNameSpaceID_None && + aAttribute == GetIDAttributeName() && !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); diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 61bfea5e020..3b8c9b835d5 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -383,9 +383,7 @@ public: PRBool aCompileEventHandlers); virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, PRBool aNullParent = PR_TRUE); - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual nsIAtom *GetClassAttributeName() const; virtual already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const; nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, diff --git a/mozilla/content/events/src/nsXMLEventsElement.cpp b/mozilla/content/events/src/nsXMLEventsElement.cpp index 4c850345913..37c07a419d7 100644 --- a/mozilla/content/events/src/nsXMLEventsElement.cpp +++ b/mozilla/content/events/src/nsXMLEventsElement.cpp @@ -46,9 +46,7 @@ public: virtual ~nsXMLEventsElement(); NS_FORWARD_NSIDOMNODE(nsXMLElement::) - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); @@ -65,21 +63,11 @@ nsXMLEventsElement::~nsXMLEventsElement() } nsIAtom * -nsXMLEventsElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsXMLEventsElement::GetIDAttributeName() const { - if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) { - aNameSpaceID = kNameSpaceID_None; + if (mNodeInfo->Equals(nsGkAtoms::listener)) return nsGkAtoms::id; - } - return nsGenericElement::GetIDAttributeName(aNameSpaceID); -} - -PRBool -nsXMLEventsElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) || - nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom); + return nsXMLElement::GetIDAttributeName(); } nsresult diff --git a/mozilla/content/events/src/nsXMLEventsManager.cpp b/mozilla/content/events/src/nsXMLEventsManager.cpp index f17cbcd1109..0924f30b2a3 100644 --- a/mozilla/content/events/src/nsXMLEventsManager.cpp +++ b/mozilla/content/events/src/nsXMLEventsManager.cpp @@ -377,11 +377,20 @@ nsXMLEventsManager::AttributeChanged(nsIDocument* aDocument, AddXMLEventsContent(aContent); nsXMLEventsListener::InitXMLEventsListener(aDocument, this, aContent); } - else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) { - //Remove possible listener - mListeners.Enumerate(EnumAndSetIncomplete, aContent); - //Add new listeners - AddListeners(aDocument); + else if (aContent->GetIDAttributeName() == 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); + } + else { + //If we are adding the ID attribute, we must check whether we can + //add new listeners + AddListeners(aDocument); + } } } } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index f0eebb8fb77..63ff13081bb 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -1493,21 +1493,9 @@ nsGenericHTMLElement::GetClasses() const } nsIAtom * -nsGenericHTMLElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsGenericHTMLElement::GetIDAttributeName() const { - if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) { - aNameSpaceID = kNameSpaceID_None; - return nsGkAtoms::id; - } - return nsGenericElement::GetIDAttributeName(aNameSpaceID); -} - -PRBool -nsGenericHTMLElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) || - nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom); + return nsGkAtoms::id; } nsIAtom * diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 63d05800cb1..8a6c0cb8f91 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -241,9 +241,7 @@ public: virtual void UpdateEditableState(); virtual const nsAttrValue* GetClasses() const; - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual nsIAtom *GetClassAttributeName() const; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); virtual nsICSSStyleRule* GetInlineStyleRule(); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 6dc67af4c6d..032b30f2f3c 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1376,7 +1376,8 @@ nsHTMLDocument::AttributeWillChange(nsIContent* aContent, PRInt32 aNameSpaceID, return; } } - } else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) { + } else if (aAttribute == aContent->GetIDAttributeName() && + aNameSpaceID == kNameSpaceID_None) { nsresult rv = RemoveFromIdTable(aContent); if (NS_FAILED(rv)) { @@ -1405,7 +1406,8 @@ nsHTMLDocument::AttributeChanged(nsIDocument* aDocument, if (name) { UpdateNameTableEntry(name, aContent); } - } else if (aContent->IsPotentialIDAttributeName(aNameSpaceID, aAttribute)) { + } else if (aAttribute == aContent->GetIDAttributeName() && + aNameSpaceID == kNameSpaceID_None) { nsIAtom* id = aContent->GetID(); if (id) { UpdateIdTableEntry(id, aContent); diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 1fcca6bc4b8..247f376d4bc 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -126,22 +126,10 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericElement) //---------------------------------------------------------------------- // nsIContent methods -nsIAtom* -nsSVGElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsIAtom * +nsSVGElement::GetIDAttributeName() const { - if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) { - aNameSpaceID = kNameSpaceID_None; - return nsGkAtoms::id; - } - return nsGenericElement::GetIDAttributeName(aNameSpaceID); -} - -PRBool -nsSVGElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) || - nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom); + return nsGkAtoms::id; } nsIAtom * diff --git a/mozilla/content/svg/content/src/nsSVGElement.h b/mozilla/content/svg/content/src/nsSVGElement.h index 9db34f2f55c..c7c31416867 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.h +++ b/mozilla/content/svg/content/src/nsSVGElement.h @@ -71,9 +71,7 @@ public: // nsIContent interface methods - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual nsIAtom *GetClassAttributeName() const; virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRBool aNotify); diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp index 638d7d8f8d8..9fdeb951713 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp @@ -265,21 +265,10 @@ nsXTFElementWrapper::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) } nsIAtom * -nsXTFElementWrapper::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsXTFElementWrapper::GetIDAttributeName() const { - if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) { - aNameSpaceID = kNameSpaceID_None; - return nsGkAtoms::id; - } - return nsXTFElementWrapperBase::GetIDAttributeName(aNameSpaceID); -} - -PRBool -nsXTFElementWrapper::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) || - nsXTFElementWrapperBase::IsPotentialIDAttributeName(aNameSpaceID, aAtom); + // XXX: + return nsGkAtoms::id; } nsresult diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.h b/mozilla/content/xtf/src/nsXTFElementWrapper.h index 3001ffcc2b1..b85fae77736 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.h +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.h @@ -78,9 +78,7 @@ public: nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify); nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + nsIAtom *GetIDAttributeName() const; nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, PRBool aNotify); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 5f3e842a80a..770477b2532 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1633,9 +1633,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify) nsIAtom* nsXULElement::GetID() const { - PRInt32 namespaceID; - nsIAtom* IDName = GetIDAttributeName(namespaceID); - const nsAttrValue* attrVal = FindLocalOrProtoAttr(namespaceID, IDName); + const nsAttrValue* attrVal = FindLocalOrProtoAttr(kNameSpaceID_None, nsGkAtoms::id); NS_ASSERTION(!attrVal || attrVal->Type() == nsAttrValue::eAtom || @@ -1741,21 +1739,9 @@ nsXULElement::IsAttributeMapped(const nsIAtom* aAttribute) const } nsIAtom * -nsXULElement::GetIDAttributeName(PRInt32& aNameSpaceID) const +nsXULElement::GetIDAttributeName() const { - if (HasAttr(kNameSpaceID_None, nsGkAtoms::id)) { - aNameSpaceID = kNameSpaceID_None; return nsGkAtoms::id; - } - return nsGenericElement::GetIDAttributeName(aNameSpaceID); -} - -PRBool -nsXULElement::IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const -{ - return (aNameSpaceID == kNameSpaceID_None && aAtom == nsGkAtoms::id) || - nsGenericElement::IsPotentialIDAttributeName(aNameSpaceID, aAtom); } nsIAtom * diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 75193ac4eff..3da3a6dea12 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -505,9 +505,7 @@ public: virtual void UnbindFromTree(PRBool aDeep, PRBool aNullParent); virtual void SetNativeAnonymous(PRBool aAnonymous); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); - virtual nsIAtom *GetIDAttributeName(PRInt32& aNameSpaceID) const; - virtual PRBool IsPotentialIDAttributeName(PRInt32 aNameSpaceID, - nsIAtom* aAtom) const; + virtual nsIAtom *GetIDAttributeName() const; virtual nsIAtom *GetClassAttributeName() const; virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aResult) const; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 5f422e1fc23..88de793d1e4 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -929,8 +929,7 @@ nsXULDocument::AttributeChanged(nsIDocument* aDocument, // XXXbz check aNameSpaceID, dammit! // First see if we need to update our element map. - if (aElement->IsPotentialIDAttributeName(aNameSpaceID, aAttribute) || - (aAttribute == nsGkAtoms::ref && aNameSpaceID == kNameSpaceID_None)) { + if ((aAttribute == nsGkAtoms::id) || (aAttribute == nsGkAtoms::ref)) { rv = mElementMap.Enumerate(RemoveElementsFromMapByContent, aElement); if (NS_FAILED(rv)) return; @@ -1758,27 +1757,29 @@ nsXULDocument::GetTemplateBuilderFor(nsIContent* aContent, return NS_OK; } +// Attributes that are used with getElementById() and the +// resource-to-element map. +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; - nsIAtom* idAtom = aElement->GetID(); - if (idAtom) { - nsAutoString idStr; - idAtom->ToString(idStr); - if (!idStr.IsEmpty()) { - rv = mElementMap.Add(idStr, 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); + 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; + } } return NS_OK; @@ -1790,21 +1791,14 @@ nsXULDocument::RemoveElementFromMap(nsIContent* aElement) { // Remove the element from the resource-to-element map. nsresult rv; - nsIAtom* idAtom = aElement->GetID(); - if (idAtom) { - nsAutoString idStr; - idAtom->ToString(idStr); - if (!idStr.IsEmpty()) { - rv = mElementMap.Remove(idStr, 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); + 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; + } } return NS_OK; diff --git a/mozilla/extensions/xforms/nsXFormsUtils.cpp b/mozilla/extensions/xforms/nsXFormsUtils.cpp index 1250f3abb14..fe3fcba8aea 100644 --- a/mozilla/extensions/xforms/nsXFormsUtils.cpp +++ b/mozilla/extensions/xforms/nsXFormsUtils.cpp @@ -1962,10 +1962,8 @@ nsXFormsUtils::GetElementById(const nsAString &aId, if (type == nsIDOMNode::ELEMENT_NODE) { nsCOMPtr content(do_QueryInterface(childNode)); NS_ASSERTION(content, "An ELEMENT_NODE not implementing nsIContent?!"); - PRInt32 namespaceID; - nsIAtom* idAtom = content->GetIDAttributeName(namespaceID); - if (idAtom && - content->AttrValueIs(namespaceID, idAtom, aId, eCaseMatters)) { + if (content->AttrValueIs(kNameSpaceID_None, content->GetIDAttributeName(), + aId, eCaseMatters)) { element = do_QueryInterface(childNode); break; } diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index e5f18c4e0f2..e65a9ab2bcf 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10128,8 +10128,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, #endif // the style tag has its own interpretation based on aHint - nsChangeHint hint = (aNameSpaceID == kNameSpaceID_None) - ? aContent->GetAttributeChangeHint(aAttribute, aModType) : nsChangeHint(0); + nsChangeHint hint = aContent->GetAttributeChangeHint(aAttribute, aModType); PRBool reframe = (hint & nsChangeHint_ReconstructFrame) != 0; @@ -10164,19 +10163,15 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, if (primaryFrame) { // See if we have appearance information for a theme. - 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); - } + 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); } } @@ -10193,7 +10188,6 @@ nsCSSFrameConstructor::AttributeChanged(nsIContent* aContent, // 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, aStateMask); diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 76fcd07c996..c1e0a2e870a 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -1445,14 +1445,12 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame, nsReStyleHint nsFrameManager::HasAttributeDependentStyle(nsIContent *aContent, - PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType, PRUint32 aStateMask) { nsReStyleHint hint = mStyleSet->HasAttributeDependentStyle(GetPresContext(), aContent, - aNameSpaceID, aAttribute, aModType, aStateMask); diff --git a/mozilla/layout/base/nsFrameManager.h b/mozilla/layout/base/nsFrameManager.h index 556d4c6e8ec..31cd2cc2688 100644 --- a/mozilla/layout/base/nsFrameManager.h +++ b/mozilla/layout/base/nsFrameManager.h @@ -191,7 +191,6 @@ public: // Determine whether an attribute affects style NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent, - PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType, PRUint32 aStateMask); diff --git a/mozilla/layout/style/nsCSSRuleProcessor.cpp b/mozilla/layout/style/nsCSSRuleProcessor.cpp index 15cb92d4115..fe360c931f7 100644 --- a/mozilla/layout/style/nsCSSRuleProcessor.cpp +++ b/mozilla/layout/style/nsCSSRuleProcessor.cpp @@ -1001,8 +1001,6 @@ static PRBool AttrMatchesValue(const nsAttrSelector* aAttrSelector, static PRBool SelectorMatches(RuleProcessorData &data, nsCSSSelector* aSelector, PRInt32 aStateMask, // states NOT to test - PRInt32 aNameSpaceID, // the namespace of the - // attribute NOT to test nsIAtom* aAttribute, // attribute NOT to test PRBool* const aDependence = nsnull) @@ -1324,9 +1322,9 @@ static PRBool SelectorMatches(RuleProcessorData &data, result = PR_TRUE; nsAttrSelector* attr = aSelector->mAttrList; do { - if (attr->mAttr == aAttribute && - (attr->mNameSpace == aNameSpaceID || - attr->mNameSpace == kNameSpaceID_Unknown)) { + if (attr->mAttr == aAttribute) { + // XXX we should really have a namespace, not just an attr + // name, in HasAttributeDependentStyle! result = PR_TRUE; if (aDependence) *aDependence = PR_TRUE; @@ -1398,9 +1396,8 @@ static PRBool SelectorMatches(RuleProcessorData &data, if (result && IDList) { // test for ID match result = PR_FALSE; - PRInt32 namespaceID; - if (aAttribute && - data.mContent->IsPotentialIDAttributeName(namespaceID, aAttribute)) { + + if (aAttribute && aAttribute == data.mContent->GetIDAttributeName()) { result = PR_TRUE; if (aDependence) *aDependence = PR_TRUE; @@ -1438,8 +1435,7 @@ static PRBool SelectorMatches(RuleProcessorData &data, if (result && aSelector->mClassList) { // test for class match - if (aAttribute && aAttribute == data.mContent->GetClassAttributeName() && - aNameSpaceID == kNameSpaceID_None) { + if (aAttribute && aAttribute == data.mContent->GetClassAttributeName()) { result = PR_TRUE; if (aDependence) *aDependence = PR_TRUE; @@ -1466,7 +1462,7 @@ static PRBool SelectorMatches(RuleProcessorData &data, for (nsCSSSelector *negation = aSelector->mNegations; result && negation; negation = negation->mNegations) { PRBool dependence = PR_FALSE; - result = !SelectorMatches(data, negation, aStateMask, aNameSpaceID, + result = !SelectorMatches(data, negation, aStateMask, 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 @@ -1540,7 +1536,7 @@ static PRBool SelectorMatchesTree(RuleProcessorData& aPrevData, if (! data) { return PR_FALSE; } - if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) { + if (SelectorMatches(*data, selector, 0, 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)) && @@ -1577,7 +1573,7 @@ static void ContentEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector, { ElementRuleProcessorData* data = (ElementRuleProcessorData*)aData; - if (SelectorMatches(*data, aSelector, 0, kNameSpaceID_Unknown, nsnull)) { + if (SelectorMatches(*data, aSelector, 0, nsnull)) { nsCSSSelector *next = aSelector->mNext; if (!next || SelectorMatchesTree(*data, next)) { // for performance, require that every implementation of @@ -1630,7 +1626,7 @@ static void PseudoEnumFunc(nsICSSStyleRule* aRule, nsCSSSelector* aSelector, if (PRUnichar('+') == selector->mOperator) { return; // not valid here, can't match } - if (SelectorMatches(*data, selector, 0, kNameSpaceID_Unknown, nsnull)) { + if (SelectorMatches(*data, selector, 0, nsnull)) { selector = selector->mNext; } else { @@ -1701,8 +1697,7 @@ PR_STATIC_CALLBACK(PRBool) StateEnumFunc(void* aSelector, void* aData) // bother calling SelectorMatches, since even if it returns false // enumData->change won't change. if ((possibleChange & ~(enumData->change)) && - SelectorMatches(*data, selector, data->mStateMask, kNameSpaceID_Unknown, - nsnull) && + SelectorMatches(*data, selector, data->mStateMask, nsnull) && SelectorMatchesTree(*data, selector->mNext)) { enumData->change = nsReStyleHint(enumData->change | possibleChange); } @@ -1756,8 +1751,7 @@ PR_STATIC_CALLBACK(PRBool) AttributeEnumFunc(void* aSelector, void* aData) // bother calling SelectorMatches, since even if it returns false // enumData->change won't change. if ((possibleChange & ~(enumData->change)) && - SelectorMatches(*data, selector, data->mStateMask, data->mNameSpaceID, - data->mAttribute) && + SelectorMatches(*data, selector, data->mStateMask, data->mAttribute) && SelectorMatchesTree(*data, selector->mNext)) { enumData->change = nsReStyleHint(enumData->change | possibleChange); } @@ -1778,7 +1772,6 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData // 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 && - aData->mNameSpaceID == kNameSpaceID_None && aData->mIsHTMLContent && (aData->mContentTag == nsGkAtoms::a || aData->mContentTag == nsGkAtoms::area || @@ -1796,13 +1789,11 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData // we have a hashtable with a per-attribute list. if (cascade) { - if (aData->mContent->IsPotentialIDAttributeName(aData->mNameSpaceID, - aData->mAttribute)) { + if (aData->mAttribute == aData->mContent->GetIDAttributeName()) { cascade->mIDSelectors.EnumerateForwards(AttributeEnumFunc, &data); } - if (aData->mNameSpaceID == kNameSpaceID_None && - aData->mAttribute == aData->mContent->GetClassAttributeName()) { + if (aData->mAttribute == aData->mContent->GetClassAttributeName()) { cascade->mClassSelectors.EnumerateForwards(AttributeEnumFunc, &data); } diff --git a/mozilla/layout/style/nsIStyleRuleProcessor.h b/mozilla/layout/style/nsIStyleRuleProcessor.h index 6569470f701..e0224d6f40c 100644 --- a/mozilla/layout/style/nsIStyleRuleProcessor.h +++ b/mozilla/layout/style/nsIStyleRuleProcessor.h @@ -153,24 +153,19 @@ struct StateRuleProcessorData : public RuleProcessorData { struct AttributeRuleProcessorData : public RuleProcessorData { AttributeRuleProcessorData(nsPresContext* aPresContext, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType, PRUint32 aStateMask) : RuleProcessorData(aPresContext, aContent, nsnull), - mNameSpaceID(aNameSpaceID), mAttribute(aAttribute), mModType(aModType), mStateMask(aStateMask) { NS_PRECONDITION(aContent, "null pointer"); } - // |HasAttributeDependentStyle| for which attribute? - PRInt32 mNameSpaceID; - nsIAtom* mAttribute; - - PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent). - PRUint32 mStateMask; // The states that changed with the attr change. + nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute? + PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent). + PRUint32 mStateMask; // The states that changed with the attr change. }; diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index 35133d96c5b..3c21988e503 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -959,10 +959,10 @@ nsStyleSet::HasStateDependentStyle(nsPresContext* aPresContext, struct AttributeData : public AttributeRuleProcessorData { AttributeData(nsPresContext* aPresContext, - nsIContent* aContent, PRInt32 aNameSpaceID, - nsIAtom* aAttribute, PRInt32 aModType, PRUint32 aStateMask) - : AttributeRuleProcessorData(aPresContext, aContent, aNameSpaceID, - aAttribute, aModType, aStateMask), + nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType, + PRUint32 aStateMask) + : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType, + aStateMask), mHint(nsReStyleHint(0)) {} nsReStyleHint mHint; @@ -982,7 +982,6 @@ SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData) nsReStyleHint nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType, PRUint32 aStateMask) @@ -997,8 +996,8 @@ nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext, mRuleProcessors[eDocSheet] || mRuleProcessors[eStyleAttrSheet] || mRuleProcessors[eOverrideSheet])) { - AttributeData data(aPresContext, aContent, aNameSpaceID, aAttribute, - aModType, aStateMask); + AttributeData data(aPresContext, aContent, aAttribute, aModType, + aStateMask); WalkRuleProcessors(SheetHasAttributeStyle, &data); result = data.mHint; } diff --git a/mozilla/layout/style/nsStyleSet.h b/mozilla/layout/style/nsStyleSet.h index bbd8992fc72..69bb6dc6af1 100644 --- a/mozilla/layout/style/nsStyleSet.h +++ b/mozilla/layout/style/nsStyleSet.h @@ -139,7 +139,6 @@ class nsStyleSet // Test if style is dependent on the presence of an attribute. nsReStyleHint HasAttributeDependentStyle(nsPresContext* aPresContext, nsIContent* aContent, - PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType, PRUint32 aStateMask); diff --git a/mozilla/layout/style/test/Makefile.in b/mozilla/layout/style/test/Makefile.in index c7fada50039..c9dc3ac1dbf 100644 --- a/mozilla/layout/style/test/Makefile.in +++ b/mozilla/layout/style/test/Makefile.in @@ -68,7 +68,6 @@ css_properties.js: host_ListCSSProperties$(HOST_BIN_SUFFIX) css_properties_like_ _TEST_FILES = test_bug74880.html \ test_bug221428.html \ - test_bug275196.xhtml \ test_bug302186.html \ test_bug319381.html \ test_bug357614.html \ diff --git a/mozilla/layout/style/test/test_bug275196.xhtml b/mozilla/layout/style/test/test_bug275196.xhtml deleted file mode 100644 index 747afa7692f..00000000000 --- a/mozilla/layout/style/test/test_bug275196.xhtml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Test for Bug 275196 - - - - - - -Mozilla Bug 275196 -

-
-
Element in XHTML namespace, attribute in null namespace
-
Element in XHTML namespace, attribute in foo namespace
- Element in foo namespace, attribute in foo namespace -
Element in XHTML namespace, id attribute
- Element in foo namespace, xml:id attribute -
-
-
-
- - -