Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Unified Diff: third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp

Issue 1856353002: Use ICU's emoji character properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uchar.h: include explicitly Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp b/third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp
index 5104df30f8699eb8fdc7dae9a6f9d42b67ad5628..39bf4ec7247859088e58a9c5845f068d38daedb0 100644
--- a/third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp
+++ b/third_party/WebKit/Source/platform/fonts/CharacterEmoji.cpp
@@ -4,19 +4,24 @@
#include "platform/fonts/Character.h"
+#include <unicode/uchar.h>
+#include <unicode/uvernum.h>
+
+#if defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 56)
drott 2016/04/05 19:40:40 Can we avoid #ifdef and only keep the ICU property
#include <unicode/uniset.h>
+#endif
using namespace WTF;
using namespace Unicode;
namespace blink {
+// ICU 56 or earlier does not have API for Emoji properties,
+// but Chrome's copy of ICU 56 does.
+#if defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 56)
// The following UnicodeSet patterns were compiled from
// http://www.unicode.org/Public/emoji/2.0//emoji-data.txt
-// FIXME crbug.com/579552:
-// These patterns should move to property group definitions in ICU.
-
static const char kEmojiTextPattern[] =
R"([[#][*][0-9][\u00A9][\u00AE][\u203C][\u2049][\u2122][\u2139])"
R"([\u2194-\u2199][\u21A9-\u21AA][\u231A-\u231B][\u2328][\u23CF])"
@@ -100,7 +105,6 @@ bool Character::isEmojiEmojiPresentation(UChar32 ch)
return emojiEmojiSet.contains(ch);
}
-
bool Character::isEmojiModifierBase(UChar32 ch)
{
DEFINE_STATIC_LOCAL(icu::UnicodeSet, emojieModifierBaseSet, ());
@@ -108,6 +112,23 @@ bool Character::isEmojiModifierBase(UChar32 ch)
applyPatternAndFreeze(&emojieModifierBaseSet, kEmojiModifierBasePattern);
return emojieModifierBaseSet.contains(ch);
}
+#else
+bool Character::isEmojiTextPresentation(UChar32 ch)
+{
+ return u_hasBinaryProperty(ch, UCHAR_EMOJI)
+ && !u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION);
+}
+
+bool Character::isEmojiEmojiPresentation(UChar32 ch)
+{
+ return u_hasBinaryProperty(ch, UCHAR_EMOJI_PRESENTATION);
+}
+
+bool Character::isEmojiModifierBase(UChar32 ch)
+{
+ return u_hasBinaryProperty(ch, UCHAR_EMOJI_MODIFIER_BASE);
+}
+#endif // defined(USING_SYSTEM_ICU) && (U_ICU_VERSION_MAJOR_NUM <= 56)
bool Character::isEmojiKeycapBase(UChar32 ch)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698