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

Side by Side Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1133853006: Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is … Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Working in process patch Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 { 208 {
209 DEFINE_STATIC_LOCAL(HarfBuzzRunCache, globalHarfBuzzRunCache, ()); 209 DEFINE_STATIC_LOCAL(HarfBuzzRunCache, globalHarfBuzzRunCache, ());
210 return globalHarfBuzzRunCache; 210 return globalHarfBuzzRunCache;
211 } 211 }
212 212
213 static inline float harfBuzzPositionToFloat(hb_position_t value) 213 static inline float harfBuzzPositionToFloat(hb_position_t value)
214 { 214 {
215 return static_cast<float>(value) / (1 << 16); 215 return static_cast<float>(value) / (1 << 16);
216 } 216 }
217 217
218 static inline unsigned countGraphemesInCluster(const UChar* normalizedBuffer, un signed normalizedBufferLength, uint16_t startIndex, uint16_t endIndex)
219 {
220 if (startIndex > endIndex) {
221 uint16_t tempIndex = startIndex;
222 startIndex = endIndex;
223 endIndex = tempIndex;
224 }
225 uint16_t length = endIndex - startIndex;
226 ASSERT(static_cast<unsigned>(startIndex + length) <= normalizedBufferLength) ;
227 TextBreakIterator* cursorPosIterator = cursorMovementIterator(&normalizedBuf fer[startIndex], length);
228
229 int cursorPos = cursorPosIterator->current();
230 int numGraphemes = -1;
231 while (0 <= cursorPos) {
232 cursorPos = cursorPosIterator->next();
233 numGraphemes++;
234 }
235 return numGraphemes < 0 ? 0 : numGraphemes;
236 }
237
238 inline HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(const SimpleFontData* fontData, unsigned startIndex, unsigned numCharacters, hb_direction_t direction, hb_script _t script) 218 inline HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(const SimpleFontData* fontData, unsigned startIndex, unsigned numCharacters, hb_direction_t direction, hb_script _t script)
239 : m_fontData(fontData) 219 : m_fontData(fontData)
240 , m_startIndex(startIndex) 220 , m_startIndex(startIndex)
241 , m_numCharacters(numCharacters) 221 , m_numCharacters(numCharacters)
242 , m_numGlyphs(0) 222 , m_numGlyphs(0)
243 , m_direction(direction) 223 , m_direction(direction)
244 , m_script(script) 224 , m_script(script)
245 , m_width(0) 225 , m_width(0)
246 { 226 {
247 } 227 }
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 1049
1070 clusterAdvance += glyphData.advance; 1050 clusterAdvance += glyphData.advance;
1071 1051
1072 if (isClusterEnd) { 1052 if (isClusterEnd) {
1073 uint16_t clusterEnd; 1053 uint16_t clusterEnd;
1074 if (m_run.rtl()) 1054 if (m_run.rtl())
1075 clusterEnd = currentCharacterIndex; 1055 clusterEnd = currentCharacterIndex;
1076 else 1056 else
1077 clusterEnd = isRunEnd ? currentRun->startIndex() + currentRun->n umCharacters() : currentRun->glyphToCharacterIndex(i + 1); 1057 clusterEnd = isRunEnd ? currentRun->startIndex() + currentRun->n umCharacters() : currentRun->glyphToCharacterIndex(i + 1);
1078 1058
1079 graphemesInCluster = countGraphemesInCluster(m_normalizedBuffer.get( ), m_normalizedBufferLength, clusterStart, clusterEnd); 1059 graphemesInCluster = countCharactersAndGraphemesInCluster(m_normaliz edBuffer.get(), m_normalizedBufferLength, clusterStart, clusterEnd).graphemes;
1080 if (!graphemesInCluster || !clusterAdvance) 1060 if (!graphemesInCluster || !clusterAdvance)
1081 continue; 1061 continue;
1082 1062
1083 float glyphAdvanceX = clusterAdvance / graphemesInCluster; 1063 float glyphAdvanceX = clusterAdvance / graphemesInCluster;
1084 for (unsigned j = 0; j < graphemesInCluster; ++j) { 1064 for (unsigned j = 0; j < graphemesInCluster; ++j) {
1085 // Do not put emphasis marks on space, separator, and control ch aracters. 1065 // Do not put emphasis marks on space, separator, and control ch aracters.
1086 if (Character::canReceiveTextEmphasis(m_run[currentCharacterInde x])) 1066 if (Character::canReceiveTextEmphasis(m_run[currentCharacterInde x]))
1087 addEmphasisMark(glyphBuffer, advanceSoFar + glyphAdvanceX / 2); 1067 addEmphasisMark(glyphBuffer, advanceSoFar + glyphAdvanceX / 2);
1088 1068
1089 advanceSoFar += glyphAdvanceX; 1069 advanceSoFar += glyphAdvanceX;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 // possibly invalid from, to arguments. 1171 // possibly invalid from, to arguments.
1192 if (!foundToX && !foundFromX) 1172 if (!foundToX && !foundFromX)
1193 fromX = toX = 0; 1173 fromX = toX = 0;
1194 1174
1195 if (fromX < toX) 1175 if (fromX < toX)
1196 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); 1176 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
1197 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); 1177 return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
1198 } 1178 }
1199 1179
1200 } // namespace blink 1180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698