diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 43c80b78a217..8f25dfa3c6fd 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -8120,7 +8120,7 @@ nsDOMStringMapSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, NS_ENSURE_SUCCESS(rv, rv); for (PRUint32 i = 0; i < properties.Length(); ++i) { - nsString& prop(properties[i]); + nsDependentString prop(properties[i]); *_retval = JS_DefineUCProperty(cx, obj, prop.get(), prop.Length(), JSVAL_VOID, nsnull, nsnull, JSPROP_ENUMERATE | JSPROP_SHARED); diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index a303eff13364..6fd4e0c2993b 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -922,7 +922,8 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const aResult.Append(NS_LITERAL_STRING("-moz-element(#")); nsAutoString tmpStr; GetStringValue(tmpStr); - nsStyleUtil::AppendEscapedCSSIdent(tmpStr, aResult); + nsStyleUtil::AppendEscapedCSSIdent( + nsDependentString(tmpStr), aResult); aResult.Append(NS_LITERAL_STRING(")")); } else if (eCSSUnit_Percent == unit) { diff --git a/netwerk/cookie/CookieServiceParent.cpp b/netwerk/cookie/CookieServiceParent.cpp index c2d3185c4a7e..47e72da16f19 100644 --- a/netwerk/cookie/CookieServiceParent.cpp +++ b/netwerk/cookie/CookieServiceParent.cpp @@ -95,9 +95,8 @@ CookieServiceParent::RecvSetCookieString(const IPC::URI& aHost, if (!hostURI) return false; - nsDependentCString cookieString(aCookieString, 0); mCookieService->SetCookieStringInternal(hostURI, aIsForeign, - cookieString, aServerTime, + aCookieString, aServerTime, aFromHttp); return true; } diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 93d4da4348ee..5893a06551df 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -1493,11 +1493,11 @@ nsCookieService::SetCookieStringCommon(nsIURI *aHostURI, } void -nsCookieService::SetCookieStringInternal(nsIURI *aHostURI, - bool aIsForeign, - nsDependentCString &aCookieHeader, - const nsCString &aServerTime, - PRBool aFromHttp) +nsCookieService::SetCookieStringInternal(nsIURI *aHostURI, + bool aIsForeign, + const nsCString &aCookieHeader, + const nsCString &aServerTime, + PRBool aFromHttp) { NS_ASSERTION(aHostURI, "null host!"); @@ -1550,8 +1550,9 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI, } // process each cookie in the header - while (SetCookieInternal(aHostURI, baseDomain, requireHostMatch, cookieStatus, - aCookieHeader, serverTime, aFromHttp)) { + nsDependentCString cookieHeader(aCookieHeader); + while (SetCookieInternal(aHostURI, baseDomain, requireHostMatch, + cookieStatus, cookieHeader, serverTime, aFromHttp)) { // document.cookie can only set one cookie at a time if (!aFromHttp) break; diff --git a/netwerk/cookie/nsCookieService.h b/netwerk/cookie/nsCookieService.h index 267ce7bc61e6..6fced2621b04 100644 --- a/netwerk/cookie/nsCookieService.h +++ b/netwerk/cookie/nsCookieService.h @@ -263,7 +263,7 @@ class nsCookieService : public nsICookieService nsresult GetCookieStringCommon(nsIURI *aHostURI, nsIChannel *aChannel, bool aHttpBound, char** aCookie); void GetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, PRBool aHttpBound, nsCString &aCookie); nsresult SetCookieStringCommon(nsIURI *aHostURI, const char *aCookieHeader, const char *aServerTime, nsIChannel *aChannel, bool aFromHttp); - void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, nsDependentCString &aCookieHeader, const nsCString &aServerTime, PRBool aFromHttp); + void SetCookieStringInternal(nsIURI *aHostURI, bool aIsForeign, const nsCString &aCookieHeader, const nsCString &aServerTime, PRBool aFromHttp); PRBool SetCookieInternal(nsIURI *aHostURI, const nsCString& aBaseDomain, PRBool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, PRInt64 aServerTime, PRBool aFromHttp); void AddInternal(const nsCString& aBaseDomain, nsCookie *aCookie, PRInt64 aCurrentTimeInUsec, nsIURI *aHostURI, const char *aCookieHeader, PRBool aFromHttp); void RemoveCookieFromList(const nsListIter &aIter, mozIStorageBindingParamsArray *aParamsArray = NULL); diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/widget/src/xpwidgets/nsXPLookAndFeel.cpp index d106e73bde4b..e698a1c4e776 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -330,7 +330,9 @@ nsXPLookAndFeel::ColorPrefChanged (unsigned int index, const char *prefName) if (!colorStr.IsEmpty()) { nscolor thecolor; if (colorStr[0] == PRUnichar('#')) { - if (NS_HexToRGB(nsDependentString(colorStr, 1), &thecolor)) { + if (NS_HexToRGB(nsDependentString( + Substring(colorStr, 1, colorStr.Length() - 1)), + &thecolor)) { PRInt32 id = NS_PTR_TO_INT32(index); CACHE_COLOR(id, thecolor); } diff --git a/xpcom/string/public/nsTDependentString.h b/xpcom/string/public/nsTDependentString.h index 818f7200d031..a9192e02a4c2 100644 --- a/xpcom/string/public/nsTDependentString.h +++ b/xpcom/string/public/nsTDependentString.h @@ -91,10 +91,11 @@ class nsTDependentString_CharT : public nsTString_CharT AssertValid(); } - nsTDependentString_CharT( const string_type& str, PRUint32 startPos ) - : string_type() + explicit + nsTDependentString_CharT( const substring_type& str ) + : string_type(const_cast(str.Data()), str.Length(), F_TERMINATED) { - Rebind(str, startPos); + AssertValid(); } // Create a nsTDependentSubstring to be bound later @@ -123,8 +124,6 @@ class nsTDependentString_CharT : public nsTString_CharT Rebind(start, PRUint32(end - start)); } - void Rebind( const string_type&, PRUint32 startPos ); - private: // NOT USED diff --git a/xpcom/string/src/nsTDependentString.cpp b/xpcom/string/src/nsTDependentString.cpp index 88a41f448fdb..f1dd21cc9262 100644 --- a/xpcom/string/src/nsTDependentString.cpp +++ b/xpcom/string/src/nsTDependentString.cpp @@ -48,20 +48,3 @@ nsTDependentString_CharT::Rebind( const char_type* data, size_type length ) SetDataFlags(F_TERMINATED); AssertValid(); } - -void -nsTDependentString_CharT::Rebind( const string_type& str, PRUint32 startPos ) - { - // If we currently own a buffer, release it. - Finalize(); - - size_type strLength = str.Length(); - - if (startPos > strLength) - startPos = strLength; - - mData = const_cast(str.Data()) + startPos; - mLength = strLength - startPos; - - SetDataFlags(F_TERMINATED); - }