Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
webkit2gtk3.22331
webkit2gtk3-icu52.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File webkit2gtk3-icu52.patch of Package webkit2gtk3.22331
diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/CMakeLists.txt webkitgtk-2.34.1/Source/JavaScriptCore/CMakeLists.txt --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/CMakeLists.txt 2021-11-09 14:46:10.896492612 -0600 +++ webkitgtk-2.34.1/Source/JavaScriptCore/CMakeLists.txt 2021-11-10 13:25:18.203985869 -0600 @@ -75,16 +75,11 @@ set(JavaScriptCore_OBJECT_LUT_SOURCES runtime/IntlDateTimeFormatPrototype.cpp runtime/IntlDisplayNamesConstructor.cpp runtime/IntlDisplayNamesPrototype.cpp - runtime/IntlListFormatConstructor.cpp - runtime/IntlListFormatPrototype.cpp - runtime/IntlLocalePrototype.cpp runtime/IntlNumberFormatConstructor.cpp runtime/IntlNumberFormatPrototype.cpp runtime/IntlObject.cpp runtime/IntlPluralRulesConstructor.cpp runtime/IntlPluralRulesPrototype.cpp - runtime/IntlRelativeTimeFormatConstructor.cpp - runtime/IntlRelativeTimeFormatPrototype.cpp runtime/IntlSegmentIteratorPrototype.cpp runtime/IntlSegmenterConstructor.cpp runtime/IntlSegmenterPrototype.cpp diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources-input.xcfilelist webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources-input.xcfilelist --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources-input.xcfilelist 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources-input.xcfilelist 2021-11-10 13:25:18.207985891 -0600 @@ -137,16 +137,12 @@ $(PROJECT_DIR)/runtime/IntlDateTimeForma $(PROJECT_DIR)/runtime/IntlDateTimeFormatPrototype.cpp $(PROJECT_DIR)/runtime/IntlDisplayNamesConstructor.cpp $(PROJECT_DIR)/runtime/IntlDisplayNamesPrototype.cpp -$(PROJECT_DIR)/runtime/IntlListFormatConstructor.cpp -$(PROJECT_DIR)/runtime/IntlListFormatPrototype.cpp $(PROJECT_DIR)/runtime/IntlLocalePrototype.cpp $(PROJECT_DIR)/runtime/IntlNumberFormatConstructor.cpp $(PROJECT_DIR)/runtime/IntlNumberFormatPrototype.cpp $(PROJECT_DIR)/runtime/IntlObject.cpp $(PROJECT_DIR)/runtime/IntlPluralRulesConstructor.cpp $(PROJECT_DIR)/runtime/IntlPluralRulesPrototype.cpp -$(PROJECT_DIR)/runtime/IntlRelativeTimeFormatConstructor.cpp -$(PROJECT_DIR)/runtime/IntlRelativeTimeFormatPrototype.cpp $(PROJECT_DIR)/runtime/IntlSegmentIteratorPrototype.cpp $(PROJECT_DIR)/runtime/IntlSegmenterConstructor.cpp $(PROJECT_DIR)/runtime/IntlSegmenterPrototype.cpp diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources.make webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources.make --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources.make 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources.make 2021-11-10 13:25:18.207985891 -0600 @@ -158,16 +158,12 @@ OBJECT_LUT_HEADERS = \ IntlDateTimeFormatPrototype.lut.h \ IntlDisplayNamesConstructor.lut.h \ IntlDisplayNamesPrototype.lut.h \ - IntlListFormatConstructor.lut.h \ - IntlListFormatPrototype.lut.h \ IntlLocalePrototype.lut.h \ IntlNumberFormatConstructor.lut.h \ IntlNumberFormatPrototype.lut.h \ IntlObject.lut.h \ IntlPluralRulesConstructor.lut.h \ IntlPluralRulesPrototype.lut.h \ - IntlRelativeTimeFormatConstructor.lut.h \ - IntlRelativeTimeFormatPrototype.lut.h \ IntlSegmentIteratorPrototype.lut.h \ IntlSegmenterConstructor.lut.h \ IntlSegmenterPrototype.lut.h \ diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources-output.xcfilelist webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources-output.xcfilelist --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/DerivedSources-output.xcfilelist 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/DerivedSources-output.xcfilelist 2021-11-10 13:25:18.207985891 -0600 @@ -28,16 +28,12 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/Jav $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlDateTimeFormatPrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlDisplayNamesConstructor.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlDisplayNamesPrototype.lut.h -$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlListFormatConstructor.lut.h -$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlListFormatPrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlLocalePrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlNumberFormatConstructor.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlNumberFormatPrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlObject.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlPluralRulesConstructor.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlPluralRulesPrototype.lut.h -$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlRelativeTimeFormatConstructor.lut.h -$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlRelativeTimeFormatPrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlSegmentIteratorPrototype.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlSegmenterConstructor.lut.h $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/IntlSegmenterPrototype.lut.h diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/CommonIdentifiers.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/CommonIdentifiers.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/CommonIdentifiers.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/CommonIdentifiers.h 2021-11-10 13:25:18.207985891 -0600 @@ -42,9 +42,7 @@ macro(Function) \ macro(Infinity) \ macro(Intl) \ - macro(ListFormat) \ macro(Loader) \ - macro(Locale) \ macro(Map) \ macro(NaN) \ macro(Number) \ @@ -54,7 +52,6 @@ macro(Promise) \ macro(Reflect) \ macro(RegExp) \ - macro(RelativeTimeFormat) \ macro(RemotePlayback) \ macro(Segmenter) \ macro(Set) \ @@ -118,7 +115,6 @@ macro(exec) \ macro(executionCount) \ macro(exitKind) \ - macro(fallback) \ macro(flags) \ macro(forEach) \ macro(formatMatcher) \ @@ -159,7 +155,6 @@ macro(jettisonReason) \ macro(join) \ macro(language) \ - macro(languageDisplay) \ macro(largestUnit) \ macro(lastIndex) \ macro(length) \ diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCache.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCache.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCache.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCache.cpp 2021-11-10 13:24:55.343864110 -0600 @@ -53,16 +53,4 @@ Vector<UChar, 32> IntlCache::getBestDate return patternBuffer; } -Vector<UChar, 32> IntlCache::getFieldDisplayName(const CString& locale, UDateTimePatternField field, UDateTimePGDisplayWidth width, UErrorCode& status) -{ - auto sharedGenerator = getSharedPatternGenerator(locale, status); - if (U_FAILURE(status)) - return { }; - Vector<UChar, 32> buffer; - status = callBufferProducingFunction(udatpg_getFieldDisplayName, sharedGenerator, field, width, buffer); - if (U_FAILURE(status)) - return { }; - return buffer; -} - } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCache.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCache.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCache.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCache.h 2021-11-10 13:24:55.343864110 -0600 @@ -39,7 +39,6 @@ public: IntlCache() = default; Vector<UChar, 32> getBestDateTimePattern(const CString& locale, const UChar* skeleton, unsigned skeletonSize, UErrorCode&); - Vector<UChar, 32> getFieldDisplayName(const CString& locale, UDateTimePatternField, UDateTimePGDisplayWidth, UErrorCode&); private: UDateTimePatternGenerator* getSharedPatternGenerator(const CString& locale, UErrorCode& status) diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCollator.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCollator.cpp 2021-11-10 13:25:18.207985891 -0600 @@ -33,6 +33,7 @@ #include "JSCInlines.h" #include "ObjectConstructor.h" #include <wtf/HexNumber.h> +#include <unicode/ucol.h> namespace JSC { @@ -42,6 +43,12 @@ namespace IntlCollatorInternal { constexpr bool verbose = false; } +void IntlCollator::UCollatorDeleter::operator()(UCollator* collator) const +{ + if (collator) + ucol_close(collator); +} + IntlCollator* IntlCollator::create(VM& vm, Structure* structure) { IntlCollator* format = new (NotNull, allocateCell<IntlCollator>(vm.heap)) IntlCollator(vm, structure); diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCollator.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlCollator.h 2021-11-10 14:42:18.544594482 -0600 @@ -27,9 +27,10 @@ #pragma once #include "IntlObject.h" -#include <unicode/ucol.h> #include <wtf/unicode/icu/ICUHelpers.h> +struct UCollator; + namespace JSC { enum class RelevantExtensionKey : uint8_t; @@ -92,7 +93,9 @@ private: enum class Sensitivity : uint8_t { Base, Accent, Case, Variant }; enum class CaseFirst : uint8_t { Upper, Lower, False }; - using UCollatorDeleter = ICUDeleter<ucol_close>; + struct UCollatorDeleter { + void operator()(UCollator*) const; + }; static ASCIILiteral usageString(Usage); static ASCIILiteral sensitivityString(Sensitivity); diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2021-11-10 13:25:18.207985891 -0600 @@ -66,6 +66,12 @@ namespace IntlDateTimeFormatInternal { static constexpr bool verbose = false; } +void IntlDateTimeFormat::UDateFormatDeleter::operator()(UDateFormat* dateFormat) const +{ + if (dateFormat) + udat_close(dateFormat); +} + IntlDateTimeFormat* IntlDateTimeFormat::create(VM& vm, Structure* structure) { IntlDateTimeFormat* format = new (NotNull, allocateCell<IntlDateTimeFormat>(vm.heap)) IntlDateTimeFormat(vm, structure); @@ -1291,6 +1297,7 @@ JSValue IntlDateTimeFormat::format(JSGlo return jsString(vm, String(result)); } +#if 0 static ASCIILiteral partTypeString(UDateFormatField field) { switch (field) { @@ -1418,6 +1425,7 @@ JSValue IntlDateTimeFormat::formatToPart return parts; } +#endif UDateIntervalFormat* IntlDateTimeFormat::createDateIntervalFormatIfNecessary(JSGlobalObject* globalObject) { diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h 2021-11-10 13:25:18.207985891 -0600 @@ -28,7 +28,6 @@ #include "JSObject.h" #include <unicode/udat.h> -#include <wtf/unicode/icu/ICUHelpers.h> struct UDateIntervalFormat; @@ -126,7 +125,9 @@ private: static void replaceHourCycleInSkeleton(Vector<UChar, 32>&, bool hour12); static void replaceHourCycleInPattern(Vector<UChar, 32>&, HourCycle); - using UDateFormatDeleter = ICUDeleter<udat_close>; + struct UDateFormatDeleter { + void operator()(UDateFormat*) const; + }; WriteBarrier<JSBoundFunction> m_boundFormat; std::unique_ptr<UDateFormat, UDateFormatDeleter> m_dateFormat; diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp 2021-11-10 14:44:40.929352838 -0600 @@ -39,7 +39,6 @@ namespace JSC { static JSC_DECLARE_CUSTOM_GETTER(intlDateTimeFormatPrototypeGetterFormat); static JSC_DECLARE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatRange); static JSC_DECLARE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatRangeToParts); -static JSC_DECLARE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatToParts); static JSC_DECLARE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncResolvedOptions); static JSC_DECLARE_HOST_FUNCTION(intlDateTimeFormatFuncFormatDateTime); @@ -55,7 +54,6 @@ const ClassInfo IntlDateTimeFormatProtot @begin dateTimeFormatPrototypeTable format intlDateTimeFormatPrototypeGetterFormat DontEnum|ReadOnly|CustomAccessor formatRange intlDateTimeFormatPrototypeFuncFormatRange DontEnum|Function 2 - formatToParts intlDateTimeFormatPrototypeFuncFormatToParts DontEnum|Function 1 resolvedOptions intlDateTimeFormatPrototypeFuncResolvedOptions DontEnum|Function 0 @end */ @@ -142,6 +140,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlDateTimeFor return JSValue::encode(boundFormat); } +#if 0 JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatToParts, (JSGlobalObject* globalObject, CallFrame* callFrame)) { VM& vm = globalObject->vm(); @@ -167,6 +166,7 @@ JSC_DEFINE_HOST_FUNCTION(intlDateTimeFor RELEASE_AND_RETURN(scope, JSValue::encode(dateTimeFormat->formatToParts(globalObject, value))); } +#endif // http://tc39.es/proposal-intl-DateTimeFormat-formatRange/#sec-intl.datetimeformat.prototype.formatRange JSC_DEFINE_HOST_FUNCTION(intlDateTimeFormatPrototypeFuncFormatRange, (JSGlobalObject* globalObject, CallFrame* callFrame)) diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp 2021-11-10 13:24:55.343864110 -0600 @@ -26,7 +26,6 @@ #include "config.h" #include "IntlDisplayNames.h" -#include "IntlCache.h" #include "IntlObjectInlines.h" #include "JSCInlines.h" #include "ObjectConstructor.h" @@ -96,7 +95,7 @@ void IntlDisplayNames::initializeDisplay m_style = intlOption<Style>(globalObject, options, vm.propertyNames->style, { { "narrow"_s, Style::Narrow }, { "short"_s, Style::Short }, { "long"_s, Style::Long } }, "style must be either \"narrow\", \"short\", or \"long\""_s, Style::Long); RETURN_IF_EXCEPTION(scope, void()); - auto type = intlOption<std::optional<Type>>(globalObject, options, vm.propertyNames->type, { { "language"_s, Type::Language }, { "region"_s, Type::Region }, { "script"_s, Type::Script }, { "currency"_s, Type::Currency }, { "calendar"_s, Type::Calendar }, { "dateTimeField"_s, Type::DateTimeField } }, "type must be either \"language\", \"region\", \"script\", \"currency\", \"calendar\", or \"dateTimeField\""_s, std::nullopt); + auto type = intlOption<std::optional<Type>>(globalObject, options, vm.propertyNames->type, { { "language"_s, Type::Language }, { "region"_s, Type::Region }, { "script"_s, Type::Script }, { "currency"_s, Type::Currency } }, "type must be either \"language\", \"region\", \"script\", or \"currency\""_s, std::nullopt); RETURN_IF_EXCEPTION(scope, void()); if (!type) { throwTypeError(globalObject, scope, "type must not be undefined"_s); @@ -104,10 +103,7 @@ void IntlDisplayNames::initializeDisplay } m_type = type.value(); - m_fallback = intlOption<Fallback>(globalObject, options, vm.propertyNames->fallback, { { "code"_s, Fallback::Code }, { "none"_s, Fallback::None } }, "fallback must be either \"code\" or \"none\""_s, Fallback::Code); - RETURN_IF_EXCEPTION(scope, void()); - - m_languageDisplay = intlOption<LanguageDisplay>(globalObject, options, vm.propertyNames->languageDisplay, { { "dialect"_s, LanguageDisplay::Dialect }, { "standard"_s, LanguageDisplay::Standard } }, "languageDisplay must be either \"dialect\" or \"standard\""_s, LanguageDisplay::Dialect); + m_fallback = intlOption<Fallback>(globalObject, options, Identifier::fromString(vm, "fallback"), { { "code"_s, Fallback::Code }, { "none"_s, Fallback::None } }, "fallback must be either \"code\" or \"none\""_s, Fallback::Code); RETURN_IF_EXCEPTION(scope, void()); #if HAVE(ICU_U_LOCALE_DISPLAY_NAMES) @@ -115,8 +111,9 @@ void IntlDisplayNames::initializeDisplay UDisplayContext contexts[] = { // en_GB displays as 'English (United Kingdom)' (Standard Names) or 'British English' (Dialect Names). + // We use Dialect Names here, aligned to the examples in the spec draft and V8's behavior. // https://github.com/tc39/proposal-intl-displaynames#language-display-names - (m_type == Type::Language && m_languageDisplay == LanguageDisplay::Standard) ? UDISPCTX_STANDARD_NAMES : UDISPCTX_DIALECT_NAMES, + UDISPCTX_DIALECT_NAMES, // Capitailization mode can be picked from several options. Possibly either UDISPCTX_CAPITALIZATION_NONE or UDISPCTX_CAPITALIZATION_FOR_STANDALONE is // preferable in Intl.DisplayNames. We use UDISPCTX_CAPITALIZATION_FOR_STANDALONE because it makes standalone date format better (fr "Juillet 2008" in ICU test suites), @@ -156,82 +153,10 @@ JSValue IntlDisplayNames::of(JSGlobalObj auto code = codeValue.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, { }); - // https://tc39.es/proposal-intl-displaynames/#sec-canonicalcodefordisplaynames - auto canonicalizeCodeForDisplayNames = [](Type type, String&& code) -> CString { - ASSERT(code.isAllASCII()); - switch (type) { - case Type::Language: { - return canonicalizeUnicodeLocaleID(code.ascii()).ascii(); - } - case Type::Region: { - // Let code be the result of mapping code to upper case as described in 6.1. - auto result = code.ascii(); - char* mutableData = result.mutableData(); - for (unsigned index = 0; index < result.length(); ++index) - mutableData[index] = toASCIIUpper(mutableData[index]); - return result; - } - case Type::Script: { - // Let code be the result of mapping the first character in code to upper case, and mapping the second, third and fourth character in code to lower case, as described in 6.1. - auto result = code.ascii(); - char* mutableData = result.mutableData(); - if (result.length() >= 1) - mutableData[0] = toASCIIUpper(mutableData[0]); - for (unsigned index = 1; index < result.length(); ++index) - mutableData[index] = toASCIILower(mutableData[index]); - return result; - } - case Type::Currency: - ASSERT_NOT_REACHED(); - break; - case Type::Calendar: { - // Let code be the result of mapping code to lower case as described in 6.1. - String lowered = code.convertToASCIILowercase(); - if (auto mapped = mapBCP47ToICUCalendarKeyword(lowered)) - lowered = WTFMove(mapped.value()); - return lowered.ascii(); - } - case Type::DateTimeField: { - ASSERT_NOT_REACHED(); - break; - } - } - return { }; - }; - Vector<UChar, 32> buffer; UErrorCode status = U_ZERO_ERROR; - CString canonicalCode; - switch (m_type) { - case Type::Language: { - if (!isUnicodeLanguageId(code)) { - throwRangeError(globalObject, scope, "argument is not a language id"_s); - return { }; - } - canonicalCode = canonicalizeCodeForDisplayNames(m_type, WTFMove(code)); - // Do not use uldn_languageDisplayName since it is not expected one for this "language" type. It returns "en-US" for "en-US" code, instead of "American English". - status = callBufferProducingFunction(uldn_localeDisplayName, m_displayNames.get(), canonicalCode.data(), buffer); - break; - } - case Type::Region: { - if (!isUnicodeRegionSubtag(code)) { - throwRangeError(globalObject, scope, "argument is not a region subtag"_s); - return { }; - } - canonicalCode = canonicalizeCodeForDisplayNames(m_type, WTFMove(code)); - status = callBufferProducingFunction(uldn_regionDisplayName, m_displayNames.get(), canonicalCode.data(), buffer); - break; - } - case Type::Script: { - if (!isUnicodeScriptSubtag(code)) { - throwRangeError(globalObject, scope, "argument is not a script subtag"_s); - return { }; - } - canonicalCode = canonicalizeCodeForDisplayNames(m_type, WTFMove(code)); - status = callBufferProducingFunction(uldn_scriptDisplayName, m_displayNames.get(), canonicalCode.data(), buffer); - break; - } - case Type::Currency: { + + if (m_type == Type::Currency) { // We do not use uldn_keyValueDisplayName + "currency". This is because of the following reasons. // 1. ICU does not respect UDISPCTX_LENGTH_FULL / UDISPCTX_LENGTH_SHORT in its implementation. // 2. There is no way to set "narrow" style in ULocaleDisplayNames while currency have "narrow" symbol style. @@ -277,82 +202,84 @@ JSValue IntlDisplayNames::of(JSGlobalObj // ICU API document. // > Returns pointer to display string of 'len' UChars. If the resource data contains no entry for 'currency', then 'currency' itself is returned. if (status == U_USING_DEFAULT_WARNING && result == currency) - return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, String(currency, 3)); + return (m_fallback == Fallback::None) ? jsUndefined() : codeValue; return jsString(vm, String(result, length)); } - case Type::Calendar: { - // a. If code does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. - if (!isUnicodeLocaleIdentifierType(code)) { - throwRangeError(globalObject, scope, "argument is not a calendar code"_s); - return { }; - } - canonicalCode = canonicalizeCodeForDisplayNames(m_type, WTFMove(code)); - status = callBufferProducingFunction(uldn_keyValueDisplayName, m_displayNames.get(), "calendar", canonicalCode.data(), buffer); - break; - } - case Type::DateTimeField: { - // We do not use uldn_keyValueDisplayName since it cannot handle narrow length. - // Instead, we use udatpg_getFieldDisplayName. - - // https://tc39.es/intl-displaynames-v2/#sec-isvaliddatetimefieldcode - auto isValidDateTimeFieldCode = [](const String& code) -> std::optional<UDateTimePatternField> { - if (code == "era"_s) - return UDATPG_ERA_FIELD; - if (code == "year"_s) - return UDATPG_YEAR_FIELD; - if (code == "quarter"_s) - return UDATPG_QUARTER_FIELD; - if (code == "month"_s) - return UDATPG_MONTH_FIELD; - if (code == "weekOfYear"_s) - return UDATPG_WEEK_OF_YEAR_FIELD; - if (code == "weekday"_s) - return UDATPG_WEEKDAY_FIELD; - if (code == "day"_s) - return UDATPG_DAY_FIELD; - if (code == "dayPeriod"_s) - return UDATPG_DAYPERIOD_FIELD; - if (code == "hour"_s) - return UDATPG_HOUR_FIELD; - if (code == "minute"_s) - return UDATPG_MINUTE_FIELD; - if (code == "second"_s) - return UDATPG_SECOND_FIELD; - if (code == "timeZoneName"_s) - return UDATPG_ZONE_FIELD; - return std::nullopt; - }; - auto field = isValidDateTimeFieldCode(code); - if (!field) { - throwRangeError(globalObject, scope, "argument is not a dateTimeField code"_s); - return { }; + // https://tc39.es/proposal-intl-displaynames/#sec-canonicalcodefordisplaynames + auto canonicalizeCodeForDisplayNames = [](Type type, const String& code) -> CString { + ASSERT(code.isAllASCII()); + auto result = code.ascii(); + char* mutableData = result.mutableData(); + switch (type) { + case Type::Language: { + // Let code be the result of mapping code to lower case as described in 6.1. + for (unsigned index = 0; index < result.length(); ++index) + mutableData[index] = toASCIILower(mutableData[index]); + break; } - - UDateTimePGDisplayWidth style = UDATPG_WIDE; - switch (m_style) { - case Style::Long: - style = UDATPG_WIDE; + case Type::Region: { + // Let code be the result of mapping code to upper case as described in 6.1. + for (unsigned index = 0; index < result.length(); ++index) + mutableData[index] = toASCIIUpper(mutableData[index]); break; - case Style::Short: - style = UDATPG_ABBREVIATED; + } + case Type::Script: { + // Let code be the result of mapping the first character in code to upper case, and mapping the second, third and fourth character in code to lower case, as described in 6.1. + if (result.length() >= 1) + mutableData[0] = toASCIIUpper(mutableData[0]); + for (unsigned index = 1; index < result.length(); ++index) + mutableData[index] = toASCIILower(mutableData[index]); break; - case Style::Narrow: - style = UDATPG_NARROW; + } + case Type::Currency: + ASSERT_NOT_REACHED(); break; } + return result; + }; - buffer = vm.intlCache().getFieldDisplayName(m_localeCString.data(), field.value(), style, status); - if (U_FAILURE(status)) - return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, code); - return jsString(vm, String(buffer)); + switch (m_type) { + case Type::Language: { + // If code does not matches the unicode_language_id production, throw a RangeError exception + if (!isUnicodeLanguageId(code)) { + throwRangeError(globalObject, scope, "argument is not a language id"_s); + return { }; + } + auto language = canonicalizeCodeForDisplayNames(m_type, code); + // Do not use uldn_languageDisplayName since it is not expected one for this "language" type. It returns "en-US" for "en-US" code, instead of "American English". + status = callBufferProducingFunction(uldn_localeDisplayName, m_displayNames.get(), language.data(), buffer); + break; + } + case Type::Region: { + // If code does not matches the unicode_region_subtag production, throw a RangeError exception + if (!isUnicodeRegionSubtag(code)) { + throwRangeError(globalObject, scope, "argument is not a region subtag"_s); + return { }; + } + auto region = canonicalizeCodeForDisplayNames(m_type, code); + status = callBufferProducingFunction(uldn_regionDisplayName, m_displayNames.get(), region.data(), buffer); + break; } + case Type::Script: { + // If code does not matches the unicode_script_subtag production, throw a RangeError exception + if (!isUnicodeScriptSubtag(code)) { + throwRangeError(globalObject, scope, "argument is not a script subtag"_s); + return { }; + } + auto script = canonicalizeCodeForDisplayNames(m_type, code); + status = callBufferProducingFunction(uldn_scriptDisplayName, m_displayNames.get(), script.data(), buffer); + break; + } + case Type::Currency: + ASSERT_NOT_REACHED(); + break; } if (U_FAILURE(status)) { // uldn_localeDisplayName, uldn_regionDisplayName, and uldn_scriptDisplayName return U_ILLEGAL_ARGUMENT_ERROR if the display-name is not found. // We should return undefined if fallback is "none". Otherwise, we should return input value. if (status == U_ILLEGAL_ARGUMENT_ERROR) - return (m_fallback == Fallback::None) ? jsUndefined() : jsString(vm, String(canonicalCode.data(), canonicalCode.length())); + return (m_fallback == Fallback::None) ? jsUndefined() : codeValue; return throwTypeError(globalObject, scope, "Failed to query a display name."_s); } return jsString(vm, String(buffer)); @@ -371,9 +298,7 @@ JSObject* IntlDisplayNames::resolvedOpti options->putDirect(vm, vm.propertyNames->locale, jsString(vm, m_locale)); options->putDirect(vm, vm.propertyNames->style, jsNontrivialString(vm, styleString(m_style))); options->putDirect(vm, vm.propertyNames->type, jsNontrivialString(vm, typeString(m_type))); - options->putDirect(vm, vm.propertyNames->fallback, jsNontrivialString(vm, fallbackString(m_fallback))); - if (m_type == Type::Language) - options->putDirect(vm, vm.propertyNames->languageDisplay, jsNontrivialString(vm, languageDisplayString(m_languageDisplay))); + options->putDirect(vm, Identifier::fromString(vm, "fallback"), jsNontrivialString(vm, fallbackString(m_fallback))); return options; } @@ -402,10 +327,6 @@ ASCIILiteral IntlDisplayNames::typeStrin return "script"_s; case Type::Currency: return "currency"_s; - case Type::Calendar: - return "calendar"_s; - case Type::DateTimeField: - return "dateTimeField"_s; } ASSERT_NOT_REACHED(); return ASCIILiteral::null(); @@ -421,18 +342,6 @@ ASCIILiteral IntlDisplayNames::fallbackS } ASSERT_NOT_REACHED(); return ASCIILiteral::null(); -} - -ASCIILiteral IntlDisplayNames::languageDisplayString(LanguageDisplay languageDisplay) -{ - switch (languageDisplay) { - case LanguageDisplay::Dialect: - return "dialect"_s; - case LanguageDisplay::Standard: - return "standard"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); } } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDisplayNames.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDisplayNames.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlDisplayNames.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlDisplayNames.h 2021-11-10 13:24:55.347864132 -0600 @@ -72,14 +72,12 @@ private: void finishCreation(VM&); enum class Style : uint8_t { Narrow, Short, Long }; - enum class Type : uint8_t { Language, Region, Script, Currency, Calendar, DateTimeField }; + enum class Type : uint8_t { Language, Region, Script, Currency }; enum class Fallback : uint8_t { Code, None }; - enum class LanguageDisplay : uint8_t { Dialect, Standard }; static ASCIILiteral styleString(Style); static ASCIILiteral typeString(Type); static ASCIILiteral fallbackString(Fallback); - static ASCIILiteral languageDisplayString(LanguageDisplay); using ULocaleDisplayNamesDeleter = ICUDeleter<uldn_close>; std::unique_ptr<ULocaleDisplayNames, ULocaleDisplayNamesDeleter> m_displayNames; @@ -90,7 +88,6 @@ private: Style m_style { Style::Long }; Type m_type { Type::Language }; Fallback m_fallback { Fallback::Code }; - LanguageDisplay m_languageDisplay { LanguageDisplay::Dialect }; }; } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp 2021-11-10 16:29:27.630837052 -0600 @@ -42,7 +42,7 @@ namespace JSC { const ClassInfo IntlNumberFormat::s_info = { "Object", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(IntlNumberFormat) }; namespace IntlNumberFormatInternal { -static constexpr bool verbose = false; +constexpr bool verbose = false; } struct IntlNumberFormatField { @@ -50,6 +50,12 @@ struct IntlNumberFormatField { size_t size; }; +void IntlNumberFormat::UNumberFormatDeleter::operator()(UNumberFormat* numberFormat) const +{ + if (numberFormat) + unum_close(numberFormat); +} + IntlNumberFormat* IntlNumberFormat::create(VM& vm, Structure* structure) { IntlNumberFormat* format = new (NotNull, allocateCell<IntlNumberFormat>(vm.heap)) IntlNumberFormat(vm, structure); @@ -117,7 +123,7 @@ static unsigned computeCurrencyDigits(co // 11.1.1 The abstract operation CurrencyDigits (currency) // "If the ISO 4217 currency and funds code list contains currency as an alphabetic code, // then return the minor unit value corresponding to the currency from the list; else return 2. - static constexpr std::pair<const char*, unsigned> currencyMinorUnits[] = { + std::pair<const char*, unsigned> currencyMinorUnits[] = { { "BHD", 3 }, { "BIF", 0 }, { "BYR", 0 }, @@ -151,69 +157,6 @@ static unsigned computeCurrencyDigits(co return 2; } -static std::optional<MeasureUnit> sanctionedSimpleUnitIdentifier(StringView unitIdentifier) -{ - ASSERT( - std::is_sorted(std::begin(simpleUnits), std::end(simpleUnits), - [](const MeasureUnit& a, const MeasureUnit& b) { - return WTF::codePointCompare(StringView(a.subType), StringView(b.subType)) < 0; - })); - - auto iterator = std::lower_bound(std::begin(simpleUnits), std::end(simpleUnits), unitIdentifier, - [](const MeasureUnit& unit, StringView unitIdentifier) { - return WTF::codePointCompare(StringView(unit.subType), unitIdentifier) < 0; - }); - if (iterator != std::end(simpleUnits) && iterator->subType == unitIdentifier) - return *iterator; - return std::nullopt; -} - -struct WellFormedUnit { -public: - explicit WellFormedUnit(MeasureUnit numerator) - : numerator(numerator) - { - } - - WellFormedUnit(MeasureUnit numerator, MeasureUnit denominator) - : numerator(numerator) - , denominator(denominator) - { - } - - MeasureUnit numerator; - std::optional<MeasureUnit> denominator; -}; - -static std::optional<WellFormedUnit> wellFormedUnitIdentifier(StringView unitIdentifier) -{ - // https://tc39.es/ecma402/#sec-iswellformedunitidentifier - if (auto unit = sanctionedSimpleUnitIdentifier(unitIdentifier)) - return WellFormedUnit(unit.value()); - - // If the substring "-per-" does not occur exactly once in unitIdentifier, then return false. - auto per = StringView("-per-"_s); - auto position = unitIdentifier.find(per); - if (position == WTF::notFound) - return std::nullopt; - if (unitIdentifier.find(per, position + per.length()) != WTF::notFound) - return std::nullopt; - - // If the result of IsSanctionedSimpleUnitIdentifier(numerator) is false, then return false. - auto numerator = unitIdentifier.substring(0, position); - auto numeratorUnit = sanctionedSimpleUnitIdentifier(numerator); - if (!numeratorUnit) - return std::nullopt; - - // If the result of IsSanctionedSimpleUnitIdentifier(denominator) is false, then return false. - auto denominator = unitIdentifier.substring(position + per.length()); - auto denominatorUnit = sanctionedSimpleUnitIdentifier(denominator); - if (!denominatorUnit) - return std::nullopt; - - return WellFormedUnit(numeratorUnit.value(), denominatorUnit.value()); -} - // https://tc39.github.io/ecma402/#sec-initializenumberformat void IntlNumberFormat::initializeNumberFormat(JSGlobalObject* globalObject, JSValue locales, JSValue optionsValue) { @@ -252,7 +195,7 @@ void IntlNumberFormat::initializeNumberF m_numberingSystem = resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Nu)]; - m_style = intlOption<Style>(globalObject, options, vm.propertyNames->style, { { "decimal"_s, Style::Decimal }, { "percent"_s, Style::Percent }, { "currency"_s, Style::Currency }, { "unit"_s, Style::Unit } }, "style must be either \"decimal\", \"percent\", \"currency\", or \"unit\""_s, Style::Decimal); + m_style = intlOption<Style>(globalObject, options, vm.propertyNames->style, { { "decimal"_s, Style::Decimal }, { "percent"_s, Style::Percent }, { "currency"_s, Style::Currency } }, "style must be either \"decimal\", \"percent\", or \"currency\""_s, Style::Decimal); RETURN_IF_EXCEPTION(scope, void()); String currency = intlStringOption(globalObject, options, Identifier::fromString(vm, "currency"), { }, nullptr, nullptr); @@ -276,207 +219,51 @@ void IntlNumberFormat::initializeNumberF currencyDigits = computeCurrencyDigits(currency); } - m_currencyDisplay = intlOption<CurrencyDisplay>(globalObject, options, Identifier::fromString(vm, "currencyDisplay"), { { "code"_s, CurrencyDisplay::Code }, { "symbol"_s, CurrencyDisplay::Symbol }, { "narrowSymbol"_s, CurrencyDisplay::NarrowSymbol }, { "name"_s, CurrencyDisplay::Name } }, "currencyDisplay must be either \"code\", \"symbol\", or \"name\""_s, CurrencyDisplay::Symbol); + m_currencyDisplay = intlOption<CurrencyDisplay>(globalObject, options, Identifier::fromString(vm, "currencyDisplay"), { { "code"_s, CurrencyDisplay::Code }, { "symbol"_s, CurrencyDisplay::Symbol }, { "name"_s, CurrencyDisplay::Name } }, "currencyDisplay must be either \"code\", \"symbol\", or \"name\""_s, CurrencyDisplay::Symbol); RETURN_IF_EXCEPTION(scope, void()); - m_currencySign = intlOption<CurrencySign>(globalObject, options, Identifier::fromString(vm, "currencySign"), { { "standard"_s, CurrencySign::Standard }, { "accounting"_s, CurrencySign::Accounting } }, "currencySign must be either \"standard\" or \"accounting\""_s, CurrencySign::Standard); + unsigned minimumIntegerDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "minimumIntegerDigits"), 1, 21, 1); RETURN_IF_EXCEPTION(scope, void()); + m_minimumIntegerDigits = minimumIntegerDigits; - String unit = intlStringOption(globalObject, options, Identifier::fromString(vm, "unit"), { }, nullptr, nullptr); + unsigned minimumFractionDigitsDefault = (m_style == Style::Currency) ? currencyDigits : 0; RETURN_IF_EXCEPTION(scope, void()); - std::optional<WellFormedUnit> wellFormedUnit; - if (!unit.isNull()) { - wellFormedUnit = wellFormedUnitIdentifier(unit); - if (!wellFormedUnit) { - throwRangeError(globalObject, scope, "unit is not a well-formed unit identifier"_s); - return; - } - m_unit = unit; - } else if (m_style == Style::Unit) { - throwTypeError(globalObject, scope, "unit must be a string"_s); - return; - } - m_unitDisplay = intlOption<UnitDisplay>(globalObject, options, Identifier::fromString(vm, "unitDisplay"), { { "short"_s, UnitDisplay::Short }, { "narrow"_s, UnitDisplay::Narrow }, { "long"_s, UnitDisplay::Long } }, "unitDisplay must be either \"short\", \"narrow\", or \"long\""_s, UnitDisplay::Short); + unsigned minimumFractionDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "minimumFractionDigits"), 0, 20, minimumFractionDigitsDefault); RETURN_IF_EXCEPTION(scope, void()); + m_minimumFractionDigits = minimumFractionDigits; - unsigned minimumFractionDigitsDefault = (m_style == Style::Currency) ? currencyDigits : 0; - unsigned maximumFractionDigitsDefault = (m_style == Style::Currency) ? currencyDigits : (m_style == Style::Percent) ? 0 : 3; + unsigned maximumFractionDigitsDefault; + if (m_style == Style::Currency) + maximumFractionDigitsDefault = std::max(minimumFractionDigits, currencyDigits); + else if (m_style == Style::Percent) + maximumFractionDigitsDefault = minimumFractionDigits; + else + maximumFractionDigitsDefault = std::max(minimumFractionDigits, 3u); - m_notation = intlOption<IntlNotation>(globalObject, options, Identifier::fromString(vm, "notation"), { { "standard"_s, IntlNotation::Standard }, { "scientific"_s, IntlNotation::Scientific }, { "engineering"_s, IntlNotation::Engineering }, { "compact"_s, IntlNotation::Compact } }, "notation must be either \"standard\", \"scientific\", \"engineering\", or \"compact\""_s, IntlNotation::Standard); + unsigned maximumFractionDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "maximumFractionDigits"), minimumFractionDigits, 20, maximumFractionDigitsDefault); RETURN_IF_EXCEPTION(scope, void()); + m_maximumFractionDigits = maximumFractionDigits; - setNumberFormatDigitOptions(globalObject, this, options, minimumFractionDigitsDefault, maximumFractionDigitsDefault, m_notation); + JSValue minimumSignificantDigitsValue = options->get(globalObject, Identifier::fromString(vm, "minimumSignificantDigits")); RETURN_IF_EXCEPTION(scope, void()); - m_compactDisplay = intlOption<CompactDisplay>(globalObject, options, Identifier::fromString(vm, "compactDisplay"), { { "short"_s, CompactDisplay::Short }, { "long"_s, CompactDisplay::Long } }, "compactDisplay must be either \"short\" or \"long\""_s, CompactDisplay::Short); + JSValue maximumSignificantDigitsValue = options->get(globalObject, Identifier::fromString(vm, "maximumSignificantDigits")); RETURN_IF_EXCEPTION(scope, void()); + if (!minimumSignificantDigitsValue.isUndefined() || !maximumSignificantDigitsValue.isUndefined()) { + unsigned minimumSignificantDigits = intlDefaultNumberOption(globalObject, minimumSignificantDigitsValue, Identifier::fromString(vm, "minimumSignificantDigits"), 1, 21, 1); + RETURN_IF_EXCEPTION(scope, void()); + unsigned maximumSignificantDigits = intlDefaultNumberOption(globalObject, maximumSignificantDigitsValue, Identifier::fromString(vm, "maximumSignificantDigits"), minimumSignificantDigits, 21, 21); + RETURN_IF_EXCEPTION(scope, void()); + m_minimumSignificantDigits = minimumSignificantDigits; + m_maximumSignificantDigits = maximumSignificantDigits; + } + TriState useGrouping = intlBooleanOption(globalObject, options, Identifier::fromString(vm, "useGrouping")); RETURN_IF_EXCEPTION(scope, void()); m_useGrouping = useGrouping != TriState::False; - m_signDisplay = intlOption<SignDisplay>(globalObject, options, Identifier::fromString(vm, "signDisplay"), { { "auto"_s, SignDisplay::Auto }, { "never"_s, SignDisplay::Never }, { "always"_s, SignDisplay::Always }, { "exceptZero"_s, SignDisplay::ExceptZero } }, "signDisplay must be either \"auto\", \"never\", \"always\", or \"exceptZero\""_s, SignDisplay::Auto); - RETURN_IF_EXCEPTION(scope, void()); - - CString dataLocaleWithExtensions = makeString(resolved.dataLocale, "-u-nu-", m_numberingSystem).utf8(); - dataLogLnIf(IntlNumberFormatInternal::verbose, "dataLocaleWithExtensions:(", dataLocaleWithExtensions , ")"); - - // Options are obtained. Configure formatter here. - -#if HAVE(ICU_U_NUMBER_FORMATTER) - // Constructing ICU Number Skeletons to configure UNumberFormatter. - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md - - StringBuilder skeletonBuilder; - skeletonBuilder.append("rounding-mode-half-up"); - - switch (m_style) { - case Style::Decimal: - // No skeleton is needed. - break; - case Style::Percent: - skeletonBuilder.append(" percent scale/100"); - break; - case Style::Currency: { - skeletonBuilder.append(" currency/", currency); - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit-width - switch (m_currencyDisplay) { - case CurrencyDisplay::Code: - skeletonBuilder.append(" unit-width-iso-code"); - break; - case CurrencyDisplay::Symbol: - // Default option. Do not specify unit-width. - break; - case CurrencyDisplay::NarrowSymbol: - skeletonBuilder.append(" unit-width-narrow"); - break; - case CurrencyDisplay::Name: - skeletonBuilder.append(" unit-width-full-name"); - break; - } - break; - } - case Style::Unit: { - // The measure-unit stem takes one required option: the unit identifier of the unit to be formatted. - // The full unit identifier is required: both the type and the subtype (for example, length-meter). - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit - skeletonBuilder.append(" measure-unit/"); - auto numeratorUnit = wellFormedUnit->numerator; - skeletonBuilder.append(numeratorUnit.type, '-', numeratorUnit.subType); - if (auto denominatorUnitValue = wellFormedUnit->denominator) { - auto denominatorUnit = denominatorUnitValue.value(); - skeletonBuilder.append(" per-measure-unit/", denominatorUnit.type, '-', denominatorUnit.subType); - } - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit-width - switch (m_unitDisplay) { - case UnitDisplay::Short: - skeletonBuilder.append(" unit-width-short"); - break; - case UnitDisplay::Narrow: - skeletonBuilder.append(" unit-width-narrow"); - break; - case UnitDisplay::Long: - skeletonBuilder.append(" unit-width-full-name"); - break; - } - break; - } - } - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#integer-width - skeletonBuilder.append(" integer-width/", WTF::ICU::majorVersion() >= 67 ? '*' : '+'); // Prior to ICU 67, use the symbol + instead of *. - for (unsigned i = 0; i < m_minimumIntegerDigits; ++i) - skeletonBuilder.append('0'); - - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: { - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision - skeletonBuilder.append(" ."); - for (unsigned i = 0; i < m_minimumFractionDigits; ++i) - skeletonBuilder.append('0'); - for (unsigned i = 0; i < m_maximumFractionDigits - m_minimumFractionDigits; ++i) - skeletonBuilder.append('#'); - break; - } - case IntlRoundingType::SignificantDigits: { - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#significant-digits-precision - skeletonBuilder.append(' '); - for (unsigned i = 0; i < m_minimumSignificantDigits; ++i) - skeletonBuilder.append('@'); - for (unsigned i = 0; i < m_maximumSignificantDigits - m_minimumSignificantDigits; ++i) - skeletonBuilder.append('#'); - break; - } - case IntlRoundingType::CompactRounding: - // Do not set anything. - break; - } - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#notation - switch (m_notation) { - case IntlNotation::Standard: - break; - case IntlNotation::Scientific: - skeletonBuilder.append(" scientific"); - break; - case IntlNotation::Engineering: - skeletonBuilder.append(" engineering"); - break; - case IntlNotation::Compact: - switch (m_compactDisplay) { - case CompactDisplay::Short: - skeletonBuilder.append(" compact-short"); - break; - case CompactDisplay::Long: - skeletonBuilder.append(" compact-long"); - break; - } - break; - } - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#sign-display - // CurrencySign's accounting is a part of SignDisplay in ICU. - bool useAccounting = (m_style == Style::Currency && m_currencySign == CurrencySign::Accounting); - switch (m_signDisplay) { - case SignDisplay::Auto: - if (useAccounting) - skeletonBuilder.append(" sign-accounting"); - else - skeletonBuilder.append(" sign-auto"); - break; - case SignDisplay::Never: - skeletonBuilder.append(" sign-never"); - break; - case SignDisplay::Always: - if (useAccounting) - skeletonBuilder.append(" sign-accounting-always"); - else - skeletonBuilder.append(" sign-always"); - break; - case SignDisplay::ExceptZero: - if (useAccounting) - skeletonBuilder.append(" sign-accounting-except-zero"); - else - skeletonBuilder.append(" sign-except-zero"); - break; - } - - if (!m_useGrouping) - skeletonBuilder.append(" group-off"); - - String skeleton = skeletonBuilder.toString(); - dataLogLnIf(IntlNumberFormatInternal::verbose, skeleton); - StringView skeletonView(skeleton); - UErrorCode status = U_ZERO_ERROR; - m_numberFormatter = std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter>(unumf_openForSkeletonAndLocale(skeletonView.upconvertedCharacters().get(), skeletonView.length(), dataLocaleWithExtensions.data(), &status)); - if (U_FAILURE(status)) { - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat"_s); - return; - } -#else UNumberFormatStyle style = UNUM_DEFAULT; switch (m_style) { case Style::Decimal: @@ -493,48 +280,19 @@ void IntlNumberFormat::initializeNumberF case CurrencyDisplay::Symbol: style = UNUM_CURRENCY; break; - case CurrencyDisplay::NarrowSymbol: - style = UNUM_CURRENCY; // Use the same option to "symbol" since linked-ICU does not support it. - break; case CurrencyDisplay::Name: style = UNUM_CURRENCY_PLURAL; break; + default: + ASSERT_NOT_REACHED(); } - switch (m_currencySign) { - case CurrencySign::Standard: - break; - case CurrencySign::Accounting: - // Ignore this case since linked ICU does not support it. - break; - } - break; - case Style::Unit: - // Ignore this case since linked ICU does not support it. - break; - } - - switch (m_notation) { - case IntlNotation::Standard: - break; - case IntlNotation::Scientific: - case IntlNotation::Engineering: - case IntlNotation::Compact: - // Ignore this case since linked ICU does not support it. - break; - } - - switch (m_signDisplay) { - case SignDisplay::Auto: - break; - case SignDisplay::Never: - case SignDisplay::Always: - case SignDisplay::ExceptZero: - // Ignore this case since linked ICU does not support it. break; + default: + ASSERT_NOT_REACHED(); } UErrorCode status = U_ZERO_ERROR; - m_numberFormat = std::unique_ptr<UNumberFormat, UNumberFormatDeleter>(unum_open(style, nullptr, 0, dataLocaleWithExtensions.data(), nullptr, &status)); + m_numberFormat = std::unique_ptr<UNumberFormat, UNumberFormatDeleter>(unum_open(style, nullptr, 0, m_locale.utf8().data(), nullptr, &status)); if (U_FAILURE(status)) { throwTypeError(globalObject, scope, "failed to initialize NumberFormat"_s); return; @@ -548,57 +306,40 @@ void IntlNumberFormat::initializeNumberF } } - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: + if (!m_minimumSignificantDigits) { unum_setAttribute(m_numberFormat.get(), UNUM_MIN_INTEGER_DIGITS, m_minimumIntegerDigits); unum_setAttribute(m_numberFormat.get(), UNUM_MIN_FRACTION_DIGITS, m_minimumFractionDigits); unum_setAttribute(m_numberFormat.get(), UNUM_MAX_FRACTION_DIGITS, m_maximumFractionDigits); - break; - case IntlRoundingType::SignificantDigits: + } else { unum_setAttribute(m_numberFormat.get(), UNUM_SIGNIFICANT_DIGITS_USED, true); unum_setAttribute(m_numberFormat.get(), UNUM_MIN_SIGNIFICANT_DIGITS, m_minimumSignificantDigits); unum_setAttribute(m_numberFormat.get(), UNUM_MAX_SIGNIFICANT_DIGITS, m_maximumSignificantDigits); - break; - case IntlRoundingType::CompactRounding: - // Ignore this case since linked ICU does not support it. - break; } unum_setAttribute(m_numberFormat.get(), UNUM_GROUPING_USED, m_useGrouping); unum_setAttribute(m_numberFormat.get(), UNUM_ROUNDING_MODE, UNUM_ROUND_HALFUP); -#endif } // https://tc39.es/ecma402/#sec-formatnumber JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, double value) const { + ASSERT(m_numberFormat); + VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); Vector<UChar, 32> buffer; -#if HAVE(ICU_U_NUMBER_FORMATTER) - ASSERT(m_numberFormatter); - UErrorCode status = U_ZERO_ERROR; - auto formattedNumber = std::unique_ptr<UFormattedNumber, UFormattedNumberDeleter>(unumf_openResult(&status)); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - unumf_formatDouble(m_numberFormatter.get(), value, formattedNumber.get(), &status); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - status = callBufferProducingFunction(unumf_resultToString, formattedNumber.get(), buffer); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); -#else - ASSERT(m_numberFormat); auto status = callBufferProducingFunction(unum_formatDouble, m_numberFormat.get(), value, buffer, nullptr); if (U_FAILURE(status)) + return throwTypeError(globalObject, scope, "Failed to format a number."_s); -#endif return jsString(vm, String(buffer)); } // https://tc39.es/ecma402/#sec-formatnumber JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, JSBigInt* value) const { + ASSERT(m_numberFormat); + VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -609,24 +350,10 @@ JSValue IntlNumberFormat::format(JSGloba auto* rawString = reinterpret_cast<const char*>(string.characters8()); Vector<UChar, 32> buffer; -#if HAVE(ICU_U_NUMBER_FORMATTER) - ASSERT(m_numberFormatter); - UErrorCode status = U_ZERO_ERROR; - auto formattedNumber = std::unique_ptr<UFormattedNumber, UFormattedNumberDeleter>(unumf_openResult(&status)); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a BigInt."_s); - unumf_formatDecimal(m_numberFormatter.get(), rawString, string.length(), formattedNumber.get(), &status); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a BigInt."_s); - status = callBufferProducingFunction(unumf_resultToString, formattedNumber.get(), buffer); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a BigInt."_s); -#else - ASSERT(m_numberFormat); auto status = callBufferProducingFunction(unum_formatDecimal, m_numberFormat.get(), rawString, string.length(), buffer, nullptr); if (U_FAILURE(status)) return throwTypeError(globalObject, scope, "Failed to format a BigInt."_s); -#endif + return jsString(vm, String(buffer)); } @@ -639,8 +366,6 @@ ASCIILiteral IntlNumberFormat::styleStri return "percent"_s; case Style::Currency: return "currency"_s; - case Style::Unit: - return "unit"_s; } ASSERT_NOT_REACHED(); return ASCIILiteral::null(); @@ -653,8 +378,6 @@ ASCIILiteral IntlNumberFormat::currencyD return "code"_s; case CurrencyDisplay::Symbol: return "symbol"_s; - case CurrencyDisplay::NarrowSymbol: - return "narrowSymbol"_s; case CurrencyDisplay::Name: return "name"_s; } @@ -662,76 +385,6 @@ ASCIILiteral IntlNumberFormat::currencyD return ASCIILiteral::null(); } -ASCIILiteral IntlNumberFormat::notationString(IntlNotation notation) -{ - switch (notation) { - case IntlNotation::Standard: - return "standard"_s; - case IntlNotation::Scientific: - return "scientific"_s; - case IntlNotation::Engineering: - return "engineering"_s; - case IntlNotation::Compact: - return "compact"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); -} - -ASCIILiteral IntlNumberFormat::currencySignString(CurrencySign currencySign) -{ - switch (currencySign) { - case CurrencySign::Standard: - return "standard"_s; - case CurrencySign::Accounting: - return "accounting"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); -} - -ASCIILiteral IntlNumberFormat::unitDisplayString(UnitDisplay unitDisplay) -{ - switch (unitDisplay) { - case UnitDisplay::Short: - return "short"_s; - case UnitDisplay::Narrow: - return "narrow"_s; - case UnitDisplay::Long: - return "long"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); -} - -ASCIILiteral IntlNumberFormat::compactDisplayString(CompactDisplay compactDisplay) -{ - switch (compactDisplay) { - case CompactDisplay::Short: - return "short"_s; - case CompactDisplay::Long: - return "long"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); -} - -ASCIILiteral IntlNumberFormat::signDisplayString(SignDisplay signDisplay) -{ - switch (signDisplay) { - case SignDisplay::Auto: - return "auto"_s; - case SignDisplay::Never: - return "never"_s; - case SignDisplay::Always: - return "always"_s; - case SignDisplay::ExceptZero: - return "exceptZero"_s; - } - ASSERT_NOT_REACHED(); - return ASCIILiteral::null(); -} - // https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions JSObject* IntlNumberFormat::resolvedOptions(JSGlobalObject* globalObject) const { @@ -740,38 +393,19 @@ JSObject* IntlNumberFormat::resolvedOpti options->putDirect(vm, vm.propertyNames->locale, jsString(vm, m_locale)); options->putDirect(vm, vm.propertyNames->numberingSystem, jsString(vm, m_numberingSystem)); options->putDirect(vm, vm.propertyNames->style, jsNontrivialString(vm, styleString(m_style))); - switch (m_style) { - case Style::Decimal: - case Style::Percent: - break; - case Style::Currency: + if (m_style == Style::Currency) { options->putDirect(vm, Identifier::fromString(vm, "currency"), jsNontrivialString(vm, m_currency)); options->putDirect(vm, Identifier::fromString(vm, "currencyDisplay"), jsNontrivialString(vm, currencyDisplayString(m_currencyDisplay))); - options->putDirect(vm, Identifier::fromString(vm, "currencySign"), jsNontrivialString(vm, currencySignString(m_currencySign))); - break; - case Style::Unit: - options->putDirect(vm, Identifier::fromString(vm, "unit"), jsNontrivialString(vm, m_unit)); - options->putDirect(vm, Identifier::fromString(vm, "unitDisplay"), jsNontrivialString(vm, unitDisplayString(m_unitDisplay))); - break; } options->putDirect(vm, vm.propertyNames->minimumIntegerDigits, jsNumber(m_minimumIntegerDigits)); - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: - options->putDirect(vm, vm.propertyNames->minimumFractionDigits, jsNumber(m_minimumFractionDigits)); - options->putDirect(vm, vm.propertyNames->maximumFractionDigits, jsNumber(m_maximumFractionDigits)); - break; - case IntlRoundingType::SignificantDigits: + options->putDirect(vm, vm.propertyNames->minimumFractionDigits, jsNumber(m_minimumFractionDigits)); + options->putDirect(vm, vm.propertyNames->maximumFractionDigits, jsNumber(m_maximumFractionDigits)); + if (m_minimumSignificantDigits) { + ASSERT(m_maximumSignificantDigits); options->putDirect(vm, vm.propertyNames->minimumSignificantDigits, jsNumber(m_minimumSignificantDigits)); options->putDirect(vm, vm.propertyNames->maximumSignificantDigits, jsNumber(m_maximumSignificantDigits)); - break; - case IntlRoundingType::CompactRounding: - break; } options->putDirect(vm, Identifier::fromString(vm, "useGrouping"), jsBoolean(m_useGrouping)); - options->putDirect(vm, Identifier::fromString(vm, "notation"), jsNontrivialString(vm, notationString(m_notation))); - if (m_notation == IntlNotation::Compact) - options->putDirect(vm, Identifier::fromString(vm, "compactDisplay"), jsNontrivialString(vm, compactDisplayString(m_compactDisplay))); - options->putDirect(vm, Identifier::fromString(vm, "signDisplay"), jsNontrivialString(vm, signDisplayString(m_signDisplay))); return options; } @@ -780,7 +414,7 @@ void IntlNumberFormat::setBoundFormat(VM m_boundFormat.set(vm, this, format); } -static ASCIILiteral partTypeString(UNumberFormatFields field, IntlNumberFormat::Style style, double value) +static ASCIILiteral partTypeString(UNumberFormatFields field, double value) { switch (field) { case UNUM_INTEGER_FIELD: @@ -793,31 +427,20 @@ static ASCIILiteral partTypeString(UNumb return "fraction"_s; case UNUM_DECIMAL_SEPARATOR_FIELD: return "decimal"_s; - case UNUM_EXPONENT_SYMBOL_FIELD: - return "exponentSeparator"_s; - case UNUM_EXPONENT_SIGN_FIELD: - return "exponentMinusSign"_s; - case UNUM_EXPONENT_FIELD: - return "exponentInteger"_s; case UNUM_GROUPING_SEPARATOR_FIELD: return "group"_s; case UNUM_CURRENCY_FIELD: return "currency"_s; case UNUM_PERCENT_FIELD: - // If the style is "unit", we should report as unit. - // JSTests/test262/test/intl402/NumberFormat/prototype/formatToParts/percent-en-US.js - return (style == IntlNumberFormat::Style::Unit) ? "unit"_s : "percentSign"_s; + return "percentSign"_s; case UNUM_SIGN_FIELD: - return std::signbit(value) ? "minusSign"_s : "plusSign"_s; -#if HAVE(ICU_U_NUMBER_FORMATTER) - case UNUM_MEASURE_UNIT_FIELD: - return "unit"_s; - case UNUM_COMPACT_FIELD: - return "compact"_s; -#endif + return value < 0 ? "minusSign"_s : "plusSign"_s; // These should not show up because there is no way to specify them in NumberFormat options. // If they do, they don't fit well into any of known part types, so consider it an "unknown". case UNUM_PERMILL_FIELD: + case UNUM_EXPONENT_SYMBOL_FIELD: + case UNUM_EXPONENT_SIGN_FIELD: + case UNUM_EXPONENT_FIELD: // Any newer additions to the UNumberFormatFields enum should just be considered an "unknown" part. default: return "unknown"_s; @@ -825,7 +448,8 @@ static ASCIILiteral partTypeString(UNumb return "unknown"_s; } -void IntlNumberFormat::formatToPartsInternal(JSGlobalObject* globalObject, Style style, double value, const String& formatted, IntlFieldIterator& iterator, JSArray* parts, JSString* unit) +#if 0 +void IntlNumberFormat::formatToPartsInternal(JSGlobalObject* globalObject, double value, const String& formatted, UFieldPositionIterator* iterator, JSArray* parts, JSString* unit) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -837,12 +461,7 @@ void IntlNumberFormat::formatToPartsInte Vector<IntlNumberFormatField, 32> fields(stringLength, literalField); int32_t beginIndex = 0; int32_t endIndex = 0; - UErrorCode status = U_ZERO_ERROR; - auto fieldType = iterator.next(beginIndex, endIndex, status); - if (U_FAILURE(status)) { - throwTypeError(globalObject, scope, "Failed to iterate field position iterator"_s); - return; - } + auto fieldType = ufieldpositer_next(iterator, &beginIndex, &endIndex); while (fieldType >= 0) { size_t size = endIndex - beginIndex; for (auto i = beginIndex; i < endIndex; ++i) { @@ -850,11 +469,7 @@ void IntlNumberFormat::formatToPartsInte if (fields[i].size >= size) fields[i] = IntlNumberFormatField { fieldType, size }; } - fieldType = iterator.next(beginIndex, endIndex, status); - if (U_FAILURE(status)) { - throwTypeError(globalObject, scope, "Failed to iterate field position iterator"_s); - return; - } + fieldType = ufieldpositer_next(iterator, &beginIndex, &endIndex); } auto literalString = jsNontrivialString(vm, "literal"_s); @@ -868,7 +483,7 @@ void IntlNumberFormat::formatToPartsInte auto fieldType = fields[currentIndex].type; while (currentIndex < stringLength && fields[currentIndex].type == fieldType) ++currentIndex; - auto partType = fieldType == literalFieldType ? literalString : jsString(vm, partTypeString(UNumberFormatFields(fieldType), style, value)); + auto partType = fieldType == literalFieldType ? literalString : jsString(vm, partTypeString(UNumberFormatFields(fieldType), value)); auto partValue = jsSubstring(vm, formatted, startIndex, currentIndex - startIndex); JSObject* part = constructEmptyObject(globalObject); part->putDirect(vm, vm.propertyNames->type, partType); @@ -883,6 +498,8 @@ void IntlNumberFormat::formatToPartsInte // https://tc39.github.io/ecma402/#sec-formatnumbertoparts JSValue IntlNumberFormat::formatToParts(JSGlobalObject* globalObject, double value) const { + ASSERT(m_numberFormat); + VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -892,28 +509,9 @@ JSValue IntlNumberFormat::formatToParts( return throwTypeError(globalObject, scope, "failed to open field position iterator"_s); Vector<UChar, 32> result; -#if HAVE(ICU_U_NUMBER_FORMATTER) - ASSERT(m_numberFormatter); - auto formattedNumber = std::unique_ptr<UFormattedNumber, UFormattedNumberDeleter>(unumf_openResult(&status)); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - unumf_formatDouble(m_numberFormatter.get(), value, formattedNumber.get(), &status); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - status = callBufferProducingFunction(unumf_resultToString, formattedNumber.get(), result); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - unumf_resultGetAllFieldPositions(formattedNumber.get(), fieldItr.get(), &status); - if (U_FAILURE(status)) - return throwTypeError(globalObject, scope, "Failed to format a number."_s); - IntlFieldIterator iterator(*fieldItr.get()); -#else - ASSERT(m_numberFormat); status = callBufferProducingFunction(unum_formatDoubleForFields, m_numberFormat.get(), value, result, fieldItr.get()); if (U_FAILURE(status)) return throwTypeError(globalObject, scope, "failed to format a number."_s); - IntlFieldIterator iterator(*fieldItr.get()); -#endif auto resultString = String(result); @@ -921,10 +519,11 @@ JSValue IntlNumberFormat::formatToParts( if (!parts) return throwOutOfMemoryError(globalObject, scope); - formatToPartsInternal(globalObject, m_style, value, resultString, iterator, parts); + formatToPartsInternal(globalObject, value, resultString, fieldItr.get(), parts); RETURN_IF_EXCEPTION(scope, { }); return parts; } +#endif } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormat.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormat.h 2021-11-10 16:35:39.656818265 -0600 @@ -29,29 +29,12 @@ #include "JSObject.h" #include <unicode/unum.h> -#include <wtf/unicode/icu/ICUHelpers.h> - -#if !defined(HAVE_ICU_U_NUMBER_FORMATTER) -// UNUM_COMPACT_FIELD and UNUM_MEASURE_UNIT_FIELD are available after ICU 64. -#if U_ICU_VERSION_MAJOR_NUM >= 64 -#define HAVE_ICU_U_NUMBER_FORMATTER 1 -#endif -#endif - -#if HAVE(ICU_U_NUMBER_FORMATTER) -#include <unicode/unumberformatter.h> -#endif namespace JSC { -class IntlFieldIterator; class JSBoundFunction; enum class RelevantExtensionKey : uint8_t; -enum class IntlRoundingType : uint8_t { FractionDigits, SignificantDigits, CompactRounding }; -enum class IntlNotation : uint8_t { Standard, Scientific, Engineering, Compact }; -template<typename IntlType> void setNumberFormatDigitOptions(JSGlobalObject*, IntlType*, JSObject*, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation); - class IntlNumberFormat final : public JSNonFinalObject { public: using Base = JSNonFinalObject; @@ -77,20 +60,11 @@ public: void initializeNumberFormat(JSGlobalObject*, JSValue locales, JSValue optionsValue); JSValue format(JSGlobalObject*, double) const; JSValue format(JSGlobalObject*, JSBigInt*) const; - JSValue formatToParts(JSGlobalObject*, double) const; JSObject* resolvedOptions(JSGlobalObject*) const; JSBoundFunction* boundFormat() const { return m_boundFormat.get(); } void setBoundFormat(VM&, JSBoundFunction*); - enum class Style : uint8_t { Decimal, Percent, Currency, Unit }; - - static void formatToPartsInternal(JSGlobalObject*, Style, double, const String& formatted, IntlFieldIterator&, JSArray*, JSString* unit = nullptr); - - template<typename IntlType> - friend void setNumberFormatDigitOptions(JSGlobalObject*, IntlType*, JSObject*, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation); - - static ASCIILiteral notationString(IntlNotation); static IntlNumberFormat* unwrapForOldFunctions(JSGlobalObject*, JSValue); @@ -101,33 +75,22 @@ private: static Vector<String> localeData(const String&, RelevantExtensionKey); - enum class CurrencyDisplay : uint8_t { Code, Symbol, NarrowSymbol, Name }; - enum class CurrencySign : uint8_t { Standard, Accounting }; - enum class UnitDisplay : uint8_t { Short, Narrow, Long }; - enum class CompactDisplay : uint8_t { Short, Long }; - enum class SignDisplay : uint8_t { Auto, Never, Always, ExceptZero }; + enum class Style : uint8_t { Decimal, Percent, Currency }; + enum class CurrencyDisplay : uint8_t { Code, Symbol, Name }; + + struct UNumberFormatDeleter { + void operator()(UNumberFormat*) const; + }; static ASCIILiteral styleString(Style); static ASCIILiteral currencyDisplayString(CurrencyDisplay); - static ASCIILiteral currencySignString(CurrencySign); - static ASCIILiteral unitDisplayString(UnitDisplay); - static ASCIILiteral compactDisplayString(CompactDisplay); - static ASCIILiteral signDisplayString(SignDisplay); WriteBarrier<JSBoundFunction> m_boundFormat; -#if HAVE(ICU_U_NUMBER_FORMATTER) - using UNumberFormatterDeleter = ICUDeleter<unumf_close>; - using UFormattedNumberDeleter = ICUDeleter<unumf_closeResult>; - std::unique_ptr<UNumberFormatter, UNumberFormatterDeleter> m_numberFormatter; -#else - using UNumberFormatDeleter = ICUDeleter<unum_close>; - std::unique_ptr<UNumberFormat, ICUDeleter<unum_close>> m_numberFormat; -#endif + std::unique_ptr<UNumberFormat, UNumberFormatDeleter> m_numberFormat; String m_locale; String m_numberingSystem; String m_currency; - String m_unit; unsigned m_minimumIntegerDigits { 1 }; unsigned m_minimumFractionDigits { 0 }; unsigned m_maximumFractionDigits { 3 }; @@ -135,13 +98,7 @@ private: unsigned m_maximumSignificantDigits { 0 }; Style m_style { Style::Decimal }; CurrencyDisplay m_currencyDisplay; - CurrencySign m_currencySign; - UnitDisplay m_unitDisplay; - CompactDisplay m_compactDisplay; - IntlNotation m_notation { IntlNotation::Standard }; - SignDisplay m_signDisplay; bool m_useGrouping { true }; - IntlRoundingType m_roundingType { IntlRoundingType::FractionDigits }; }; } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h 2021-11-10 16:37:32.689420197 -0600 @@ -32,96 +32,6 @@ namespace JSC { -template<typename IntlType> -void setNumberFormatDigitOptions(JSGlobalObject* globalObject, IntlType* intlInstance, JSObject* options, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation notation) -{ - VM& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - - unsigned minimumIntegerDigits = intlNumberOption(globalObject, options, vm.propertyNames->minimumIntegerDigits, 1, 21, 1); - RETURN_IF_EXCEPTION(scope, void()); - - JSValue minimumFractionDigitsValue = jsUndefined(); - JSValue maximumFractionDigitsValue = jsUndefined(); - JSValue minimumSignificantDigitsValue = jsUndefined(); - JSValue maximumSignificantDigitsValue = jsUndefined(); - if (options) { - minimumFractionDigitsValue = options->get(globalObject, vm.propertyNames->minimumFractionDigits); - RETURN_IF_EXCEPTION(scope, void()); - - maximumFractionDigitsValue = options->get(globalObject, vm.propertyNames->maximumFractionDigits); - RETURN_IF_EXCEPTION(scope, void()); - - minimumSignificantDigitsValue = options->get(globalObject, vm.propertyNames->minimumSignificantDigits); - RETURN_IF_EXCEPTION(scope, void()); - - maximumSignificantDigitsValue = options->get(globalObject, vm.propertyNames->maximumSignificantDigits); - RETURN_IF_EXCEPTION(scope, void()); - } - - intlInstance->m_minimumIntegerDigits = minimumIntegerDigits; - - if (!minimumSignificantDigitsValue.isUndefined() || !maximumSignificantDigitsValue.isUndefined()) { - intlInstance->m_roundingType = IntlRoundingType::SignificantDigits; - unsigned minimumSignificantDigits = intlDefaultNumberOption(globalObject, minimumSignificantDigitsValue, vm.propertyNames->minimumSignificantDigits, 1, 21, 1); - RETURN_IF_EXCEPTION(scope, void()); - unsigned maximumSignificantDigits = intlDefaultNumberOption(globalObject, maximumSignificantDigitsValue, vm.propertyNames->maximumSignificantDigits, minimumSignificantDigits, 21, 21); - RETURN_IF_EXCEPTION(scope, void()); - intlInstance->m_minimumSignificantDigits = minimumSignificantDigits; - intlInstance->m_maximumSignificantDigits = maximumSignificantDigits; - return; - } - - if (!minimumFractionDigitsValue.isUndefined() || !maximumFractionDigitsValue.isUndefined()) { - constexpr unsigned undefinedValue = UINT32_MAX; - intlInstance->m_roundingType = IntlRoundingType::FractionDigits; - unsigned specifiedMinimumFractionDigits = intlDefaultNumberOption(globalObject, minimumFractionDigitsValue, vm.propertyNames->minimumFractionDigits, 0, 20, undefinedValue); - RETURN_IF_EXCEPTION(scope, void()); - unsigned specifiedMaximumFractionDigits = intlDefaultNumberOption(globalObject, maximumFractionDigitsValue, vm.propertyNames->maximumFractionDigits, 0, 20, undefinedValue); - RETURN_IF_EXCEPTION(scope, void()); - if (specifiedMaximumFractionDigits != undefinedValue) - minimumFractionDigitsDefault = std::min(minimumFractionDigitsDefault, specifiedMaximumFractionDigits); - unsigned minimumFractionDigits = intlDefaultNumberOption(globalObject, (specifiedMinimumFractionDigits == undefinedValue) ? jsUndefined() : jsNumber(specifiedMinimumFractionDigits), vm.propertyNames->minimumFractionDigits, 0, 20, minimumFractionDigitsDefault); - RETURN_IF_EXCEPTION(scope, void()); - unsigned maximumFractionDigits = intlDefaultNumberOption(globalObject, (specifiedMaximumFractionDigits == undefinedValue) ? jsUndefined() : jsNumber(specifiedMaximumFractionDigits), vm.propertyNames->maximumFractionDigits, 0, 20, std::max(maximumFractionDigitsDefault, minimumFractionDigits)); - RETURN_IF_EXCEPTION(scope, void()); - if (minimumFractionDigits > maximumFractionDigits) { - throwRangeError(globalObject, scope, "Computed minimumFractionDigits is larger than maximumFractionDigits"_s); - return; - } - intlInstance->m_minimumFractionDigits = minimumFractionDigits; - intlInstance->m_maximumFractionDigits = maximumFractionDigits; - return; - } - - if (notation == IntlNotation::Compact) { - intlInstance->m_roundingType = IntlRoundingType::CompactRounding; - return; - } - - intlInstance->m_roundingType = IntlRoundingType::FractionDigits; - intlInstance->m_minimumFractionDigits = minimumFractionDigitsDefault; - intlInstance->m_maximumFractionDigits = maximumFractionDigitsDefault; -} - -class IntlFieldIterator { -public: - WTF_MAKE_NONCOPYABLE(IntlFieldIterator); - - explicit IntlFieldIterator(UFieldPositionIterator& iterator) - : m_iterator(iterator) - { - } - - int32_t next(int32_t& beginIndex, int32_t& endIndex, UErrorCode&) - { - return ufieldpositer_next(&m_iterator, &beginIndex, &endIndex); - } - -private: - UFieldPositionIterator& m_iterator; -}; - // https://tc39.es/ecma402/#sec-unwrapnumberformat inline IntlNumberFormat* IntlNumberFormat::unwrapForOldFunctions(JSGlobalObject* globalObject, JSValue thisValue) { diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp 2021-11-10 16:43:22.503283436 -0600 @@ -28,14 +28,12 @@ #include "IntlNumberFormatPrototype.h" #include "BuiltinNames.h" -#include "IntlNumberFormatInlines.h" #include "JSBoundFunction.h" #include "JSCInlines.h" namespace JSC { static JSC_DECLARE_CUSTOM_GETTER(intlNumberFormatPrototypeGetterFormat); -static JSC_DECLARE_HOST_FUNCTION(intlNumberFormatPrototypeFuncFormatToParts); static JSC_DECLARE_HOST_FUNCTION(intlNumberFormatPrototypeFuncResolvedOptions); static JSC_DECLARE_HOST_FUNCTION(intlNumberFormatFuncFormat); @@ -50,7 +48,6 @@ const ClassInfo IntlNumberFormatPrototyp /* Source for IntlNumberFormatPrototype.lut.h @begin numberFormatPrototypeTable format intlNumberFormatPrototypeGetterFormat DontEnum|ReadOnly|CustomAccessor - formatToParts intlNumberFormatPrototypeFuncFormatToParts DontEnum|Function 1 resolvedOptions intlNumberFormatPrototypeFuncResolvedOptions DontEnum|Function 0 @end */ @@ -137,6 +134,7 @@ JSC_DEFINE_CUSTOM_GETTER(intlNumberForma return JSValue::encode(boundFormat); } +#if 0 JSC_DEFINE_HOST_FUNCTION(intlNumberFormatPrototypeFuncFormatToParts, (JSGlobalObject* globalObject, CallFrame* callFrame)) { VM& vm = globalObject->vm(); @@ -155,6 +153,7 @@ JSC_DEFINE_HOST_FUNCTION(intlNumberForma RELEASE_AND_RETURN(scope, JSValue::encode(numberFormat->formatToParts(globalObject, value))); } +#endif JSC_DEFINE_HOST_FUNCTION(intlNumberFormatPrototypeFuncResolvedOptions, (JSGlobalObject* globalObject, CallFrame* callFrame)) { diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlObject.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlObject.cpp 2021-11-10 16:47:03.088458158 -0600 @@ -39,19 +39,11 @@ #include "IntlDisplayNames.h" #include "IntlDisplayNamesConstructor.h" #include "IntlDisplayNamesPrototype.h" -#include "IntlListFormat.h" -#include "IntlListFormatConstructor.h" -#include "IntlListFormatPrototype.h" -#include "IntlLocale.h" -#include "IntlLocaleConstructor.h" -#include "IntlLocalePrototype.h" #include "IntlNumberFormatConstructor.h" #include "IntlNumberFormatPrototype.h" #include "IntlObjectInlines.h" #include "IntlPluralRulesConstructor.h" #include "IntlPluralRulesPrototype.h" -#include "IntlRelativeTimeFormatConstructor.h" -#include "IntlRelativeTimeFormatPrototype.h" #include "IntlSegmenter.h" #include "IntlSegmenterConstructor.h" #include "IntlSegmenterPrototype.h" @@ -61,7 +53,6 @@ #include <unicode/ucal.h> #include <unicode/ucol.h> #include <unicode/ucurr.h> -#include <unicode/ufieldpositer.h> #include <unicode/uloc.h> #include <unicode/unumsys.h> #include <wtf/Assertions.h> @@ -69,7 +60,6 @@ #include <wtf/NeverDestroyed.h> #include <wtf/text/StringBuilder.h> #include <wtf/text/StringImpl.h> -#include <wtf/text/StringParsingBuffer.h> #include <wtf/unicode/icu/ICUHelpers.h> namespace JSC { @@ -100,20 +90,6 @@ static JSValue createDisplayNamesConstru return IntlDisplayNamesConstructor::create(vm, IntlDisplayNamesConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<IntlDisplayNamesPrototype*>(globalObject->displayNamesStructure()->storedPrototypeObject())); } -static JSValue createListFormatConstructor(VM& vm, JSObject* object) -{ - IntlObject* intlObject = jsCast<IntlObject*>(object); - JSGlobalObject* globalObject = intlObject->globalObject(vm); - return IntlListFormatConstructor::create(vm, IntlListFormatConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<IntlListFormatPrototype*>(globalObject->listFormatStructure()->storedPrototypeObject())); -} - -static JSValue createLocaleConstructor(VM& vm, JSObject* object) -{ - IntlObject* intlObject = jsCast<IntlObject*>(object); - JSGlobalObject* globalObject = intlObject->globalObject(vm); - return IntlLocaleConstructor::create(vm, IntlLocaleConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<IntlLocalePrototype*>(globalObject->localeStructure()->storedPrototypeObject())); -} - static JSValue createNumberFormatConstructor(VM& vm, JSObject* object) { IntlObject* intlObject = jsCast<IntlObject*>(object); @@ -128,13 +104,6 @@ static JSValue createPluralRulesConstruc return IntlPluralRulesConstructor::create(vm, IntlPluralRulesConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<IntlPluralRulesPrototype*>(globalObject->pluralRulesStructure()->storedPrototypeObject())); } -static JSValue createRelativeTimeFormatConstructor(VM& vm, JSObject* object) -{ - IntlObject* intlObject = jsCast<IntlObject*>(object); - JSGlobalObject* globalObject = intlObject->globalObject(vm); - return IntlRelativeTimeFormatConstructor::create(vm, IntlRelativeTimeFormatConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<IntlRelativeTimeFormatPrototype*>(globalObject->relativeTimeFormatStructure()->storedPrototypeObject())); -} - static JSValue createSegmenterConstructor(VM& vm, JSObject* object) { IntlObject* intlObject = jsCast<IntlObject*>(object); @@ -153,10 +122,8 @@ namespace JSC { getCanonicalLocales intlObjectFuncGetCanonicalLocales DontEnum|Function 1 Collator createCollatorConstructor DontEnum|PropertyCallback DateTimeFormat createDateTimeFormatConstructor DontEnum|PropertyCallback - Locale createLocaleConstructor DontEnum|PropertyCallback NumberFormat createNumberFormatConstructor DontEnum|PropertyCallback PluralRules createPluralRulesConstructor DontEnum|PropertyCallback - RelativeTimeFormat createRelativeTimeFormatConstructor DontEnum|PropertyCallback Segmenter createSegmenterConstructor DontEnum|PropertyCallback @end */ @@ -169,11 +136,13 @@ struct MatcherResult { const ClassInfo IntlObject::s_info = { "Intl", &Base::s_info, &intlObjectTable, nullptr, CREATE_METHOD_TABLE(IntlObject) }; +#if 0 void UFieldPositionIteratorDeleter::operator()(UFieldPositionIterator* iterator) const { if (iterator) ufieldpositer_close(iterator); } +#endif const MeasureUnit simpleUnits[43] = { { "area"_s, "acre"_s }, @@ -243,11 +212,6 @@ void IntlObject::finishCreation(VM& vm, #else UNUSED_PARAM(&createDisplayNamesConstructor); #endif -#if HAVE(ICU_U_LIST_FORMATTER) - putDirectWithoutTransition(vm, vm.propertyNames->ListFormat, createListFormatConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum)); -#else - UNUSED_PARAM(&createListFormatConstructor); -#endif if (Options::useIntlEnumeration()) JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("supportedValuesOf", intlObjectFuncSupportedValuesOf, static_cast<unsigned>(PropertyAttribute::DontEnum), 1); } @@ -661,29 +625,24 @@ unsigned intlDefaultNumberOption(JSGloba // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier bool isUnicodeLocaleIdentifierType(StringView string) { - // Matching the Unicode Locale Identifier type nonterminal. - // Because the spec abstract operation is not mentioning to BCP-47 conformance for this matching, - // '-' and '_' separators are allowed while BCP-47 only accepts '-'. - // On the other hand, IsStructurallyValidLanguageTag explicitly mentions to BCP-47. - return readCharactersForParsing(string, [](auto buffer) -> bool { - while (true) { - auto begin = buffer.position(); - while (buffer.hasCharactersRemaining() && isASCIIAlphanumeric(*buffer)) - ++buffer; - unsigned length = buffer.position() - begin; - if (length < 3 || length > 8) - return false; - if (!buffer.hasCharactersRemaining()) - return true; - if (*buffer != '-' && *buffer != '_') + ASSERT(!string.isNull()); + + for (auto part : string.splitAllowingEmptyEntries('-')) { + auto length = part.length(); + if (length < 3 || length > 8) + return false; + + for (auto character : part.codeUnits()) { + if (!isASCIIAlphanumeric(character)) return false; - ++buffer; } - }); + } + + return true; } // https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid -String canonicalizeUnicodeLocaleID(const CString& tag) +static String canonicalizeLanguageTag(const CString& tag) { auto buffer = localeIDBufferForLanguageTagWithNullTerminator(tag); if (buffer.isEmpty()) @@ -710,7 +669,7 @@ Vector<String> canonicalizeLocaleList(JS return seen; JSObject* localesObject; - if (locales.isString() || locales.inherits<IntlLocale>(vm)) { + if (locales.isString()) { JSArray* localesArray = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous)); if (!localesArray) { throwOutOfMemoryError(globalObject, scope); @@ -747,19 +706,15 @@ Vector<String> canonicalizeLocaleList(JS } String tag; - if (kValue.inherits<IntlLocale>(vm)) - tag = jsCast<IntlLocale*>(kValue)->toString(); - else { - JSString* string = kValue.toString(globalObject); - RETURN_IF_EXCEPTION(scope, Vector<String>()); + JSString* string = kValue.toString(globalObject); + RETURN_IF_EXCEPTION(scope, Vector<String>()); - tag = string->value(globalObject); - RETURN_IF_EXCEPTION(scope, Vector<String>()); - } + tag = string->value(globalObject); + RETURN_IF_EXCEPTION(scope, Vector<String>()); if (isStructurallyValidLanguageTag(tag)) { ASSERT(tag.isAllASCII()); - String canonicalizedTag = canonicalizeUnicodeLocaleID(tag.ascii()); + String canonicalizedTag = canonicalizeLanguageTag(tag.ascii()); if (!canonicalizedTag.isNull()) { if (seenSet.add(canonicalizedTag).isNewEntry) seen.append(canonicalizedTag); @@ -796,14 +751,14 @@ String defaultLocale(JSGlobalObject* glo // be determined by WebCore-specific logic like some WK settings. Usually this will return the // same thing as userPreferredLanguages()[0]. if (auto defaultLanguage = globalObject->globalObjectMethodTable()->defaultLanguage) { - String locale = canonicalizeUnicodeLocaleID(defaultLanguage().utf8()); + String locale = canonicalizeLanguageTag(defaultLanguage().utf8()); if (!locale.isEmpty()) return locale; } Vector<String> languages = userPreferredLanguages(); for (const auto& language : languages) { - String locale = canonicalizeUnicodeLocaleID(language.utf8()); + String locale = canonicalizeLanguageTag(language.utf8()); if (!locale.isEmpty()) return locale; } @@ -1526,19 +1481,9 @@ std::optional<String> mapICUCalendarKeyw return std::nullopt; } -std::optional<String> mapBCP47ToICUCalendarKeyword(const String& calendar) -{ - if (calendar == "gregory"_s) - return "gregorian"_s; - if (calendar == "islamicc"_s) - return "islamic-civil"_s; - if (calendar == "ethioaa"_s) - return "ethiopic-amete-alem"_s; - return std::nullopt; -} - std::optional<String> mapICUCollationKeywordToBCP47(const String& collation) { + // Map keyword values to BCP 47 equivalents. if (collation == "dictionary"_s) return "dict"_s; if (collation == "gb2312han"_s) diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlObject.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlObject.h 2021-11-10 16:48:19.080862856 -0600 @@ -99,7 +99,6 @@ inline const LocaleSet& intlDisplayNames inline const LocaleSet& intlNumberFormatAvailableLocales() { return intlAvailableLocales(); } inline const LocaleSet& intlPluralRulesAvailableLocales() { return intlAvailableLocales(); } inline const LocaleSet& intlRelativeTimeFormatAvailableLocales() { return intlAvailableLocales(); } -inline const LocaleSet& intlListFormatAvailableLocales() { return intlAvailableLocales(); } using CalendarID = unsigned; const Vector<String>& intlAvailableCalendars(); @@ -147,7 +146,6 @@ bool isUnicodeRegionSubtag(StringView); bool isUnicodeVariantSubtag(StringView); bool isUnicodeLanguageId(StringView); bool isStructurallyValidLanguageTag(StringView); -String canonicalizeUnicodeLocaleID(const CString& languageTag); bool isWellFormedCurrencyCode(StringView); @@ -159,6 +157,5 @@ struct UFieldPositionIteratorDeleter { std::optional<String> mapICUCollationKeywordToBCP47(const String&); std::optional<String> mapICUCalendarKeywordToBCP47(const String&); -std::optional<String> mapBCP47ToICUCalendarKeyword(const String&); } // namespace JSC diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlPluralRules.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlPluralRules.cpp 2021-11-16 17:13:23.221144236 -0600 @@ -36,7 +36,25 @@ namespace JSC { const ClassInfo IntlPluralRules::s_info = { "Object", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(IntlPluralRules) }; -using UEnumerationDeleter = ICUDeleter<uenum_close>; +void IntlPluralRules::UPluralRulesDeleter::operator()(UPluralRules* pluralRules) const +{ + if (pluralRules) + uplrules_close(pluralRules); +} + +void IntlPluralRules::UNumberFormatDeleter::operator()(UNumberFormat* numberFormat) const +{ + if (numberFormat) + unum_close(numberFormat); +} + +struct UEnumerationDeleter { + void operator()(UEnumeration* enumeration) const + { + if (enumeration) + uenum_close(enumeration); + } +}; IntlPluralRules* IntlPluralRules::create(VM& vm, Structure* structure) { @@ -104,8 +122,34 @@ void IntlPluralRules::initializePluralRu m_type = intlOption<Type>(globalObject, options, vm.propertyNames->type, { { "cardinal"_s, Type::Cardinal }, { "ordinal"_s, Type::Ordinal } }, "type must be \"cardinal\" or \"ordinal\""_s, Type::Cardinal); RETURN_IF_EXCEPTION(scope, void()); - setNumberFormatDigitOptions(globalObject, this, options, 0, 3, IntlNotation::Standard); + unsigned minimumIntegerDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "minimumIntegerDigits"), 1, 21, 1); + RETURN_IF_EXCEPTION(scope, void()); + m_minimumIntegerDigits = minimumIntegerDigits; + + unsigned minimumFractionDigitsDefault = 0; + unsigned minimumFractionDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "minimumFractionDigits"), 0, 20, minimumFractionDigitsDefault); RETURN_IF_EXCEPTION(scope, void()); + m_minimumFractionDigits = minimumFractionDigits; + + unsigned maximumFractionDigitsDefault = std::max(minimumFractionDigits, 3u); + unsigned maximumFractionDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "maximumFractionDigits"), minimumFractionDigits, 20, maximumFractionDigitsDefault); + RETURN_IF_EXCEPTION(scope, void()); + m_maximumFractionDigits = maximumFractionDigits; + + JSValue minimumSignificantDigitsValue = options->get(globalObject, Identifier::fromString(vm, "minimumSignificantDigits")); + RETURN_IF_EXCEPTION(scope, void()); + + JSValue maximumSignificantDigitsValue = options->get(globalObject, Identifier::fromString(vm, "maximumSignificantDigits")); + RETURN_IF_EXCEPTION(scope, void()); + + if (!minimumSignificantDigitsValue.isUndefined() || !maximumSignificantDigitsValue.isUndefined()) { + unsigned minimumSignificantDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "minimumSignificantDigits"), 1, 21, 1); + RETURN_IF_EXCEPTION(scope, void()); + unsigned maximumSignificantDigits = intlNumberOption(globalObject, options, Identifier::fromString(vm, "maximumSignificantDigits"), minimumSignificantDigits, 21, 21); + RETURN_IF_EXCEPTION(scope, void()); + m_minimumSignificantDigits = minimumSignificantDigits; + m_maximumSignificantDigits = maximumSignificantDigits; + } UErrorCode status = U_ZERO_ERROR; m_numberFormat = std::unique_ptr<UNumberFormat, UNumberFormatDeleter>(unum_open(UNUM_DECIMAL, nullptr, 0, m_locale.utf8().data(), nullptr, &status)); @@ -114,20 +158,14 @@ void IntlPluralRules::initializePluralRu return; } - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: - unum_setAttribute(m_numberFormat.get(), UNUM_MIN_INTEGER_DIGITS, m_minimumIntegerDigits); - unum_setAttribute(m_numberFormat.get(), UNUM_MIN_FRACTION_DIGITS, m_minimumFractionDigits); - unum_setAttribute(m_numberFormat.get(), UNUM_MAX_FRACTION_DIGITS, m_maximumFractionDigits); - break; - case IntlRoundingType::SignificantDigits: + if (m_minimumSignificantDigits) { unum_setAttribute(m_numberFormat.get(), UNUM_SIGNIFICANT_DIGITS_USED, true); unum_setAttribute(m_numberFormat.get(), UNUM_MIN_SIGNIFICANT_DIGITS, m_minimumSignificantDigits); unum_setAttribute(m_numberFormat.get(), UNUM_MAX_SIGNIFICANT_DIGITS, m_maximumSignificantDigits); - break; - default: - RELEASE_ASSERT_NOT_REACHED(); - break; + } else { + unum_setAttribute(m_numberFormat.get(), UNUM_MIN_INTEGER_DIGITS, m_minimumIntegerDigits); + unum_setAttribute(m_numberFormat.get(), UNUM_MIN_FRACTION_DIGITS, m_minimumFractionDigits); + unum_setAttribute(m_numberFormat.get(), UNUM_MAX_FRACTION_DIGITS, m_maximumFractionDigits); } status = U_ZERO_ERROR; @@ -150,20 +188,14 @@ JSObject* IntlPluralRules::resolvedOptio options->putDirect(vm, vm.propertyNames->locale, jsNontrivialString(vm, m_locale)); options->putDirect(vm, vm.propertyNames->type, jsNontrivialString(vm, m_type == Type::Ordinal ? "ordinal"_s : "cardinal"_s)); options->putDirect(vm, vm.propertyNames->minimumIntegerDigits, jsNumber(m_minimumIntegerDigits)); - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: - options->putDirect(vm, vm.propertyNames->minimumFractionDigits, jsNumber(m_minimumFractionDigits)); - options->putDirect(vm, vm.propertyNames->maximumFractionDigits, jsNumber(m_maximumFractionDigits)); - break; - case IntlRoundingType::SignificantDigits: + options->putDirect(vm, vm.propertyNames->minimumFractionDigits, jsNumber(m_minimumFractionDigits)); + options->putDirect(vm, vm.propertyNames->maximumFractionDigits, jsNumber(m_maximumFractionDigits)); + if (m_minimumSignificantDigits) { options->putDirect(vm, vm.propertyNames->minimumSignificantDigits, jsNumber(m_minimumSignificantDigits)); options->putDirect(vm, vm.propertyNames->maximumSignificantDigits, jsNumber(m_maximumSignificantDigits)); - break; - default: - RELEASE_ASSERT_NOT_REACHED(); - break; } +#if 0 JSArray* categories = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), 0); if (UNLIKELY(!categories)) { throwOutOfMemoryError(globalObject, scope); @@ -183,6 +215,7 @@ JSObject* IntlPluralRules::resolvedOptio RETURN_IF_EXCEPTION(scope, { }); } options->putDirect(vm, Identifier::fromString(vm, "pluralCategories"), categories); +#endif RELEASE_AND_RETURN(scope, options); } @@ -198,11 +231,35 @@ JSValue IntlPluralRules::select(JSGlobal if (!std::isfinite(value)) return jsNontrivialString(vm, "other"_s); +#if 0 UErrorCode status = U_ZERO_ERROR; Vector<UChar, 8> result(8); auto length = uplrules_selectWithFormat(m_pluralRules.get(), value, m_numberFormat.get(), result.data(), result.size(), &status); if (U_FAILURE(status)) return throwTypeError(globalObject, scope, "failed to select plural value"_s); +#else + UErrorCode status = U_ZERO_ERROR; + Vector<UChar, 32> buffer(32); + auto length = unum_formatDouble(m_numberFormat.get(), value, buffer.data(), buffer.size(), nullptr, &status); + if (status == U_BUFFER_OVERFLOW_ERROR) { + buffer.grow(length); + status = U_ZERO_ERROR; + unum_formatDouble(m_numberFormat.get(), value, buffer.data(), length, nullptr, &status); + } + if (U_FAILURE(status)) + return throwTypeError(globalObject, scope, "failed to select plural value"_s); + + double formatted = unum_parseDouble(m_numberFormat.get(), buffer.data(), length, nullptr, &status); + if (U_FAILURE(status)) + return throwTypeError(globalObject, scope, "failed to select plural value"_s); + + // Can only be 'zero', 'one', 'two', 'few', 'many' or 'other' + status = U_ZERO_ERROR; + Vector<UChar, 8> result(8); + length = uplrules_select(m_pluralRules.get(), formatted, result.data(), result.size(), &status); + if (U_FAILURE(status)) + return throwTypeError(globalObject, scope, "failed to select plural value"_s); +#endif return jsString(vm, String(result.data(), length)); } diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlPluralRules.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlPluralRules.h 2021-11-16 16:19:51.167980376 -0600 @@ -26,10 +26,9 @@ #pragma once -#include "IntlNumberFormat.h" +#include "JSObject.h" #include <unicode/unum.h> #include <unicode/upluralrules.h> -#include <wtf/unicode/icu/ICUHelpers.h> namespace JSC { @@ -57,9 +56,6 @@ public: DECLARE_INFO; - template<typename IntlType> - friend void setNumberFormatDigitOptions(JSGlobalObject*, IntlType*, JSObject*, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation); - void initializePluralRules(JSGlobalObject*, JSValue locales, JSValue options); JSValue select(JSGlobalObject*, double value) const; JSObject* resolvedOptions(JSGlobalObject*) const; @@ -73,8 +69,12 @@ private: enum class Type : bool { Cardinal, Ordinal }; - using UPluralRulesDeleter = ICUDeleter<uplrules_close>; - using UNumberFormatDeleter = ICUDeleter<unum_close>; + struct UPluralRulesDeleter { + void operator()(UPluralRules*) const; + }; + struct UNumberFormatDeleter { + void operator()(UNumberFormat*) const; + }; std::unique_ptr<UPluralRules, UPluralRulesDeleter> m_pluralRules; std::unique_ptr<UNumberFormat, UNumberFormatDeleter> m_numberFormat; @@ -85,7 +85,6 @@ private: unsigned m_maximumFractionDigits { 3 }; unsigned m_minimumSignificantDigits { 0 }; unsigned m_maximumSignificantDigits { 0 }; - IntlRoundingType m_roundingType { IntlRoundingType::FractionDigits }; Type m_type { Type::Cardinal }; }; diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp 2021-11-10 13:25:18.215985933 -0600 @@ -27,7 +27,7 @@ #include "config.h" #include "IntlRelativeTimeFormat.h" -#include "IntlNumberFormatInlines.h" +#include "IntlNumberFormat.h" #include "IntlObjectInlines.h" #include "JSCInlines.h" #include "ObjectConstructor.h" @@ -40,6 +40,18 @@ const ClassInfo IntlRelativeTimeFormat:: namespace IntlRelativeTimeFormatInternal { } +void IntlRelativeTimeFormat::URelativeDateTimeFormatterDeleter::operator()(URelativeDateTimeFormatter* relativeDateTimeFormatter) const +{ + if (relativeDateTimeFormatter) + ureldatefmt_close(relativeDateTimeFormatter); +} + +void IntlRelativeTimeFormat::UNumberFormatDeleter::operator()(UNumberFormat* numberFormat) const +{ + if (numberFormat) + unum_close(numberFormat); +} + IntlRelativeTimeFormat* IntlRelativeTimeFormat::create(VM& vm, Structure* structure) { auto* format = new (NotNull, allocateCell<IntlRelativeTimeFormat>(vm.heap)) IntlRelativeTimeFormat(vm, structure); @@ -317,8 +329,7 @@ JSValue IntlRelativeTimeFormat::formatTo RETURN_IF_EXCEPTION(scope, { }); } - IntlFieldIterator fieldIterator(*iterator.get()); - IntlNumberFormat::formatToPartsInternal(globalObject, IntlNumberFormat::Style::Decimal, absValue, formattedNumber, fieldIterator, parts, jsString(vm, singularUnit(unit).toString())); + IntlNumberFormat::formatToPartsInternal(globalObject, absValue, formattedNumber, iterator.get(), parts, jsString(vm, singularUnit(unit).toString())); RETURN_IF_EXCEPTION(scope, { }); } diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h 2021-11-10 13:25:18.215985933 -0600 @@ -28,7 +28,6 @@ #include "JSObject.h" #include <unicode/ureldatefmt.h> -#include <wtf/unicode/icu/ICUHelpers.h> namespace JSC { @@ -72,8 +71,12 @@ private: enum class Style : uint8_t { Long, Short, Narrow }; - using URelativeDateTimeFormatterDeleter = ICUDeleter<ureldatefmt_close>; - using UNumberFormatDeleter = ICUDeleter<unum_close>; + struct URelativeDateTimeFormatterDeleter { + void operator()(URelativeDateTimeFormatter*) const; + }; + struct UNumberFormatDeleter { + void operator()(UNumberFormat*) const; + }; static ASCIILiteral styleString(Style); diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSDateMath.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSDateMath.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSDateMath.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSDateMath.cpp 2021-11-10 16:53:04.866384777 -0600 @@ -391,7 +391,7 @@ void DateCache::timeZoneCacheSlow() m_timeZoneCache = std::unique_ptr<OpaqueICUTimeZone, OpaqueICUTimeZoneDeleter>(cache); #else // Do not use icu::TimeZone::createDefault. ICU internally has a cache for timezone and createDefault returns this cached value. - m_timeZoneCache = std::unique_ptr<OpaqueICUTimeZone, OpaqueICUTimeZoneDeleter>(bitwise_cast<OpaqueICUTimeZone*>(icu::TimeZone::detectHostTimeZone())); + m_timeZoneCache = std::unique_ptr<OpaqueICUTimeZone, OpaqueICUTimeZoneDeleter>(bitwise_cast<OpaqueICUTimeZone*>(icu::TimeZone::createDefault())); #endif } diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObject.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObject.cpp 2021-11-10 13:25:18.215985933 -0600 @@ -80,18 +80,12 @@ #include "IntlDateTimeFormatPrototype.h" #include "IntlDisplayNames.h" #include "IntlDisplayNamesPrototype.h" -#include "IntlListFormat.h" -#include "IntlListFormatPrototype.h" -#include "IntlLocale.h" -#include "IntlLocalePrototype.h" #include "IntlNumberFormat.h" #include "IntlNumberFormatConstructor.h" #include "IntlNumberFormatPrototype.h" #include "IntlObject.h" #include "IntlPluralRules.h" #include "IntlPluralRulesPrototype.h" -#include "IntlRelativeTimeFormat.h" -#include "IntlRelativeTimeFormatPrototype.h" #include "IntlSegmentIterator.h" #include "IntlSegmentIteratorPrototype.h" #include "IntlSegmenter.h" @@ -1145,30 +1139,12 @@ capitalName ## Constructor* lowerName ## IntlDisplayNamesPrototype* displayNamesPrototype = IntlDisplayNamesPrototype::create(init.vm, IntlDisplayNamesPrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); init.set(IntlDisplayNames::createStructure(init.vm, globalObject, displayNamesPrototype)); }); - m_listFormatStructure.initLater( - [] (const Initializer<Structure>& init) { - JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); - IntlListFormatPrototype* listFormatPrototype = IntlListFormatPrototype::create(init.vm, IntlListFormatPrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); - init.set(IntlListFormat::createStructure(init.vm, globalObject, listFormatPrototype)); - }); - m_localeStructure.initLater( - [] (const Initializer<Structure>& init) { - JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); - IntlLocalePrototype* localePrototype = IntlLocalePrototype::create(init.vm, IntlLocalePrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); - init.set(IntlLocale::createStructure(init.vm, globalObject, localePrototype)); - }); m_pluralRulesStructure.initLater( [] (const Initializer<Structure>& init) { JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); IntlPluralRulesPrototype* pluralRulesPrototype = IntlPluralRulesPrototype::create(init.vm, globalObject, IntlPluralRulesPrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); init.set(IntlPluralRules::createStructure(init.vm, globalObject, pluralRulesPrototype)); }); - m_relativeTimeFormatStructure.initLater( - [] (const Initializer<Structure>& init) { - JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); - IntlRelativeTimeFormatPrototype* relativeTimeFormatPrototype = IntlRelativeTimeFormatPrototype::create(init.vm, IntlRelativeTimeFormatPrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype())); - init.set(IntlRelativeTimeFormat::createStructure(init.vm, globalObject, relativeTimeFormatPrototype)); - }); m_segmentIteratorStructure.initLater( [] (const Initializer<Structure>& init) { JSGlobalObject* globalObject = jsCast<JSGlobalObject*>(init.owner); @@ -2098,10 +2074,7 @@ void JSGlobalObject::visitChildrenImpl(J thisObject->m_defaultCollator.visit(visitor); thisObject->m_collatorStructure.visit(visitor); thisObject->m_displayNamesStructure.visit(visitor); - thisObject->m_listFormatStructure.visit(visitor); - thisObject->m_localeStructure.visit(visitor); thisObject->m_pluralRulesStructure.visit(visitor); - thisObject->m_relativeTimeFormatStructure.visit(visitor); thisObject->m_segmentIteratorStructure.visit(visitor); thisObject->m_segmenterStructure.visit(visitor); thisObject->m_segmentsStructure.visit(visitor); diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp 2021-11-10 13:25:18.215985933 -0600 @@ -169,7 +169,7 @@ static JSValue decode(JSGlobalObject* gl int charLen = 0; if (k <= length - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) { const char b0 = Lexer<CharType>::convertHex(p[1], p[2]); - const int sequenceLen = 1 + U8_COUNT_TRAIL_BYTES(b0); + const int sequenceLen = 1 + U8_COUNT_TRAIL_BYTES(static_cast<unsigned char>(b0)); if (k <= length - sequenceLen * 3) { charLen = sequenceLen * 3; uint8_t sequence[U8_MAX_LENGTH]; diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObject.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/JSGlobalObject.h 2021-11-10 13:25:18.215985933 -0600 @@ -314,10 +314,7 @@ public: LazyProperty<JSGlobalObject, IntlCollator> m_defaultCollator; LazyProperty<JSGlobalObject, Structure> m_collatorStructure; LazyProperty<JSGlobalObject, Structure> m_displayNamesStructure; - LazyProperty<JSGlobalObject, Structure> m_listFormatStructure; - LazyProperty<JSGlobalObject, Structure> m_localeStructure; LazyProperty<JSGlobalObject, Structure> m_pluralRulesStructure; - LazyProperty<JSGlobalObject, Structure> m_relativeTimeFormatStructure; LazyProperty<JSGlobalObject, Structure> m_segmentIteratorStructure; LazyProperty<JSGlobalObject, Structure> m_segmenterStructure; LazyProperty<JSGlobalObject, Structure> m_segmentsStructure; @@ -859,11 +856,8 @@ public: Structure* collatorStructure() { return m_collatorStructure.get(this); } Structure* dateTimeFormatStructure() { return m_dateTimeFormatStructure.get(this); } Structure* displayNamesStructure() { return m_displayNamesStructure.get(this); } - Structure* listFormatStructure() { return m_listFormatStructure.get(this); } Structure* numberFormatStructure() { return m_numberFormatStructure.get(this); } - Structure* localeStructure() { return m_localeStructure.get(this); } Structure* pluralRulesStructure() { return m_pluralRulesStructure.get(this); } - Structure* relativeTimeFormatStructure() { return m_relativeTimeFormatStructure.get(this); } Structure* segmentIteratorStructure() { return m_segmentIteratorStructure.get(this); } Structure* segmenterStructure() { return m_segmenterStructure.get(this); } Structure* segmentsStructure() { return m_segmentsStructure.get(this); } diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/VM.cpp webkitgtk-2.34.1/Source/JavaScriptCore/runtime/VM.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/VM.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/VM.cpp 2021-11-10 13:25:18.215985933 -0600 @@ -69,11 +69,8 @@ #include "IntlCollator.h" #include "IntlDateTimeFormat.h" #include "IntlDisplayNames.h" -#include "IntlListFormat.h" -#include "IntlLocale.h" #include "IntlNumberFormat.h" #include "IntlPluralRules.h" -#include "IntlRelativeTimeFormat.h" #include "IntlSegmentIterator.h" #include "IntlSegmenter.h" #include "IntlSegments.h" @@ -322,11 +319,8 @@ VM::VM(VMType vmType, HeapType heapType, , intlCollatorHeapCellType(IsoHeapCellType::create<IntlCollator>()) , intlDateTimeFormatHeapCellType(IsoHeapCellType::create<IntlDateTimeFormat>()) , intlDisplayNamesHeapCellType(IsoHeapCellType::create<IntlDisplayNames>()) - , intlListFormatHeapCellType(IsoHeapCellType::create<IntlListFormat>()) - , intlLocaleHeapCellType(IsoHeapCellType::create<IntlLocale>()) , intlNumberFormatHeapCellType(IsoHeapCellType::create<IntlNumberFormat>()) , intlPluralRulesHeapCellType(IsoHeapCellType::create<IntlPluralRules>()) - , intlRelativeTimeFormatHeapCellType(IsoHeapCellType::create<IntlRelativeTimeFormat>()) , intlSegmentIteratorHeapCellType(IsoHeapCellType::create<IntlSegmentIterator>()) , intlSegmenterHeapCellType(IsoHeapCellType::create<IntlSegmenter>()) , intlSegmentsHeapCellType(IsoHeapCellType::create<IntlSegments>()) @@ -1612,11 +1606,8 @@ DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW( DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlCollatorSpace, intlCollatorHeapCellType.get(), IntlCollator) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlDateTimeFormatSpace, intlDateTimeFormatHeapCellType.get(), IntlDateTimeFormat) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlDisplayNamesSpace, intlDisplayNamesHeapCellType.get(), IntlDisplayNames) -DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlListFormatSpace, intlListFormatHeapCellType.get(), IntlListFormat) -DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlLocaleSpace, intlLocaleHeapCellType.get(), IntlLocale) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlNumberFormatSpace, intlNumberFormatHeapCellType.get(), IntlNumberFormat) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlPluralRulesSpace, intlPluralRulesHeapCellType.get(), IntlPluralRules) -DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlRelativeTimeFormatSpace, intlRelativeTimeFormatHeapCellType.get(), IntlRelativeTimeFormat) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlSegmentIteratorSpace, intlSegmentIteratorHeapCellType.get(), IntlSegmentIterator) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlSegmenterSpace, intlSegmenterHeapCellType.get(), IntlSegmenter) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlSegmentsSpace, intlSegmentsHeapCellType.get(), IntlSegments) diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/VM.h webkitgtk-2.34.1/Source/JavaScriptCore/runtime/VM.h --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/runtime/VM.h 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/runtime/VM.h 2021-11-10 13:25:18.215985933 -0600 @@ -129,11 +129,8 @@ class IntlCache; class IntlCollator; class IntlDateTimeFormat; class IntlDisplayNames; -class IntlListFormat; -class IntlLocale; class IntlNumberFormat; class IntlPluralRules; -class IntlRelativeTimeFormat; class IntlSegmentIterator; class IntlSegmenter; class IntlSegments; @@ -438,11 +435,8 @@ public: std::unique_ptr<IsoHeapCellType> intlCollatorHeapCellType; std::unique_ptr<IsoHeapCellType> intlDateTimeFormatHeapCellType; std::unique_ptr<IsoHeapCellType> intlDisplayNamesHeapCellType; - std::unique_ptr<IsoHeapCellType> intlListFormatHeapCellType; - std::unique_ptr<IsoHeapCellType> intlLocaleHeapCellType; std::unique_ptr<IsoHeapCellType> intlNumberFormatHeapCellType; std::unique_ptr<IsoHeapCellType> intlPluralRulesHeapCellType; - std::unique_ptr<IsoHeapCellType> intlRelativeTimeFormatHeapCellType; std::unique_ptr<IsoHeapCellType> intlSegmentIteratorHeapCellType; std::unique_ptr<IsoHeapCellType> intlSegmenterHeapCellType; std::unique_ptr<IsoHeapCellType> intlSegmentsHeapCellType; @@ -610,11 +604,8 @@ public: DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlCollatorSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlDateTimeFormatSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlDisplayNamesSpace) - DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlListFormatSpace) - DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlLocaleSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlNumberFormatSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlPluralRulesSpace) - DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlRelativeTimeFormatSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlSegmentIteratorSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlSegmenterSpace) DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlSegmentsSpace) diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/Sources.txt webkitgtk-2.34.1/Source/JavaScriptCore/Sources.txt --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/Sources.txt 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/Sources.txt 2021-11-10 13:25:18.215985933 -0600 @@ -829,12 +829,6 @@ runtime/IntlDateTimeFormatPrototype.cpp runtime/IntlDisplayNames.cpp runtime/IntlDisplayNamesConstructor.cpp runtime/IntlDisplayNamesPrototype.cpp -runtime/IntlListFormat.cpp @no-unify // Confine U_HIDE_DRAFT_API's effect in this file. -runtime/IntlListFormatConstructor.cpp -runtime/IntlListFormatPrototype.cpp -runtime/IntlLocale.cpp -runtime/IntlLocaleConstructor.cpp -runtime/IntlLocalePrototype.cpp runtime/IntlNumberFormat.cpp runtime/IntlNumberFormatConstructor.cpp runtime/IntlNumberFormatPrototype.cpp @@ -842,9 +836,6 @@ runtime/IntlObject.cpp runtime/IntlPluralRules.cpp runtime/IntlPluralRulesConstructor.cpp runtime/IntlPluralRulesPrototype.cpp -runtime/IntlRelativeTimeFormat.cpp -runtime/IntlRelativeTimeFormatConstructor.cpp -runtime/IntlRelativeTimeFormatPrototype.cpp runtime/IntlSegmentIterator.cpp runtime/IntlSegmentIteratorPrototype.cpp runtime/IntlSegmenter.cpp diff -urpN webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/tools/JSDollarVM.cpp webkitgtk-2.34.1/Source/JavaScriptCore/tools/JSDollarVM.cpp --- webkitgtk-2.34.1.gstreamer/Source/JavaScriptCore/tools/JSDollarVM.cpp 2021-09-01 04:16:46.000000000 -0500 +++ webkitgtk-2.34.1/Source/JavaScriptCore/tools/JSDollarVM.cpp 2021-11-10 13:25:18.219985955 -0600 @@ -60,7 +60,6 @@ #include <wtf/Language.h> #include <wtf/ProcessID.h> #include <wtf/StringPrintStream.h> -#include <wtf/unicode/icu/ICUHelpers.h> #if !USE(SYSTEM_MALLOC) #include <bmalloc/BPlatform.h> @@ -3660,7 +3659,9 @@ JSC_DEFINE_HOST_FUNCTION(functionSetUser JSC_DEFINE_HOST_FUNCTION(functionICUVersion, (JSGlobalObject*, CallFrame*)) { DollarVMAssertScope assertScope; - return JSValue::encode(jsNumber(WTF::ICU::majorVersion())); + UVersionInfo versionInfo; + u_getVersion(versionInfo); + return JSValue::encode(jsNumber(versionInfo[0])); } JSC_DEFINE_HOST_FUNCTION(functionICUHeaderVersion, (JSGlobalObject*, CallFrame*)) diff -urpN webkitgtk-2.34.1.gstreamer/Source/WebCore/platform/text/CharacterProperties.h webkitgtk-2.34.1/Source/WebCore/platform/text/CharacterProperties.h --- webkitgtk-2.34.1.gstreamer/Source/WebCore/platform/text/CharacterProperties.h 2021-09-01 04:16:50.000000000 -0500 +++ webkitgtk-2.34.1/Source/WebCore/platform/text/CharacterProperties.h 2021-11-10 13:25:18.219985955 -0600 @@ -41,10 +41,8 @@ static_assert(UBLOCK_SYMBOLS_AND_PICTOGR switch (static_cast<int>(ublock_getCode(character))) { case UBLOCK_MISCELLANEOUS_SYMBOLS: case UBLOCK_DINGBATS: - case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: case UBLOCK_EMOTICONS: case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: - case UBLOCK_SUPPLEMENTAL_SYMBOLS_AND_PICTOGRAPHS: case UBLOCK_SYMBOLS_AND_PICTOGRAPHS_EXTENDED_A: return true; default: @@ -80,12 +78,12 @@ inline bool isEmojiRegionalIndicator(UCh inline bool isEmojiWithPresentationByDefault(UChar32 character) { - return u_hasBinaryProperty(character, UCHAR_EMOJI_PRESENTATION); + return false; } inline bool isEmojiModifierBase(UChar32 character) { - return u_hasBinaryProperty(character, UCHAR_EMOJI_MODIFIER_BASE); + return false; } inline bool isDefaultIgnorableCodePoint(UChar32 character)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor