Backout of bug 611503 because Android has some weird string code
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 14 Sep 2011 21:14:57 +0100
changeset 78269 f2a2adaaacba0f0b1d470430c4fb8f6fb6125fbf
parent 78268 6f8b4709a5086900076d18eaf5fd343ae08b8135
child 78270 f1eef5e80caf7271ef046bc0081da3c9088d1b0d
child 78295 b2c01d6dbd4afadc9a23df5abad2465c01c5025d
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs611503
milestone9.0a1
first release with
nightly linux32
f2a2adaaacba / 9.0a1 / 20110915030845 / files
nightly linux64
f2a2adaaacba / 9.0a1 / 20110915030845 / files
nightly mac
f2a2adaaacba / 9.0a1 / 20110915030845 / files
nightly win32
f2a2adaaacba / 9.0a1 / 20110915030845 / files
nightly win64
f2a2adaaacba / 9.0a1 / 20110915030845 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout of bug 611503 because Android has some weird string code
dom/base/nsDOMClassInfo.cpp
layout/style/nsCSSValue.cpp
netwerk/cookie/CookieServiceParent.cpp
netwerk/cookie/nsCookieService.cpp
netwerk/cookie/nsCookieService.h
widget/src/xpwidgets/nsXPLookAndFeel.cpp
xpcom/string/public/nsTDependentString.h
xpcom/string/src/nsTDependentString.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -8115,17 +8115,17 @@ nsDOMStringMapSH::Enumerate(nsIXPConnect
   NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
 
   nsDOMStringMap* stringMap = static_cast<nsDOMStringMap*>(dataset.get());
   nsTArray<nsString> properties;
   nsresult rv = stringMap->GetDataPropList(properties);
   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);
     NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
   }
 
   return NS_OK;
 }
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -917,17 +917,18 @@ nsCSSValue::AppendToString(nsCSSProperty
     nsStyleUtil::AppendEscapedCSSString(
       nsDependentString(GetOriginalURLValue()), aResult);
     aResult.Append(NS_LITERAL_STRING(")"));
   }
   else if (eCSSUnit_Element == unit) {
     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) {
     aResult.AppendFloat(GetPercentValue() * 100.0f);
   }
   else if (eCSSUnit_Percent < unit) {  // length unit
     aResult.AppendFloat(GetFloatValue());
   }
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -90,18 +90,17 @@ CookieServiceParent::RecvSetCookieString
     return true;
 
   // Deserialize URI. Having a host URI is mandatory and should always be
   // provided by the child; thus we consider failure fatal.
   nsCOMPtr<nsIURI> hostURI(aHost);
   if (!hostURI)
     return false;
 
-  nsDependentCString cookieString(aCookieString, 0);
   mCookieService->SetCookieStringInternal(hostURI, aIsForeign,
-                                          cookieString, aServerTime,
+                                          aCookieString, aServerTime,
                                           aFromHttp);
   return true;
 }
 
 }
 }
 
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -1488,21 +1488,21 @@ nsCookieService::SetCookieStringCommon(n
   nsDependentCString cookieString(aCookieHeader);
   nsDependentCString serverTime(aServerTime ? aServerTime : "");
   SetCookieStringInternal(aHostURI, isForeign, cookieString,
                           serverTime, aFromHttp);
   return NS_OK;
 }
 
 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!");
 
   if (!mDBState) {
     NS_WARNING("No DBState! Profile already closed?");
     return;
   }
 
@@ -1545,18 +1545,19 @@ nsCookieService::SetCookieStringInternal
                                        &tempServerTime);
   if (result == PR_SUCCESS) {
     serverTime = tempServerTime / PRInt64(PR_USEC_PER_SEC);
   } else {
     serverTime = PR_Now() / PR_USEC_PER_SEC;
   }
 
   // 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;
   }
 }
 
 // notify observers that a cookie was rejected due to the users' prefs.
 void
--- a/netwerk/cookie/nsCookieService.h
+++ b/netwerk/cookie/nsCookieService.h
@@ -258,17 +258,17 @@ class nsCookieService : public nsICookie
     void                          EnsureReadDomain(const nsCString &aBaseDomain);
     void                          EnsureReadComplete();
     nsresult                      NormalizeHost(nsCString &aHost);
     nsresult                      GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, PRBool &aRequireHostMatch);
     nsresult                      GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
     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);
     void                          AddCookieToList(const nsCString& aBaseDomain, nsCookie *aCookie, DBState *aDBState, mozIStorageBindingParamsArray *aParamsArray, PRBool aWriteToDB = PR_TRUE);
     void                          UpdateCookieInList(nsCookie *aCookie, PRInt64 aLastAccessed, mozIStorageBindingParamsArray *aParamsArray);
     static PRBool                 GetTokenValue(nsASingleFragmentCString::const_char_iterator &aIter, nsASingleFragmentCString::const_char_iterator &aEndIter, nsDependentCSubstring &aTokenString, nsDependentCSubstring &aTokenValue, PRBool &aEqualsFound);
     static PRBool                 ParseAttributes(nsDependentCString &aCookieHeader, nsCookieAttributes &aCookie);
     bool                          RequireThirdPartyCheck();
--- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp
@@ -325,17 +325,19 @@ nsXPLookAndFeel::ColorPrefChanged (unsig
   nsAutoString colorStr;
   nsresult rv = Preferences::GetString(prefName, &colorStr);
   if (NS_FAILED(rv)) {
     return;
   }
   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);
       }
     } else if (NS_ColorNameToRGB(colorStr, &thecolor)) {
       PRInt32 id = NS_PTR_TO_INT32(index);
       CACHE_COLOR(id, thecolor);
 #ifdef DEBUG_akkana
       printf("====== Changed color pref %s to 0x%lx\n",
--- a/xpcom/string/public/nsTDependentString.h
+++ b/xpcom/string/public/nsTDependentString.h
@@ -86,20 +86,21 @@ class nsTDependentString_CharT : public 
 
       explicit
       nsTDependentString_CharT( const char_type* data )
         : string_type(const_cast<char_type*>(data), PRUint32(char_traits::length(data)), F_TERMINATED)
         {
           AssertValid();
         }
 
-      nsTDependentString_CharT( const string_type& str, PRUint32 startPos )
-        : string_type()
+      explicit
+      nsTDependentString_CharT( const substring_type& str )
+        : string_type(const_cast<char_type*>(str.Data()), str.Length(), F_TERMINATED)
         {
-          Rebind(str, startPos);
+          AssertValid();
         }
 
       // Create a nsTDependentSubstring to be bound later
       nsTDependentString_CharT()
         : string_type() {}
 
       // XXX are you sure??
       // auto-generated copy-constructor OK
@@ -118,15 +119,13 @@ class nsTDependentString_CharT : public 
 
       void Rebind( const char_type* data, size_type length );
 
       void Rebind( const char_type* start, const char_type* end )
         {
           Rebind(start, PRUint32(end - start));
         }
 
-      void Rebind( const string_type&, PRUint32 startPos );
-
     private:
       
       // NOT USED
       nsTDependentString_CharT( const substring_tuple_type& );
   };
--- a/xpcom/string/src/nsTDependentString.cpp
+++ b/xpcom/string/src/nsTDependentString.cpp
@@ -43,25 +43,8 @@ nsTDependentString_CharT::Rebind( const 
     // If we currently own a buffer, release it.
     Finalize();
 
     mData = const_cast<char_type*>(data);
     mLength = 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<char_type*>(str.Data()) + startPos;
-    mLength = strLength - startPos;
-
-    SetDataFlags(F_TERMINATED);
-  }