Elements whose contents start with an astral Unicode symbol disappear when CSS `...
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2014 03:53:47 +0000 (03:53 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Aug 2014 03:53:47 +0000 (03:53 +0000)
commit51240820c23fa06ea01609a69ec1f5ff784fb143
tree41b18ab5c620afc072698521098c3d76b630efdb
parent95393eb6ca5d0cf200b33fa8bb18ce5805235e9f
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
LayoutTests/ChangeLog
LayoutTests/css1/pseudo/firstletter-surrogate-expected.html [new file with mode: 0644]
LayoutTests/css1/pseudo/firstletter-surrogate.html [new file with mode: 0644]
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringView.h
Source/WebCore/ChangeLog
Source/WebCore/platform/text/TextBreakIterator.cpp
Source/WebCore/platform/text/TextBreakIterator.h
Source/WebCore/rendering/RenderBlock.cpp