Complex path should be used when UVS exists in text run
authorbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jan 2012 10:46:31 +0000 (10:46 +0000)
committerbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jan 2012 10:46:31 +0000 (10:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75289

Source/WebCore:

Uses complex path when a text run contains UVS. The range from U+180B to U+180D already uses complex path.
Removes unnecessary functions that were added by r102915.

Reviewed by Dan Bernstein.

No new tests. fast/text/unicode-variation-selector.html should take care of this change.

* platform/graphics/Font.cpp:
(WebCore::Font::codePath): Use Complex path when the text run contains UVS.
* platform/graphics/SimpleFontData.h: Removed updateGlyphWithVariationSelector().
* platform/graphics/SurrogatePairAwareTextIterator.cpp: Removed unnecessary static functions.
* platform/graphics/SurrogatePairAwareTextIterator.h: Removed hasTrailingVariationSelector().
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advance): Removed UVS detection code.
* platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: Removed updateGlyphWithVariationSelector().
* platform/graphics/freetype/SimpleFontDataFreeType.cpp: Ditto.
* platform/graphics/harfbuzz/SimpleFontDataSkia.cpp: Ditto.
* platform/graphics/mac/SimpleFontDataMac.mm: Ditto.
* platform/graphics/pango/SimpleFontDataPango.cpp: Ditto.
* platform/graphics/qt/SimpleFontDataQt.cpp: Ditto.
* platform/graphics/win/SimpleFontDataWin.cpp: Ditto.
* platform/graphics/wince/SimpleFontDataWinCE.cpp: Ditto.
* platform/graphics/wx/SimpleFontDataWx.cpp: Ditto.

LayoutTests:

Reviewed by Dan Bernstein.

* platform/chromium/test_expectations.txt: Updates expectation for fast/text/unicode-variation-selector.html. Need rebaselines.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104545 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/SimpleFontData.h
Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp
Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
Source/WebCore/platform/graphics/harfbuzz/SimpleFontDataSkia.cpp
Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp
Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp

index 4cee490..a54ce54 100644 (file)
@@ -1,3 +1,12 @@
+2012-01-10  Kenichi Ishibashi  <bashi@chromium.org>
+
+        Complex path should be used when UVS exists in text run
+        https://bugs.webkit.org/show_bug.cgi?id=75289
+
+        Reviewed by Dan Bernstein.
+
+        * platform/chromium/test_expectations.txt: Updates expectation for fast/text/unicode-variation-selector.html. Need rebaselines.
+
 2012-01-10  Mike Lawther  <mikelawther@chromium.org>
 
         block mask overlay test for CSS3 calc
index cb0b348..8486b58 100644 (file)
@@ -3774,7 +3774,7 @@ BUGWK74374 WIN : fast/forms/select-listbox-multiple-no-focusring.html = PASS IMA
 // The test hits an ASSERT in Debug.
 BUGWK68859 DEBUG : fast/dynamic/crash-paint-no-documentElement-renderer.html = CRASH
 
-BUGWK74662 MAC : fast/text/unicode-variation-selector.html = PASS CRASH
+BUGWK74662 : fast/text/unicode-variation-selector.html = IMAGE+TEXT
 
 BUGWK74634 WIN : compositing/absolute-position-changed-with-composited-parent-layer.html = IMAGE
 
index 1ffbf04..85396f7 100644 (file)
@@ -1,5 +1,34 @@
 2012-01-10  Kenichi Ishibashi  <bashi@chromium.org>
 
+        Complex path should be used when UVS exists in text run
+        https://bugs.webkit.org/show_bug.cgi?id=75289
+
+        Uses complex path when a text run contains UVS. The range from U+180B to U+180D already uses complex path.
+        Removes unnecessary functions that were added by r102915.
+
+        Reviewed by Dan Bernstein.
+
+        No new tests. fast/text/unicode-variation-selector.html should take care of this change.
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::codePath): Use Complex path when the text run contains UVS.
+        * platform/graphics/SimpleFontData.h: Removed updateGlyphWithVariationSelector().
+        * platform/graphics/SurrogatePairAwareTextIterator.cpp: Removed unnecessary static functions.
+        * platform/graphics/SurrogatePairAwareTextIterator.h: Removed hasTrailingVariationSelector().
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advance): Removed UVS detection code.
+        * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: Removed updateGlyphWithVariationSelector().
+        * platform/graphics/freetype/SimpleFontDataFreeType.cpp: Ditto.
+        * platform/graphics/harfbuzz/SimpleFontDataSkia.cpp: Ditto.
+        * platform/graphics/mac/SimpleFontDataMac.mm: Ditto.
+        * platform/graphics/pango/SimpleFontDataPango.cpp: Ditto.
+        * platform/graphics/qt/SimpleFontDataQt.cpp: Ditto.
+        * platform/graphics/win/SimpleFontDataWin.cpp: Ditto.
+        * platform/graphics/wince/SimpleFontDataWinCE.cpp: Ditto.
+        * platform/graphics/wx/SimpleFontDataWx.cpp: Ditto.
+
+2012-01-10  Kenichi Ishibashi  <bashi@chromium.org>
+
         WebFonts are re-fetched from the server upon Document::styleSelectorChanged call.
         https://bugs.webkit.org/show_bug.cgi?id=73419
 
index 445d1d0..c2d9c58 100644 (file)
@@ -404,12 +404,22 @@ Font::CodePath Font::codePath(const TextRun& run) const
             if (supplementaryCharacter <= 0x1F1FF)
                 return Complex;
 
+            if (supplementaryCharacter < 0xE0100) // U+E0100 through U+E01EF Unicode variation selectors.
+                continue;
+            if (supplementaryCharacter <= 0xE01EF)
+                return Complex;
+
             // FIXME: Check for Brahmi (U+11000 block), Kaithi (U+11080 block) and other complex scripts
             // in plane 1 or higher.
 
             continue;
         }
 
+        if (c < 0xFE00) // U+FE00 through U+FE0F Unicode variation selectors
+            continue;
+        if (c <= 0xFE0F)
+            return Complex;
+
         if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks
             continue;
         if (c <= 0xFE2F)
index de4a56b..dd86f00 100644 (file)
@@ -158,7 +158,6 @@ public:
 
     const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
     void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; }
-    void updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph&) const;
 
 #ifndef NDEBUG
     virtual String description() const;
index 119b3a4..ac0bae3 100644 (file)
@@ -32,21 +32,6 @@ using namespace Unicode;
 
 namespace WebCore {
 
-inline static bool isUnicodeBMPVariationSelector(UChar character)
-{
-    return (0x180B <= character && character <= 0x180D) || (0xFE00 <= character && character <= 0xFE0F);
-}
-
-inline static bool isUnicodeSupplementaryVariationSelector(UChar lead, UChar trail)
-{
-    // A non-BMP variation selector character is in the range of U+E0100 to U+E01EF.
-    // It can be a surrogate pair in which the high surrogate is 0xDB40 and
-    // the low surrogate is in the range of U16_TRAIL(0xE0100 - 0x10000) to U16_TRAIL(0xE01EF - 0x10000).
-    static const UChar trailStart = U16_TRAIL(0xE0100 - 0x10000);
-    static const UChar trailEnd = U16_TRAIL(0xE01EF - 0x10000);
-    return lead == 0xDB40 && trailStart <= trail && trail <= trailEnd;
-}
-
 SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, int currentCharacter, int lastCharacter, int endCharacter)
     : m_characters(characters)
     , m_currentCharacter(currentCharacter)
@@ -98,21 +83,6 @@ bool SurrogatePairAwareTextIterator::consume(UChar32& character, unsigned& clust
     return true;
 }
 
-bool SurrogatePairAwareTextIterator::hasTrailingVariationSelector(UChar32& selector, unsigned& clusterLength)
-{
-    if (static_cast<int>(m_currentCharacter + clusterLength) < m_endCharacter && isUnicodeBMPVariationSelector(m_characters[clusterLength])) {
-        selector = m_characters[clusterLength];
-        clusterLength += 1;
-        return true;
-    }
-    if (static_cast<int>(m_currentCharacter + clusterLength + 1) < m_endCharacter && isUnicodeSupplementaryVariationSelector(m_characters[clusterLength], m_characters[clusterLength + 1])) {
-        selector = U16_GET_SUPPLEMENTARY(m_characters[clusterLength], m_characters[clusterLength + 1]);
-        clusterLength += 2;
-        return true;
-    }
-    return false;
-}
-
 void SurrogatePairAwareTextIterator::advance(unsigned advanceLength)
 {
     m_characters += advanceLength;
index 8dcea8d..1d56eb8 100644 (file)
@@ -32,7 +32,6 @@ public:
     SurrogatePairAwareTextIterator(const UChar*, int currentCharacter, int lastCharacter, int endCharacter);
 
     bool consume(UChar32& character, unsigned& clusterLength);
-    bool hasTrailingVariationSelector(UChar32& selector, unsigned& clusterLength);
     void advance(unsigned advanceLength);
 
     int currentCharacter() const { return m_currentCharacter; }
index 06826be..d749a4f 100644 (file)
@@ -115,13 +115,6 @@ unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
 
         ASSERT(fontData);
 
-        // If a variation selector follows, update glyph with the selector if possible.
-        UChar32 selector = 0;
-        if (textIterator.hasTrailingVariationSelector(selector, clusterLength)) {
-            fontData->updateGlyphWithVariationSelector(character, selector, glyph);
-            advanceLength = clusterLength;
-        }
-
         // Now that we have a glyph and font data, get its width.
         float width;
         if (character == '\t' && m_run.allowTabs()) {
index 9681746..78ad56a 100644 (file)
@@ -199,9 +199,4 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return static_cast<float>(width);
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }  // namespace WebCore
index 3cc6be7..5d6e7fb 100644 (file)
@@ -162,9 +162,4 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return w;    
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }
index d02c12a..782b02f 100644 (file)
@@ -236,9 +236,4 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return round(SkScalarToFloat(width));
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 } // namespace WebCore
index 17f2264..54c03f8 100644 (file)
@@ -467,32 +467,4 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
     return true;
 }
 
-static inline void decomposeToUTF16(UChar* buffer, unsigned& length, const UChar32 character)
-{
-    if (U_IS_BMP(character)) {
-        buffer[length] = character;
-        ++length;
-        return;
-    }
-
-    buffer[length] = U16_LEAD(character);
-    buffer[length + 1] = U16_TRAIL(character);
-    length += 2;
-}
-
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    unsigned length = 0;
-    UChar buffer[4];
-
-    decomposeToUTF16(buffer, length, character);
-    decomposeToUTF16(buffer, length, selector);
-    ASSERT(length <= 4);
-
-    CGGlyph glyphs[4];
-    wkGetGlyphsForCharacters(platformData().cgFont(), buffer, glyphs, length);
-    if (glyphs[0])
-        glyph = glyphs[0];
-}
-
 } // namespace WebCore
index d6428d9..ee8ee0f 100644 (file)
@@ -160,9 +160,4 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return width;    
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }
index 4ff23be..e95b8c5 100644 (file)
@@ -189,9 +189,4 @@ void SimpleFontData::platformDestroy()
 {
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }
index a49abe2..de6687f 100644 (file)
@@ -282,9 +282,4 @@ SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
     return m_scriptFontProperties;
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }
index 1ba6690..e3b8424 100644 (file)
@@ -180,9 +180,4 @@ void SimpleFontData::platformCharWidthInit()
     m_maxCharWidth = (tm.tmMaxCharWidth * m_platformData.size() + 36) / 72;
 }
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 } // namespace WebCore
index d98ecbd..cb7fb3d 100644 (file)
@@ -194,9 +194,4 @@ float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
 }
 #endif
 
-void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
-{
-    // FIXME: Implement.
-}
-
 }