Update js-display-names.cc
This commit is contained in:
parent
695366befd
commit
d60fe5adf5
1 changed files with 18 additions and 35 deletions
|
@ -452,24 +452,12 @@ MaybeHandle<JSDisplayNames> JSDisplayNames::New(Isolate* isolate,
|
||||||
// 12. Let type be ? GetOption(options, "type", "string", « "language",
|
// 12. Let type be ? GetOption(options, "type", "string", « "language",
|
||||||
// "region", "script", "currency" , "calendar", "dateTimeField", "unit"»,
|
// "region", "script", "currency" , "calendar", "dateTimeField", "unit"»,
|
||||||
// undefined).
|
// undefined).
|
||||||
Maybe<Type> maybe_type =
|
Maybe<Type> maybe_type = GetStringOption<Type>(
|
||||||
FLAG_harmony_intl_displaynames_v2
|
isolate, options, "type", service,
|
||||||
? GetStringOption<Type>(
|
{"language", "region", "script", "currency", "calendar", "dateTimeField"},
|
||||||
isolate, options, "type", service,
|
{Type::kLanguage, Type::kRegion, Type::kScript, Type::kCurrency,
|
||||||
{"language", "region", "script", "currency", "calendar",
|
Type::kCalendar, Type::kDateTimeField},
|
||||||
"dateTimeField"},
|
Type::kUndefined);
|
||||||
{Type::kLanguage, Type::kRegion, Type::kScript, Type::kCurrency,
|
|
||||||
Type::kCalendar, Type::kDateTimeField},
|
|
||||||
Type::kUndefined)
|
|
||||||
: GetStringOption<Type>(isolate, options, "type", service,
|
|
||||||
{"language", "region", "script", "currency"},
|
|
||||||
{
|
|
||||||
Type::kLanguage,
|
|
||||||
Type::kRegion,
|
|
||||||
Type::kScript,
|
|
||||||
Type::kCurrency,
|
|
||||||
},
|
|
||||||
Type::kUndefined);
|
|
||||||
MAYBE_RETURN(maybe_type, MaybeHandle<JSDisplayNames>());
|
MAYBE_RETURN(maybe_type, MaybeHandle<JSDisplayNames>());
|
||||||
Type type_enum = maybe_type.FromJust();
|
Type type_enum = maybe_type.FromJust();
|
||||||
|
|
||||||
|
@ -492,21 +480,18 @@ MaybeHandle<JSDisplayNames> JSDisplayNames::New(Isolate* isolate,
|
||||||
// 16. Set displayNames.[[Fallback]] to fallback.
|
// 16. Set displayNames.[[Fallback]] to fallback.
|
||||||
|
|
||||||
LanguageDisplay language_display_enum = LanguageDisplay::kDialect;
|
LanguageDisplay language_display_enum = LanguageDisplay::kDialect;
|
||||||
if (FLAG_harmony_intl_displaynames_v2) {
|
// 24. Let languageDisplay be ? GetOption(options, "languageDisplay",
|
||||||
// 24. Let languageDisplay be ? GetOption(options, "languageDisplay",
|
// "string", « "dialect", "standard" », "dialect").
|
||||||
// "string", « "dialect", "standard" », "dialect").
|
Maybe<LanguageDisplay> maybe_language_display =
|
||||||
Maybe<LanguageDisplay> maybe_language_display =
|
GetStringOption<LanguageDisplay>(
|
||||||
GetStringOption<LanguageDisplay>(
|
isolate, options, "languageDisplay", service, {"dialect", "standard"},
|
||||||
isolate, options, "languageDisplay", service,
|
{LanguageDisplay::kDialect, LanguageDisplay::kStandard},
|
||||||
{"dialect", "standard"},
|
LanguageDisplay::kDialect);
|
||||||
{LanguageDisplay::kDialect, LanguageDisplay::kStandard},
|
MAYBE_RETURN(maybe_language_display, MaybeHandle<JSDisplayNames>());
|
||||||
LanguageDisplay::kDialect);
|
// 25. If type is "language", then
|
||||||
MAYBE_RETURN(maybe_language_display, MaybeHandle<JSDisplayNames>());
|
if (type_enum == Type::kLanguage) {
|
||||||
// 25. If type is "language", then
|
// a. Set displayNames.[[LanguageDisplay]] to languageDisplay.
|
||||||
if (type_enum == Type::kLanguage) {
|
language_display_enum = maybe_language_display.FromJust();
|
||||||
// a. Set displayNames.[[LanguageDisplay]] to languageDisplay.
|
|
||||||
language_display_enum = maybe_language_display.FromJust();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set displayNames.[[Fallback]] to fallback.
|
// Set displayNames.[[Fallback]] to fallback.
|
||||||
|
@ -594,7 +579,6 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
|
||||||
DCHECK(maybe_create_fallback.FromJust());
|
DCHECK(maybe_create_fallback.FromJust());
|
||||||
USE(maybe_create_fallback);
|
USE(maybe_create_fallback);
|
||||||
|
|
||||||
if (FLAG_harmony_intl_displaynames_v2) {
|
|
||||||
if (std::strcmp("language", internal->type()) == 0) {
|
if (std::strcmp("language", internal->type()) == 0) {
|
||||||
Maybe<bool> maybe_create_language_display =
|
Maybe<bool> maybe_create_language_display =
|
||||||
JSReceiver::CreateDataProperty(isolate, options,
|
JSReceiver::CreateDataProperty(isolate, options,
|
||||||
|
@ -603,7 +587,6 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
|
||||||
DCHECK(maybe_create_language_display.FromJust());
|
DCHECK(maybe_create_language_display.FromJust());
|
||||||
USE(maybe_create_language_display);
|
USE(maybe_create_language_display);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue