You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
9.1 KiB
204 lines
9.1 KiB
diff --git a/Source/JavaScriptCore/runtime/IntlCache.cpp b/Source/JavaScriptCore/runtime/IntlCache.cpp
|
|
index 0941a7278e2a..75134587adbb 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/TZoneMallocInlines.h>
|
|
#include <wtf/Vector.h>
|
|
|
|
@@ -56,6 +57,7 @@ Vector<UChar, 32> IntlCache::getBestDateTimePattern(const CString& locale, std::
|
|
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);
|
|
@@ -67,5 +69,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 4c818fd59424..2c7e464a6955 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/TZoneMalloc.h>
|
|
@@ -40,7 +41,9 @@ public:
|
|
IntlCache() = default;
|
|
|
|
Vector<UChar, 32> getBestDateTimePattern(const CString& locale, std::span<const UChar> skeleton, 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
|
|
index 2af8cdd5cfa9..c78c94e5e054 100644
|
|
--- a/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
|
|
+++ b/Source/JavaScriptCore/runtime/IntlDisplayNames.cpp
|
|
@@ -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[] = {
|
|
@@ -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
|
|
@@ -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, { });
|
|
@@ -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
|
|
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;
|
|
diff --git a/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp b/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
|
|
index 1423760a9593..d15f4db69c47 100644
|
|
--- a/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
|
|
+++ b/Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
|
|
@@ -42,7 +42,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
|
|
@@ -50,6 +49,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
|
|
index 5850a14d8876..ca4f8b3ca79a 100644
|
|
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
|
|
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
|
|
@@ -166,7 +166,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
|
|
@@ -254,6 +253,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)
|
|
putDirectWithoutTransition(vm, vm.propertyNames->DurationFormat, createDurationFormatConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
|
|
putDirectWithoutTransition(vm, vm.propertyNames->ListFormat, createListFormatConstructor(vm, this), static_cast<unsigned>(PropertyAttribute::DontEnum));
|
|
diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake
|
|
index 523177737358..3606076882f3 100644
|
|
--- a/Source/cmake/OptionsGTK.cmake
|
|
+++ b/Source/cmake/OptionsGTK.cmake
|
|
@@ -11,7 +11,7 @@ find_package(Cairo 1.16.0 REQUIRED)
|
|
find_package(LibGcrypt 1.7.0 REQUIRED)
|
|
find_package(Libtasn1 REQUIRED)
|
|
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(Epoxy 1.5.4 REQUIRED)
|
|
find_package(LibXml2 2.8.0 REQUIRED)
|
|
diff --git a/Source/WTF/wtf/unicode/UTF8Conversion.cpp b/Source/WTF/wtf/unicode/UTF8Conversion.cpp
|
|
index f903eb1038c2..1014974bd8ae 100644
|
|
--- a/Source/WTF/wtf/unicode/UTF8Conversion.cpp
|
|
+++ b/Source/WTF/wtf/unicode/UTF8Conversion.cpp
|
|
@@ -49,14 +49,18 @@ template<> char32_t next<Replacement::None, LChar>(std::span<const LChar> charac
|
|
template<> char32_t next<Replacement::None, char8_t>(std::span<const char8_t> characters, size_t& offset)
|
|
{
|
|
char32_t character;
|
|
- U8_NEXT(characters, offset, characters.size(), character);
|
|
+ int32_t narrowedOffset = offset;
|
|
+ U8_NEXT(characters.data(), narrowedOffset, static_cast<int32_t>(characters.size()), character);
|
|
+ offset = narrowedOffset;
|
|
return U_IS_SURROGATE(character) ? sentinelCodePoint : character;
|
|
}
|
|
|
|
template<> char32_t next<Replacement::ReplaceInvalidSequences, char8_t>(std::span<const char8_t> characters, size_t& offset)
|
|
{
|
|
char32_t character;
|
|
- U8_NEXT_OR_FFFD(characters, offset, characters.size(), character);
|
|
+ int32_t narrowedOffset = offset;
|
|
+ U8_NEXT_OR_FFFD(characters.data(), narrowedOffset, static_cast<int32_t>(characters.size()), character);
|
|
+ offset = narrowedOffset;
|
|
return character;
|
|
}
|
|
|
|
@@ -77,7 +81,9 @@ template<> char32_t next<Replacement::ReplaceInvalidSequences, char16_t>(std::sp
|
|
template<> bool append<Replacement::None, char8_t>(std::span<char8_t> characters, size_t& offset, char32_t character)
|
|
{
|
|
UBool sawError = false;
|
|
- U8_APPEND(characters, offset, characters.size(), character, sawError);
|
|
+ int32_t narrowedOffset = offset;
|
|
+ U8_APPEND((uint8_t*)characters.data(), narrowedOffset, static_cast<int32_t>(characters.size()), character, sawError);
|
|
+ offset = narrowedOffset;
|
|
return sawError;
|
|
}
|
|
|