webkit2gtk3/icu60.patch

168 lines
7.3 KiB
Diff
Raw Permalink Normal View History

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 @@
#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
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 @@
#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)
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
2023-09-18 23:53:17 +00:00
index ed8dd34fdf44..9ec789b65413 100644
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
2023-09-18 23:53:17 +00:00
@@ -104,6 +104,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[] = {
2023-09-18 23:53:17 +00:00
@@ -131,6 +132,10 @@ void IntlDisplayNames::initializeDisplayNames(JSGlobalObject* globalObject, JSVa
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;
+#endif
}
// https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.of
2023-09-18 23:53:17 +00:00
@@ -140,6 +145,7 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
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, { });
2023-09-18 23:53:17 +00:00
@@ -344,6 +350,11 @@ JSValue IntlDisplayNames::of(JSGlobalObject* globalObject, JSValue codeValue) co
return throwTypeError(globalObject, scope, "Failed to query a display name."_s);
}
return jsString(vm, String(WTFMove(buffer)));
+#else
+ UNUSED_PARAM(codeValue);
+ throwTypeError(globalObject, scope, "failed to initialize Intl.DisplayNames since feature is not supported by the ICU version"_s);
+ return { };
+#endif
}
// https://tc39.es/proposal-intl-displaynames/#sec-Intl.DisplayNames.prototype.resolvedOptions
diff --git a/Source/JavaScriptCore/runtime/IntlDisplayNames.h b/Source/JavaScriptCore/runtime/IntlDisplayNames.h
2023-09-18 23:53:17 +00:00
index 2101c342865e..87a95a26f55c 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>
+#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
+
namespace JSC {
enum class RelevantExtensionKey : uint8_t;
2023-09-18 23:53:17 +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 {
diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp
2023-09-18 23:53:17 +00:00
index cba15c79bc45..9553eb6b263b 100644
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
2023-09-18 23:53:17 +00:00
@@ -165,7 +165,6 @@ namespace JSC {
supportedValuesOf intlObjectFuncSupportedValuesOf DontEnum|Function 1
Collator createCollatorConstructor DontEnum|PropertyCallback
DateTimeFormat createDateTimeFormatConstructor DontEnum|PropertyCallback
- DisplayNames createDisplayNamesConstructor DontEnum|PropertyCallback
Locale createLocaleConstructor DontEnum|PropertyCallback
NumberFormat createNumberFormatConstructor DontEnum|PropertyCallback
PluralRules createPluralRulesConstructor DontEnum|PropertyCallback
2023-09-18 23:53:17 +00:00
@@ -253,6 +252,11 @@ void IntlObject::finishCreation(VM& vm, JSGlobalObject*)
Base::finishCreation(vm);
ASSERT(inherits(info()));
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));
diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake
2023-09-18 23:53:17 +00:00
index 526fe7cfe0cf..7b057f87b67e 100644
--- a/Source/cmake/OptionsGTK.cmake
+++ b/Source/cmake/OptionsGTK.cmake
2023-09-18 23:53:17 +00:00
@@ -18,7 +18,7 @@ find_package(Fontconfig 2.13.0 REQUIRED)
find_package(Freetype 2.9.0 REQUIRED)
find_package(LibGcrypt 1.6.0 REQUIRED)
2023-09-18 23:53:17 +00:00
find_package(HarfBuzz 1.4.2 REQUIRED COMPONENTS ICU)
-find_package(ICU 61.2 REQUIRED COMPONENTS data i18n uc)
+find_package(ICU 60 REQUIRED COMPONENTS data i18n uc)
find_package(JPEG REQUIRED)
find_package(LibEpoxy 1.4.0 REQUIRED)
find_package(LibXml2 2.8.0 REQUIRED)