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

Unified Diff: Source/platform/fonts/UTF16TextIterator.cpp

Issue 1285633003: Change handling of unmatched surrogate pairs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
Index: Source/platform/fonts/UTF16TextIterator.cpp
diff --git a/Source/platform/fonts/UTF16TextIterator.cpp b/Source/platform/fonts/UTF16TextIterator.cpp
index 1448a49fac8c9a5a78c1729c04814aec5563583c..d087cc5146889821a9c44f65fa7570f65216652d 100644
--- a/Source/platform/fonts/UTF16TextIterator.cpp
+++ b/Source/platform/fonts/UTF16TextIterator.cpp
@@ -48,11 +48,8 @@ UTF16TextIterator::UTF16TextIterator(const UChar* characters, int currentCharact
{
}
-bool UTF16TextIterator::consumeSurrogatePair(UChar32& character)
+bool UTF16TextIterator::isValidSurrogatePair(UChar32& character)
{
- if (!U16_IS_SURROGATE(character))
- return true;
-
// If we have a surrogate pair, make sure it starts with the high part.
if (!U16_IS_SURROGATE_LEAD(character))
return false;
@@ -66,7 +63,20 @@ bool UTF16TextIterator::consumeSurrogatePair(UChar32& character)
UChar low = m_characters[1];
if (!U16_IS_TRAIL(low))
return false;
+ return true;
+}
+bool UTF16TextIterator::consumeSurrogatePair(UChar32& character)
+{
+ if (!U16_IS_SURROGATE(character))
+ return true;
+
+ if (!isValidSurrogatePair(character)) {
+ character = replacementCharacter;
+ return true;
+ }
+
+ UChar low = m_characters[1];
character = U16_GET_SUPPLEMENTARY(character, low);
m_currentGlyphLength = 2;
return true;

Powered by Google App Engine
This is Rietveld 408576698