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

Unified Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1277803004: Revert of Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is … (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
« no previous file with comments | « Source/core/dom/FirstLetterPseudoElement.cpp ('k') | Source/platform/text/TextBreakIterator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp
diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
index a9de6cdb9864eebfa05e207a4246040f87d5456d..895bb6c77785f5c555e36a190bee8022ab77db0b 100644
--- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
+++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
@@ -212,6 +212,27 @@
return advanceSoFar - initialAdvance;
}
+static inline unsigned countGraphemesInCluster(const UChar* str,
+ unsigned strLength, uint16_t startIndex, uint16_t endIndex)
+{
+ if (startIndex > endIndex) {
+ uint16_t tempIndex = startIndex;
+ startIndex = endIndex;
+ endIndex = tempIndex;
+ }
+ uint16_t length = endIndex - startIndex;
+ ASSERT(static_cast<unsigned>(startIndex + length) <= strLength);
+ TextBreakIterator* cursorPosIterator = cursorMovementIterator(&str[startIndex], length);
+
+ int cursorPos = cursorPosIterator->current();
+ int numGraphemes = -1;
+ while (0 <= cursorPos) {
+ cursorPos = cursorPosIterator->next();
+ numGraphemes++;
+ }
+ return numGraphemes < 0 ? 0 : numGraphemes;
+}
+
static inline void addEmphasisMark(GlyphBuffer* buffer,
const GlyphData* emphasisData, FloatPoint glyphCenter,
float midGlyphOffset)
@@ -289,7 +310,7 @@
else
clusterEnd = isRunEnd ? run->m_startIndex + run->m_numCharacters + runOffset : run->glyphToCharacterIndex(i + 1) + runOffset;
- graphemesInCluster = countCharactersAndGraphemesInCluster(textRun.characters16(), textRun.charactersLength(), clusterStart, clusterEnd).graphemes;
+ graphemesInCluster = countGraphemesInCluster(textRun.characters16(), textRun.charactersLength(), clusterStart, clusterEnd);
if (!graphemesInCluster || !clusterAdvance)
continue;
« no previous file with comments | « Source/core/dom/FirstLetterPseudoElement.cpp ('k') | Source/platform/text/TextBreakIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698