From a965de089e34b523e394476073344061c0eeb742 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Fri, 2 Jun 2000 22:54:35 +0000 Subject: [PATCH] Bug 41321. Use PRUnichar* instead of nsString* to store string values for nsCSSValue and nsHTMLValue. r=attinasi. --- content/base/src/nsHTMLValue.cpp | 16 ++++++++-------- content/base/src/nsHTMLValue.h | 13 ++++++++----- content/html/style/src/nsCSSValue.cpp | 14 +++++++------- content/html/style/src/nsCSSValue.h | 10 +++++----- content/html/style/src/nsHTMLValue.cpp | 16 ++++++++-------- content/html/style/src/nsHTMLValue.h | 13 ++++++++----- content/shared/public/nsHTMLValue.h | 13 ++++++++----- content/shared/src/nsHTMLValue.cpp | 16 ++++++++-------- layout/html/style/src/nsCSSValue.cpp | 14 +++++++------- layout/html/style/src/nsCSSValue.h | 10 +++++----- layout/html/style/src/nsHTMLValue.cpp | 16 ++++++++-------- layout/html/style/src/nsHTMLValue.h | 13 ++++++++----- layout/style/nsCSSValue.cpp | 14 +++++++------- layout/style/nsCSSValue.h | 10 +++++----- 14 files changed, 100 insertions(+), 88 deletions(-) diff --git a/content/base/src/nsHTMLValue.cpp b/content/base/src/nsHTMLValue.cpp index a86f70b92532..0e8d718f9821 100644 --- a/content/base/src/nsHTMLValue.cpp +++ b/content/base/src/nsHTMLValue.cpp @@ -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 { diff --git a/content/base/src/nsHTMLValue.h b/content/base/src/nsHTMLValue.h index 39d5cd557ce4..0592eb6c4c7c 100644 --- a/content/base/src/nsHTMLValue.h +++ b/content/base/src/nsHTMLValue.h @@ -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) { - PRInt32 err=0; - return (mValue.mString) ? mValue.mString->ToInteger(&err):0; + if (mValue.mString) { + PRInt32 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; } } diff --git a/content/html/style/src/nsCSSValue.cpp b/content/html/style/src/nsCSSValue.cpp index 945e64b1ec2b..7ac11d675c75 100644 --- a/content/html/style/src/nsCSSValue.cpp +++ b/content/html/style/src/nsCSSValue.cpp @@ -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 { diff --git a/content/html/style/src/nsCSSValue.h b/content/html/style/src/nsCSSValue.h index 13527ed48fb4..70f11fe34f08 100644 --- a/content/html/style/src/nsCSSValue.h +++ b/content/html/style/src/nsCSSValue.h @@ -144,10 +144,10 @@ public: protected: nsCSSUnit mUnit; union { - PRInt32 mInt; - float mFloat; - nsString* mString; - nscolor mColor; + PRInt32 mInt; + float mFloat; + 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; } diff --git a/content/html/style/src/nsHTMLValue.cpp b/content/html/style/src/nsHTMLValue.cpp index a86f70b92532..0e8d718f9821 100644 --- a/content/html/style/src/nsHTMLValue.cpp +++ b/content/html/style/src/nsHTMLValue.cpp @@ -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 { diff --git a/content/html/style/src/nsHTMLValue.h b/content/html/style/src/nsHTMLValue.h index 39d5cd557ce4..0592eb6c4c7c 100644 --- a/content/html/style/src/nsHTMLValue.h +++ b/content/html/style/src/nsHTMLValue.h @@ -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) { - PRInt32 err=0; - return (mValue.mString) ? mValue.mString->ToInteger(&err):0; + if (mValue.mString) { + PRInt32 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; } } diff --git a/content/shared/public/nsHTMLValue.h b/content/shared/public/nsHTMLValue.h index 39d5cd557ce4..0592eb6c4c7c 100644 --- a/content/shared/public/nsHTMLValue.h +++ b/content/shared/public/nsHTMLValue.h @@ -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) { - PRInt32 err=0; - return (mValue.mString) ? mValue.mString->ToInteger(&err):0; + if (mValue.mString) { + PRInt32 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; } } diff --git a/content/shared/src/nsHTMLValue.cpp b/content/shared/src/nsHTMLValue.cpp index a86f70b92532..0e8d718f9821 100644 --- a/content/shared/src/nsHTMLValue.cpp +++ b/content/shared/src/nsHTMLValue.cpp @@ -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 { diff --git a/layout/html/style/src/nsCSSValue.cpp b/layout/html/style/src/nsCSSValue.cpp index 945e64b1ec2b..7ac11d675c75 100644 --- a/layout/html/style/src/nsCSSValue.cpp +++ b/layout/html/style/src/nsCSSValue.cpp @@ -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 { diff --git a/layout/html/style/src/nsCSSValue.h b/layout/html/style/src/nsCSSValue.h index 13527ed48fb4..70f11fe34f08 100644 --- a/layout/html/style/src/nsCSSValue.h +++ b/layout/html/style/src/nsCSSValue.h @@ -144,10 +144,10 @@ public: protected: nsCSSUnit mUnit; union { - PRInt32 mInt; - float mFloat; - nsString* mString; - nscolor mColor; + PRInt32 mInt; + float mFloat; + 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; } diff --git a/layout/html/style/src/nsHTMLValue.cpp b/layout/html/style/src/nsHTMLValue.cpp index a86f70b92532..0e8d718f9821 100644 --- a/layout/html/style/src/nsHTMLValue.cpp +++ b/layout/html/style/src/nsHTMLValue.cpp @@ -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 { diff --git a/layout/html/style/src/nsHTMLValue.h b/layout/html/style/src/nsHTMLValue.h index 39d5cd557ce4..0592eb6c4c7c 100644 --- a/layout/html/style/src/nsHTMLValue.h +++ b/layout/html/style/src/nsHTMLValue.h @@ -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) { - PRInt32 err=0; - return (mValue.mString) ? mValue.mString->ToInteger(&err):0; + if (mValue.mString) { + PRInt32 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; } } diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 945e64b1ec2b..7ac11d675c75 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -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 { diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index 13527ed48fb4..70f11fe34f08 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -144,10 +144,10 @@ public: protected: nsCSSUnit mUnit; union { - PRInt32 mInt; - float mFloat; - nsString* mString; - nscolor mColor; + PRInt32 mInt; + float mFloat; + 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; }