зеркало из https://github.com/mozilla/pjs.git
Backout of bug 153586. a=asa
This commit is contained in:
Родитель
0ed88eb6e1
Коммит
9d3e99b64f
|
@ -78,9 +78,6 @@
|
|||
#include "nsIAtom.h"
|
||||
|
||||
// For locale aware string methods
|
||||
#include "plstr.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsICollation.h"
|
||||
|
@ -137,7 +134,6 @@ static nsIScriptSecurityManager *sSecurityManager;
|
|||
|
||||
static nsICollation *gCollation;
|
||||
|
||||
static nsIUnicodeDecoder *gDecoder;
|
||||
|
||||
void JS_DLL_CALLBACK
|
||||
NS_ScriptErrorReporter(JSContext *cx,
|
||||
|
@ -302,78 +298,6 @@ NS_ScriptErrorReporter(JSContext *cx,
|
|||
::JS_ClearPendingException(cx);
|
||||
}
|
||||
|
||||
static JSBool JS_DLL_CALLBACK
|
||||
LocaleToUnicode(JSContext *cx, char *src, jsval *rval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!gDecoder) {
|
||||
// use app default locale
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString locale;
|
||||
rv = appLocale->
|
||||
GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME##PLATFORM").get(),
|
||||
getter_Copies(locale));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get app locale info");
|
||||
|
||||
nsCOMPtr<nsIPlatformCharset> platformCharset =
|
||||
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString charset;
|
||||
rv = platformCharset->GetDefaultCharsetForLocale(locale, charset);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// get/create unicode decoder for charset
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
ccm->GetUnicodeDecoder(charset.get(), &gDecoder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSString *str = nsnull;
|
||||
PRInt32 srcLength = PL_strlen(src);
|
||||
|
||||
if (gDecoder) {
|
||||
PRInt32 unicharLength = srcLength;
|
||||
PRUnichar *unichars = (PRUnichar *)malloc(srcLength * sizeof(PRUnichar));
|
||||
if (unichars) {
|
||||
rv = gDecoder->Convert(src, &srcLength, unichars, &unicharLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// nsIUnicodeDecoder::Convert may use fewer than srcLength PRUnichars
|
||||
if (unicharLength < srcLength) {
|
||||
PRUnichar *shrunkUnichars =
|
||||
(PRUnichar *)realloc(unichars, unicharLength * sizeof(PRUnichar));
|
||||
if (shrunkUnichars)
|
||||
unichars = shrunkUnichars;
|
||||
}
|
||||
str = JS_NewUCString(cx,
|
||||
NS_REINTERPRET_CAST(jschar*, unichars),
|
||||
unicharLength);
|
||||
}
|
||||
if (!str)
|
||||
free(unichars);
|
||||
}
|
||||
}
|
||||
|
||||
if (!str) {
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static JSBool
|
||||
ChangeCase(JSContext *cx, JSString *src, jsval *rval,
|
||||
void(* changeCaseFnc)(const nsAString&, nsAString&))
|
||||
|
@ -603,8 +527,7 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
|
|||
{
|
||||
LocaleToUpperCase,
|
||||
LocaleToLowerCase,
|
||||
LocaleCompare,
|
||||
LocaleToUnicode
|
||||
LocaleCompare
|
||||
};
|
||||
|
||||
::JS_SetLocaleCallbacks(mContext, &localeCallbacks);
|
||||
|
@ -659,7 +582,6 @@ nsJSContext::~nsJSContext()
|
|||
NS_IF_RELEASE(sRuntimeService);
|
||||
NS_IF_RELEASE(sSecurityManager);
|
||||
NS_IF_RELEASE(gCollation);
|
||||
NS_IF_RELEASE(gDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1988,7 +1910,6 @@ void nsJSEnvironment::ShutDown()
|
|||
NS_IF_RELEASE(sRuntimeService);
|
||||
NS_IF_RELEASE(sSecurityManager);
|
||||
NS_IF_RELEASE(gCollation);
|
||||
NS_IF_RELEASE(gDecoder);
|
||||
}
|
||||
|
||||
sDidShutdown = PR_TRUE;
|
||||
|
|
|
@ -1524,7 +1524,6 @@ struct JSLocaleCallbacks {
|
|||
JSLocaleToUpperCase localeToUpperCase;
|
||||
JSLocaleToLowerCase localeToLowerCase;
|
||||
JSLocaleCompare localeCompare;
|
||||
JSLocaleToUnicode localeToUnicode;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -1640,9 +1640,6 @@ date_toLocaleHelper(JSContext *cx, JSObject *obj, uintN argc,
|
|||
|
||||
}
|
||||
|
||||
if (cx->localeCallbacks && cx->localeCallbacks->localeToUnicode)
|
||||
return cx->localeCallbacks->localeToUnicode(cx, buf, rval);
|
||||
|
||||
str = JS_NewStringCopyZ(cx, buf);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -527,9 +527,6 @@ typedef JSBool
|
|||
JSString *src1, JSString *src2,
|
||||
jsval *rval);
|
||||
|
||||
typedef JSBool
|
||||
(* JS_DLL_CALLBACK JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);
|
||||
|
||||
/*
|
||||
* Security protocol types.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче