зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1663365
- Move Intl extras functionality (Mozilla extensions, standardized-but-not-stable/shippable-yet) to namespace JS, improve comments, and make various styling tweaks. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D92167
This commit is contained in:
Родитель
00ac7c27d4
Коммит
28464c988b
|
@ -209,7 +209,7 @@ void js::DateTimeFormatObject::finalize(JSFreeOp* fop, JSObject* obj) {
|
|||
}
|
||||
}
|
||||
|
||||
bool js::AddMozDateTimeFormatConstructor(JSContext* cx,
|
||||
bool JS::AddMozDateTimeFormatConstructor(JSContext* cx,
|
||||
JS::Handle<JSObject*> intl) {
|
||||
RootedObject ctor(
|
||||
cx, GlobalObject::createConstructor(cx, MozDateTimeFormat,
|
||||
|
|
|
@ -223,7 +223,7 @@ void js::DisplayNamesObject::finalize(JSFreeOp* fop, JSObject* obj) {
|
|||
}
|
||||
}
|
||||
|
||||
bool js::AddDisplayNamesConstructor(JSContext* cx, HandleObject intl) {
|
||||
bool JS::AddDisplayNamesConstructor(JSContext* cx, HandleObject intl) {
|
||||
JSObject* ctor =
|
||||
GlobalObject::getOrCreateConstructor(cx, JSProto_DisplayNames);
|
||||
if (!ctor) {
|
||||
|
@ -234,7 +234,7 @@ bool js::AddDisplayNamesConstructor(JSContext* cx, HandleObject intl) {
|
|||
return DefineDataProperty(cx, intl, cx->names().DisplayNames, ctorValue, 0);
|
||||
}
|
||||
|
||||
bool js::AddMozDisplayNamesConstructor(JSContext* cx, HandleObject intl) {
|
||||
bool JS::AddMozDisplayNamesConstructor(JSContext* cx, HandleObject intl) {
|
||||
RootedObject ctor(cx, GlobalObject::createConstructor(
|
||||
cx, MozDisplayNames, cx->names().DisplayNames, 2));
|
||||
if (!ctor) {
|
||||
|
|
|
@ -867,15 +867,15 @@ static bool IntlNotEnabled(JSContext* cx) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool js::AddMozDateTimeFormatConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
bool JS::AddMozDateTimeFormatConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
return IntlNotEnabled(cx);
|
||||
}
|
||||
|
||||
bool js::AddMozDisplayNamesConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
bool JS::AddMozDisplayNamesConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
return IntlNotEnabled(cx);
|
||||
}
|
||||
|
||||
bool js::AddDisplayNamesConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
bool JS::AddDisplayNamesConstructor(JSContext* cx, JS::HandleObject intl) {
|
||||
return IntlNotEnabled(cx);
|
||||
}
|
||||
|
||||
|
|
|
@ -852,36 +852,56 @@ extern JS_FRIEND_API bool ReportIsNotFunction(JSContext* cx, JS::HandleValue v);
|
|||
extern JS_FRIEND_API JSObject* ConvertArgsToArray(JSContext* cx,
|
||||
const JS::CallArgs& args);
|
||||
|
||||
// Create and add the Intl.MozDateTimeFormat constructor function to the
|
||||
// provided object.
|
||||
// If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
// exception.
|
||||
//
|
||||
// This custom date/time formatter constructor gives users the ability
|
||||
// to specify a custom format pattern. This pattern is passed *directly*
|
||||
// to ICU with NO SYNTAX PARSING OR VALIDATION WHATSOEVER. ICU appears to
|
||||
// have a a modicum of testing of this, and it won't fall over completely
|
||||
// if passed bad input. But the current behavior is entirely under-specified
|
||||
// and emphatically not shippable on the web, and it *must* be fixed before
|
||||
// this functionality can be exposed in the real world. (There are also some
|
||||
// questions about whether the format exposed here is the *right* one to
|
||||
// standardize, that will also need to be resolved to ship this.)
|
||||
extern bool AddMozDateTimeFormatConstructor(JSContext* cx,
|
||||
JS::Handle<JSObject*> intl);
|
||||
} // namespace js
|
||||
|
||||
// Create and add the Intl.MozDisplayNames constructor function to the
|
||||
// provided object.
|
||||
// If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
// exception.
|
||||
extern bool AddMozDisplayNamesConstructor(JSContext* cx,
|
||||
JS::Handle<JSObject*> intl);
|
||||
namespace JS {
|
||||
|
||||
// Create and add the Intl.DisplayNames constructor function to the provided
|
||||
// object.
|
||||
// If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
// exception.
|
||||
extern bool AddDisplayNamesConstructor(JSContext* cx,
|
||||
JS::Handle<JSObject*> intl);
|
||||
/**
|
||||
* Create and add the Intl.MozDateTimeFormat constructor function to the
|
||||
* provided object.
|
||||
*
|
||||
* This custom date/time formatter constructor gives users the ability to
|
||||
* specify a custom format pattern. This pattern is passed *directly* to ICU
|
||||
* with NO SYNTAX PARSING OR VALIDATION WHATSOEVER. ICU appears to have a
|
||||
* modicum of testing of this, and it won't fall over completely if passed bad
|
||||
* input. But the current behavior is entirely under-specified and emphatically
|
||||
* not shippable on the web, and it *must* be fixed before this functionality
|
||||
* can be exposed in the real world. (There are also some questions about
|
||||
* whether the format exposed here is the *right* one to standardize, that will
|
||||
* also need to be resolved to ship this.)
|
||||
*
|
||||
* If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
* exception.
|
||||
*/
|
||||
extern JS_FRIEND_API bool AddMozDateTimeFormatConstructor(
|
||||
JSContext* cx, Handle<JSObject*> intl);
|
||||
|
||||
/**
|
||||
* Create and add the Intl.MozDisplayNames constructor function to the
|
||||
* provided object. This constructor acts like the standard |Intl.DisplayNames|
|
||||
* but accepts certain additional syntax that isn't standardized to the point of
|
||||
* being shippable.
|
||||
*
|
||||
* If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
* exception.
|
||||
*/
|
||||
extern JS_FRIEND_API bool AddMozDisplayNamesConstructor(JSContext* cx,
|
||||
Handle<JSObject*> intl);
|
||||
|
||||
/**
|
||||
* Create and add the Intl.DisplayNames constructor function to the provided
|
||||
* object, implementing standardized behavior (that isn't yet shippable because
|
||||
* we're not *quite* comfortable with the spec's progress yet).
|
||||
*
|
||||
* If JS was built without JS_HAS_INTL_API, this function will throw an
|
||||
* exception.
|
||||
*/
|
||||
extern JS_FRIEND_API bool AddDisplayNamesConstructor(JSContext* cx,
|
||||
Handle<JSObject*> intl);
|
||||
|
||||
} // namespace JS
|
||||
|
||||
namespace js {
|
||||
|
||||
class MOZ_STACK_CLASS JS_FRIEND_API AutoAssertNoContentJS {
|
||||
public:
|
||||
|
|
|
@ -1320,11 +1320,11 @@ static bool AddIntlExtras(JSContext* cx, unsigned argc, Value* vp) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!js::AddMozDateTimeFormatConstructor(cx, intl)) {
|
||||
if (!JS::AddMozDateTimeFormatConstructor(cx, intl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!js::AddMozDisplayNamesConstructor(cx, intl)) {
|
||||
if (!JS::AddMozDisplayNamesConstructor(cx, intl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ MozIntlHelper::AddDateTimeFormatConstructor(JS::Handle<JS::Value> val,
|
|||
|
||||
JSAutoRealm ar(cx, realIntlObj);
|
||||
|
||||
if (!js::AddMozDateTimeFormatConstructor(cx, realIntlObj)) {
|
||||
if (!JS::AddMozDateTimeFormatConstructor(cx, realIntlObj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче