Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
webkit2gtk3.21041
webkit2gtk3-icu52.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File webkit2gtk3-icu52.patch of Package webkit2gtk3.21041
diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/CMakeLists.txt webkitgtk-2.32.1/Source/JavaScriptCore/CMakeLists.txt --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/CMakeLists.txt 2021-05-19 15:01:41.332822507 -0500 +++ webkitgtk-2.32.1/Source/JavaScriptCore/CMakeLists.txt 2021-05-21 10:34:49.404979984 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources-input.xcfilelist webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources-input.xcfilelist --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources-input.xcfilelist 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources-input.xcfilelist 2021-05-21 10:35:14.161110644 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources.make webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources.make --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources.make 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources.make 2021-05-21 10:36:03.265369856 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources-output.xcfilelist webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources-output.xcfilelist --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/DerivedSources-output.xcfilelist 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/DerivedSources-output.xcfilelist 2021-05-21 10:35:41.541255177 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/CommonIdentifiers.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/CommonIdentifiers.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/CommonIdentifiers.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/CommonIdentifiers.h 2021-05-21 10:37:23.085791206 -0500 @@ -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) \ diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlCollator.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlCollator.cpp 2021-05-21 12:47:44.147082978 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlCollator.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlCollator.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlCollator.h 2021-05-21 12:46:18.642631535 -0500 @@ -27,8 +27,8 @@ #pragma once #include "JSObject.h" -#include <unicode/ucol.h> -#include <wtf/unicode/icu/ICUHelpers.h> + +struct UCollator; namespace JSC { @@ -92,7 +92,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2021-05-21 12:46:18.642631535 -0500 @@ -67,6 +67,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); @@ -1207,6 +1213,7 @@ JSValue IntlDateTimeFormat::format(JSGlo return jsString(vm, String(result)); } +#if 0 static ASCIILiteral partTypeString(UDateFormatField field) { switch (field) { @@ -1334,6 +1341,7 @@ JSValue IntlDateTimeFormat::formatToPart return parts; } +#endif UDateIntervalFormat* IntlDateTimeFormat::createDateIntervalFormatIfNecessary(JSGlobalObject* globalObject) { diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h 2021-05-21 12:46:18.642631535 -0500 @@ -28,7 +28,6 @@ #include "JSObject.h" #include <unicode/udat.h> -#include <wtf/unicode/icu/ICUHelpers.h> struct UDateIntervalFormat; @@ -125,7 +124,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp 2021-05-20 16:29:04.549036374 -0500 @@ -39,7 +39,7 @@ namespace JSC { static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeGetterFormat); static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncFormatRange); static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncFormatRangeToParts); -static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncFormatToParts); +//static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncFormatToParts); static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncResolvedOptions); static JSC_DECLARE_HOST_FUNCTION(IntlDateTimeFormatFuncFormatDateTime); @@ -55,7 +55,6 @@ const ClassInfo IntlDateTimeFormatProtot @begin dateTimeFormatPrototypeTable format IntlDateTimeFormatPrototypeGetterFormat DontEnum|Accessor formatRange IntlDateTimeFormatPrototypeFuncFormatRange DontEnum|Function 2 - formatToParts IntlDateTimeFormatPrototypeFuncFormatToParts DontEnum|Function 1 resolvedOptions IntlDateTimeFormatPrototypeFuncResolvedOptions DontEnum|Function 0 @end */ @@ -143,6 +142,7 @@ JSC_DEFINE_HOST_FUNCTION(IntlDateTimeFor return JSValue::encode(boundFormat); } +#if 0 JSC_DEFINE_HOST_FUNCTION(IntlDateTimeFormatPrototypeFuncFormatToParts, (JSGlobalObject* globalObject, CallFrame* callFrame)) { VM& vm = globalObject->vm(); @@ -168,6 +168,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp 2021-05-22 16:00:30.670479300 -0500 @@ -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,120 +157,6 @@ static unsigned computeCurrencyDigits(co return 2; } -// Create MeasureUnit like ICU4J. -struct MeasureUnit { - ASCIILiteral type; - ASCIILiteral subType; -}; - -static Optional<MeasureUnit> sanctionedSimpleUnitIdentifier(StringView unitIdentifier) -{ - static constexpr MeasureUnit simpleUnits[] = { - { "area"_s, "acre"_s }, - { "digital"_s, "bit"_s }, - { "digital"_s, "byte"_s }, - { "temperature"_s, "celsius"_s }, - { "length"_s, "centimeter"_s }, - { "duration"_s, "day"_s }, - { "angle"_s, "degree"_s }, - { "temperature"_s, "fahrenheit"_s }, - { "volume"_s, "fluid-ounce"_s }, - { "length"_s, "foot"_s }, - { "volume"_s, "gallon"_s }, - { "digital"_s, "gigabit"_s }, - { "digital"_s, "gigabyte"_s }, - { "mass"_s, "gram"_s }, - { "area"_s, "hectare"_s }, - { "duration"_s, "hour"_s }, - { "length"_s, "inch"_s }, - { "digital"_s, "kilobit"_s }, - { "digital"_s, "kilobyte"_s }, - { "mass"_s, "kilogram"_s }, - { "length"_s, "kilometer"_s }, - { "volume"_s, "liter"_s }, - { "digital"_s, "megabit"_s }, - { "digital"_s, "megabyte"_s }, - { "length"_s, "meter"_s }, - { "length"_s, "mile"_s }, - { "length"_s, "mile-scandinavian"_s }, - { "volume"_s, "milliliter"_s }, - { "length"_s, "millimeter"_s }, - { "duration"_s, "millisecond"_s }, - { "duration"_s, "minute"_s }, - { "duration"_s, "month"_s }, - { "mass"_s, "ounce"_s }, - { "concentr"_s, "percent"_s }, - { "digital"_s, "petabyte"_s }, - { "mass"_s, "pound"_s }, - { "duration"_s, "second"_s }, - { "mass"_s, "stone"_s }, - { "digital"_s, "terabit"_s }, - { "digital"_s, "terabyte"_s }, - { "duration"_s, "week"_s }, - { "length"_s, "yard"_s }, - { "duration"_s, "year"_s }, - }; - 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 WTF::nullopt; -} - -struct WellFormedUnit { -public: - explicit WellFormedUnit(MeasureUnit numerator) - : numerator(numerator) - { - } - - WellFormedUnit(MeasureUnit numerator, MeasureUnit denominator) - : numerator(numerator) - , denominator(denominator) - { - } - - MeasureUnit numerator; - Optional<MeasureUnit> denominator; -}; - -static 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 WTF::nullopt; - if (unitIdentifier.find(per, position + per.length()) != WTF::notFound) - return WTF::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 WTF::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 WTF::nullopt; - - return WellFormedUnit(numeratorUnit.value(), denominatorUnit.value()); -} - // https://tc39.github.io/ecma402/#sec-initializenumberformat void IntlNumberFormat::initializeNumberFormat(JSGlobalObject* globalObject, JSValue locales, JSValue optionsValue) { @@ -303,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); @@ -327,210 +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()); - 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.appendLiteral("rounding-mode-half-up"); - - switch (m_style) { - case Style::Decimal: - // No skeleton is needed. - break; - case Style::Percent: - skeletonBuilder.appendLiteral(" percent scale/100"); - break; - case Style::Currency: { - skeletonBuilder.appendLiteral(" currency/"); - skeletonBuilder.append(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.appendLiteral(" unit-width-iso-code"); - break; - case CurrencyDisplay::Symbol: - // Default option. Do not specify unit-width. - break; - case CurrencyDisplay::NarrowSymbol: - skeletonBuilder.appendLiteral(" unit-width-narrow"); - break; - case CurrencyDisplay::Name: - skeletonBuilder.appendLiteral(" 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.appendLiteral(" measure-unit/"); - auto numeratorUnit = wellFormedUnit->numerator; - skeletonBuilder.append(numeratorUnit.type, '-', numeratorUnit.subType); - if (auto denominatorUnitValue = wellFormedUnit->denominator) { - auto denominatorUnit = denominatorUnitValue.value(); - skeletonBuilder.appendLiteral(" per-measure-unit/"); - skeletonBuilder.append(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.appendLiteral(" unit-width-short"); - break; - case UnitDisplay::Narrow: - skeletonBuilder.appendLiteral(" unit-width-narrow"); - break; - case UnitDisplay::Long: - skeletonBuilder.appendLiteral(" unit-width-full-name"); - break; - } - break; - } - } - - // https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#integer-width - skeletonBuilder.appendLiteral(" integer-width/"); - skeletonBuilder.append((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.appendLiteral(" scientific"); - break; - case IntlNotation::Engineering: - skeletonBuilder.appendLiteral(" engineering"); - break; - case IntlNotation::Compact: - switch (m_compactDisplay) { - case CompactDisplay::Short: - skeletonBuilder.appendLiteral(" compact-short"); - break; - case CompactDisplay::Long: - skeletonBuilder.appendLiteral(" 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.appendLiteral(" sign-accounting"); - else - skeletonBuilder.appendLiteral(" sign-auto"); - break; - case SignDisplay::Never: - skeletonBuilder.appendLiteral(" sign-never"); - break; - case SignDisplay::Always: - if (useAccounting) - skeletonBuilder.appendLiteral(" sign-accounting-always"); - else - skeletonBuilder.appendLiteral(" sign-always"); - break; - case SignDisplay::ExceptZero: - if (useAccounting) - skeletonBuilder.appendLiteral(" sign-accounting-except-zero"); - else - skeletonBuilder.appendLiteral(" sign-except-zero"); - break; - } - - if (!m_useGrouping) - skeletonBuilder.appendLiteral(" 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: @@ -547,48 +280,19 @@ void IntlNumberFormat::initializeNumberF case CurrencyDisplay::Symbol: style = UNUM_CURRENCY; break; - case CurrencyDisplay::NarrowSymbol: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; case CurrencyDisplay::Name: style = UNUM_CURRENCY_PLURAL; break; + default: + ASSERT_NOT_REACHED(); } - switch (m_currencySign) { - case CurrencySign::Standard: - break; - case CurrencySign::Accounting: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; - } - break; - case Style::Unit: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; - } - - switch (m_notation) { - case IntlNotation::Standard: - break; - case IntlNotation::Scientific: - case IntlNotation::Engineering: - case IntlNotation::Compact: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; - } - - switch (m_signDisplay) { - case SignDisplay::Auto: break; - case SignDisplay::Never: - case SignDisplay::Always: - case SignDisplay::ExceptZero: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; + 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; @@ -601,58 +305,40 @@ void IntlNumberFormat::initializeNumberF return; } } - - 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: - throwTypeError(globalObject, scope, "Failed to initialize NumberFormat since used feature is not supported in the linked ICU version"_s); - return; } 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); @@ -663,24 +349,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)); } @@ -693,8 +365,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(); @@ -707,8 +377,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; } @@ -716,76 +384,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 { @@ -794,38 +392,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; } @@ -834,7 +413,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: @@ -847,31 +426,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; @@ -879,7 +447,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); @@ -891,12 +460,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) { @@ -904,11 +468,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); @@ -922,7 +482,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); @@ -937,6 +497,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); @@ -946,28 +508,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); @@ -975,10 +518,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormat.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormat.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormat.h 2021-05-21 16:13:31.568272151 -0500 @@ -29,29 +29,13 @@ #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*, Optional<JSObject&>, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation); - class IntlNumberFormat final : public JSNonFinalObject { public: using Base = JSNonFinalObject; @@ -77,20 +61,13 @@ public: void initializeNumberFormat(JSGlobalObject*, JSValue locales, JSValue optionsValue); JSValue format(JSGlobalObject*, double) const; JSValue format(JSGlobalObject*, JSBigInt*) const; - JSValue formatToParts(JSGlobalObject*, double) 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*, Optional<JSObject&>, unsigned minimumFractionDigitsDefault, unsigned maximumFractionDigitsDefault, IntlNotation); - - static ASCIILiteral notationString(IntlNotation); + //static void formatToPartsInternal(JSGlobalObject*, double, const String& formatted, UFieldPositionIterator*, JSArray*, JSString* unit = nullptr); static IntlNumberFormat* unwrapForOldFunctions(JSGlobalObject*, JSValue); @@ -101,33 +78,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 +101,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormatInlines.h 2021-05-22 16:04:48.435840065 -0500 @@ -32,96 +32,6 @@ namespace JSC { -template<typename IntlType> -void setNumberFormatDigitOptions(JSGlobalObject* globalObject, IntlType* intlInstance, Optional<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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp 2021-05-21 16:39:54.008627131 -0500 @@ -28,14 +28,13 @@ #include "IntlNumberFormatPrototype.h" #include "BuiltinNames.h" -#include "IntlNumberFormatInlines.h" #include "JSBoundFunction.h" #include "JSCInlines.h" namespace JSC { static JSC_DECLARE_HOST_FUNCTION(IntlNumberFormatPrototypeGetterFormat); -static JSC_DECLARE_HOST_FUNCTION(IntlNumberFormatPrototypeFuncFormatToParts); +//static JSC_DECLARE_HOST_FUNCTION(IntlNumberFormatPrototypeFuncFormatToParts); static JSC_DECLARE_HOST_FUNCTION(IntlNumberFormatPrototypeFuncResolvedOptions); static JSC_DECLARE_HOST_FUNCTION(IntlNumberFormatFuncFormat); @@ -50,7 +49,6 @@ const ClassInfo IntlNumberFormatPrototyp /* Source for IntlNumberFormatPrototype.lut.h @begin numberFormatPrototypeTable format IntlNumberFormatPrototypeGetterFormat DontEnum|Accessor - formatToParts IntlNumberFormatPrototypeFuncFormatToParts DontEnum|Function 1 resolvedOptions IntlNumberFormatPrototypeFuncResolvedOptions DontEnum|Function 0 @end */ @@ -137,6 +135,7 @@ JSC_DEFINE_HOST_FUNCTION(IntlNumberForma return JSValue::encode(boundFormat); } +#if 0 JSC_DEFINE_HOST_FUNCTION(IntlNumberFormatPrototypeFuncFormatToParts, (JSGlobalObject* globalObject, CallFrame* callFrame)) { VM& vm = globalObject->vm(); @@ -155,6 +154,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlObject.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlObject.cpp 2021-05-21 10:54:14.891133075 -0500 @@ -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" @@ -59,7 +51,6 @@ #include "Options.h" #include <unicode/ubrk.h> #include <unicode/ucol.h> -#include <unicode/ufieldpositer.h> #include <unicode/uloc.h> #include <unicode/unumsys.h> #include <wtf/Assertions.h> @@ -96,20 +87,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); @@ -124,13 +101,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); @@ -149,10 +119,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 */ @@ -165,11 +133,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 IntlObject::IntlObject(VM& vm, Structure* structure) : Base(vm, structure) @@ -193,11 +163,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 } Structure* IntlObject::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) @@ -624,7 +589,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); @@ -661,15 +626,11 @@ 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()); diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlObject.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlObject.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlObject.h 2021-05-21 10:55:06.947407936 -0500 @@ -89,7 +89,6 @@ inline const HashSet<String>& intlDispla inline const HashSet<String>& intlNumberFormatAvailableLocales() { return intlAvailableLocales(); } inline const HashSet<String>& intlPluralRulesAvailableLocales() { return intlAvailableLocales(); } inline const HashSet<String>& intlRelativeTimeFormatAvailableLocales() { return intlAvailableLocales(); } -inline const HashSet<String>& intlListFormatAvailableLocales() { return intlAvailableLocales(); } TriState intlBooleanOption(JSGlobalObject*, Optional<JSObject&> options, PropertyName); String intlStringOption(JSGlobalObject*, Optional<JSObject&> options, PropertyName, std::initializer_list<const char*> values, const char* notFound, const char* fallback); diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlPluralRules.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlPluralRules.cpp 2021-05-22 16:01:09.158682536 -0500 @@ -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,9 +122,35 @@ 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)); if (U_FAILURE(status)) { @@ -114,20 +158,14 @@ void IntlPluralRules::initializePluralRu return; } - switch (m_roundingType) { - case IntlRoundingType::FractionDigits: + if (m_minimumSignificantDigits) { + unum_setAttribute(m_numberFormat.get(), UNUM_SIGNIFICANT_DIGITS_USED, true); + unum_setAttribute(m_numberFormat.get(), UNUM_MIN_SIGNIFICANT_DIGITS, m_minimumSignificantDigits.value()); + unum_setAttribute(m_numberFormat.get(), UNUM_MAX_SIGNIFICANT_DIGITS, m_maximumSignificantDigits.value()); + } 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); - break; - case IntlRoundingType::SignificantDigits: - 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; } 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->minimumSignificantDigits, jsNumber(m_minimumSignificantDigits)); - options->putDirect(vm, vm.propertyNames->maximumSignificantDigits, jsNumber(m_maximumSignificantDigits)); - break; - default: - RELEASE_ASSERT_NOT_REACHED(); - break; + 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.value())); + options->putDirect(vm, vm.propertyNames->maximumSignificantDigits, jsNumber(m_maximumSignificantDigits.value())); } +#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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlPluralRules.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlPluralRules.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlPluralRules.h 2021-05-21 15:52:00.625456493 -0500 @@ -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*, Optional<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; @@ -83,9 +83,8 @@ private: unsigned m_minimumIntegerDigits { 1 }; unsigned m_minimumFractionDigits { 0 }; unsigned m_maximumFractionDigits { 3 }; - unsigned m_minimumSignificantDigits { 0 }; - unsigned m_maximumSignificantDigits { 0 }; - IntlRoundingType m_roundingType { IntlRoundingType::FractionDigits }; + Optional<unsigned> m_minimumSignificantDigits; + Optional<unsigned> m_maximumSignificantDigits; Type m_type { Type::Cardinal }; }; diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp 2021-05-21 12:46:18.646631555 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h 2021-05-21 12:46:18.646631555 -0500 @@ -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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSDateMath.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSDateMath.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSDateMath.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSDateMath.cpp 2021-05-21 18:20:02.452348872 -0500 @@ -315,7 +315,7 @@ void DateCache::timeZoneCacheSlow() { // Do not use icu::TimeZone::createDefault. ICU internally has a cache for timezone and createDefault returns this cached value. ASSERT(!m_timeZoneCache); - 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())); } void DateCache::reset() diff -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObject.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObject.cpp 2021-05-21 18:23:04.061307663 -0500 @@ -78,18 +78,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" @@ -1034,30 +1028,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); @@ -1935,10 +1911,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp 2021-05-20 15:31:28.090789302 -0500 @@ -168,7 +168,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObject.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/JSGlobalObject.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/JSGlobalObject.h 2021-05-21 10:56:34.299869188 -0500 @@ -311,10 +311,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; @@ -846,11 +843,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/VM.cpp webkitgtk-2.32.1/Source/JavaScriptCore/runtime/VM.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/VM.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/VM.cpp 2021-05-21 10:57:21.888120502 -0500 @@ -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" @@ -317,11 +314,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>()) @@ -1542,11 +1536,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/VM.h webkitgtk-2.32.1/Source/JavaScriptCore/runtime/VM.h --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/runtime/VM.h 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/runtime/VM.h 2021-05-21 10:57:53.296286350 -0500 @@ -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; @@ -391,11 +388,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; @@ -558,11 +552,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/Sources.txt webkitgtk-2.32.1/Source/JavaScriptCore/Sources.txt --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/Sources.txt 2021-05-05 00:33:24.000000000 -0500 +++ webkitgtk-2.32.1/Source/JavaScriptCore/Sources.txt 2021-05-21 10:37:01.053674896 -0500 @@ -825,12 +825,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 @@ -838,9 +832,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 -urp webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/tools/JSDollarVM.cpp webkitgtk-2.32.1/Source/JavaScriptCore/tools/JSDollarVM.cpp --- webkitgtk-2.32.1.gstreamer/Source/JavaScriptCore/tools/JSDollarVM.cpp 2021-02-26 03:57:05.000000000 -0600 +++ webkitgtk-2.32.1/Source/JavaScriptCore/tools/JSDollarVM.cpp 2021-05-21 15:54:04.322109454 -0500 @@ -57,7 +57,6 @@ #include <wtf/Language.h> #include <wtf/ProcessID.h> #include <wtf/StringPrintStream.h> -#include <wtf/unicode/icu/ICUHelpers.h> #if ENABLE(WEBASSEMBLY) #include "JSWebAssemblyHelpers.h" @@ -3493,7 +3492,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 -urp webkitgtk-2.32.1.gstreamer/Source/WebCore/platform/text/CharacterProperties.h webkitgtk-2.32.1/Source/WebCore/platform/text/CharacterProperties.h --- webkitgtk-2.32.1.gstreamer/Source/WebCore/platform/text/CharacterProperties.h 2021-02-26 03:57:14.000000000 -0600 +++ webkitgtk-2.32.1/Source/WebCore/platform/text/CharacterProperties.h 2021-05-20 18:02:59.510785410 -0500 @@ -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