mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 534136 Part 3: Optimize atom-using code for the fact that atoms store 16bit strings. Also take advantage of new nsAtomString API. r=bz
This commit is contained in:
parent
c7c7514f75
commit
0e6d5d8188
@ -64,9 +64,7 @@ nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
|
||||
{
|
||||
aAttrValue.Truncate();
|
||||
|
||||
nsCAutoString attrName;
|
||||
aAttrName->ToUTF8String(attrName);
|
||||
aAttributes->GetStringProperty(attrName, aAttrValue);
|
||||
aAttributes->GetStringProperty(nsAtomCString(aAttrName), aAttrValue);
|
||||
}
|
||||
|
||||
void
|
||||
@ -76,8 +74,7 @@ nsAccUtils::SetAccAttr(nsIPersistentProperties *aAttributes,
|
||||
nsAutoString oldValue;
|
||||
nsCAutoString attrName;
|
||||
|
||||
aAttrName->ToUTF8String(attrName);
|
||||
aAttributes->SetStringProperty(attrName, aAttrValue, oldValue);
|
||||
aAttributes->SetStringProperty(nsAtomCString(aAttrName), aAttrValue, oldValue);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -270,13 +270,13 @@ public:
|
||||
if (!GetPrefixAtom())
|
||||
return Equals(aNameAtom);
|
||||
|
||||
return QualifiedNameEqualsInternal(nsAtomCString(aNameAtom));
|
||||
return QualifiedNameEqualsInternal(nsDependentAtomString(aNameAtom));
|
||||
}
|
||||
|
||||
PRBool QualifiedNameEquals(const nsACString& aQualifiedName) const
|
||||
PRBool QualifiedNameEquals(const nsAString& aQualifiedName) const
|
||||
{
|
||||
if (!GetPrefixAtom())
|
||||
return mInner.mName->EqualsUTF8(aQualifiedName);
|
||||
return mInner.mName->Equals(aQualifiedName);
|
||||
|
||||
return QualifiedNameEqualsInternal(aQualifiedName);
|
||||
}
|
||||
@ -291,7 +291,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual PRBool
|
||||
QualifiedNameEqualsInternal(const nsACString& aQualifiedName) const = 0;
|
||||
QualifiedNameEqualsInternal(const nsAString& aQualifiedName) const = 0;
|
||||
|
||||
/*
|
||||
* nsNodeInfoInner is used for two things:
|
||||
|
@ -513,7 +513,7 @@ nsAttrAndChildArray::GetSafeAttrNameAt(PRUint32 aPos) const
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
nsAttrAndChildArray::GetExistingAttrNameFromQName(const nsACString& aName) const
|
||||
nsAttrAndChildArray::GetExistingAttrNameFromQName(const nsAString& aName) const
|
||||
{
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
|
@ -114,8 +114,7 @@ public:
|
||||
// Returns attribute name at given position or null if aPos is out-of-bounds
|
||||
const nsAttrName* GetSafeAttrNameAt(PRUint32 aPos) const;
|
||||
|
||||
// aName is UTF-8 encoded
|
||||
const nsAttrName* GetExistingAttrNameFromQName(const nsACString& aName) const;
|
||||
const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
|
||||
PRInt32 IndexOfAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID = kNameSpaceID_None) const;
|
||||
|
||||
nsresult SetAndTakeMappedAttr(nsIAtom* aLocalName, nsAttrValue& aValue,
|
||||
|
@ -175,9 +175,9 @@ public:
|
||||
return IsAtom() ? nsnull : NodeInfo()->GetPrefixAtom();
|
||||
}
|
||||
|
||||
PRBool QualifiedNameEquals(const nsACString& aName) const
|
||||
PRBool QualifiedNameEquals(const nsAString& aName) const
|
||||
{
|
||||
return IsAtom() ? Atom()->EqualsUTF8(aName) :
|
||||
return IsAtom() ? Atom()->Equals(aName) :
|
||||
NodeInfo()->QualifiedNameEquals(aName);
|
||||
}
|
||||
|
||||
|
@ -716,10 +716,11 @@ nsAttrValue::Equals(const nsAString& aValue,
|
||||
return aValue.IsEmpty();
|
||||
}
|
||||
case eAtomBase:
|
||||
// Need a way to just do case-insensitive compares on atoms..
|
||||
if (aCaseSensitive == eCaseMatters) {
|
||||
return static_cast<nsIAtom*>(GetPtr())->Equals(aValue);;
|
||||
return static_cast<nsIAtom*>(GetPtr())->Equals(aValue);
|
||||
}
|
||||
return nsDependentAtomString(static_cast<nsIAtom*>(GetPtr())).
|
||||
Equals(aValue, nsCaseInsensitiveStringComparator());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -749,7 +750,7 @@ nsAttrValue::Equals(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const
|
||||
str->StorageSize()/sizeof(PRUnichar) - 1);
|
||||
return aValue->Equals(dep);
|
||||
}
|
||||
return aValue->EqualsUTF8(EmptyCString());
|
||||
return aValue == nsGkAtoms::_empty;
|
||||
}
|
||||
case eAtomBase:
|
||||
{
|
||||
|
@ -468,7 +468,6 @@ nsDOMAttributeMap::GetNamedItemNSInternal(const nsAString& aNamespaceURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 utf8Name(aLocalName);
|
||||
PRInt32 nameSpaceID = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
@ -487,7 +486,7 @@ nsDOMAttributeMap::GetNamedItemNSInternal(const nsAString& aNamespaceURI,
|
||||
nsIAtom* nameAtom = name->LocalName();
|
||||
|
||||
if (nameSpaceID == attrNS &&
|
||||
nameAtom->EqualsUTF8(utf8Name)) {
|
||||
nameAtom->Equals(aLocalName)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
ni = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID);
|
||||
|
@ -4265,8 +4265,7 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aEventName,
|
||||
const nsAttrName*
|
||||
nsGenericElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
{
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(
|
||||
NS_ConvertUTF16toUTF8(aStr));
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(aStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -4423,12 +4422,11 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
|
||||
|
||||
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
|
||||
|
||||
nsAutoString attrName;
|
||||
aName->ToString(attrName);
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
nsAutoString ns;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
|
||||
GetAttributeNodeNS(ns, attrName, getter_AddRefs(attrNode));
|
||||
GetAttributeNodeNS(ns, nsDependentAtomString(aName),
|
||||
getter_AddRefs(attrNode));
|
||||
mutation.mRelatedNode = attrNode;
|
||||
|
||||
mutation.mAttrName = aName;
|
||||
@ -4626,11 +4624,10 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// Grab the attr node if needed before we remove it from the attr map
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
if (hasMutationListeners) {
|
||||
nsAutoString attrName;
|
||||
aName->ToString(attrName);
|
||||
nsAutoString ns;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns);
|
||||
GetAttributeNodeNS(ns, attrName, getter_AddRefs(attrNode));
|
||||
GetAttributeNodeNS(ns, nsDependentAtomString(aName),
|
||||
getter_AddRefs(attrNode));
|
||||
}
|
||||
|
||||
// Clear binding to nsIDOMNamedNodeMap
|
||||
|
@ -111,7 +111,7 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
||||
return;
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString nameStr, valueStr;
|
||||
nsAutoString valueStr;
|
||||
NS_NAMED_LITERAL_STRING(_mozStr, "_moz");
|
||||
|
||||
for (PRInt32 index = count; index > 0;) {
|
||||
@ -179,7 +179,7 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
||||
}
|
||||
}
|
||||
|
||||
attrName->ToString(nameStr);
|
||||
nsDependentAtomString nameStr(attrName);
|
||||
|
||||
// Expand shorthand attribute.
|
||||
if (IsShorthandAttr(attrName, aTagName) && valueStr.IsEmpty()) {
|
||||
@ -235,9 +235,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
|
||||
AppendToString(kLessThan, aStr);
|
||||
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
AppendToString(nsDependentAtomString(name), aStr);
|
||||
|
||||
MaybeEnterInPreContent(content);
|
||||
|
||||
@ -375,11 +373,8 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||
mAddSpace = PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString nameStr;
|
||||
name->ToString(nameStr);
|
||||
|
||||
AppendToString(kEndTag, aStr);
|
||||
AppendToString(nameStr.get(), -1, aStr);
|
||||
AppendToString(nsDependentAtomString(name), aStr);
|
||||
AppendToString(kGreaterThan, aStr);
|
||||
|
||||
MaybeLeaveFromPreContent(content);
|
||||
|
@ -244,12 +244,12 @@ nsMappedAttributes::RemoveAttrAt(PRUint32 aPos, nsAttrValue& aValue)
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
nsMappedAttributes::GetExistingAttrNameFromQName(const nsACString& aName) const
|
||||
nsMappedAttributes::GetExistingAttrNameFromQName(const nsAString& aName) const
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mAttrCount; ++i) {
|
||||
if (Attrs()[i].mName.IsAtom()) {
|
||||
if (Attrs()[i].mName.Atom()->EqualsUTF8(aName)) {
|
||||
if (Attrs()[i].mName.Atom()->Equals(aName)) {
|
||||
return &Attrs()[i].mName;
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
// Remove the attr at position aPos. The value of the attr is placed in
|
||||
// aValue; any value that was already in aValue is destroyed.
|
||||
void RemoveAttrAt(PRUint32 aPos, nsAttrValue& aValue);
|
||||
const nsAttrName* GetExistingAttrNameFromQName(const nsACString& aName) const;
|
||||
const nsAttrName* GetExistingAttrNameFromQName(const nsAString& aName) const;
|
||||
PRInt32 IndexOfAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID) const;
|
||||
|
||||
|
||||
|
@ -248,16 +248,16 @@ nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsNodeInfo::QualifiedNameEqualsInternal(const nsACString& aQualifiedName) const
|
||||
nsNodeInfo::QualifiedNameEqualsInternal(const nsAString& aQualifiedName) const
|
||||
{
|
||||
NS_PRECONDITION(mInner.mPrefix, "Must have prefix");
|
||||
|
||||
nsACString::const_iterator start;
|
||||
nsAString::const_iterator start;
|
||||
aQualifiedName.BeginReading(start);
|
||||
|
||||
nsACString::const_iterator colon(start);
|
||||
nsAString::const_iterator colon(start);
|
||||
|
||||
nsAtomCString prefix(mInner.mPrefix);
|
||||
nsDependentAtomString prefix(mInner.mPrefix);
|
||||
|
||||
if (prefix.Length() >= aQualifiedName.Length()) {
|
||||
return PR_FALSE;
|
||||
@ -277,12 +277,12 @@ nsNodeInfo::QualifiedNameEqualsInternal(const nsACString& aQualifiedName) const
|
||||
|
||||
++colon; // Skip the ':'
|
||||
|
||||
nsACString::const_iterator end;
|
||||
nsAString::const_iterator end;
|
||||
aQualifiedName.EndReading(end);
|
||||
|
||||
// Compare the local name to the string between the colon and the
|
||||
// end of aQualifiedName
|
||||
return mInner.mName->EqualsUTF8(Substring(colon, end));
|
||||
return mInner.mName->Equals(Substring(colon, end));
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
PRInt32 aNamespaceID) const;
|
||||
virtual PRBool NamespaceEquals(const nsAString& aNamespaceURI) const;
|
||||
virtual PRBool
|
||||
QualifiedNameEqualsInternal(const nsACString& aQualifiedName) const;
|
||||
QualifiedNameEqualsInternal(const nsAString& aQualifiedName) const;
|
||||
|
||||
// nsNodeInfo
|
||||
// Create objects with Create
|
||||
|
@ -1818,8 +1818,7 @@ nsPlainTextSerializer::GetAttributeValue(const nsIParserNode* aNode,
|
||||
}
|
||||
}
|
||||
else if (aNode) {
|
||||
nsAutoString name;
|
||||
aName->ToString(name);
|
||||
nsDependentAtomString name(aName);
|
||||
|
||||
PRInt32 count = aNode->GetAttributeCount();
|
||||
for (PRInt32 i=0;i<count;i++) {
|
||||
|
@ -271,7 +271,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 index, count;
|
||||
nsAutoString nameStr, prefixStr, uriStr, valueStr;
|
||||
nsAutoString prefixStr, uriStr, valueStr;
|
||||
nsAutoString xmlnsStr;
|
||||
xmlnsStr.AssignLiteral(kXMLNS);
|
||||
|
||||
@ -367,7 +367,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
|
||||
aContent->GetAttr(namespaceID, attrName, valueStr);
|
||||
|
||||
attrName->ToString(nameStr);
|
||||
nsDependentAtomString nameStr(attrName);
|
||||
|
||||
// XXX Hack to get around the fact that MathML can add
|
||||
// attributes starting with '-', which makes them
|
||||
|
@ -718,7 +718,7 @@ nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
|
||||
const nsAString& aTagNamespaceURI)
|
||||
{
|
||||
PRUint32 index, count;
|
||||
nsAutoString nameStr, prefixStr, uriStr, valueStr;
|
||||
nsAutoString uriStr, valueStr;
|
||||
|
||||
count = aContent->GetAttrCount();
|
||||
|
||||
@ -758,8 +758,8 @@ nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
|
||||
}
|
||||
}
|
||||
else {
|
||||
attrName->ToString(nameStr);
|
||||
PushNameSpaceDecl(nameStr, uriStr, aOriginalElement);
|
||||
PushNameSpaceDecl(nsDependentAtomString(attrName), uriStr,
|
||||
aOriginalElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -819,7 +819,7 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
PRBool aAddNSAttr)
|
||||
{
|
||||
|
||||
nsAutoString nameStr, prefixStr, uriStr, valueStr;
|
||||
nsAutoString prefixStr, uriStr, valueStr;
|
||||
nsAutoString xmlnsStr;
|
||||
xmlnsStr.AssignLiteral(kXMLNS);
|
||||
PRUint32 index, count;
|
||||
@ -867,7 +867,7 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
}
|
||||
|
||||
aContent->GetAttr(namespaceID, attrName, valueStr);
|
||||
attrName->ToString(nameStr);
|
||||
nsDependentAtomString nameStr(attrName);
|
||||
|
||||
// XXX Hack to get around the fact that MathML can add
|
||||
// attributes starting with '-', which makes them
|
||||
|
@ -250,9 +250,7 @@ NS_METHOD nsDOMEvent::GetType(nsAString& aType)
|
||||
mCachedType = aType;
|
||||
return NS_OK;
|
||||
} else if (mEvent->message == NS_USER_DEFINED_EVENT && mEvent->userType) {
|
||||
nsAutoString name;
|
||||
mEvent->userType->ToString(name);
|
||||
aType = Substring(name, 2, name.Length() - 2); // Remove "on"
|
||||
aType = Substring(nsDependentAtomString(mEvent->userType), 2); // Remove "on"
|
||||
mCachedType = aType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1484,10 +1484,8 @@ nsEventListenerManager::GetListenerInfo(nsCOMArray<nsIEventListenerInfo>* aList)
|
||||
} else if (ls.mEventType == NS_USER_DEFINED_EVENT) {
|
||||
// Handle user defined event types.
|
||||
if (ls.mTypeAtom) {
|
||||
nsAutoString atomName;
|
||||
ls.mTypeAtom->ToString(atomName);
|
||||
const nsDependentSubstring& eventType =
|
||||
Substring(atomName, 2, atomName.Length() - 2);
|
||||
Substring(nsDependentAtomString(ls.mTypeAtom), 2);
|
||||
nsRefPtr<nsEventListenerInfo> info =
|
||||
new nsEventListenerInfo(eventType, ls.mListener, capturing,
|
||||
allowsUntrusted, systemGroup);
|
||||
|
@ -2999,12 +2999,10 @@ nsGenericHTMLElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr
|
||||
if (IsInHTMLDocument()) {
|
||||
nsAutoString lower;
|
||||
nsContentUtils::ASCIIToLower(aStr, lower);
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(
|
||||
NS_ConvertUTF16toUTF8(lower));
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(lower);
|
||||
}
|
||||
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(
|
||||
NS_ConvertUTF16toUTF8(aStr));
|
||||
return mAttrsAndChildren.GetExistingAttrNameFromQName(aStr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -425,7 +425,6 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCAutoString k;
|
||||
nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
|
||||
|
||||
// The attributes are on the parser node in the order they came in in the
|
||||
@ -454,15 +453,12 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
|
||||
step = -1;
|
||||
}
|
||||
|
||||
nsAutoString key;
|
||||
for (; i != limit; i += step) {
|
||||
// Get lower-cased key
|
||||
const nsAString& key = aNode.GetKeyAt(i);
|
||||
// Copy up-front to avoid shared-buffer overhead (and convert to UTF-8
|
||||
// at the same time since that's what the atom table uses).
|
||||
CopyUTF16toUTF8(key, k);
|
||||
ToLowerCase(k);
|
||||
nsContentUtils::ASCIIToLower(aNode.GetKeyAt(i), key);
|
||||
|
||||
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(k);
|
||||
nsCOMPtr<nsIAtom> keyAtom = do_GetAtom(key);
|
||||
|
||||
if (aCheckIfPresent && aContent->HasAttr(kNameSpaceID_None, keyAtom)) {
|
||||
continue;
|
||||
|
@ -643,9 +643,8 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation(
|
||||
// overlap, 'auto' = 'CSS'. (SMILANIM 3.1)
|
||||
PRBool isCSS;
|
||||
if (attributeType == eSMILTargetAttrType_auto) {
|
||||
nsAutoString attributeNameStr;
|
||||
attributeName->ToString(attributeNameStr);
|
||||
nsCSSProperty prop = nsCSSProps::LookupProperty(attributeNameStr);
|
||||
nsCSSProperty prop =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName));
|
||||
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
|
||||
} else {
|
||||
isCSS = (attributeType == eSMILTargetAttrType_CSS);
|
||||
|
@ -149,9 +149,8 @@ nsISMILAttr*
|
||||
nsSMILCompositor::CreateSMILAttr()
|
||||
{
|
||||
if (mKey.mIsCSS) {
|
||||
nsAutoString name;
|
||||
mKey.mAttributeName->ToString(name);
|
||||
nsCSSProperty propId = nsCSSProps::LookupProperty(name);
|
||||
nsCSSProperty propId =
|
||||
nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName));
|
||||
if (nsSMILCSSProperty::IsPropertyAnimatable(propId)) {
|
||||
return new nsSMILCSSProperty(propId, mKey.mElement.get());
|
||||
}
|
||||
|
@ -1087,16 +1087,13 @@ nsSVGElement::UpdateContentStyleRule()
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
attrName->Atom()->ToString(name);
|
||||
|
||||
nsAutoString value;
|
||||
mAttrsAndChildren.AttrAt(i)->ToString(value);
|
||||
|
||||
PRBool changed;
|
||||
parser.ParseProperty(nsCSSProps::LookupProperty(name), value,
|
||||
docURI, baseURI, NodePrincipal(),
|
||||
declaration, &changed);
|
||||
parser.ParseProperty(
|
||||
nsCSSProps::LookupProperty(nsAtomString(attrName->Atom())), value,
|
||||
docURI, baseURI, NodePrincipal(), declaration, &changed);
|
||||
}
|
||||
|
||||
if (declaration) {
|
||||
@ -1736,10 +1733,9 @@ nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
|
||||
nsIAtom* aAttribute,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
nsAutoString attributeName;
|
||||
aAttribute->ToString(attributeName);
|
||||
const nsAFlatString& attributeValue = PromiseFlatString(aValue);
|
||||
const PRUnichar *strings[] = { attributeName.get(), attributeValue.get() };
|
||||
const PRUnichar *strings[] = { aAttribute->GetUTF16String(),
|
||||
attributeValue.get() };
|
||||
return nsSVGUtils::ReportToConsole(aDocument,
|
||||
"AttributeParseWarning",
|
||||
strings, NS_ARRAY_LENGTH(strings));
|
||||
|
@ -342,9 +342,7 @@ nsSVGLength::GetValueAsString(nsAString & aValueAsString)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsAutoString unitString;
|
||||
UnitAtom->ToString(unitString);
|
||||
aValueAsString.Append(unitString);
|
||||
aValueAsString.Append(nsDependentAtomString(UnitAtom));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -851,9 +851,6 @@ nsXBLBinding::InstallEventHandlers()
|
||||
eventAtom == nsGkAtoms::keypress)
|
||||
continue;
|
||||
|
||||
nsAutoString type;
|
||||
eventAtom->ToString(type);
|
||||
|
||||
// If this is a command, add it in the system event group, otherwise
|
||||
// add it to the standard event group.
|
||||
|
||||
@ -879,7 +876,9 @@ nsXBLBinding::InstallEventHandlers()
|
||||
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
|
||||
}
|
||||
|
||||
manager->AddEventListenerByType(handler, type, flags, eventGroup);
|
||||
manager->AddEventListenerByType(handler,
|
||||
nsDependentAtomString(eventAtom),
|
||||
flags, eventGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,9 +1014,6 @@ nsXBLBinding::UnhookEventHandlers()
|
||||
eventAtom == nsGkAtoms::keypress)
|
||||
continue;
|
||||
|
||||
nsAutoString type;
|
||||
eventAtom->ToString(type);
|
||||
|
||||
// Figure out if we're using capturing or not.
|
||||
PRInt32 flags = (curr->GetPhase() == NS_PHASE_CAPTURING) ?
|
||||
NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
||||
@ -1035,7 +1031,9 @@ nsXBLBinding::UnhookEventHandlers()
|
||||
eventGroup = systemEventGroup;
|
||||
}
|
||||
|
||||
manager->RemoveEventListenerByType(handler, type, flags, eventGroup);
|
||||
manager->RemoveEventListenerByType(handler,
|
||||
nsDependentAtomString(eventAtom),
|
||||
flags, eventGroup);
|
||||
}
|
||||
|
||||
const nsCOMArray<nsXBLKeyEventHandler>* keyHandlers =
|
||||
|
@ -260,11 +260,8 @@ nsXBLPrototypeHandler::ExecuteHandler(nsPIDOMEventTarget* aTarget,
|
||||
|
||||
// Look for a compiled handler on the element.
|
||||
// Should be compiled and bound with "on" in front of the name.
|
||||
nsAutoString onEvent(NS_LITERAL_STRING("onxbl"));
|
||||
nsAutoString str;
|
||||
mEventName->ToString(str);
|
||||
onEvent += str;
|
||||
nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(onEvent);
|
||||
nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(NS_LITERAL_STRING("onxbl") +
|
||||
nsDependentAtomString(mEventName));
|
||||
|
||||
// Compile the event handler.
|
||||
PRUint32 stID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
@ -442,10 +439,7 @@ nsXBLPrototypeHandler::DispatchXBLCommand(nsPIDOMEventTarget* aTarget, nsIDOMEve
|
||||
else
|
||||
controller = GetController(aTarget); // We're attached to the receiver possibly.
|
||||
|
||||
nsAutoString type;
|
||||
mEventName->ToString(type);
|
||||
|
||||
if (type.EqualsLiteral("keypress") &&
|
||||
if (mEventName == nsGkAtoms::keypress &&
|
||||
mDetail == nsIDOMKeyEvent::DOM_VK_SPACE &&
|
||||
mMisc == 1) {
|
||||
// get the focused element so that we can pageDown only at
|
||||
|
@ -179,17 +179,17 @@ txExprLexer::parse(const nsASingleFragmentString& aPattern)
|
||||
}
|
||||
}
|
||||
if (nextIsOperatorToken(prevToken)) {
|
||||
NS_ConvertUTF16toUTF8 opUTF8(Substring(start, mPosition));
|
||||
if (txXPathAtoms::_and->EqualsUTF8(opUTF8)) {
|
||||
nsDependentSubstring op(Substring(start, mPosition));
|
||||
if (txXPathAtoms::_and->Equals(op)) {
|
||||
defType = Token::AND_OP;
|
||||
}
|
||||
else if (txXPathAtoms::_or->EqualsUTF8(opUTF8)) {
|
||||
else if (txXPathAtoms::_or->Equals(op)) {
|
||||
defType = Token::OR_OP;
|
||||
}
|
||||
else if (txXPathAtoms::mod->EqualsUTF8(opUTF8)) {
|
||||
else if (txXPathAtoms::mod->Equals(op)) {
|
||||
defType = Token::MODULUS_OP;
|
||||
}
|
||||
else if (txXPathAtoms::div->EqualsUTF8(opUTF8)) {
|
||||
else if (txXPathAtoms::div->Equals(op)) {
|
||||
defType = Token::DIVIDE_OP;
|
||||
}
|
||||
else {
|
||||
|
@ -146,15 +146,15 @@ void
|
||||
FunctionCall::toString(nsAString& aDest)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> functionNameAtom;
|
||||
nsAutoString functionName;
|
||||
if (NS_FAILED(getNameAtom(getter_AddRefs(functionNameAtom))) ||
|
||||
NS_FAILED(functionNameAtom->ToString(functionName))) {
|
||||
if (NS_FAILED(getNameAtom(getter_AddRefs(functionNameAtom)))) {
|
||||
NS_ERROR("Can't get function name.");
|
||||
return;
|
||||
}
|
||||
|
||||
aDest.Append(functionName);
|
||||
aDest.Append(PRUnichar('('));
|
||||
|
||||
|
||||
aDest.Append(nsDependentAtomString(functionNameAtom) +
|
||||
NS_LITERAL_STRING("("));
|
||||
for (PRUint32 i = 0; i < mParams.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aDest.Append(PRUnichar(','));
|
||||
|
@ -827,13 +827,13 @@ txXPathNativeNode::getNode(const txXPathNode& aNode, nsIDOMNode** aResult)
|
||||
|
||||
const nsAttrName* name = aNode.Content()->GetAttrNameAt(aNode.mIndex);
|
||||
|
||||
nsAutoString namespaceURI, localname;
|
||||
nsAutoString namespaceURI;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(name->NamespaceID(), namespaceURI);
|
||||
name->LocalName()->ToString(localname);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode.mNode);
|
||||
nsCOMPtr<nsIDOMAttr> attr;
|
||||
element->GetAttributeNodeNS(namespaceURI, localname,
|
||||
element->GetAttributeNodeNS(namespaceURI,
|
||||
nsDependentAtomString(name->LocalName()),
|
||||
getter_AddRefs(attr));
|
||||
|
||||
return CallQueryInterface(attr, aResult);
|
||||
|
@ -99,9 +99,9 @@ txUnknownHandler::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
|
||||
// Use aLocalName and not aLowercaseLocalName in case the output
|
||||
// handler cares about case. For eHTMLOutput the handler will hardcode
|
||||
// to 'html' anyway.
|
||||
nsAutoString name;
|
||||
aLocalName->ToString(name);
|
||||
nsresult rv = createHandlerAndFlush(htmlRoot, name, aNsID);
|
||||
nsresult rv = createHandlerAndFlush(htmlRoot,
|
||||
nsDependentAtomString(aLocalName),
|
||||
aNsID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mEs->mResultHandler->startElement(aPrefix, aLocalName,
|
||||
|
@ -1161,9 +1161,8 @@ nsXULElement::ParseAttribute(PRInt32 aNamespaceID,
|
||||
const nsAttrName*
|
||||
nsXULElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
{
|
||||
NS_ConvertUTF16toUTF8 name(aStr);
|
||||
const nsAttrName* attrName =
|
||||
mAttrsAndChildren.GetExistingAttrNameFromQName(name);
|
||||
mAttrsAndChildren.GetExistingAttrNameFromQName(aStr);
|
||||
if (attrName) {
|
||||
return attrName;
|
||||
}
|
||||
@ -1172,7 +1171,7 @@ nsXULElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mPrototype->mNumAttributes; ++i) {
|
||||
attrName = &mPrototype->mAttributes[i].mName;
|
||||
if (attrName->QualifiedNameEquals(name)) {
|
||||
if (attrName->QualifiedNameEquals(aStr)) {
|
||||
return attrName;
|
||||
}
|
||||
}
|
||||
@ -1320,11 +1319,9 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
if (hasMutationListeners) {
|
||||
nsAutoString attrName;
|
||||
aName->ToString(attrName);
|
||||
nsAutoString ns;
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns);
|
||||
GetAttributeNodeNS(ns, attrName, getter_AddRefs(attrNode));
|
||||
GetAttributeNodeNS(ns, nsDependentAtomString(aName), getter_AddRefs(attrNode));
|
||||
}
|
||||
|
||||
nsDOMSlots *slots = GetExistingDOMSlots();
|
||||
|
@ -1071,12 +1071,8 @@ nsXULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
nsAutoString persist;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist);
|
||||
if (!persist.IsEmpty()) {
|
||||
nsAutoString attr;
|
||||
rv = aAttribute->ToString(attr);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// XXXldb This should check that it's a token, not just a substring.
|
||||
if (persist.Find(attr) >= 0) {
|
||||
if (persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
|
||||
rv = Persist(aElement, kNameSpaceID_None, aAttribute);
|
||||
if (NS_FAILED(rv)) return;
|
||||
}
|
||||
@ -4186,17 +4182,12 @@ nsXULDocument::BroadcasterHookup::~BroadcasterHookup()
|
||||
attribute.AssignLiteral("*");
|
||||
}
|
||||
|
||||
nsAutoString tagStr;
|
||||
rv = tag->ToString(tagStr);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCAutoString tagstrC, attributeC,broadcasteridC;
|
||||
tagstrC.AssignWithConversion(tagStr);
|
||||
nsCAutoString attributeC,broadcasteridC;
|
||||
attributeC.AssignWithConversion(attribute);
|
||||
broadcasteridC.AssignWithConversion(broadcasterID);
|
||||
PR_LOG(gXULLog, PR_LOG_WARNING,
|
||||
("xul: broadcaster hookup failed <%s attribute='%s'> to %s",
|
||||
tagstrC.get(),
|
||||
nsAtomCString(tag).get(),
|
||||
attributeC.get(),
|
||||
broadcasteridC.get()));
|
||||
}
|
||||
@ -4366,17 +4357,12 @@ nsXULDocument::CheckBroadcasterHookup(nsIContent* aElement,
|
||||
if (! content)
|
||||
return rv;
|
||||
|
||||
nsAutoString tagStr;
|
||||
rv = content->Tag()->ToString(tagStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString tagstrC, attributeC,broadcasteridC;
|
||||
tagstrC.AssignWithConversion(tagStr);
|
||||
nsCAutoString attributeC,broadcasteridC;
|
||||
attributeC.AssignWithConversion(attribute);
|
||||
broadcasteridC.AssignWithConversion(broadcasterID);
|
||||
PR_LOG(gXULLog, PR_LOG_NOTICE,
|
||||
("xul: broadcaster hookup <%s attribute='%s'> to %s",
|
||||
tagstrC.get(),
|
||||
nsAtomCString(content->Tag()).get(),
|
||||
attributeC.get(),
|
||||
broadcasteridC.get()));
|
||||
}
|
||||
|
@ -395,13 +395,8 @@ nsXULContentUtils::GetResource(PRInt32 aNameSpaceID, nsIAtom* aAttribute, nsIRDF
|
||||
if (! aAttribute)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString attr;
|
||||
rv = aAttribute->ToString(attr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return GetResource(aNameSpaceID, attr, aResult);
|
||||
return GetResource(aNameSpaceID, nsDependentAtomString(aAttribute),
|
||||
aResult);
|
||||
}
|
||||
|
||||
|
||||
|
@ -652,9 +652,9 @@ nsXULTemplateQueryProcessorRDF::TranslateRef(nsISupports* aDatasource,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTemplateQueryProcessorRDF::CompareResults(nsIXULTemplateResult* aLeft,
|
||||
nsIXULTemplateResult* aRight,
|
||||
nsIAtom* aVar,
|
||||
PRInt32* aResult)
|
||||
nsIXULTemplateResult* aRight,
|
||||
nsIAtom* aVar,
|
||||
PRInt32* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLeft);
|
||||
NS_ENSURE_ARG_POINTER(aRight);
|
||||
@ -673,8 +673,7 @@ nsXULTemplateQueryProcessorRDF::CompareResults(nsIXULTemplateResult* aLeft,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString sortkey;
|
||||
aVar->ToString(sortkey);
|
||||
nsDependentAtomString sortkey(aVar);
|
||||
|
||||
nsCOMPtr<nsISupports> leftNode, rightNode;
|
||||
|
||||
|
@ -9113,9 +9113,7 @@ nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState& aState,
|
||||
// no? And if we cared we could look through the item list
|
||||
// instead of groveling through the framelist here..
|
||||
nsIContent *badKid = AnyKidsNeedBlockParent(aFrameItems.FirstChild());
|
||||
nsAutoString parentTag, kidTag;
|
||||
aContent->Tag()->ToString(parentTag);
|
||||
badKid->Tag()->ToString(kidTag);
|
||||
nsDependentAtomString parentTag(aContent->Tag()), kidTag(badKid->Tag());
|
||||
const PRUnichar* params[] = { parentTag.get(), kidTag.get() };
|
||||
nsStyleContext *frameStyleContext = aFrame->GetStyleContext();
|
||||
const nsStyleDisplay *display = frameStyleContext->GetStyleDisplay();
|
||||
|
@ -699,8 +699,7 @@ inDOMView::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
|
||||
nsCOMPtr<nsIDOMNode> content(do_QueryInterface(aContent));
|
||||
nsCOMPtr<nsIDOMElement> el(do_QueryInterface(aContent));
|
||||
nsCOMPtr<nsIDOMAttr> domAttr;
|
||||
nsAutoString attrStr;
|
||||
aAttribute->ToString(attrStr);
|
||||
nsDependentAtomString attrStr(aAttribute);
|
||||
if (aNameSpaceID) {
|
||||
nsCOMPtr<nsINameSpaceManager> nsm =
|
||||
do_GetService(NS_NAMESPACEMANAGER_CONTRACTID);
|
||||
|
@ -1441,10 +1441,7 @@ CSSNameSpaceRuleImpl::GetCssText(nsAString& aCssText)
|
||||
{
|
||||
aCssText.AssignLiteral("@namespace ");
|
||||
if (mPrefix) {
|
||||
nsString atomStr;
|
||||
mPrefix->ToString(atomStr);
|
||||
aCssText.Append(atomStr);
|
||||
aCssText.AppendLiteral(" ");
|
||||
aCssText.Append(nsDependentAtomString(mPrefix) + NS_LITERAL_STRING(" "));
|
||||
}
|
||||
aCssText.AppendLiteral("url(");
|
||||
nsStyleUtil::AppendEscapedCSSString(mURLSpec, aCssText);
|
||||
|
@ -595,9 +595,8 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations
|
||||
nsIAtom *prefixAtom = sheetNS->FindPrefix(mNameSpace);
|
||||
NS_ASSERTION(prefixAtom, "how'd we get a non-default namespace "
|
||||
"without a prefix?");
|
||||
nsAutoString prefix;
|
||||
prefixAtom->ToString(prefix);
|
||||
nsStyleUtil::AppendEscapedCSSIdent(prefix, aString);
|
||||
nsStyleUtil::AppendEscapedCSSIdent(nsDependentAtomString(prefixAtom),
|
||||
aString);
|
||||
aString.Append(PRUnichar('|'));
|
||||
wroteNamespace = PR_TRUE;
|
||||
} else {
|
||||
|
@ -375,8 +375,6 @@ nsMediaQueryResultCacheKey::Matches(nsPresContext* aPresContext) const
|
||||
void
|
||||
nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
{
|
||||
nsAutoString buffer;
|
||||
|
||||
if (mHadUnknownExpression) {
|
||||
aString.AppendLiteral("not all");
|
||||
return;
|
||||
@ -391,9 +389,7 @@ nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
} else if (mHasOnly) {
|
||||
aString.AppendLiteral("only ");
|
||||
}
|
||||
mMediaType->ToString(buffer);
|
||||
aString.Append(buffer);
|
||||
buffer.Truncate();
|
||||
aString.Append(nsDependentAtomString(mMediaType));
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0, i_end = mExpressions.Length(); i < i_end; ++i) {
|
||||
@ -409,9 +405,7 @@ nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
}
|
||||
|
||||
const nsMediaFeature *feature = expr.mFeature;
|
||||
(*feature->mName)->ToString(buffer);
|
||||
aString.Append(buffer);
|
||||
buffer.Truncate();
|
||||
aString.Append(nsDependentAtomString(*feature->mName));
|
||||
|
||||
if (expr.mValue.GetUnit() != eCSSUnit_Null) {
|
||||
aString.AppendLiteral(": ");
|
||||
@ -450,15 +444,18 @@ nsMediaQuery::AppendToString(nsAString& aString) const
|
||||
}
|
||||
break;
|
||||
case nsMediaFeature::eResolution:
|
||||
buffer.AppendFloat(expr.mValue.GetFloatValue());
|
||||
aString.Append(buffer);
|
||||
buffer.Truncate();
|
||||
if (expr.mValue.GetUnit() == eCSSUnit_Inch) {
|
||||
aString.AppendLiteral("dpi");
|
||||
} else {
|
||||
NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Centimeter,
|
||||
"bad unit");
|
||||
aString.AppendLiteral("dpcm");
|
||||
{
|
||||
nsAutoString buffer;
|
||||
buffer.AppendFloat(expr.mValue.GetFloatValue());
|
||||
aString.Append(buffer);
|
||||
buffer.Truncate();
|
||||
if (expr.mValue.GetUnit() == eCSSUnit_Inch) {
|
||||
aString.AppendLiteral("dpi");
|
||||
} else {
|
||||
NS_ASSERTION(expr.mValue.GetUnit() == eCSSUnit_Centimeter,
|
||||
"bad unit");
|
||||
aString.AppendLiteral("dpcm");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case nsMediaFeature::eEnumerated:
|
||||
|
@ -223,9 +223,8 @@ public:
|
||||
|
||||
NS_IMETHODIMP Run()
|
||||
{
|
||||
nsAutoString which;
|
||||
mWhich->ToString(which);
|
||||
return mListener->ValueChanged(which, mValue, mUserChanged);
|
||||
return mListener->ValueChanged(nsDependentAtomString(mWhich),
|
||||
mValue, mUserChanged);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISliderListener> mListener;
|
||||
|
@ -65,10 +65,7 @@ NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
||||
PRInt32
|
||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aAtom->ToString(tagName);
|
||||
|
||||
return nsHTMLTags::LookupTag(tagName);
|
||||
return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom));
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
Loading…
x
Reference in New Issue
Block a user