зеркало из https://github.com/mozilla/gecko-dev.git
Bug 41321. Use PRUnichar* instead of nsString* to store string values for nsCSSValue and nsHTMLValue. r=attinasi.
This commit is contained in:
Родитель
c03d90e200
Коммит
a965de089e
|
@ -67,7 +67,7 @@ nsHTMLValue::nsHTMLValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
(eHTMLUnit_ColorName == aUnit), "not a string value");
|
||||
if ((eHTMLUnit_String == aUnit) ||
|
||||
(eHTMLUnit_ColorName == aUnit)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eHTMLUnit_Null;
|
||||
|
@ -93,7 +93,7 @@ nsHTMLValue::nsHTMLValue(const nsHTMLValue& aCopy)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -125,7 +125,7 @@ nsHTMLValue& nsHTMLValue::operator=(const nsHTMLValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -154,7 +154,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->EqualsIgnoreCase(*(aOther.mValue.mString));
|
||||
return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -178,7 +178,7 @@ PRUint32 nsHTMLValue::HashValue(void) const
|
|||
return PRUint32(mUnit) ^
|
||||
((((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) &&
|
||||
(nsnull != mValue.mString)) ?
|
||||
nsCRT::HashValue(mValue.mString->GetUnicode()) :
|
||||
nsCRT::HashValue(mValue.mString) :
|
||||
mValue.mInt);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void nsHTMLValue::Reset(void)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -231,7 +231,7 @@ void nsHTMLValue::SetStringValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
Reset();
|
||||
if ((eHTMLUnit_String == aUnit) || (eHTMLUnit_ColorName == aUnit)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void nsHTMLValue::AppendToString(nsString& aBuffer) const
|
|||
else if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nsISupports* mISupports;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
|
@ -102,8 +102,11 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
|||
return mValue.mInt;
|
||||
}
|
||||
else if (mUnit == eHTMLUnit_String) {
|
||||
if (mValue.mString) {
|
||||
PRInt32 err=0;
|
||||
return (mValue.mString) ? mValue.mString->ToInteger(&err):0;
|
||||
nsAutoString str = mValue.mString; // XXX copy. new string APIs will make this better, right?
|
||||
return str.ToInteger(&err);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,7 +136,7 @@ inline nsString& nsHTMLValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.SetLength(0);
|
||||
if (((mUnit == eHTMLUnit_String) || (mUnit == eHTMLUnit_ColorName)) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ inline nscolor nsHTMLValue::GetColorValue(void) const
|
|||
}
|
||||
if ((mUnit == eHTMLUnit_ColorName) && (mValue.mString)) {
|
||||
nscolor color;
|
||||
if (NS_ColorNameToRGB(*(mValue.mString), &color)) {
|
||||
if (NS_ColorNameToRGB(nsAutoString(mValue.mString), &color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ nsCSSValue::nsCSSValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
{
|
||||
NS_ASSERTION((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters), "not a string value");
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eCSSUnit_Null;
|
||||
|
@ -89,7 +89,7 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -117,7 +117,7 @@ nsCSSValue& nsCSSValue::operator=(const nsCSSValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -142,7 +142,7 @@ PRBool nsCSSValue::operator==(const nsCSSValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->Equals(*(aOther.mValue.mString));
|
||||
return nsCRT::strcmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -200,7 +200,7 @@ void nsCSSValue::Reset(void)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
mUnit = eCSSUnit_Null;
|
||||
mValue.mInt = 0;
|
||||
|
@ -241,7 +241,7 @@ void nsCSSValue::SetStringValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
Reset();
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ void nsCSSValue::AppendToString(nsString& aBuffer, nsCSSProperty aPropID) const
|
|||
}
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
};
|
||||
|
@ -186,7 +186,7 @@ inline nsString& nsCSSValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.Truncate();
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ nsHTMLValue::nsHTMLValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
(eHTMLUnit_ColorName == aUnit), "not a string value");
|
||||
if ((eHTMLUnit_String == aUnit) ||
|
||||
(eHTMLUnit_ColorName == aUnit)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eHTMLUnit_Null;
|
||||
|
@ -93,7 +93,7 @@ nsHTMLValue::nsHTMLValue(const nsHTMLValue& aCopy)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -125,7 +125,7 @@ nsHTMLValue& nsHTMLValue::operator=(const nsHTMLValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -154,7 +154,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->EqualsIgnoreCase(*(aOther.mValue.mString));
|
||||
return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -178,7 +178,7 @@ PRUint32 nsHTMLValue::HashValue(void) const
|
|||
return PRUint32(mUnit) ^
|
||||
((((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) &&
|
||||
(nsnull != mValue.mString)) ?
|
||||
nsCRT::HashValue(mValue.mString->GetUnicode()) :
|
||||
nsCRT::HashValue(mValue.mString) :
|
||||
mValue.mInt);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void nsHTMLValue::Reset(void)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -231,7 +231,7 @@ void nsHTMLValue::SetStringValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
Reset();
|
||||
if ((eHTMLUnit_String == aUnit) || (eHTMLUnit_ColorName == aUnit)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void nsHTMLValue::AppendToString(nsString& aBuffer) const
|
|||
else if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nsISupports* mISupports;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
|
@ -102,8 +102,11 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
|||
return mValue.mInt;
|
||||
}
|
||||
else if (mUnit == eHTMLUnit_String) {
|
||||
if (mValue.mString) {
|
||||
PRInt32 err=0;
|
||||
return (mValue.mString) ? mValue.mString->ToInteger(&err):0;
|
||||
nsAutoString str = mValue.mString; // XXX copy. new string APIs will make this better, right?
|
||||
return str.ToInteger(&err);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,7 +136,7 @@ inline nsString& nsHTMLValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.SetLength(0);
|
||||
if (((mUnit == eHTMLUnit_String) || (mUnit == eHTMLUnit_ColorName)) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ inline nscolor nsHTMLValue::GetColorValue(void) const
|
|||
}
|
||||
if ((mUnit == eHTMLUnit_ColorName) && (mValue.mString)) {
|
||||
nscolor color;
|
||||
if (NS_ColorNameToRGB(*(mValue.mString), &color)) {
|
||||
if (NS_ColorNameToRGB(nsAutoString(mValue.mString), &color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nsISupports* mISupports;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
|
@ -102,8 +102,11 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
|||
return mValue.mInt;
|
||||
}
|
||||
else if (mUnit == eHTMLUnit_String) {
|
||||
if (mValue.mString) {
|
||||
PRInt32 err=0;
|
||||
return (mValue.mString) ? mValue.mString->ToInteger(&err):0;
|
||||
nsAutoString str = mValue.mString; // XXX copy. new string APIs will make this better, right?
|
||||
return str.ToInteger(&err);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,7 +136,7 @@ inline nsString& nsHTMLValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.SetLength(0);
|
||||
if (((mUnit == eHTMLUnit_String) || (mUnit == eHTMLUnit_ColorName)) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ inline nscolor nsHTMLValue::GetColorValue(void) const
|
|||
}
|
||||
if ((mUnit == eHTMLUnit_ColorName) && (mValue.mString)) {
|
||||
nscolor color;
|
||||
if (NS_ColorNameToRGB(*(mValue.mString), &color)) {
|
||||
if (NS_ColorNameToRGB(nsAutoString(mValue.mString), &color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ nsHTMLValue::nsHTMLValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
(eHTMLUnit_ColorName == aUnit), "not a string value");
|
||||
if ((eHTMLUnit_String == aUnit) ||
|
||||
(eHTMLUnit_ColorName == aUnit)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eHTMLUnit_Null;
|
||||
|
@ -93,7 +93,7 @@ nsHTMLValue::nsHTMLValue(const nsHTMLValue& aCopy)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -125,7 +125,7 @@ nsHTMLValue& nsHTMLValue::operator=(const nsHTMLValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -154,7 +154,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->EqualsIgnoreCase(*(aOther.mValue.mString));
|
||||
return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -178,7 +178,7 @@ PRUint32 nsHTMLValue::HashValue(void) const
|
|||
return PRUint32(mUnit) ^
|
||||
((((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) &&
|
||||
(nsnull != mValue.mString)) ?
|
||||
nsCRT::HashValue(mValue.mString->GetUnicode()) :
|
||||
nsCRT::HashValue(mValue.mString) :
|
||||
mValue.mInt);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void nsHTMLValue::Reset(void)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -231,7 +231,7 @@ void nsHTMLValue::SetStringValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
Reset();
|
||||
if ((eHTMLUnit_String == aUnit) || (eHTMLUnit_ColorName == aUnit)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void nsHTMLValue::AppendToString(nsString& aBuffer) const
|
|||
else if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -70,7 +70,7 @@ nsCSSValue::nsCSSValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
{
|
||||
NS_ASSERTION((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters), "not a string value");
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eCSSUnit_Null;
|
||||
|
@ -89,7 +89,7 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -117,7 +117,7 @@ nsCSSValue& nsCSSValue::operator=(const nsCSSValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -142,7 +142,7 @@ PRBool nsCSSValue::operator==(const nsCSSValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->Equals(*(aOther.mValue.mString));
|
||||
return nsCRT::strcmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -200,7 +200,7 @@ void nsCSSValue::Reset(void)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
mUnit = eCSSUnit_Null;
|
||||
mValue.mInt = 0;
|
||||
|
@ -241,7 +241,7 @@ void nsCSSValue::SetStringValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
Reset();
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ void nsCSSValue::AppendToString(nsString& aBuffer, nsCSSProperty aPropID) const
|
|||
}
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
};
|
||||
|
@ -186,7 +186,7 @@ inline nsString& nsCSSValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.Truncate();
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ nsHTMLValue::nsHTMLValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
(eHTMLUnit_ColorName == aUnit), "not a string value");
|
||||
if ((eHTMLUnit_String == aUnit) ||
|
||||
(eHTMLUnit_ColorName == aUnit)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eHTMLUnit_Null;
|
||||
|
@ -93,7 +93,7 @@ nsHTMLValue::nsHTMLValue(const nsHTMLValue& aCopy)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -125,7 +125,7 @@ nsHTMLValue& nsHTMLValue::operator=(const nsHTMLValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = aCopy.mValue.mString->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -154,7 +154,7 @@ PRBool nsHTMLValue::operator==(const nsHTMLValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->EqualsIgnoreCase(*(aOther.mValue.mString));
|
||||
return 0 == nsCRT::strcasecmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -178,7 +178,7 @@ PRUint32 nsHTMLValue::HashValue(void) const
|
|||
return PRUint32(mUnit) ^
|
||||
((((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) &&
|
||||
(nsnull != mValue.mString)) ?
|
||||
nsCRT::HashValue(mValue.mString->GetUnicode()) :
|
||||
nsCRT::HashValue(mValue.mString) :
|
||||
mValue.mInt);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void nsHTMLValue::Reset(void)
|
|||
{
|
||||
if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
}
|
||||
else if (eHTMLUnit_ISupports == mUnit) {
|
||||
|
@ -231,7 +231,7 @@ void nsHTMLValue::SetStringValue(const nsString& aValue, nsHTMLUnit aUnit)
|
|||
Reset();
|
||||
if ((eHTMLUnit_String == aUnit) || (eHTMLUnit_ColorName == aUnit)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void nsHTMLValue::AppendToString(nsString& aBuffer) const
|
|||
else if ((eHTMLUnit_String == mUnit) || (eHTMLUnit_ColorName == mUnit)) {
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nsISupports* mISupports;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
|
@ -102,8 +102,11 @@ inline PRInt32 nsHTMLValue::GetIntValue(void) const
|
|||
return mValue.mInt;
|
||||
}
|
||||
else if (mUnit == eHTMLUnit_String) {
|
||||
if (mValue.mString) {
|
||||
PRInt32 err=0;
|
||||
return (mValue.mString) ? mValue.mString->ToInteger(&err):0;
|
||||
nsAutoString str = mValue.mString; // XXX copy. new string APIs will make this better, right?
|
||||
return str.ToInteger(&err);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,7 +136,7 @@ inline nsString& nsHTMLValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.SetLength(0);
|
||||
if (((mUnit == eHTMLUnit_String) || (mUnit == eHTMLUnit_ColorName)) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ inline nscolor nsHTMLValue::GetColorValue(void) const
|
|||
}
|
||||
if ((mUnit == eHTMLUnit_ColorName) && (mValue.mString)) {
|
||||
nscolor color;
|
||||
if (NS_ColorNameToRGB(*(mValue.mString), &color)) {
|
||||
if (NS_ColorNameToRGB(nsAutoString(mValue.mString), &color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ nsCSSValue::nsCSSValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
{
|
||||
NS_ASSERTION((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters), "not a string value");
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
else {
|
||||
mUnit = eCSSUnit_Null;
|
||||
|
@ -89,7 +89,7 @@ nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
else {
|
||||
mValue.mString = nsnull;
|
||||
|
@ -117,7 +117,7 @@ nsCSSValue& nsCSSValue::operator=(const nsCSSValue& aCopy)
|
|||
mUnit = aCopy.mUnit;
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters)) {
|
||||
if (nsnull != aCopy.mValue.mString) {
|
||||
mValue.mString = (aCopy.mValue.mString)->ToNewString();
|
||||
mValue.mString = nsCRT::strdup(aCopy.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -142,7 +142,7 @@ PRBool nsCSSValue::operator==(const nsCSSValue& aOther) const
|
|||
}
|
||||
}
|
||||
else if (nsnull != aOther.mValue.mString) {
|
||||
return mValue.mString->Equals(*(aOther.mValue.mString));
|
||||
return nsCRT::strcmp(mValue.mString, aOther.mValue.mString);
|
||||
}
|
||||
}
|
||||
else if ((eCSSUnit_Integer <= mUnit) && (mUnit <= eCSSUnit_Enumerated)) {
|
||||
|
@ -200,7 +200,7 @@ void nsCSSValue::Reset(void)
|
|||
{
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
delete mValue.mString;
|
||||
nsCRT::free(mValue.mString);
|
||||
}
|
||||
mUnit = eCSSUnit_Null;
|
||||
mValue.mInt = 0;
|
||||
|
@ -241,7 +241,7 @@ void nsCSSValue::SetStringValue(const nsString& aValue, nsCSSUnit aUnit)
|
|||
Reset();
|
||||
if ((eCSSUnit_String <= aUnit) && (aUnit <= eCSSUnit_Counters)) {
|
||||
mUnit = aUnit;
|
||||
mValue.mString = aValue.ToNewString();
|
||||
mValue.mString = aValue.ToNewUnicode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ void nsCSSValue::AppendToString(nsString& aBuffer, nsCSSProperty aPropID) const
|
|||
}
|
||||
if (nsnull != mValue.mString) {
|
||||
aBuffer.AppendWithConversion('"');
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
aBuffer.AppendWithConversion('"');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
union {
|
||||
PRInt32 mInt;
|
||||
float mFloat;
|
||||
nsString* mString;
|
||||
PRUnichar* mString;
|
||||
nscolor mColor;
|
||||
} mValue;
|
||||
};
|
||||
|
@ -186,7 +186,7 @@ inline nsString& nsCSSValue::GetStringValue(nsString& aBuffer) const
|
|||
aBuffer.Truncate();
|
||||
if ((eCSSUnit_String <= mUnit) && (mUnit <= eCSSUnit_Counters) &&
|
||||
(nsnull != mValue.mString)) {
|
||||
aBuffer.Append(*(mValue.mString));
|
||||
aBuffer.Append(mValue.mString);
|
||||
}
|
||||
return aBuffer;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче