Bug 284950: DeCOMTaminate nsIContent::GetAttrNameAt

r/sr=bz
This commit is contained in:
cvshook%sicking.cc 2005-12-28 21:52:39 +00:00
parent 4956a7786b
commit 79b8f5fc24
34 changed files with 224 additions and 373 deletions

View File

@ -54,6 +54,7 @@
#include "nsPIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIServiceManager.h"
#include "nsAttrName.h"
/// the accessible library and cached methods
HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull;
@ -191,21 +192,17 @@ STDMETHODIMP nsAccessNodeWrap::get_attributes(
numAttribs = aMaxAttribs;
*aNumAttribs = NS_STATIC_CAST(unsigned short, numAttribs);
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> nameAtom, prefixAtom;
for (PRUint32 index = 0; index < numAttribs; index++) {
aNameSpaceIDs[index] = 0; aAttribValues[index] = aAttribNames[index] = nsnull;
nsAutoString attributeValue;
const char *pszAttributeName;
if (NS_SUCCEEDED(content->GetAttrNameAt(index, &nameSpaceID, getter_AddRefs(nameAtom), getter_AddRefs(prefixAtom)))) {
aNameSpaceIDs[index] = NS_STATIC_CAST(short, nameSpaceID);
nameAtom->GetUTF8String(&pszAttributeName);
aAttribNames[index] = ::SysAllocString(NS_ConvertUTF8toUCS2(pszAttributeName).get());
content->GetAttr(nameSpaceID, nameAtom, attributeValue);
aAttribValues[index] = ::SysAllocString(attributeValue.get());
}
const nsAttrName* name = content->GetAttrNameAt(index);
aNameSpaceIDs[index] = NS_STATIC_CAST(short, name->NamespaceID());
name->LocalName()->GetUTF8String(&pszAttributeName);
aAttribNames[index] = ::SysAllocString(NS_ConvertUTF8toUCS2(pszAttributeName).get());
content->GetAttr(name->NamespaceID(), name->LocalName(), attributeValue);
aAttribValues[index] = ::SysAllocString(attributeValue.get());
}
return S_OK;

View File

@ -66,6 +66,7 @@ class nsIURI;
class nsICSSStyleRule;
class nsRuleWalker;
class nsAttrValue;
class nsAttrName;
// IID for the nsIContent interface
// ffc6f2b8-bcdc-4cf7-b72f-e843860f14a6
@ -410,14 +411,15 @@ public:
/**
* Get the namespace / name / prefix of a given attribute.
*
* @param aIndex the index of the attribute name
* @param aNameSpace the name space ID of the attribute name [OUT]
* @param aName the attribute name [OUT]
* @param aPrefix the attribute prefix [OUT]
*
* @param aIndex the index of the attribute name
* @returns The name at the given index, or null if the index is
* out-of-bounds.
* @note The document returned by NodeInfo()->GetDocument() (if one is
* present) is *not* neccesarily the owner document of the element.
* @note The pointer returned by this function is only valid until the
* next call of either GetAttrNameAt or SetAttr on the element.
*/
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const = 0;
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const = 0;
/**
* Get the number of all specified attributes.

View File

@ -77,6 +77,7 @@ REQUIRES = xpcom \
EXPORTS = \
nsAtomListUtils.h \
nsAttrName.h \
nsContentList.h \
nsNodeInfoManager.h \
nsPropertyTable.h \

View File

@ -461,13 +461,16 @@ nsAttrAndChildArray::GetSafeAttrNameAt(PRUint32 aPos) const
return mImpl->mMappedAttrs->NameAt(aPos);
}
// Warn here since we should make this non-bounds safe
aPos -= mapped;
PRUint32 slotCount = AttrSlotCount();
NS_ENSURE_TRUE(aPos < slotCount, nsnull);
if (aPos < slotCount) {
return nsnull;
}
void** pos = mImpl->mBuffer + aPos * ATTRSIZE;
NS_ENSURE_TRUE(*pos, nsnull);
if (!*pos) {
return nsnull;
}
return &NS_REINTERPRET_CAST(InternalAttr*, pos)->mName;
}

View File

@ -147,6 +147,13 @@ public:
return IsAtom() ? kNameSpaceID_None : NodeInfo()->NamespaceID();
}
PRInt32 NamespaceEquals(PRInt32 aNamespaceID) const
{
return aNamespaceID == kNameSpaceID_None ?
IsAtom() :
(!IsAtom() && NodeInfo()->NamespaceEquals(aNamespaceID));
}
nsIAtom* LocalName() const
{
return IsAtom() ? Atom() : NodeInfo()->NameAtom();

View File

@ -44,6 +44,7 @@
#include "nsDOMError.h"
#include "nsContentUtils.h"
#include "nsNodeInfoManager.h"
#include "nsAttrName.h"
//----------------------------------------------------------------------
@ -316,27 +317,23 @@ NS_IMETHODIMP
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> nameAtom, prefix;
nsresult rv = NS_OK;
if (mContent &&
NS_SUCCEEDED(mContent->GetAttrNameAt(aIndex,
&nameSpaceID,
getter_AddRefs(nameAtom),
getter_AddRefs(prefix)))) {
const nsAttrName* name;
if (mContent && (name = mContent->GetAttrNameAt(aIndex))) {
// Don't use the nodeinfo even if one exists since it can
// have the wrong owner document.
nsCOMPtr<nsINodeInfo> ni;
mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(nameAtom, prefix, nameSpaceID, getter_AddRefs(ni));
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(),
getter_AddRefs(ni));
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
rv = GetAttribute(ni, aReturn);
}
else {
*aReturn = nsnull;
return GetAttribute(ni, aReturn);
}
return rv;
*aReturn = nsnull;
return NS_OK;
}
nsresult
@ -389,15 +386,16 @@ nsDOMAttributeMap::GetNamedItemNSInternal(const nsAString& aNamespaceURI,
PRUint32 i, count = mContent->GetAttrCount();
for (i = 0; i < count; ++i) {
PRInt32 attrNS;
nsCOMPtr<nsIAtom> nameAtom, prefix;
mContent->GetAttrNameAt(i, &attrNS, getter_AddRefs(nameAtom),
getter_AddRefs(prefix));
const nsAttrName* name = mContent->GetAttrNameAt(i);
PRInt32 attrNS = name->NamespaceID();
nsIAtom* nameAtom = name->LocalName();
if (nameSpaceID == attrNS &&
nameAtom->EqualsUTF8(utf8Name)) {
nsCOMPtr<nsINodeInfo> ni;
mContent->NodeInfo()->NodeInfoManager()->
GetNodeInfo(nameAtom, prefix, nameSpaceID, getter_AddRefs(ni));
GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID,
getter_AddRefs(ni));
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
return GetAttribute(ni, aReturn, aRemove);

View File

@ -149,13 +149,9 @@ public:
{
return NS_OK;
}
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const
virtual nsAttrName* GetAttrNameAt(PRUint32 aIndex) const
{
*aNameSpaceID = kNameSpaceID_None;
*aName = nsnull;
*aPrefix = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
return nsnull;
}
virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,

View File

@ -820,15 +820,10 @@ nsGenericDOMDataNode::HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const
return PR_FALSE;
}
nsresult
nsGenericDOMDataNode::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const
const nsAttrName*
nsGenericDOMDataNode::GetAttrNameAt(PRUint32 aIndex) const
{
*aNameSpaceID = kNameSpaceID_None;
*aName = nsnull;
*aPrefix = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
return nsnull;
}
PRUint32

View File

@ -202,8 +202,7 @@ public:
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
nsAString& aResult) const;
virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const;
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const;
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
virtual PRUint32 GetAttrCount() const;
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;

View File

@ -470,10 +470,6 @@ nsNode3Tearoff::LookupPrefix(const nsAString& aNamespaceURI,
return NS_OK;
}
nsCOMPtr<nsIAtom> name, prefix;
PRInt32 namespace_id;
nsAutoString ns;
// Trace up the content parent chain looking for the namespace
// declaration that defines the aNamespaceURI namespace. Once found,
// return the prefix (i.e. the attribute localName).
@ -482,16 +478,14 @@ nsNode3Tearoff::LookupPrefix(const nsAString& aNamespaceURI,
PRUint32 attrCount = content->GetAttrCount();
for (PRUint32 i = 0; i < attrCount; ++i) {
content->GetAttrNameAt(i, &namespace_id, getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* name = content->GetAttrNameAt(i);
if (namespace_id == kNameSpaceID_XMLNS) {
if (content->AttrValueIs(namespace_id, name, aNamespaceURI,
eCaseMatters)) {
name->ToString(aPrefix);
if (name->NamespaceEquals(kNameSpaceID_XMLNS) &&
content->AttrValueIs(kNameSpaceID_XMLNS, name->LocalName(),
aNamespaceURI, eCaseMatters)) {
name->LocalName()->ToString(aPrefix);
return NS_OK;
}
return NS_OK;
}
}
}
@ -4330,24 +4324,10 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
return NS_OK;
}
nsresult
nsGenericElement::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const
const nsAttrName*
nsGenericElement::GetAttrNameAt(PRUint32 aIndex) const
{
const nsAttrName* name = mAttrsAndChildren.GetSafeAttrNameAt(aIndex);
if (name) {
*aNameSpaceID = name->NamespaceID();
NS_ADDREF(*aName = name->LocalName());
NS_IF_ADDREF(*aPrefix = name->GetPrefix());
return NS_OK;
}
*aNameSpaceID = kNameSpaceID_None;
*aName = nsnull;
*aPrefix = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
return mAttrsAndChildren.GetSafeAttrNameAt(aIndex);
}
PRUint32

View File

@ -392,8 +392,7 @@ public:
nsCaseTreatment aCaseSensitive) const;
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
PRBool aNotify);
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const;
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
virtual PRUint32 GetAttrCount() const;
virtual nsresult RangeAdd(nsIDOMRange* aRange);
virtual void RangeRemove(nsIDOMRange* aRange);

View File

@ -58,6 +58,7 @@
#include "nsIParserService.h"
#include "nsContentUtils.h"
#include "nsLWBrkCIID.h"
#include "nsAttrName.h"
#define kIndentStr NS_LITERAL_STRING(" ")
#define kLessThan NS_LITERAL_STRING("<")
@ -540,8 +541,6 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
nsresult rv;
PRUint32 index, count;
nsAutoString nameStr, valueStr;
PRInt32 namespaceID;
nsCOMPtr<nsIAtom> attrName, attrPrefix;
count = aContent->GetAttrCount();
@ -552,10 +551,9 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
// index is unsigned, hence index >= 0 is always true.
for (index = count; index > 0; ) {
--index;
aContent->GetAttrNameAt(index,
&namespaceID,
getter_AddRefs(attrName),
getter_AddRefs(attrPrefix));
const nsAttrName* name = aContent->GetAttrNameAt(index);
PRInt32 namespaceID = name->NamespaceID();
nsIAtom* attrName = name->LocalName();
// Filter out any attribute starting with [-|_]moz
const char* sharedName;

View File

@ -66,6 +66,7 @@
#include "nsIScriptContext.h"
#include "nsIHTMLDocument.h"
#include "nsCRT.h"
#include "nsAttrName.h"
#include "nsIJSContextStack.h"
// XXX Temporary inclusion to deal with fragment parsing
@ -2337,7 +2338,6 @@ nsRange::CreateContextualFragment(const nsAString& aFragment,
parent->GetNodeType(&nodeType);
if (nsIDOMNode::ELEMENT_NODE == nodeType) {
PRInt32 namespaceID;
nsAutoString tagName, uriStr;
parent->GetNodeName(tagName);
@ -2348,23 +2348,18 @@ nsRange::CreateContextualFragment(const nsAString& aFragment,
if (count > 0) {
PRUint32 index;
nsAutoString nameStr, prefixStr, valueStr;
nsCOMPtr<nsIAtom> attrName, attrPrefix;
for (index = 0; index < count; index++) {
content->GetAttrNameAt(index,
&namespaceID,
getter_AddRefs(attrName),
getter_AddRefs(attrPrefix));
if (namespaceID == kNameSpaceID_XMLNS) {
content->GetAttr(namespaceID, attrName, uriStr);
const nsAttrName* name = content->GetAttrNameAt(index);
if (name->NamespaceEquals(kNameSpaceID_XMLNS)) {
content->GetAttr(kNameSpaceID_XMLNS, name->LocalName(), uriStr);
// really want something like nsXMLContentSerializer::SerializeAttr()
tagName.Append(NS_LITERAL_STRING(" xmlns")); // space important
if (attrPrefix) {
if (name->GetPrefix()) {
tagName.Append(PRUnichar(':'));
attrName->ToString(nameStr);
name->LocalName()->ToString(nameStr);
tagName.Append(nameStr);
}
else {

View File

@ -56,6 +56,7 @@
#include "nsCRT.h"
#include "nsContentUtils.h"
#include "nsLayoutAtoms.h"
#include "nsAttrName.h"
typedef struct {
nsString mPrefix;
@ -580,21 +581,17 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
aElement->GetLocalName(tagLocalName);
aElement->GetNamespaceURI(tagNamespaceURI);
PRInt32 namespaceID;
PRUint32 index, count;
nsAutoString nameStr, prefixStr, uriStr, valueStr;
nsCOMPtr<nsIAtom> attrName, attrPrefix;
count = content->GetAttrCount();
// First scan for namespace declarations, pushing each on the stack
for (index = 0; index < count; index++) {
content->GetAttrNameAt(index,
&namespaceID,
getter_AddRefs(attrName),
getter_AddRefs(attrPrefix));
const nsAttrName* name = content->GetAttrNameAt(index);
PRInt32 namespaceID = name->NamespaceID();
nsIAtom *attrName = name->LocalName();
if (namespaceID == kNameSpaceID_XMLNS ||
// Also push on the stack attrs named "xmlns" in the null
@ -606,7 +603,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
attrName == nsLayoutAtoms::xmlnsNameSpace)) {
content->GetAttr(namespaceID, attrName, uriStr);
if (!attrPrefix) {
if (!name->GetPrefix()) {
// Default NS attribute does not have prefix (and the name is "xmlns")
PushNameSpaceDecl(EmptyString(), uriStr, aElement);
} else {
@ -646,10 +643,10 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
// XXX Unfortunately we need a namespace manager to get
// attribute URIs.
for (index = 0; index < count; index++) {
content->GetAttrNameAt(index,
&namespaceID,
getter_AddRefs(attrName),
getter_AddRefs(attrPrefix));
const nsAttrName* name = content->GetAttrNameAt(index);
PRInt32 namespaceID = name->NamespaceID();
nsIAtom* attrName = name->LocalName();
nsIAtom* attrPrefix = name->GetPrefix();
if (attrPrefix) {
attrPrefix->ToString(prefixStr);

View File

@ -1918,18 +1918,14 @@ nsGenericHTMLElement::ListAttributes(FILE* out) const
for (index = 0; index < count; index++) {
// name
nsCOMPtr<nsIAtom> attr;
nsCOMPtr<nsIAtom> prefix;
PRInt32 nameSpaceID;
GetAttrNameAt(index, &nameSpaceID, getter_AddRefs(attr),
getter_AddRefs(prefix));
const nsAttrName* name = GetAttrNameAt(index);
nsAutoString buffer;
attr->ToString(buffer);
name->LocalName()->ToString(buffer);
// value
nsAutoString value;
GetAttr(nameSpaceID, attr, value);
GetAttr(name->NamespaceID(), name->LocalName(), value);
buffer.AppendLiteral("=\"");
for (int i = value.Length(); i >= 0; --i) {
if (value[i] == PRUnichar('"'))

View File

@ -83,6 +83,7 @@
#include "nsIPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScrollableView.h"
#include "nsAttrName.h"
#include "nsNetCID.h"
#include "nsIIOService.h"
@ -1970,13 +1971,8 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
// Remove all attributes from the root element
while (count-- > 0) {
nsCOMPtr<nsIAtom> name, prefix;
PRInt32 nsid;
root->GetAttrNameAt(count, &nsid, getter_AddRefs(name),
getter_AddRefs(prefix));
root->UnsetAttr(nsid, name, PR_FALSE);
const nsAttrName* name = root->GetAttrNameAt(count);
root->UnsetAttr(name->NamespaceID(), name->LocalName(), PR_FALSE);
}
// Remove the root from the childlist

View File

@ -601,18 +601,15 @@ nsSVGUseElement::CreateAnonymousContent(nsPresContext* aPresContext,
}
// copy attributes
const nsAttrName* name;
PRUint32 i;
for (i = 0; i < newcontent->GetAttrCount(); i++) {
PRInt32 nsID;
nsCOMPtr<nsIAtom> name;
nsCOMPtr<nsIAtom> prefix;
for (i = 0; (name = newcontent->GetAttrNameAt(i)); i++) {
nsAutoString value;
PRInt32 nsID = name->NamespaceID();
nsIAtom* lname = name->LocalName();
newcontent->GetAttrNameAt(i, &nsID,
getter_AddRefs(name),
getter_AddRefs(prefix));
newcontent->GetAttr(nsID, name, value);
svgNode->SetAttr(nsID, name, prefix, value, PR_FALSE);
newcontent->GetAttr(nsID, lname, value);
svgNode->SetAttr(nsID, lname, name->GetPrefix(), value, PR_FALSE);
}
// move the children over

View File

@ -85,6 +85,7 @@
#include "nsIDOMMutationListener.h"
#include "nsIDOMContextMenuListener.h"
#include "nsIDOMEventGroup.h"
#include "nsAttrName.h"
#include "nsXBLAtoms.h"
#include "nsXULAtoms.h"
@ -615,15 +616,10 @@ nsXBLBinding::GenerateAnonymousContent()
// Always check the content element for potential attributes.
// This shorthand hack always happens, even when we didn't
// build anonymous content.
PRUint32 length = content->GetAttrCount();
PRInt32 namespaceID;
nsCOMPtr<nsIAtom> name;
nsCOMPtr<nsIAtom> prefix;
for (PRUint32 i = 0; i < length; ++i) {
content->GetAttrNameAt(i, &namespaceID, getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* attrName;
for (PRUint32 i = 0; (attrName = content->GetAttrNameAt(i)); ++i) {
PRInt32 namespaceID = attrName->NamespaceID();
nsIAtom* name = attrName->LocalName();
if (name != nsXBLAtoms::includes) {
nsAutoString value;

View File

@ -54,6 +54,7 @@
#include "txXMLUtils.h"
#include "txLog.h"
#include "nsUnicharUtils.h"
#include "nsAttrName.h"
const PRUint32 kUnknownIndex = PRUint32(-1);
@ -136,17 +137,12 @@ txXPathTreeWalker::moveToValidAttribute(PRUint32 aStartIndex)
return PR_FALSE;
}
PRInt32 namespaceID;
nsCOMPtr<nsIAtom> name, prefix;
PRUint32 index;
for (index = aStartIndex; index < total; ++index) {
mPosition.mContent->GetAttrNameAt(index, &namespaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* name = mPosition.mContent->GetAttrNameAt(index);
// We need to ignore XMLNS attributes.
if (namespaceID != kNameSpaceID_XMLNS) {
if (name->NamespaceID() != kNameSpaceID_XMLNS) {
mPosition.mIndex = index;
return PR_TRUE;
@ -382,11 +378,8 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
return nsnull;
}
nsIAtom* localName;
nsCOMPtr<nsIAtom> prefix;
PRInt32 namespaceID;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID, &localName,
getter_AddRefs(prefix));
nsIAtom* localName = aNode.mContent->GetAttrNameAt(aNode.mIndex)->LocalName();
NS_ADDREF(localName);
return localName;
}
@ -428,12 +421,8 @@ txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName)
return;
}
nsCOMPtr<nsIAtom> prefix, localName;
PRInt32 namespaceID;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
getter_AddRefs(localName),
getter_AddRefs(prefix));
localName->ToString(aLocalName);
aNode.mContent->GetAttrNameAt(aNode.mIndex)->LocalName()->
ToString(aLocalName);
// Check for html
if (aNode.mContent->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
@ -479,24 +468,7 @@ txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
return;
}
nsCOMPtr<nsIAtom> name, prefix;
PRInt32 namespaceID;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
if (prefix) {
prefix->ToString(aName);
aName.Append(PRUnichar(':'));
}
else {
aName.Truncate();
}
const char* attrName;
name->GetUTF8String(&attrName);
AppendUTF8toUTF16(attrName, aName);
aNode.mContent->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
// Check for html
if (aNode.mContent->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
@ -517,12 +489,7 @@ txXPathNodeUtils::getNamespaceID(const txXPathNode& aNode)
return aNode.mContent->GetNameSpaceID();
}
nsCOMPtr<nsIAtom> name, prefix;
PRInt32 namespaceID;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
return namespaceID;
return aNode.mContent->GetAttrNameAt(aNode.mIndex)->NamespaceID();
}
/* static */
@ -572,14 +539,10 @@ void
txXPathNodeUtils::appendNodeValue(const txXPathNode& aNode, nsAString& aResult)
{
if (aNode.isAttribute()) {
nsCOMPtr<nsIAtom> name, prefix;
PRInt32 namespaceID;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* name = aNode.mContent->GetAttrNameAt(aNode.mIndex);
nsAutoString result;
aNode.mContent->GetAttr(namespaceID, name, result);
aNode.mContent->GetAttr(name->NamespaceID(), name->LocalName(), result);
aResult.Append(result);
return;
@ -885,14 +848,10 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode)
return nsnull;
}
nsCOMPtr<nsIAtom> attName, attPrefix;
PRInt32 attNS;
PRUint32 i, total = parent->GetAttrCount();
for (i = 0; i < total; ++i) {
parent->GetAttrNameAt(i, &attNS, getter_AddRefs(attName),
getter_AddRefs(attPrefix));
if (nodeInfo->Equals(attName, attNS)) {
const nsAttrName* name = parent->GetAttrNameAt(i);
if (nodeInfo->Equals(name->LocalName(), name->NamespaceID())) {
return new txXPathNode(parent, i);
}
}
@ -931,15 +890,11 @@ txXPathNativeNode::getNode(const txXPathNode& aNode, nsIDOMNode** aResult)
return CallQueryInterface(aNode.mContent, aResult);
}
PRInt32 namespaceID;
nsCOMPtr<nsIAtom> name, prefix;
aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* name = aNode.mContent->GetAttrNameAt(aNode.mIndex);
nsAutoString namespaceURI, localname;
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(namespaceID, namespaceURI);
name->ToString(localname);
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(name->NamespaceID(), namespaceURI);
name->LocalName()->ToString(localname);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode.mContent);
nsCOMPtr<nsIDOMAttr> attr;

View File

@ -66,6 +66,7 @@
#include "txMozillaXSLTProcessor.h"
#include "txStylesheetCompiler.h"
#include "txXMLUtils.h"
#include "nsAttrName.h"
static const char kLoadAsData[] = "loadAsData";
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
@ -628,9 +629,10 @@ handleNode(nsIDOMNode* aNode, txStylesheetCompiler* aCompiler)
PRUint32 counter;
for (counter = 0; counter < attsCount; ++counter) {
txStylesheetAttr& att = atts[counter];
element->GetAttrNameAt(counter, &att.mNamespaceID,
getter_AddRefs(att.mLocalName),
getter_AddRefs(att.mPrefix));
const nsAttrName* name = element->GetAttrNameAt(counter);
att.mNamespaceID = name->NamespaceID();
att.mLocalName = name->LocalName();
att.mPrefix = name->GetPrefix();
element->GetAttr(att.mNamespaceID, att.mLocalName, att.mValue);
}
}

View File

@ -53,11 +53,14 @@
#include "nsIXTFService.h"
#include "nsDOMAttributeMap.h"
#include "nsUnicharUtils.h"
#include "nsLayoutAtoms.h"
nsXTFElementWrapper::nsXTFElementWrapper(nsINodeInfo* aNodeInfo)
: nsXTFElementWrapperBase(aNodeInfo),
mNotificationMask(0),
mIntrinsicState(0)
mIntrinsicState(0),
mTmpAttrName(nsLayoutAtoms::wildcard) // XXX this is a hack, but names
// have to have a value
{
}
@ -400,9 +403,8 @@ nsXTFElementWrapper::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
return rv;
}
nsresult
nsXTFElementWrapper::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const
const nsAttrName*
nsXTFElementWrapper::GetAttrNameAt(PRUint32 aIndex) const
{
PRUint32 innerCount=0;
if (mAttributeHandler) {
@ -410,13 +412,15 @@ nsXTFElementWrapper::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
}
if (aIndex < innerCount) {
*aNameSpaceID = kNameSpaceID_None;
*aPrefix = nsnull;
return mAttributeHandler->GetAttributeNameAt(aIndex, aName);
nsCOMPtr<nsIAtom> localName;
nsresult rv = mAttributeHandler->GetAttributeNameAt(aIndex, getter_AddRefs(localName));
NS_ENSURE_SUCCESS(rv, nsnull);
NS_CONST_CAST(nsXTFElementWrapper*, this)->mTmpAttrName.SetTo(localName);
return &mTmpAttrName;
}
else { // wrapper handles attrib
return nsXTFElementWrapperBase::GetAttrNameAt(aIndex - innerCount, aNameSpaceID,
aName, aPrefix);
return nsXTFElementWrapperBase::GetAttrNameAt(aIndex - innerCount);
}
}

View File

@ -101,8 +101,7 @@ public:
nsCaseTreatment aCaseSensitive) const;
nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
PRBool aNotify);
nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const;
const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
PRUint32 GetAttrCount() const;
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
@ -149,6 +148,9 @@ protected:
* @see nsIContent::IntrinsicState()
*/
PRInt32 mIntrinsicState;
// Temporary owner used by GetAttrNameAt
nsAttrName mTmpAttrName;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsXTFElementWrapper, NS_XTFELEMENTWRAPPER_IID)

View File

@ -1484,9 +1484,8 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
return NS_OK;
}
nsresult
nsXULElement::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const
const nsAttrName*
nsXULElement::GetAttrNameAt(PRUint32 aIndex) const
{
#ifdef DEBUG_ATTRIBUTE_STATS
int proto = mPrototype ? mPrototype->mNumAttributes : 0;
@ -1496,15 +1495,10 @@ nsXULElement::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
PRUint32 localAttrCount = mAttrsAndChildren.AttrCount();
if (aIndex < localAttrCount) {
const nsAttrName* name = mAttrsAndChildren.GetSafeAttrNameAt(aIndex);
*aNameSpaceID = name->NamespaceID();
NS_ADDREF(*aName = name->LocalName());
NS_IF_ADDREF(*aPrefix = name->GetPrefix());
#ifdef DEBUG_ATTRIBUTE_STATS
fprintf(stderr, " local!\n");
#endif
return NS_OK;
return mAttrsAndChildren.GetSafeAttrNameAt(aIndex);
}
aIndex -= localAttrCount;
@ -1529,11 +1523,7 @@ nsXULElement::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
#ifdef DEBUG_ATTRIBUTE_STATS
fprintf(stderr, " proto[%d]!\n", aIndex);
#endif
*aNameSpaceID = attr->mName.NamespaceID();
NS_ADDREF(*aName = attr->mName.LocalName());
NS_IF_ADDREF(*aPrefix = attr->mName.GetPrefix());
return NS_OK;
return &(attr->mName);
}
// else, we are out of attrs to return, fall-through
}
@ -1542,11 +1532,7 @@ nsXULElement::GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
fprintf(stderr, " not found\n");
#endif
*aNameSpaceID = kNameSpaceID_None;
*aName = nsnull;
*aPrefix = nsnull;
return NS_ERROR_ILLEGAL_VALUE;
return nsnull;
}
PRUint32
@ -1623,27 +1609,15 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
PRUint32 nattrs = GetAttrCount();
for (i = 0; i < nattrs; ++i) {
nsCOMPtr<nsIAtom> attr;
nsCOMPtr<nsIAtom> prefix;
PRInt32 nameSpaceID;
GetAttrNameAt(i, &nameSpaceID, getter_AddRefs(attr),
getter_AddRefs(prefix));
const nsAttrName* name = GetAttrNameAt(i);
nsAutoString v;
GetAttr(nameSpaceID, attr, v);
GetAttr(name->NamespaceID(), name->LocalName(), v);
fputs(" ", out);
nsAutoString s;
if (prefix) {
prefix->ToString(s);
fputs(NS_LossyConvertUCS2toASCII(s).get(), out);
fputs(":", out);
}
attr->ToString(s);
name->GetQualifiedName(s);
fputs(NS_LossyConvertUCS2toASCII(s).get(), out);
fputs("=", out);

View File

@ -487,8 +487,7 @@ public:
nsCaseTreatment aCaseSensitive) const;
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify);
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
nsIAtom** aName, nsIAtom** aPrefix) const;
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
virtual PRUint32 GetAttrCount() const;
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;

View File

@ -837,12 +837,9 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
if (aAttr.EqualsLiteral("*")) {
PRUint32 count = broadcaster->GetAttrCount();
while (count-- > 0) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> name;
nsCOMPtr<nsIAtom> prefix;
broadcaster->GetAttrNameAt(count, &nameSpaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
const nsAttrName* attrName = broadcaster->GetAttrNameAt(count);
PRInt32 nameSpaceID = attrName->NamespaceID();
nsIAtom* name = attrName->LocalName();
// _Don't_ push the |id|, |ref|, or |persist| attribute's value!
if (! CanBroadcast(nameSpaceID, name))
@ -850,7 +847,8 @@ nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
nsAutoString value;
broadcaster->GetAttr(nameSpaceID, name, value);
listener->SetAttr(nameSpaceID, name, prefix, value, PR_FALSE);
listener->SetAttr(nameSpaceID, name, attrName->GetPrefix(), value,
PR_FALSE);
#if 0
// XXX we don't fire the |onbroadcast| handler during
@ -3859,20 +3857,17 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
// Merge attributes from the overlay content node to that of the
// actual document.
PRUint32 i, attrCount = aOverlayNode->GetAttrCount();
for (i = 0; i < attrCount; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr, prefix;
rv = aOverlayNode->GetAttrNameAt(i, &nameSpaceID,
getter_AddRefs(attr),
getter_AddRefs(prefix));
if (NS_FAILED(rv)) return rv;
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 (nameSpaceID == kNameSpaceID_None && attr.get() == nsXULAtoms::id)
if (name->Equals(nsXULAtoms::id))
continue;
PRInt32 nameSpaceID = name->NamespaceID();
nsIAtom* attr = name->LocalName();
nsIAtom* prefix = name->GetPrefix();
nsAutoString value;
aOverlayNode->GetAttr(nameSpaceID, attr, value);

View File

@ -71,6 +71,7 @@
#include "nsNodeInfoManager.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentUtils.h"
#include "nsAttrName.h"
#include "jsapi.h"
#include "pldhash.h"
@ -711,13 +712,9 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
PRUint32 numAttribs = tmplKid->GetAttrCount();
for (PRUint32 attr = 0; attr < numAttribs; attr++) {
PRInt32 attribNameSpaceID;
nsCOMPtr<nsIAtom> attribName, prefix;
rv = tmplKid->GetAttrNameAt(attr, &attribNameSpaceID,
getter_AddRefs(attribName),
getter_AddRefs(prefix));
if (NS_FAILED(rv)) return rv;
const nsAttrName* name = tmplKid->GetAttrNameAt(attr);
PRInt32 attribNameSpaceID = name->NamespaceID();
nsIAtom* attribName = name->LocalName();
if (! IsIgnoreableAttribute(attribNameSpaceID, attribName)) {
// Create a buffer here, because there's a good
@ -897,15 +894,12 @@ nsXULContentBuilder::SynchronizeUsingTemplate(nsIContent* aTemplateNode,
// check all attributes on the template node; if they reference a resource,
// update the equivalent attribute on the content node
PRUint32 numAttribs = aTemplateNode->GetAttrCount();
const nsAttrName* name;
PRUint32 loop;
for (loop = 0; (name = aTemplateNode->GetAttrNameAt(loop)); ++loop) {
for (PRUint32 loop = 0; loop < numAttribs; ++loop) {
PRInt32 attribNameSpaceID;
nsCOMPtr<nsIAtom> attribName, prefix;
rv = aTemplateNode->GetAttrNameAt(loop, &attribNameSpaceID,
getter_AddRefs(attribName),
getter_AddRefs(prefix));
if (NS_FAILED(rv)) break;
PRInt32 attribNameSpaceID = name->NamespaceID();
nsIAtom* attribName = name->LocalName();
// See if it's one of the attributes that we unilaterally
// ignore. If so, on to the next one...

View File

@ -2083,30 +2083,21 @@ nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement,
PRBool hasContainerTest = PR_FALSE;
PRUint32 count = aRuleElement->GetAttrCount();
// Add constraints for the LHS
for (PRUint32 i = 0; i < count; ++i) {
PRInt32 attrNameSpaceID;
nsCOMPtr<nsIAtom> attr, prefix;
rv = aRuleElement->GetAttrNameAt(i, &attrNameSpaceID,
getter_AddRefs(attr),
getter_AddRefs(prefix));
if (NS_FAILED(rv)) return rv;
const nsAttrName* name;
for (PRUint32 i = 0; (name = aRuleElement->GetAttrNameAt(i)); ++i) {
// Note: some attributes must be skipped on XUL template rule subtree
// never compare against rdf:property attribute
if ((attr.get() == nsXULAtoms::property) && (attrNameSpaceID == kNameSpaceID_RDF))
continue;
// never compare against rdf:instanceOf attribute
else if ((attr.get() == nsXULAtoms::instanceOf) && (attrNameSpaceID == kNameSpaceID_RDF))
continue;
// never compare against {}:id attribute
else if ((attr.get() == nsXULAtoms::id) && (attrNameSpaceID == kNameSpaceID_None))
continue;
else if ((attr.get() == nsXULAtoms::parsetype) && (attrNameSpaceID == kNameSpaceID_None))
// never compare against rdf:property, rdf:instanceOf, {}:id or {}:parsetype attribute
if (name->Equals(nsXULAtoms::property, kNameSpaceID_RDF) ||
name->Equals(nsXULAtoms::instanceOf, kNameSpaceID_RDF) ||
name->Equals(nsXULAtoms::id, kNameSpaceID_None) ||
name->Equals(nsXULAtoms::parsetype, kNameSpaceID_None)) {
continue;
}
PRInt32 attrNameSpaceID = name->NamespaceID();
nsIAtom* attr = name->LocalName();
nsAutoString value;
aRuleElement->GetAttr(attrNameSpaceID, attr, value);
@ -2116,8 +2107,8 @@ nsXULTemplateBuilder::CompileSimpleRule(nsIContent* aRuleElement,
if (CompileSimpleAttributeCondition(attrNameSpaceID, attr, value, aParentNode, &testnode)) {
// handled by subclass
}
else if (((attrNameSpaceID == kNameSpaceID_None) && (attr.get() == nsXULAtoms::iscontainer)) ||
((attrNameSpaceID == kNameSpaceID_None) && (attr.get() == nsXULAtoms::isempty))) {
else if (name->Equals(nsXULAtoms::iscontainer, kNameSpaceID_None) ||
name->Equals(nsXULAtoms::isempty, kNameSpaceID_None)) {
// Tests about containerhood and emptiness. These can be
// globbed together, mostly. Check to see if we've already
// added a container test: we only need one.
@ -2248,14 +2239,10 @@ nsXULTemplateBuilder::AddSimpleRuleBindings(nsTemplateRule* aRule, nsIContent* a
PRUint32 count = element->GetAttrCount();
for (i = 0; i < count; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr, prefix;
element->GetAttrNameAt(i, &nameSpaceID, getter_AddRefs(attr),
getter_AddRefs(prefix));
const nsAttrName* name = element->GetAttrNameAt(i);
nsAutoString value;
element->GetAttr(nameSpaceID, attr, value);
element->GetAttr(name->NamespaceID(), name->LocalName(), value);
// Scan the attribute for variables, adding a binding for
// each one.

View File

@ -166,6 +166,7 @@ EDITOR_ATOM(cssWidth, "width")
EDITOR_ATOM(cssZIndex, "z-index")
EDITOR_ATOM(cssMozUserSelect, "-moz-user-select")
EDITOR_ATOM(mozdirty, "_moz_dirty")
EDITOR_ATOM(cssPxUnit, "px")
EDITOR_ATOM(cssEmUnit, "em")

View File

@ -56,6 +56,7 @@
#include "nsUnicharUtils.h"
#include "nsHTMLCSSUtils.h"
#include "nsColor.h"
#include "nsAttrName.h"
static
void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString,
@ -658,14 +659,7 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsIDOMNode *aNode, nsIAtom *aProperty, cons
}
else if (1 == attrCount) {
// incredible hack in case the only remaining attribute is a _moz_dirty...
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attrName, prefix;
res = content->GetAttrNameAt(0, &nameSpaceID, getter_AddRefs(attrName),
getter_AddRefs(prefix));
if (NS_FAILED(res)) return res;
nsAutoString attrString, tmp;
attrName->ToString(attrString);
if (attrString.EqualsLiteral("_moz_dirty")) {
if (content->GetAttrNameAt(0)->Equals(nsEditProperty::mozdirty)) {
res = mHTMLEditor->RemoveContainer(aNode);
if (NS_FAILED(res)) return res;
}

View File

@ -58,6 +58,7 @@
#include "nsIEnumerator.h"
#include "nsIContent.h"
#include "nsIContentIterator.h"
#include "nsAttrName.h"
NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
@ -782,25 +783,20 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
if (!content) return PR_FALSE; // ooops
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attrName, prefix;
PRUint32 i, attrCount = content->GetAttrCount();
for (i = 0; i < attrCount; ++i)
{
content->GetAttrNameAt(i, &nameSpaceID, getter_AddRefs(attrName),
getter_AddRefs(prefix));
nsAutoString attrString, tmp;
if (!attrName) continue; // ooops
attrName->ToString(attrString);
// if it's the attribute we know about, keep looking
if (attrString.Equals(*aAttribute,nsCaseInsensitiveStringComparator())) continue;
// if it's a special _moz... attribute, keep looking
attrString.Left(tmp,4);
if (tmp.LowerCaseEqualsLiteral("_moz")) continue;
// otherwise, it's another attribute, so return false
return PR_FALSE;
for (i = 0; i < attrCount; ++i) {
nsAutoString attrString;
const nsAttrName name = content->GetAttrNameAt(i);
if (!name->NamespaceEquals(kNameSpaceID_None)) {
return PR_FALSE;
}
name->LocalName()->ToString(attrString);
// if it's the attribute we know about, or a special _moz attribute,
// keep looking
if (!attrString.Equals(*aAttribute, nsCaseInsensitiveStringComparator()) &&
!StringBeginsWith(attrString, NS_LITERAL_STRING("_moz"))) {
return PR_FALSE;
}
}
// if we made it through all of them without finding a real attribute
// other than aAttribute, then return PR_TRUE

View File

@ -119,6 +119,7 @@
#include "nsPIDOMWindow.h"
#include "nsContentUtils.h"
#include "nsIStringBundle.h"
#include "nsAttrName.h"
// headers for plugin scriptability
#include "nsIScriptGlobalObject.h"
@ -2918,12 +2919,9 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
increment = 1;
}
for (PRInt16 index = start; index != end; index += increment) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> atom;
nsCOMPtr<nsIAtom> prefix;
content->GetAttrNameAt(index, &nameSpaceID,
getter_AddRefs(atom),
getter_AddRefs(prefix));
const nsAttrName* name = content->GetAttrNameAt(index);
PRInt32 nameSpaceID = name->NamespaceID();
nsIAtom* atom = name->LocalName();
nsAutoString value;
content->GetAttr(nameSpaceID, atom, value);
nsAutoString name;

View File

@ -63,6 +63,7 @@
#include "nsMathMLContainerFrame.h"
#include "nsAutoPtr.h"
#include "nsStyleSet.h"
#include "nsCSSFrameConstructor.h"
NS_DEFINE_CID(kInlineFrameCID, NS_INLINE_FRAME_CID);
@ -987,7 +988,10 @@ nsMathMLContainerFrame::RemoveFrame(nsIAtom* aListName,
return NS_ERROR_INVALID_ARG;
}
// remove the child frame
mFrames.DestroyFrame(GetPresContext(), aOldFrame);
nsPresContext* presContext = GetPresContext();
presContext->PresShell()->FrameConstructor()->
RemoveMappingsForFrameSubtree(aOldFrame);
mFrames.DestroyFrame(presContext, aOldFrame);
return ChildListChanged(nsIDOMMutationEvent::REMOVAL);
}

View File

@ -57,6 +57,7 @@
#include "nsAutoPtr.h"
#include "nsStyleSet.h"
#include "nsStyleUtil.h"
#include "nsAttrName.h"
static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID);
@ -599,14 +600,13 @@ nsMathMLFrame::MapAttributesIntoCSS(nsPresContext* aPresContext,
nsCOMPtr<nsICSSStyleSheet> cssSheet;
nsCOMPtr<nsIDOMCSSStyleSheet> domSheet;
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> prefix;
nsCOMPtr<nsIAtom> attrAtom;
PRInt32 ruleCount = 0;
for (PRUint32 i = 0; i < attrCount; ++i) {
aContent->GetAttrNameAt(i, &nameSpaceID,
getter_AddRefs(attrAtom),
getter_AddRefs(prefix));
const nsAttrName* name = aContent->GetAttrNameAt(i);
if (name->NamespaceID() != kNameSpaceID_None)
continue;
nsIAtom* attrAtom = name->LocalName();
// lookup the equivalent CSS property
const nsCSSMapping* map = kCSSMappingTable;
@ -617,7 +617,7 @@ nsMathMLFrame::MapAttributesIntoCSS(nsPresContext* aPresContext,
nsAutoString cssProperty(NS_ConvertASCIItoUCS2(map->cssProperty));
nsAutoString attrValue;
aContent->GetAttr(nameSpaceID, attrAtom, attrValue);
aContent->GetAttr(kNameSpaceID_None, attrAtom, attrValue);
if (attrValue.IsEmpty())
continue;
nsAutoString escapedAttrValue;

View File

@ -95,6 +95,7 @@
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsAttrValue.h"
#include "nsAttrName.h"
struct RuleValue {
/**
@ -3144,20 +3145,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
// have a chance at matching, of course, are ones that the element
// actually has attributes in), short-circuiting if we ever match.
PRUint32 attrCount = data.mContent->GetAttrCount();
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> name;
nsCOMPtr<nsIAtom> prefix;
result = PR_FALSE;
for (PRUint32 i = 0; i < attrCount; ++i) {
#ifdef DEBUG
nsresult attrState =
#endif
data.mContent->GetAttrNameAt(i, &nameSpaceID,
getter_AddRefs(name),
getter_AddRefs(prefix));
NS_ASSERTION(NS_SUCCEEDED(attrState),
"GetAttrCount lied or GetAttrNameAt failed");
if (name != attr->mAttr) {
const nsAttrName* attrName =
data.mContent->GetAttrNameAt(i);
NS_ASSERTION(attrName, "GetAttrCount lied or GetAttrNameAt failed");
if (attrName->LocalName() != attr->mAttr) {
continue;
}
if (attr->mFunction == NS_ATTR_FUNC_SET) {
@ -3167,7 +3160,8 @@ static PRBool SelectorMatches(RuleProcessorData &data,
#ifdef DEBUG
PRBool hasAttr =
#endif
data.mContent->GetAttr(nameSpaceID, name, value);
data.mContent->GetAttr(attrName->NamespaceID(),
attrName->LocalName(), value);
NS_ASSERTION(hasAttr, "GetAttrNameAt lied");
result = AttrMatchesValue(attr, value);
}