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
|
2024-05-31 17:15:10 +00:00
|
|
|
index ed8dd34fdf44..9ec789b65413 100644
|
2023-05-16 06:08:37 +00:00
|
|
|
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
|
|
|
|
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -104,6 +104,7 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
|
2022-09-15 07:31:24 +00:00
|
|
|
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[] = {
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -131,6 +132,10 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
|
2022-09-15 07:31:24 +00:00
|
|
|
throwTypeError(globalObject, scope, "failed to initialize DisplayNames"_s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+#else
|
2023-12-12 08:26:30 +00:00
|
|
|
+ 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
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -140,6 +145,7 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
|
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, { });
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -344,6 +350,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
|
2024-05-31 17:15:10 +00:00
|
|
|
index 2101c342865e..87a95a26f55c 100644
|
2023-05-16 06:08:37 +00:00
|
|
|
--- 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;
|
2024-05-31 17:15:10 +00:00
|
|
|
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 {
|
2023-05-16 06:08:37 +00:00
|
|
|
diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp
|
2024-05-31 17:15:10 +00:00
|
|
|
index cba15c79bc45..9553eb6b263b 100644
|
2023-05-16 06:08:37 +00:00
|
|
|
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
|
|
|
|
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -165,7 +165,6 @@ namespace JSC {
|
2023-12-12 08:26:30 +00:00
|
|
|
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
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -253,6 +252,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)
|
2023-12-12 08:26:30 +00:00
|
|
|
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
|
2024-05-31 17:15:10 +00:00
|
|
|
index 526fe7cfe0cf..7b057f87b67e 100644
|
2023-05-16 06:08:37 +00:00
|
|
|
--- a/Source/cmake/OptionsGTK.cmake
|
|
|
|
+++ b/Source/cmake/OptionsGTK.cmake
|
2024-05-31 17:15:10 +00:00
|
|
|
@@ -18,7 +18,7 @@ find_package(Fontconfig 2.13.0 REQUIRED)
|
|
|
|
find_package(Freetype 2.9.0 REQUIRED)
|
2022-09-15 07:31:24 +00:00
|
|
|
find_package(LibGcrypt 1.6.0 REQUIRED)
|
2024-05-31 17:15:10 +00:00
|
|
|
find_package(HarfBuzz 1.4.2 REQUIRED COMPONENTS ICU)
|
2022-09-15 07:31:24 +00:00
|
|
|
-find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
|
2023-12-12 08:26:30 +00:00
|
|
|
+find_package(ICU 60 REQUIRED COMPONENTS data i18n uc)
|
2022-09-15 07:31:24 +00:00
|
|
|
find_package(JPEG REQUIRED)
|
2023-12-12 08:26:30 +00:00
|
|
|
find_package(LibEpoxy 1.4.0 REQUIRED)
|
2022-09-15 07:31:24 +00:00
|
|
|
find_package(LibXml2 2.8.0 REQUIRED)
|