webkit2gtk3/SOURCES/icu60.patch

170 lines
7.3 KiB
Diff
Raw Permalink Normal View History

2023-05-16 06:08:37 +00:00
diff --git a/Source/JavaScriptCore/runtime/IntlCache.cpp b/Source/JavaScriptCore/runtime/IntlCache.cpp
index b17d7340df56..94a5474059b6 100644
--- a/Source/JavaScriptCore/runtime/IntlCache.cpp
+++ b/Source/JavaScriptCore/runtime/IntlCache.cpp
@@ -26,6 +26,7 @@
2022-09-15 07:31:24 +00:00
#include "config.h"
#include "IntlCache.h"
+#include "IntlDisplayNames.h"
#include <wtf/Vector.h>
namespace JSC {
@@ -53,6 +54,7 @@ Vector<UChar, 32> IntlCache::getBestDateTimePattern(const CString& locale, const
return patternBuffer;
}
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
Vector<UChar, 32> IntlCache::getFieldDisplayName(const CString& locale, UDateTimePatternField field, UDateTimePGDisplayWidth width, UErrorCode& status)
{
auto sharedGenerator = getSharedPatternGenerator(locale, status);
@@ -64,5 +66,6 @@ Vector<UChar, 32> IntlCache::getFieldDisplayName(const CString& locale, UDateTim
return { };
return buffer;
}
+#endif
} // namespace JSC
2023-05-16 06:08:37 +00:00
diff --git a/Source/JavaScriptCore/runtime/IntlCache.h b/Source/JavaScriptCore/runtime/IntlCache.h
index 058b2423786d..e7a8c82f392b 100644
--- a/Source/JavaScriptCore/runtime/IntlCache.h
+++ b/Source/JavaScriptCore/runtime/IntlCache.h
@@ -25,6 +25,7 @@
2022-09-15 07:31:24 +00:00
#pragma once
+#include "IntlDisplayNames.h"
#include <unicode/udatpg.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/CString.h>
@@ -39,7 +40,9 @@ public:
IntlCache() = default;
Vector<UChar, 32> getBestDateTimePattern(const CString& locale, const UChar* skeleton, unsigned skeletonSize, UErrorCode&);
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
Vector<UChar, 32> getFieldDisplayName(const CString& locale, UDateTimePatternField, UDateTimePGDisplayWidth, UErrorCode&);
+#endif
private:
UDateTimePatternGenerator* getSharedPatternGenerator(const CString& locale, UErrorCode& status)
2023-05-16 06:08:37 +00:00
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
index f38161e7f95b..068613ce8feb 100644
2023-05-16 06:08:37 +00:00
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
2022-09-15 07:31:24 +00:00
@@ -110,6 +110,7 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
m_languageDisplay = intlOption<LanguageDisplay>(globalObject, options, vm.propertyNames->languageDisplay, { { "dialect"_s, LanguageDisplay::Dialect }, { "standard"_s, LanguageDisplay::Standard } }, "languageDisplay must be either \"dialect\" or \"standard\""_s, LanguageDisplay::Dialect);
RETURN_IF_EXCEPTION(scope, void());
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
UErrorCode status = U_ZERO_ERROR;
UDisplayContext contexts[] = {
@@ -137,15 +138,19 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
2022-09-15 07:31:24 +00:00
throwTypeError(globalObject, scope, "failed to initialize DisplayNames"_s);
return;
}
+#else
+ throwTypeError(globalObject, scope, "failed to initialize Intl.DisplayNames since feature is not supported by the ICU version"_s);
+ return;
2022-09-15 07:31:24 +00:00
+#endif
}
// https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.of
JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) const
{
-
2022-09-15 07:31:24 +00:00
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
ASSERT(m_displayNames);
auto code = codeValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, { });
@@ -350,6 +355,11 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
2022-09-15 07:31:24 +00:00
return throwTypeError(globalObject, scope, "Failed to query a display name."_s);
}
2023-05-16 06:08:37 +00:00
return jsString(vm, String(WTFMove(buffer)));
2022-09-15 07:31:24 +00:00
+#else
+ UNUSED_PARAM(codeValue);
2023-05-16 06:08:37 +00:00
+ throwTypeError(globalObject, scope, "failed to initialize Intl.DisplayNames since feature is not supported by the ICU version"_s);
2022-09-15 07:31:24 +00:00
+ return { };
+#endif
}
// https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.resolvedOptions
2023-05-16 06:08:37 +00:00
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.h b/Source/JavaScriptCore/runtime/IntlDisplayNames.h
index d80dc3d83a15..f2bf36275c79 100644
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.h
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.h
@@ -29,6 +29,13 @@
#include <unicode/uldnames.h>
#include <wtf/unicode/icu/ICUHelpers.h>
2022-09-15 07:31:24 +00:00
+#if !defined(HAVE_ICU_U_LOCALE_DISPLAY_NAMES)
+// We need 61 or later since part of implementation uses UCURR_NARROW_SYMBOL_NAME.
+#if U_ICU_VERSION_MAJOR_NUM >= 61
+#define HAVE_ICU_U_LOCALE_DISPLAY_NAMES 1
+#endif
+#endif
+
2023-05-16 06:08:37 +00:00
namespace JSC {
2022-09-15 07:31:24 +00:00
2023-05-16 06:08:37 +00:00
enum class RelevantExtensionKey : uint8_t;
diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp
index 0080abf51be4..d23c7c021334 100644
2023-05-16 06:08:37 +00:00
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
@@ -164,7 +164,6 @@ namespace JSC {
supportedValuesOf intlObjectFuncSupportedValuesOf DontEnum|Function 1
2022-09-15 07:31:24 +00:00
Collator createCollatorConstructor DontEnum|PropertyCallback
DateTimeFormat createDateTimeFormatConstructor DontEnum|PropertyCallback
- DisplayNames createDisplayNamesConstructor DontEnum|PropertyCallback
Locale createLocaleConstructor DontEnum|PropertyCallback
NumberFormat createNumberFormatConstructor DontEnum|PropertyCallback
PluralRules createPluralRulesConstructor DontEnum|PropertyCallback
@@ -252,6 +251,11 @@ void IntlObject::finishCreation(VM& vm, JSGlobalObject*)
2022-09-15 07:31:24 +00:00
Base::finishCreation(vm);
2023-05-16 06:08:37 +00:00
ASSERT(inherits(info()));
2022-09-15 07:31:24 +00:00
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+#if HAVE(ICU_U_LOCALE_DISPLAY_NAMES)
+ putDirectWithoutTransition(vm, vm.propertyNames->DisplayNames, createDisplayNamesConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
+#else
+ UNUSED_PARAM(&createDisplayNamesConstructor);
+#endif
#if HAVE(ICU_U_LIST_FORMATTER)
if (Options::useIntlDurationFormat())
putDirectWithoutTransition(vm, vm.propertyNames->DurationFormat, createDurationFormatConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
2023-05-16 06:08:37 +00:00
diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake
index 8bd6ed347418..9d0a7e88b16a 100644
2023-05-16 06:08:37 +00:00
--- a/Source/cmake/OptionsGTK.cmake
+++ b/Source/cmake/OptionsGTK.cmake
@@ -18,7 +18,7 @@ find_package(Fontconfig 2.8.0 REQUIRED)
find_package(Freetype 2.4.2 REQUIRED)
2022-09-15 07:31:24 +00:00
find_package(LibGcrypt 1.6.0 REQUIRED)
find_package(HarfBuzz 0.9.18 REQUIRED COMPONENTS ICU)
-find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
+find_package(ICU 60 REQUIRED COMPONENTS data i18n uc)
2022-09-15 07:31:24 +00:00
find_package(JPEG REQUIRED)
find_package(LibEpoxy 1.4.0 REQUIRED)
2022-09-15 07:31:24 +00:00
find_package(LibXml2 2.8.0 REQUIRED)
diff --git a/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp b/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
index fdcaa71f2011..f6aa1b0e3def 100644
--- a/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
@@ -41,7 +41,6 @@
#endif
#endif
#include <unicode/ulistformatter.h>
-#include <unicode/unumberformatter.h>
#include <unicode/ures.h>
#if HAVE(ICU_U_LIST_FORMATTER)
#define U_HIDE_DRAFT_API 1
@@ -49,6 +48,7 @@
#if HAVE(ICU_U_LIST_FORMATTER)
#include <unicode/uformattedvalue.h>
+#include <unicode/unumberformatter.h>
#endif
namespace JSC {