diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 9e2c1079c8d1..7bdf7960892f 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -54,8 +54,7 @@ JSErrorFormatString ErrorFormatString[] = { }; const JSErrorFormatString* -GetErrorMessage(void* aUserRef, const char* aLocale, - const unsigned aErrorNumber) +GetErrorMessage(void* aUserRef, const unsigned aErrorNumber) { MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString)); return &ErrorFormatString[aErrorNumber]; @@ -139,8 +138,7 @@ ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...) mResult = NS_ERROR_TYPE_ERR; Message* message = new Message(); message->mErrorNumber = errorNumber; - uint16_t argCount = - dom::GetErrorMessage(nullptr, nullptr, errorNumber)->argCount; + uint16_t argCount = dom::GetErrorMessage(nullptr, errorNumber)->argCount; MOZ_ASSERT(argCount <= 10); argCount = std::min(argCount, 10); while (argCount--) { diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index da6e97a7cb86..4354e1b1bbf8 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -877,7 +877,7 @@ static const JSErrorFormatString ErrorFormatString[CTYPESERR_LIMIT] = { }; static const JSErrorFormatString* -GetErrorMessage(void* userRef, const char* locale, const unsigned errorNumber) +GetErrorMessage(void* userRef, const unsigned errorNumber) { if (0 < errorNumber && errorNumber < CTYPESERR_LIMIT) return &ErrorFormatString[errorNumber]; diff --git a/js/src/jsapi.h b/js/src/jsapi.h index c42aa76cfcf3..24226b102b4c 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -733,8 +733,7 @@ typedef struct JSErrorFormatString { } JSErrorFormatString; typedef const JSErrorFormatString * -(* JSErrorCallback)(void *userRef, const char *locale, - const unsigned errorNumber); +(* JSErrorCallback)(void *userRef, const unsigned errorNumber); typedef bool (* JSLocaleToUpperCase)(JSContext *cx, JS::HandleString src, JS::MutableHandleValue rval); @@ -4536,7 +4535,6 @@ struct JSLocaleCallbacks { JSLocaleToLowerCase localeToLowerCase; JSLocaleCompare localeCompare; // not used #if EXPOSE_INTL_API JSLocaleToUnicode localeToUnicode; - JSErrorCallback localeGetErrorMessage; }; /* diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index 37e49c7c161c..9831da0cc081 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -391,8 +391,7 @@ js_ReportOutOfMemory(ThreadSafeContext *cxArg) } /* Get the message for this error, but we don't expand any arguments. */ - const JSErrorFormatString *efs = - js_GetLocalizedErrorMessage(cx, nullptr, nullptr, JSMSG_OUT_OF_MEMORY); + const JSErrorFormatString *efs = js_GetErrorMessage(nullptr, JSMSG_OUT_OF_MEMORY); const char *msg = efs ? efs->format : "Out of memory"; /* Fill out the report, but don't do anything that requires allocation. */ @@ -671,13 +670,14 @@ js_ExpandErrorArguments(ExclusiveContext *cx, JSErrorCallback callback, *messagep = nullptr; - /* Most calls supply js_GetErrorMessage; if this is so, assume nullptr. */ - if (!callback || callback == js_GetErrorMessage) { - efs = js_GetLocalizedErrorMessage(cx, userRef, nullptr, errorNumber); - } else { + if (!callback) + callback = js_GetErrorMessage; + + { AutoSuppressGC suppressGC(cx); - efs = callback(userRef, nullptr, errorNumber); + efs = callback(userRef, errorNumber); } + if (efs) { reportp->exnType = efs->exnType; @@ -1004,9 +1004,9 @@ const JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = { }; JS_FRIEND_API(const JSErrorFormatString *) -js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber) +js_GetErrorMessage(void *userRef, const unsigned errorNumber) { - if ((errorNumber > 0) && (errorNumber < JSErr_Limit)) + if (errorNumber > 0 && errorNumber < JSErr_Limit) return &js_ErrorFormatString[errorNumber]; return nullptr; } diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index fc1d2114a497..87dafb620278 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -579,28 +579,6 @@ ErrorObject::createConstructor(JSContext *cx, JSProtoKey key) return ctor; } -const JSErrorFormatString* -js_GetLocalizedErrorMessage(ExclusiveContext *cx, void *userRef, const char *locale, - const unsigned errorNumber) -{ - const JSErrorFormatString *errorString = nullptr; - - // The locale callbacks might not be thread safe, so don't call them if - // we're not on the main thread. When used with XPConnect, - // |localeGetErrorMessage| will be nullptr anyways. - if (cx->isJSContext() && - cx->asJSContext()->runtime()->localeCallbacks && - cx->asJSContext()->runtime()->localeCallbacks->localeGetErrorMessage) - { - JSLocaleCallbacks *callbacks = cx->asJSContext()->runtime()->localeCallbacks; - errorString = callbacks->localeGetErrorMessage(userRef, locale, errorNumber); - } - - if (!errorString) - errorString = js_GetErrorMessage(userRef, locale, errorNumber); - return errorString; -} - JS_FRIEND_API(JSFlatString *) js::GetErrorTypeName(JSRuntime *rt, int16_t exnType) { @@ -628,11 +606,9 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp, // Find the exception index associated with this error. JSErrNum errorNumber = static_cast(reportp->errorNumber); - const JSErrorFormatString *errorString; - if (!callback || callback == js_GetErrorMessage) - errorString = js_GetLocalizedErrorMessage(cx, nullptr, nullptr, errorNumber); - else - errorString = callback(userRef, nullptr, errorNumber); + if (!callback) + callback = js_GetErrorMessage; + const JSErrorFormatString *errorString = callback(userRef, errorNumber); JSExnType exnType = errorString ? static_cast(errorString->exnType) : JSEXN_NONE; MOZ_ASSERT(exnType < JSEXN_LIMIT); diff --git a/js/src/jsexn.h b/js/src/jsexn.h index a56eeecb3aa5..858df5187eca 100644 --- a/js/src/jsexn.h +++ b/js/src/jsexn.h @@ -76,10 +76,6 @@ js_ReportUncaughtException(JSContext *cx); extern JSErrorReport * js_ErrorFromException(JSContext *cx, js::HandleObject obj); -extern const JSErrorFormatString * -js_GetLocalizedErrorMessage(js::ExclusiveContext *cx, void *userRef, const char *locale, - const unsigned errorNumber); - /* * Make a copy of errobj parented to cx's compartment's global. * diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index e22cb9e5bda3..d4ed1a5afca6 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -1242,7 +1242,7 @@ typedef enum JSErrNum { } JSErrNum; extern JS_FRIEND_API(const JSErrorFormatString *) -js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber); +js_GetErrorMessage(void *userRef, const unsigned errorNumber); namespace js { diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 94d43f5f140c..83def21c8d24 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -198,7 +198,7 @@ NewGlobalObject(JSContext *cx, JS::CompartmentOptions &options, JSPrincipals *principals); static const JSErrorFormatString * -my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber); +my_GetErrorMessage(void *userRef, const unsigned errorNumber); /* @@ -5115,7 +5115,7 @@ static const JSErrorFormatString jsShell_ErrorFormatString[JSShellErr_Limit] = { }; static const JSErrorFormatString * -my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber) +my_GetErrorMessage(void *userRef, const unsigned errorNumber) { if (errorNumber == 0 || errorNumber >= JSShellErr_Limit) return nullptr; diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index e2a280553d77..14331b67ba70 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -120,8 +120,7 @@ js::intrinsic_ThrowError(JSContext *cx, unsigned argc, Value *vp) uint32_t errorNumber = args[0].toInt32(); #ifdef DEBUG - const JSErrorFormatString *efs = - js_GetLocalizedErrorMessage(cx, nullptr, nullptr, errorNumber); + const JSErrorFormatString *efs = js_GetErrorMessage(nullptr, errorNumber); JS_ASSERT(efs->argCount == args.length() - 1); #endif diff --git a/js/xpconnect/src/XPCLocale.cpp b/js/xpconnect/src/XPCLocale.cpp index ca51f8370943..03ecd931e0c6 100644 --- a/js/xpconnect/src/XPCLocale.cpp +++ b/js/xpconnect/src/XPCLocale.cpp @@ -43,7 +43,6 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks localeToLowerCase = LocaleToLowerCase; localeCompare = LocaleCompare; localeToUnicode = LocaleToUnicode; - localeGetErrorMessage = nullptr; } ~XPCLocaleCallbacks() diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 2d31748ce62b..1aa67a32e717 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -881,7 +881,7 @@ static const JSErrorFormatString jsShell_ErrorFormatString[JSShellErr_Limit] = { }; static const JSErrorFormatString * -my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber) +my_GetErrorMessage(void *userRef, const unsigned errorNumber) { if (errorNumber == 0 || errorNumber >= JSShellErr_Limit) return nullptr;