mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 14:47:31 +09:00
Issue #1756 - Expose NumberFormat.formatToParts() to content.
This commit is contained in:
parent
5df0028108
commit
bdcb9cc504
4 changed files with 1 additions and 44 deletions
|
|
@ -755,6 +755,7 @@ static const JSFunctionSpec numberFormat_static_methods[] = {
|
||||||
|
|
||||||
static const JSFunctionSpec numberFormat_methods[] = {
|
static const JSFunctionSpec numberFormat_methods[] = {
|
||||||
JS_SELF_HOSTED_FN("resolvedOptions", "Intl_NumberFormat_resolvedOptions", 0, 0),
|
JS_SELF_HOSTED_FN("resolvedOptions", "Intl_NumberFormat_resolvedOptions", 0, 0),
|
||||||
|
JS_SELF_HOSTED_FN("formatToParts", "Intl_NumberFormat_formatToParts", 1, 0),
|
||||||
#if JS_HAS_TOSOURCE
|
#if JS_HAS_TOSOURCE
|
||||||
JS_FN(js_toSource_str, numberFormat_toSource, 0, 0),
|
JS_FN(js_toSource_str, numberFormat_toSource, 0, 0),
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -905,24 +906,6 @@ CreateNumberFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObjec
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
|
|
||||||
// If the still-experimental NumberFormat.prototype.formatToParts method is
|
|
||||||
// enabled, also add it.
|
|
||||||
if (cx->compartment()->creationOptions().experimentalNumberFormatFormatToPartsEnabled()) {
|
|
||||||
RootedValue ftp(cx);
|
|
||||||
HandlePropertyName name = cx->names().formatToParts;
|
|
||||||
if (!GlobalObject::getSelfHostedFunction(cx, cx->global(),
|
|
||||||
cx->names().NumberFormatFormatToParts,
|
|
||||||
name, 1, &ftp))
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DefineProperty(cx, proto, cx->names().formatToParts, ftp, nullptr, nullptr, 0))
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
|
|
||||||
|
|
||||||
RootedValue options(cx);
|
RootedValue options(cx);
|
||||||
if (!CreateDefaultOptions(cx, &options))
|
if (!CreateDefaultOptions(cx, &options))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -2206,7 +2206,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
|
||||||
mergeable_(false),
|
mergeable_(false),
|
||||||
preserveJitCode_(false),
|
preserveJitCode_(false),
|
||||||
cloneSingletons_(false),
|
cloneSingletons_(false),
|
||||||
experimentalNumberFormatFormatToPartsEnabled_(false),
|
|
||||||
sharedMemoryAndAtomics_(false),
|
sharedMemoryAndAtomics_(false),
|
||||||
secureContext_(false)
|
secureContext_(false)
|
||||||
{
|
{
|
||||||
|
|
@ -2271,23 +2270,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECMA-402 is considering adding a "formatToParts" NumberFormat method,
|
|
||||||
// that exposes not just a formatted string but its subcomponents. The
|
|
||||||
// method, its semantics, and its name aren't finalized, so for now it's
|
|
||||||
// exposed *only* if requested.
|
|
||||||
//
|
|
||||||
// Until "formatToParts" is included in a final specification edition, it's
|
|
||||||
// subject to change or removal at any time. Do *not* rely on it in
|
|
||||||
// mission-critical code that can't be changed if ECMA-402 decides not to
|
|
||||||
// accept the method in its current form.
|
|
||||||
bool experimentalNumberFormatFormatToPartsEnabled() const {
|
|
||||||
return experimentalNumberFormatFormatToPartsEnabled_;
|
|
||||||
}
|
|
||||||
CompartmentCreationOptions& setExperimentalNumberFormatFormatToPartsEnabled(bool flag) {
|
|
||||||
experimentalNumberFormatFormatToPartsEnabled_ = flag;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getSharedMemoryAndAtomicsEnabled() const;
|
bool getSharedMemoryAndAtomicsEnabled() const;
|
||||||
CompartmentCreationOptions& setSharedMemoryAndAtomicsEnabled(bool flag);
|
CompartmentCreationOptions& setSharedMemoryAndAtomicsEnabled(bool flag);
|
||||||
|
|
||||||
|
|
@ -2312,7 +2294,6 @@ class JS_PUBLIC_API(CompartmentCreationOptions)
|
||||||
bool mergeable_;
|
bool mergeable_;
|
||||||
bool preserveJitCode_;
|
bool preserveJitCode_;
|
||||||
bool cloneSingletons_;
|
bool cloneSingletons_;
|
||||||
bool experimentalNumberFormatFormatToPartsEnabled_;
|
|
||||||
bool sharedMemoryAndAtomics_;
|
bool sharedMemoryAndAtomics_;
|
||||||
bool secureContext_;
|
bool secureContext_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4684,11 +4684,6 @@ NewGlobal(JSContext* cx, unsigned argc, Value* vp)
|
||||||
if (v.isBoolean())
|
if (v.isBoolean())
|
||||||
creationOptions.setCloneSingletons(v.toBoolean());
|
creationOptions.setCloneSingletons(v.toBoolean());
|
||||||
|
|
||||||
if (!JS_GetProperty(cx, opts, "experimentalNumberFormatFormatToPartsEnabled", &v))
|
|
||||||
return false;
|
|
||||||
if (v.isBoolean())
|
|
||||||
creationOptions.setExperimentalNumberFormatFormatToPartsEnabled(v.toBoolean());
|
|
||||||
|
|
||||||
if (!JS_GetProperty(cx, opts, "sameZoneAs", &v))
|
if (!JS_GetProperty(cx, opts, "sameZoneAs", &v))
|
||||||
return false;
|
return false;
|
||||||
if (v.isObject())
|
if (v.isObject())
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,6 @@
|
||||||
macro(forceInterpreter, forceInterpreter, "forceInterpreter") \
|
macro(forceInterpreter, forceInterpreter, "forceInterpreter") \
|
||||||
macro(forEach, forEach, "forEach") \
|
macro(forEach, forEach, "forEach") \
|
||||||
macro(format, format, "format") \
|
macro(format, format, "format") \
|
||||||
macro(formatToParts, formatToParts, "formatToParts") \
|
|
||||||
macro(fraction, fraction, "fraction") \
|
macro(fraction, fraction, "fraction") \
|
||||||
macro(frame, frame, "frame") \
|
macro(frame, frame, "frame") \
|
||||||
macro(from, from, "from") \
|
macro(from, from, "from") \
|
||||||
|
|
@ -253,7 +252,6 @@
|
||||||
macro(notes, notes, "notes") \
|
macro(notes, notes, "notes") \
|
||||||
macro(NumberFormat, NumberFormat, "NumberFormat") \
|
macro(NumberFormat, NumberFormat, "NumberFormat") \
|
||||||
macro(NumberFormatFormatGet, NumberFormatFormatGet, "Intl_NumberFormat_format_get") \
|
macro(NumberFormatFormatGet, NumberFormatFormatGet, "Intl_NumberFormat_format_get") \
|
||||||
macro(NumberFormatFormatToParts, NumberFormatFormatToParts, "Intl_NumberFormat_formatToParts") \
|
|
||||||
macro(numeric, numeric, "numeric") \
|
macro(numeric, numeric, "numeric") \
|
||||||
macro(objectArguments, objectArguments, "[object Arguments]") \
|
macro(objectArguments, objectArguments, "[object Arguments]") \
|
||||||
macro(objectArray, objectArray, "[object Array]") \
|
macro(objectArray, objectArray, "[object Array]") \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue