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

Side by Side Diff: third_party/WebKit/Source/platform/text/CharacterEmoji.cpp

Issue 1902553004: Do not break after ZWJ if the trailing character is Emoji. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to isEmoji method 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/text/Character.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/text/Character.h" 5 #include "platform/text/Character.h"
6 6
7 #include <unicode/uniset.h> 7 #include <unicode/uniset.h>
8 8
9 using namespace WTF; 9 using namespace WTF;
10 using namespace Unicode; 10 using namespace Unicode;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 static void applyPatternAndFreeze(icu::UnicodeSet* unicodeSet, const char* patte rn) 78 static void applyPatternAndFreeze(icu::UnicodeSet* unicodeSet, const char* patte rn)
79 { 79 {
80 UErrorCode err = U_ZERO_ERROR; 80 UErrorCode err = U_ZERO_ERROR;
81 // Use ICU's invariant-character initialization method. 81 // Use ICU's invariant-character initialization method.
82 unicodeSet->applyPattern(icu::UnicodeString(pattern, -1, US_INV), err); 82 unicodeSet->applyPattern(icu::UnicodeString(pattern, -1, US_INV), err);
83 unicodeSet->freeze(); 83 unicodeSet->freeze();
84 ASSERT(err == U_ZERO_ERROR); 84 ASSERT(err == U_ZERO_ERROR);
85 } 85 }
86 86
87 bool Character::isEmoji(UChar32 ch)
88 {
89 return Character::isEmojiTextDefault(ch) || Character::isEmojiEmojiDefault(c h);
90 }
91
87 bool Character::isEmojiTextDefault(UChar32 ch) 92 bool Character::isEmojiTextDefault(UChar32 ch)
88 { 93 {
89 DEFINE_STATIC_LOCAL(icu::UnicodeSet, emojiTextSet, ()); 94 DEFINE_STATIC_LOCAL(icu::UnicodeSet, emojiTextSet, ());
90 if (emojiTextSet.isEmpty()) 95 if (emojiTextSet.isEmpty())
91 applyPatternAndFreeze(&emojiTextSet, kEmojiTextPattern); 96 applyPatternAndFreeze(&emojiTextSet, kEmojiTextPattern);
92 return emojiTextSet.contains(ch) && !isEmojiEmojiDefault(ch); 97 return emojiTextSet.contains(ch) && !isEmojiEmojiDefault(ch);
93 } 98 }
94 99
95 bool Character::isEmojiEmojiDefault(UChar32 ch) 100 bool Character::isEmojiEmojiDefault(UChar32 ch)
96 { 101 {
(...skipping 17 matching lines...) Expand all
114 return (ch >= '0' && ch <= '9') || ch == '#'; 119 return (ch >= '0' && ch <= '9') || ch == '#';
115 } 120 }
116 121
117 bool Character::isRegionalIndicator(UChar32 ch) 122 bool Character::isRegionalIndicator(UChar32 ch)
118 { 123 {
119 return (ch >= 0x1F1E6 && ch <= 0x1F1FF); 124 return (ch >= 0x1F1E6 && ch <= 0x1F1FF);
120 } 125 }
121 126
122 127
123 }; // namespace blink 128 }; // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/Character.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698