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

Unified Diff: Source/core/dom/FirstLetterPseudoElement.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: Fixed UAF failures for ASan 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/core/dom/FirstLetterPseudoElement.cpp
diff --git a/Source/core/dom/FirstLetterPseudoElement.cpp b/Source/core/dom/FirstLetterPseudoElement.cpp
index 08d3a1c00b881de7a045f75bbd5140ccb52c246d..b79a20da6c8819f116af0a487944363946c52c7a 100644
--- a/Source/core/dom/FirstLetterPseudoElement.cpp
+++ b/Source/core/dom/FirstLetterPseudoElement.cpp
@@ -30,6 +30,7 @@
#include "core/layout/LayoutObjectInlines.h"
#include "core/layout/LayoutText.h"
#include "core/layout/LayoutTextFragment.h"
+#include "platform/text/TextBreakIterator.h"
#include "wtf/TemporaryChange.h"
#include "wtf/text/WTFString.h"
#include "wtf/text/icu/UnicodeIcu.h"
@@ -77,7 +78,8 @@ unsigned FirstLetterPseudoElement::firstLetterLength(const String& text)
return 0;
// Account the next character for first letter.
- length++;
+ const String substring = text.is8Bit() ? String::make16BitFrom8BitSource(text.substring(length).characters8(), textLength - length) : text.substring(length);
+ length += countCharactersAndGraphemesInCluster(substring.characters16(), substring.length(), 0, 1).characters;
// Keep looking for allowed punctuation for the :first-letter.
for (; length < textLength; ++length) {
« no previous file with comments | « LayoutTests/css1/pseudo/firstletter-surrogate-expected.html ('k') | Source/platform/fonts/shaping/HarfBuzzShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698