Elements whose contents start with an astral Unicode symbol disappear when CSS `::first-letter` is applied to them
https://bugs.webkit.org/show_bug.cgi?id=135756
Reviewed by Darin Adler.
Source/WebCore:
The previous code assumed that all "characters" are exactly 1 16-bit code unit wide. Instead, use numCharactersInGraphemeClusters().
This patch also modifies the signature of numCharactersInGraphemeClusters() to take a StringView instead
of a string, which will avoid a copy.
Test: css1/pseudo/firstletter-surrogate.html
* platform/text/TextBreakIterator.cpp:
(WebCore::numCharactersInGraphemeClusters): Update numCharactersInGraphemeClusters() to take a StringView.
* platform/text/TextBreakIterator.h: Ditto.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::createFirstLetterRenderer): Use numCharactersInGraphemeClusters() to determine the length
of the first letter, rather than assuming it has length of 1 code unit
(WebCore::RenderBlock::updateFirstLetter): Add a FIXME comment.
Source/WTF:
Add a method to StringView which passes through contains() to find().
* wtf/text/StringView.h:
(WTF::StringView::contains):
LayoutTests:
Make sure the pseudoclass matches manually wrapping a <span> around the character.
* css1/pseudo/firstletter-surrogate-expected.html: Added.
* css1/pseudo/firstletter-surrogate.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172513
268f45cc-cd09-0410-ab3c-
d52691b4dbfc