Title: [208894] trunk
Revision
208894
Author
[email protected]
Date
2016-11-18 13:55:09 -0800 (Fri, 18 Nov 2016)

Log Message

Unsupported emoji are invisible
https://bugs.webkit.org/show_bug.cgi?id=164944
<rdar://problem/28591608>

Reviewed by Dean Jackson.

Source/WebCore:

In WidthIterator, we explicitly skip characters which the OS has no font
to render with. However, for emoji, we should draw something to show that
there is missing content. Because we have nothing to draw, we can draw
the .notdef glyph (empty box, or "tofu").

Test: fast/text/emoji-draws.html

* platform/graphics/WidthIterator.cpp:
(WebCore::characterMustDrawSomething):
(WebCore::WidthIterator::advanceInternal):

LayoutTests:

* fast/text/emoji-draws-expected-mismatch.html: Added.
* fast/text/emoji-draws.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208893 => 208894)


--- trunk/LayoutTests/ChangeLog	2016-11-18 21:47:42 UTC (rev 208893)
+++ trunk/LayoutTests/ChangeLog	2016-11-18 21:55:09 UTC (rev 208894)
@@ -1,3 +1,14 @@
+2016-11-18  Myles C. Maxfield  <[email protected]>
+
+        Unsupported emoji are invisible
+        https://bugs.webkit.org/show_bug.cgi?id=164944
+        <rdar://problem/28591608>
+
+        Reviewed by Dean Jackson.
+
+        * fast/text/emoji-draws-expected-mismatch.html: Added.
+        * fast/text/emoji-draws.html: Added.
+
 2016-11-18  Sam Weinig  <[email protected]>
 
         [WebIDL] Add support for record types

Added: trunk/LayoutTests/fast/text/emoji-draws-expected-mismatch.html (0 => 208894)


--- trunk/LayoutTests/fast/text/emoji-draws-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/emoji-draws-expected-mismatch.html	2016-11-18 21:55:09 UTC (rev 208894)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/emoji-draws.html (0 => 208894)


--- trunk/LayoutTests/fast/text/emoji-draws.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/emoji-draws.html	2016-11-18 21:55:09 UTC (rev 208894)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="font: 100px 'Apple Color Emoji'";>&#x1f988;</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (208893 => 208894)


--- trunk/Source/WebCore/ChangeLog	2016-11-18 21:47:42 UTC (rev 208893)
+++ trunk/Source/WebCore/ChangeLog	2016-11-18 21:55:09 UTC (rev 208894)
@@ -1,3 +1,22 @@
+2016-11-18  Myles C. Maxfield  <[email protected]>
+
+        Unsupported emoji are invisible
+        https://bugs.webkit.org/show_bug.cgi?id=164944
+        <rdar://problem/28591608>
+
+        Reviewed by Dean Jackson.
+
+        In WidthIterator, we explicitly skip characters which the OS has no font
+        to render with. However, for emoji, we should draw something to show that
+        there is missing content. Because we have nothing to draw, we can draw
+        the .notdef glyph (empty box, or "tofu").
+
+        Test: fast/text/emoji-draws.html
+
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::characterMustDrawSomething):
+        (WebCore::WidthIterator::advanceInternal):
+
 2016-11-18  Sam Weinig  <[email protected]>
 
         [WebIDL] Add support for record types

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (208893 => 208894)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2016-11-18 21:47:42 UTC (rev 208893)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2016-11-18 21:55:09 UTC (rev 208894)
@@ -162,6 +162,13 @@
     return std::make_pair(expandLeft, expandRight);
 }
 
+static bool characterMustDrawSomething(UChar32 character)
+{
+    // u_hasBinaryProperty(character, UCHAR_EMOJI) would be better to use, but many OSes which
+    // WebKit runs on only have ICU version 55.1 or earlier. UCHAR_EMOJI was added in ICU 57.
+    return character >= 0x1F900 && character <= 0x1F9FF;
+}
+
 template <typename TextIterator>
 inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer* glyphBuffer)
 {
@@ -195,11 +202,11 @@
         int currentCharacter = textIterator.currentIndex();
         const GlyphData& glyphData = m_font->glyphDataForCharacter(character, rtl);
         Glyph glyph = glyphData.glyph;
-        if (!glyph) {
+        if (!glyph && !characterMustDrawSomething(character)) {
             textIterator.advance(advanceLength);
             continue;
         }
-        const Font* font = glyphData.font;
+        const Font* font = glyphData.font ? glyphData.font : &m_font->primaryFont();
         ASSERT(font);
 
         // Now that we have a glyph and font data, get its width.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to