[HarfBuzz] Remove the HarfBuzz-old code
authordominik.rottsches@intel.com <dominik.rottsches@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 10:45:58 +0000 (10:45 +0000)
committerdominik.rottsches@intel.com <dominik.rottsches@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 10:45:58 +0000 (10:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108077

Reviewed by Benjamin Poulain.

.:

Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ since there
won't be a distinction between ng and non-ng HarfBuzz after
removing the old code.

* Source/cmake/OptionsEfl.cmake:

Source/WebCore:

Removing unused old variant of the HarfBuzz code.

No new tests, no change in functionality.

* GNUmakefile.am: Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ
* WebCore.gypi: Removing ComplexTextControllerHarfBuzz* and HarfBuzzSkia* files,
* platform/graphics/SimpleFontData.h:
(SimpleFontData): USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
* platform/graphics/freetype/FontPlatformData.h:
(FontPlatformData): Removing USE(HARFBUZZ_NG) ifdefs.
* platform/graphics/freetype/FontPlatformDataFreeType.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::harfbuzzFace):
* platform/graphics/freetype/SimpleFontDataFreeType.cpp: USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
(WebCore):
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: Removed.
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h: Removed.
* platform/graphics/harfbuzz/FontHarfBuzz.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
(WebCore::Font::drawComplexText):
(WebCore::Font::floatWidthForComplexText):
(WebCore::Font::offsetForPositionForComplexText):
(WebCore::Font::selectionRectForComplexText):
* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
(WebCore::FontPlatformData::harfbuzzFace):
* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h: Removing USE(HARFBUZZ_NG) ifdefs.
(WebCore):
(FontPlatformData):
* platform/graphics/harfbuzz/HarfBuzzSkia.cpp: Removed.
* platform/graphics/harfbuzz/HarfBuzzSkia.h: Removed.
* platform/graphics/skia/SimpleFontDataSkia.cpp: USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
(WebCore):

Source/WebKit/chromium:

Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ since there
won't be a distinction between ng and non-ng HarfBuzz after
removing the old code.

* features.gypi:

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

19 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/SimpleFontData.h
Source/WebCore/platform/graphics/freetype/FontPlatformData.h
Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp [deleted file]
Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h [deleted file]
Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp
Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp [deleted file]
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h [deleted file]
Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi
Source/cmake/OptionsEfl.cmake

index a666ca7..c2b99d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-01-30  Dominik Röttsches  <dominik.rottsches@intel.com>
+
+        [HarfBuzz] Remove the HarfBuzz-old code
+        https://bugs.webkit.org/show_bug.cgi?id=108077
+
+        Reviewed by Benjamin Poulain.
+
+        Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ since there
+        won't be a distinction between ng and non-ng HarfBuzz after
+        removing the old code.
+
+        * Source/cmake/OptionsEfl.cmake:
+
 2013-01-29  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK build fix after r141175.
index 57ccc47..b3b7b30 100644 (file)
@@ -1,3 +1,43 @@
+2013-01-30  Dominik Röttsches  <dominik.rottsches@intel.com>
+
+        [HarfBuzz] Remove the HarfBuzz-old code
+        https://bugs.webkit.org/show_bug.cgi?id=108077
+
+        Reviewed by Benjamin Poulain.
+
+        Removing unused old variant of the HarfBuzz code.
+
+        No new tests, no change in functionality.
+
+        * GNUmakefile.am: Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ
+        * WebCore.gypi: Removing ComplexTextControllerHarfBuzz* and HarfBuzzSkia* files,
+        * platform/graphics/SimpleFontData.h:
+        (SimpleFontData): USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
+        * platform/graphics/freetype/FontPlatformData.h:
+        (FontPlatformData): Removing USE(HARFBUZZ_NG) ifdefs.
+        * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
+        (WebCore::FontPlatformData::operator=):
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::harfbuzzFace):
+        * platform/graphics/freetype/SimpleFontDataFreeType.cpp: USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
+        (WebCore):
+        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: Removed.
+        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h: Removed.
+        * platform/graphics/harfbuzz/FontHarfBuzz.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
+        (WebCore::Font::drawComplexText):
+        (WebCore::Font::floatWidthForComplexText):
+        (WebCore::Font::offsetForPositionForComplexText):
+        (WebCore::Font::selectionRectForComplexText):
+        * platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp: Removing USE(HARFBUZZ_NG) ifdefs.
+        (WebCore::FontPlatformData::harfbuzzFace):
+        * platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h: Removing USE(HARFBUZZ_NG) ifdefs.
+        (WebCore):
+        (FontPlatformData):
+        * platform/graphics/harfbuzz/HarfBuzzSkia.cpp: Removed.
+        * platform/graphics/harfbuzz/HarfBuzzSkia.h: Removed.
+        * platform/graphics/skia/SimpleFontDataSkia.cpp: USE(HARFBUZZ_NG) renamed to USE(HARFBUZZ).
+        (WebCore):
+
 2013-01-30  David Faure  <faure@kde.org>
 
         [Qt] Major performance improvement in Qt's PluginDatabase implementation
index d3463ca..0a4ac25 100644 (file)
@@ -6,7 +6,7 @@ WEBCORE_CSS_VALUE_KEYWORDS := $(WebCore)/css/CSSValueKeywords.in
 
 webcore_cppflags += \
        -DWTF_USE_FREETYPE=1 \
-       -DWTF_USE_HARFBUZZ_NG=1 \
+       -DWTF_USE_HARFBUZZ=1 \
        -DWTF_USE_WEBP=1 \
        -I$(srcdir)/Source/ThirdParty/ANGLE/src \
        -I$(srcdir)/Source/ThirdParty/ANGLE/include \
index 6538d47..32bdf9b 100644 (file)
             'platform/graphics/gtk/ImageGtk.cpp',
             'platform/graphics/gtk/IntPointGtk.cpp',
             'platform/graphics/gtk/IntRectGtk.cpp',
-            'platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp',
-            'platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h',
             'platform/graphics/harfbuzz/FontHarfBuzz.cpp',
             'platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp',
             'platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h',
-            'platform/graphics/harfbuzz/HarfBuzzSkia.cpp',
-            'platform/graphics/harfbuzz/HarfBuzzSkia.h',
             'platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp',
             'platform/graphics/harfbuzz/HarfBuzzShaperBase.h',
             'platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCoreText.cpp',
index 41f8015..97ea5a2 100644 (file)
@@ -195,7 +195,7 @@ public:
     CFDictionaryRef getCFStringAttributes(TypesettingFeatures, FontOrientation) const;
 #endif
 
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ_NG)
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ)
     bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
 #endif
 
@@ -317,7 +317,7 @@ private:
     mutable HashMap<unsigned, RetainPtr<CFDictionaryRef> > m_CFStringAttributes;
 #endif
 
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ_NG)
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ)
     mutable OwnPtr<HashMap<String, bool> > m_combiningCharacterSequenceSupport;
 #endif
 
index 6a62c6c..8fe7061 100644 (file)
@@ -29,9 +29,7 @@
 #include "FontDescription.h"
 #include "FontOrientation.h"
 #include "GlyphBuffer.h"
-#if USE(HARFBUZZ_NG)
 #include "HarfBuzzNGFace.h"
-#endif
 #include "RefPtrCairo.h"
 #include <wtf/Forward.h>
 #include <wtf/HashFunctions.h>
@@ -67,9 +65,7 @@ public:
 
     ~FontPlatformData();
 
-#if USE(HARFBUZZ_NG)
     HarfBuzzNGFace* harfbuzzFace() const;
-#endif
 
     bool isFixedPitch();
     float size() const { return m_size; }
@@ -106,9 +102,7 @@ public:
     bool m_syntheticOblique;
     bool m_fixedWidth;
     cairo_scaled_font_t* m_scaledFont;
-#if USE(HARFBUZZ_NG)
     mutable RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
-#endif
 
 private:
     void initializeWithFontFace(cairo_font_face_t*, const FontDescription& = FontDescription());
index a21d596..f72d9c0 100644 (file)
@@ -191,9 +191,7 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
         cairo_scaled_font_destroy(m_scaledFont);
     m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
 
-#if USE(HARFBUZZ_NG)
     m_harfbuzzFace = other.m_harfbuzzFace;
-#endif
 
     return *this;
 }
@@ -201,17 +199,13 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
 FontPlatformData::FontPlatformData(const FontPlatformData& other)
     : m_fallbacks(0)
     , m_scaledFont(0)
-#if USE(HARFBUZZ_NG)
     , m_harfbuzzFace(other.m_harfbuzzFace)
-#endif
 {
     *this = other;
 }
 
 FontPlatformData::FontPlatformData(const FontPlatformData& other, float size)
-#if USE(HARFBUZZ_NG)
     : m_harfbuzzFace(other.m_harfbuzzFace)
-#endif
 {
     *this = other;
 
@@ -232,7 +226,6 @@ FontPlatformData::~FontPlatformData()
         cairo_scaled_font_destroy(m_scaledFont);
 }
 
-#if USE(HARFBUZZ_NG)
 HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
 {
     if (!m_harfbuzzFace)
@@ -240,7 +233,6 @@ HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
 
     return m_harfbuzzFace.get();
 }
-#endif
 
 bool FontPlatformData::isFixedPitch()
 {
index 87e6663..21eefb7 100644 (file)
@@ -160,7 +160,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return w;    
 }
 
-#if USE(HARFBUZZ_NG)
+#if USE(HARFBUZZ)
 bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
 {
     if (!m_combiningCharacterSequenceSupport)
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
deleted file mode 100644 (file)
index 8a4d872..0000000
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ComplexTextControllerHarfBuzz.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "SurrogatePairAwareTextIterator.h"
-#include "TextRun.h"
-
-#if OS(ANDROID)
-#include "FontCache.h"
-#include "SkTypeface_android.h"
-#endif
-
-extern "C" {
-#include "harfbuzz-unicode.h"
-}
-
-#include <unicode/normlzr.h>
-
-namespace WebCore {
-
-// Harfbuzz uses 26.6 fixed point values for pixel offsets. However, we don't
-// handle subpixel positioning so this function is used to truncate Harfbuzz
-// values to a number of pixels.
-static int truncateFixedPointToInteger(HB_Fixed value)
-{
-    return value >> 6;
-}
-
-ComplexTextController::ComplexTextController(const Font* font, const TextRun& run, int startingX, int startingY)
-    : HarfBuzzShaperBase(font, run)
-{
-    NormalizeMode mode = m_run.rtl() ? NormalizeMirrorChars : DoNotNormalizeMirrorChars;
-    setNormalizedBuffer(mode);
-
-    memset(&m_item, 0, sizeof(m_item));
-    // We cannot know, ahead of time, how many glyphs a given script run
-    // will produce. We take a guess that script runs will not produce more
-    // than twice as many glyphs as there are code points plus a bit of
-    // padding and fallback if we find that we are wrong.
-    createGlyphArrays((m_normalizedBufferLength + 2) * 2);
-
-    m_item.face = 0;
-    m_item.font = allocHarfbuzzFont();
-
-    m_item.item.bidiLevel = m_run.rtl();
-
-    m_item.string = m_normalizedBuffer.get();
-    m_item.stringLength = m_normalizedBufferLength;
-
-    reset(startingX);
-    m_startingY = startingY;
-
-    setPadding(m_run.expansion());
-}
-
-ComplexTextController::~ComplexTextController()
-{
-    fastFree(m_item.font);
-    deleteGlyphArrays();
-}
-
-void ComplexTextController::reset(int offset)
-{
-    m_indexOfNextScriptRun = 0;
-    m_offsetX = offset;
-}
-
-void ComplexTextController::setupForRTL()
-{
-    int padding = m_padding;
-    // FIXME: this causes us to shape the text twice -- once to compute the width and then again
-    // below when actually rendering. Change ComplexTextController to match platform/mac and
-    // platform/chromium/win by having it store the shaped runs, so we can reuse the results.
-    reset(m_offsetX + widthOfFullRun());
-    // We need to set the padding again because ComplexTextController layout consumed the value.
-    // Fixing the above problem would help here too.
-    setPadding(padding);
-}
-
-// Advance to the next script run, returning false when the end of the
-// TextRun has been reached.
-bool ComplexTextController::nextScriptRun()
-{
-    // Ensure we're not pointing at the small caps buffer.
-    m_item.string = m_normalizedBuffer.get();
-
-    if (!hb_utf16_script_run_next(0, &m_item.item, m_normalizedBuffer.get(), m_normalizedBufferLength, &m_indexOfNextScriptRun))
-        return false;
-
-    // It is actually wrong to consider script runs at all in this code.
-    // Other WebKit code (e.g. Mac) segments complex text just by finding
-    // the longest span of text covered by a single font.
-    // But we currently need to call hb_utf16_script_run_next anyway to fill
-    // in the harfbuzz data structures to e.g. pick the correct script's shaper.
-    // So we allow that to run first, then do a second pass over the range it
-    // found and take the largest subregion that stays within a single font.
-    SurrogatePairAwareTextIterator iterator(static_cast<const UChar*>(&m_item.string[m_item.item.pos]), 0, static_cast<int>(m_item.item.length), static_cast<int>(m_item.item.length));
-    UChar32 character;
-    unsigned clusterLength = 0;
-    if (!iterator.consume(character, clusterLength))
-        return false;
-    m_currentFontData = m_font->glyphDataForCharacter(character, false).fontData;
-    iterator.advance(clusterLength);
-    while (iterator.consume(character, clusterLength)) {
-        const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character, false).fontData;
-        if (nextFontData != m_currentFontData)
-            break;
-        iterator.advance(clusterLength);
-    }
-    m_item.item.length = iterator.currentCharacter();
-    m_indexOfNextScriptRun = m_item.item.pos + iterator.currentCharacter();
-
-    setupFontForScriptRun();
-    shapeGlyphs();
-    setGlyphPositions(rtl());
-
-    return true;
-}
-
-float ComplexTextController::widthOfFullRun()
-{
-    float widthSum = 0;
-    while (nextScriptRun())
-        widthSum += width();
-
-    return widthSum;
-}
-
-static void setupFontFeatures(const FontFeatureSettings* settings, HB_FaceRec_* hbFace)
-{
-    if (!settings)
-        return;
-
-    if (hbFace->gsub)
-        HB_GSUB_Clear_Features(hbFace->gsub);
-    if (hbFace->gpos)
-        HB_GPOS_Clear_Features(hbFace->gpos);
-
-    HB_UShort scriptIndex = 0;
-    HB_GSUB_Select_Script(hbFace->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &scriptIndex);
-    size_t numFeatures = settings->size();
-    for (size_t i = 0; i < numFeatures; ++i) {
-        if (!settings->at(i).value())
-            continue;
-        HB_UShort featureIndex = 0;
-        const UChar* tag = settings->at(i).tag().characters();
-        HB_UInt feature = HB_MAKE_TAG(tag[0], tag[1], tag[2], tag[3]);
-        if (hbFace->gsub && HB_GSUB_Select_Feature(hbFace->gsub, feature, scriptIndex, 0xffff, &featureIndex) == HB_Err_Ok)
-            HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, settings->at(i).value());
-        else if (hbFace->gpos && HB_GPOS_Select_Feature(hbFace->gpos, feature, scriptIndex, 0xffff, &featureIndex) == HB_Err_Ok)
-            HB_GPOS_Add_Feature(hbFace->gpos, featureIndex, settings->at(i).value());
-    }
-}
-
-static UChar32 surrogatePairAwareFirstCharacter(const UChar* characters, unsigned length)
-{
-    if (U16_IS_SURROGATE(characters[0])) {
-        if (!U16_IS_SURROGATE_LEAD(characters[0]) || length < 2 || !U16_IS_TRAIL(characters[1]))
-            return ' ';
-        return U16_GET_SUPPLEMENTARY(characters[0], characters[1]);
-    }
-    return characters[0];
-}
-
-const FontPlatformData* ComplexTextController::getComplexFontPlatformData()
-{
-#if OS(ANDROID)
-    // There are 2 kinds of font on Android: system fonts and fallback fonts.
-    // System fonts have a name, and are accessible in FontPlatformData.
-    // Fallback fonts do not have specific names, so they are not accessible
-    // from WebKit directly. To feed Harfbuzz, use a trick to get correct
-    // SkTypeface based on script.
-    FallbackScripts fallbackScript = kFallbackScriptNumber; // invalid script value.
-    switch (m_item.item.script) {
-    case HB_Script_Arabic:
-        fallbackScript = kArabic_FallbackScript;
-        break;
-    case HB_Script_Armenian:
-        fallbackScript = kArmenian_FallbackScript;
-        break;
-    case HB_Script_Bengali:
-        fallbackScript = kBengali_FallbackScript;
-        break;
-    case HB_Script_Devanagari:
-        fallbackScript = kDevanagari_FallbackScript;
-        break;
-    case HB_Script_Georgian:
-        fallbackScript = kGeorgian_FallbackScript;
-        break;
-    case HB_Script_Hebrew:
-        if (m_font->fontDescription().weight() >= FontWeightBold)
-            fallbackScript = kHebrewBold_FallbackScript;
-        else
-            fallbackScript = kHebrewRegular_FallbackScript;
-        break;
-    case HB_Script_Kannada:
-        fallbackScript = kKannada_FallbackScript;
-        break;
-    case HB_Script_Malayalam:
-        fallbackScript = kMalayalam_FallbackScript;
-        break;
-    case HB_Script_Tamil:
-        if (m_font->fontDescription().weight() >= FontWeightBold)
-            fallbackScript = kTamilBold_FallbackScript;
-        else
-            fallbackScript = kTamilRegular_FallbackScript;
-        break;
-    case HB_Script_Telugu:
-        fallbackScript = kTelugu_FallbackScript;
-        break;
-    case HB_Script_Thai:
-        fallbackScript = kThai_FallbackScript;
-        break;
-    default:
-        return 0;
-    }
-    return fontCache()->getCachedFontPlatformData(m_font->fontDescription(), SkGetFallbackScriptID(fallbackScript), true);
-#else
-    // Only Android needs the extra logic.
-    return 0;
-#endif
-}
-
-void ComplexTextController::setupFontForScriptRun()
-{
-    FontDataVariant fontDataVariant = AutoVariant;
-    // Determine if this script run needs to be converted to small caps.
-    // nextScriptRun() will always send us a run of the same case, because a
-    // case change while in small-caps mode always results in different
-    // FontData, so we only need to check the first character's case.
-    if (m_font->isSmallCaps() && u_islower(m_item.string[m_item.item.pos])) {
-        m_smallCapsString = String(m_normalizedBuffer.get() + m_item.item.pos, m_item.item.length);
-        m_smallCapsString.makeUpper();
-        m_item.string = m_smallCapsString.characters();
-        m_item.item.pos = 0;
-        fontDataVariant = SmallCapsVariant;
-    }
-    const FontPlatformData* platformData = getComplexFontPlatformData();
-    if (!platformData) {
-        UChar32 current = surrogatePairAwareFirstCharacter(static_cast<const UChar*>(&m_item.string[m_item.item.pos]), m_item.item.length - m_item.item.pos);
-        const FontData* fontData = m_font->glyphDataForCharacter(current, false, fontDataVariant).fontData;
-        platformData = &fontData->fontDataForCharacter(' ')->platformData();
-    }
-    m_item.face = platformData->harfbuzzFace()->face();
-    // We only need to setup font features at the beginning of the run.
-    if (!m_item.item.pos)
-        setupFontFeatures(m_font->fontDescription().featureSettings(), m_item.face);
-    void* opaquePlatformData = const_cast<FontPlatformData*>(platformData);
-    m_item.font->userData = opaquePlatformData;
-
-    int size = platformData->size();
-    m_item.font->x_ppem = size;
-    m_item.font->y_ppem = size;
-    // x_ and y_scale are the conversion factors from font design space (fEmSize) to 1/64th of device pixels in 16.16 format.
-    const int devicePixelFraction = 64;
-    const int multiplyFor16Dot16 = 1 << 16;
-    int scale = devicePixelFraction * size * multiplyFor16Dot16 / platformData->emSizeInFontUnits();
-    m_item.font->x_scale = scale;
-    m_item.font->y_scale = scale;
-}
-
-void ComplexTextController::deleteGlyphArrays()
-{
-    delete[] m_item.glyphs;
-    delete[] m_item.attributes;
-    delete[] m_item.advances;
-    delete[] m_item.offsets;
-    delete[] m_item.log_clusters;
-    delete[] m_glyphs16;
-    delete[] m_positions;
-}
-
-void ComplexTextController::createGlyphArrays(int size)
-{
-    m_item.glyphs = new HB_Glyph[size];
-    m_item.attributes = new HB_GlyphAttributes[size];
-    m_item.advances = new HB_Fixed[size];
-    m_item.offsets = new HB_FixedPoint[size];
-    m_item.log_clusters = new unsigned short[size];
-
-    m_glyphs16 = new uint16_t[size];
-    m_positions = new SkPoint[size];
-
-    m_item.num_glyphs = size;
-    m_glyphsArrayCapacity = size; // Save the GlyphArrays size.
-    resetGlyphArrays();
-}
-
-void ComplexTextController::resetGlyphArrays()
-{
-    int size = m_item.num_glyphs;
-    // All the types here don't have pointers. It is safe to reset to
-    // zero unless Harfbuzz breaks the compatibility in the future.
-    memset(m_item.glyphs, 0, size * sizeof(HB_Glyph));
-    memset(m_item.attributes, 0, size * sizeof(HB_GlyphAttributes));
-    memset(m_item.advances, 0, size * sizeof(HB_Fixed));
-    memset(m_item.offsets, 0, size * sizeof(HB_FixedPoint));
-    memset(m_glyphs16, 0, size * sizeof(uint16_t));
-    memset(m_positions, 0, size * sizeof(SkPoint));
-}
-
-void ComplexTextController::shapeGlyphs()
-{
-    // HB_ShapeItem() resets m_item.num_glyphs. If the previous call to
-    // HB_ShapeItem() used less space than was available, the capacity of
-    // the array may be larger than the current value of m_item.num_glyphs.
-    // So, we need to reset the num_glyphs to the capacity of the array.
-    m_item.num_glyphs = m_glyphsArrayCapacity;
-    resetGlyphArrays();
-    while (!HB_ShapeItem(&m_item)) {
-        // We overflowed our arrays. Resize and retry.
-        // HB_ShapeItem fills in m_item.num_glyphs with the needed size.
-        deleteGlyphArrays();
-        // The |+ 1| here is a workaround for a bug in Harfbuzz: the Khmer
-        // shaper (at least) can fail because of insufficient glyph buffers
-        // and request 0 additional glyphs: throwing us into an infinite
-        // loop.
-        createGlyphArrays(m_item.num_glyphs + 1);
-    }
-}
-
-void ComplexTextController::setGlyphPositions(bool isRTL)
-{
-    const double rtlFlip = isRTL ? -1 : 1;
-    double position = 0;
-
-    // logClustersIndex indexes logClusters for the first codepoint of the current glyph.
-    // Each time we advance a glyph, we skip over all the codepoints that contributed to the current glyph.
-    size_t logClustersIndex = 0;
-
-    // Iterate through the glyphs in logical order, flipping for RTL where necessary.
-    // Glyphs are positioned starting from m_offsetX; in RTL mode they go leftwards from there.
-    for (size_t i = 0; i < m_item.num_glyphs; ++i) {
-        while (logClustersIndex < m_item.item.length && m_item.log_clusters[logClustersIndex] < i)
-            logClustersIndex++;
-
-        // If the current glyph is just after a space, add in the word spacing.
-        if (logClustersIndex < m_item.item.length && isWordEnd(m_item.item.pos + logClustersIndex))
-            position += determineWordBreakSpacing();
-
-        m_glyphs16[i] = m_item.glyphs[i];
-        double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
-        double offsetY = truncateFixedPointToInteger(m_item.offsets[i].y);
-        double advance = truncateFixedPointToInteger(m_item.advances[i]);
-        if (isRTL)
-            offsetX -= advance;
-
-        m_positions[i].set(m_offsetX + (position * rtlFlip) + offsetX,
-                           m_startingY + offsetY);
-
-        if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i]))
-            continue;
-
-        // At the end of each cluster, add in the letter spacing.
-        if (i + 1 == m_item.num_glyphs || m_item.attributes[i + 1].clusterStart)
-            position += m_letterSpacing;
-
-        position += advance;
-    }
-    m_pixelWidth = std::max(position, 0.0);
-    m_offsetX += m_pixelWidth * rtlFlip;
-}
-
-int ComplexTextController::glyphIndexForXPositionInScriptRun(int targetX) const
-{
-    // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous
-    // position and halfway through the current glyph.
-    // FIXME: this code probably belongs in ComplexTextController.
-    int lastX = offsetX() - (rtl() ? -m_pixelWidth : m_pixelWidth);
-    for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < length(); ++glyphIndex) {
-        int advance = truncateFixedPointToInteger(m_item.advances[glyphIndex]);
-        int nextX = static_cast<int>(positions()[glyphIndex].x()) + advance / 2;
-        if (std::min(nextX, lastX) <= targetX && targetX <= std::max(nextX, lastX))
-            return glyphIndex;
-        lastX = nextX;
-    }
-
-    return length() - 1;
-}
-
-int ComplexTextController::offsetForPosition(int targetX)
-{
-    unsigned basePosition = 0;
-
-    int x = offsetX();
-    while (nextScriptRun()) {
-        int nextX = offsetX();
-
-        if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) {
-            // The x value in question is within this script run.
-            const int glyphIndex = glyphIndexForXPositionInScriptRun(targetX);
-
-            // Now that we have a glyph index, we have to turn that into a
-            // code-point index. Because of ligatures, several code-points may
-            // have gone into a single glyph. We iterate over the clusters log
-            // and find the first code-point which contributed to the glyph.
-
-            // Some shapers (i.e. Khmer) will produce cluster logs which report
-            // that /no/ code points contributed to certain glyphs. Because of
-            // this, we take any code point which contributed to the glyph in
-            // question, or any subsequent glyph. If we run off the end, then
-            // we take the last code point.
-            for (unsigned j = 0; j < numCodePoints(); ++j) {
-                if (m_item.log_clusters[j] >= glyphIndex)
-                    return basePosition + j;
-            }
-
-            return basePosition + numCodePoints() - 1;
-        }
-
-        basePosition += numCodePoints();
-    }
-
-    return basePosition;
-}
-
-FloatRect ComplexTextController::selectionRect(const FloatPoint& point, int height, int from, int to)
-{
-    int fromX = -1, toX = -1;
-    // Iterate through the script runs in logical order, searching for the run covering the positions of interest.
-    while (nextScriptRun() && (fromX == -1 || toX == -1)) {
-        if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < numCodePoints()) {
-            // |from| is within this script run. So we index the clusters log to
-            // find which glyph this code-point contributed to and find its x
-            // position.
-            int glyph = m_item.log_clusters[from];
-            fromX = positions()[glyph].x();
-            if (rtl())
-                fromX += truncateFixedPointToInteger(m_item.advances[glyph]);
-        } else
-            from -= numCodePoints();
-
-        if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < numCodePoints()) {
-            int glyph = m_item.log_clusters[to];
-            toX = positions()[glyph].x();
-            if (rtl())
-                toX += truncateFixedPointToInteger(m_item.advances[glyph]);
-        } else
-            to -= numCodePoints();
-    }
-
-    // The position in question might be just after the text.
-    if (fromX == -1)
-        fromX = offsetX();
-    if (toX == -1)
-        toX = offsetX();
-
-    ASSERT(fromX != -1 && toX != -1);
-
-    if (fromX < toX)
-        return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
-
-    return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
-}
-
-void ComplexTextController::glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength)
-{
-    // Character offsets within the current run. THESE MAY NOT BE IN RANGE and may
-    // be negative, etc. The code below handles this.
-    int fromChar = from - m_item.item.pos;
-    int toChar = to - m_item.item.pos;
-
-    // See if there are any characters in the current run.
-    if (!numCodePoints() || fromChar >= static_cast<int>(numCodePoints()) || toChar <= 0) {
-        fromGlyph = -1;
-        glyphLength = 0;
-        return;
-    }
-
-    // Compute the starting glyph within this span. |from| and |to| are
-    // global offsets that may intersect arbitrarily with our local run.
-    fromGlyph = m_item.log_clusters[fromChar < 0 ? 0 : fromChar];
-    if (toChar >= static_cast<int>(numCodePoints()))
-        glyphLength = length() - fromGlyph;
-    else
-        glyphLength = m_item.log_clusters[toChar] - fromGlyph;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h b/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h
deleted file mode 100644 (file)
index 1758a3c..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ComplexTextControllerHarfBuzz_h
-#define ComplexTextControllerHarfBuzz_h
-
-#include "HarfBuzzShaperBase.h"
-#include "HarfBuzzSkia.h"
-#include "SkPoint.h"
-#include "SkScalar.h"
-#include "TextRun.h"
-
-extern "C" {
-#include "harfbuzz-shaper.h"
-}
-
-#include <unicode/uchar.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-class Font;
-class FontPlatformData;
-class SimpleFontData;
-
-// ComplexTextController walks a TextRun and presents each script run in sequence. A
-// TextRun is a sequence of code-points with the same embedding level (i.e. they
-// are all left-to-right or right-to-left). A script run is a subsequence where
-// all the characters have the same script (e.g. Arabic, Thai etc). Shaping is
-// only ever done with script runs since the shapers only know how to deal with
-// a single script.
-//
-// Iteration is always in logical (aka reading) order. For RTL text that means
-// the rightmost part of the text will be first.
-//
-// Once you have setup the object, call |nextScriptRun| to get the first script
-// run. This will return false when the iteration is complete. At any time you
-// can call |reset| to start over again.
-class ComplexTextController : public HarfBuzzShaperBase {
-public:
-    ComplexTextController(const Font*, const TextRun&, int startingX, int startingY);
-    virtual ~ComplexTextController();
-
-    void reset(int offset);
-    // Advance to the next script run, returning false when the end of the
-    // TextRun has been reached.
-    bool nextScriptRun();
-    float widthOfFullRun();
-
-    void setupForRTL();
-    bool rtl() const { return m_run.rtl(); }
-    const uint16_t* glyphs() const { return m_glyphs16; }
-
-    // Return the start index and length of glyphs for the range [from, to) in the current script run.
-    void glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength);
-
-    // Return the length of the array returned by |glyphs|
-    unsigned length() const { return m_item.num_glyphs; }
-
-    // Return the offset for each of the glyphs. Note that this is translated
-    // by the current x offset and that the x offset is updated for each script
-    // run.
-    const SkPoint* positions() const { return m_positions; }
-
-    // return the number of code points in the current script run
-    unsigned numCodePoints() const { return m_item.item.length; }
-
-    // Return the current pixel position of the controller.
-    unsigned offsetX() const { return m_offsetX; }
-
-    const FontPlatformData* fontPlatformDataForScriptRun() { return reinterpret_cast<FontPlatformData*>(m_item.font->userData); }
-
-    int offsetForPosition(int);
-    FloatRect selectionRect(const FloatPoint&, int height, int from , int to);
-
-private:
-    // Return the width (in px) of the current script run.
-    unsigned width() const { return m_pixelWidth; }
-
-    const FontPlatformData* getComplexFontPlatformData();
-    void setupFontForScriptRun();
-    void deleteGlyphArrays();
-    void createGlyphArrays(int);
-    void resetGlyphArrays();
-    void shapeGlyphs();
-    void setGlyphPositions(bool);
-
-    int glyphIndexForXPositionInScriptRun(int targetX) const;
-
-    const SimpleFontData* m_currentFontData;
-    HB_ShaperItem m_item;
-    uint16_t* m_glyphs16; // A vector of 16-bit glyph ids.
-    SkPoint* m_positions; // A vector of positions for each glyph.
-    ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|.
-    int m_offsetX; // Offset in pixels to the start of the next script run.
-    int m_startingY; // The Y starting point of the script run.
-    unsigned m_pixelWidth; // Width (in px) of the current script run.
-    unsigned m_glyphsArrayCapacity; // Current size of all the Harfbuzz arrays.
-
-    String m_smallCapsString; // substring of m_run converted to small caps.
-};
-
-} // namespace WebCore
-
-#endif // ComplexTextControllerHarfBuzz_h
index 5c79004..eb709e3 100644 (file)
 #include "config.h"
 #include "Font.h"
 
-#if USE(HARFBUZZ_NG)
-#include "HarfBuzzShaper.h"
-#else
-#include "ComplexTextControllerHarfBuzz.h"
-#include "HarfBuzzSkia.h"
-#endif
-
 #include "FloatRect.h"
 #include "GlyphBuffer.h"
 #include "GraphicsContext.h"
+#include "HarfBuzzShaper.h"
 #include "NotImplemented.h"
 #include "PlatformContextSkia.h"
 #include "SimpleFontData.h"
@@ -182,7 +176,6 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
         setupForTextPainting(&strokePaint, gc->strokeColor().rgb());
     }
 
-#if USE(HARFBUZZ_NG)
     GlyphBuffer glyphBuffer;
     HarfBuzzShaper shaper(this, run);
     shaper.setDrawRange(from, to);
@@ -190,32 +183,6 @@ void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
         return;
     FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
     drawGlyphBuffer(gc, run, glyphBuffer, adjustedPoint);
-#else
-    PlatformContextSkia* platformContext = gc->platformContext();
-    ComplexTextController controller(this, run, point.x(), point.y());
-    if (run.rtl())
-        controller.setupForRTL();
-
-    while (controller.nextScriptRun()) {
-        // Check if there is any glyph found in the current script run.
-        int fromGlyph, glyphLength;
-        controller.glyphsForRange(from, to, fromGlyph, glyphLength);
-        if (fromGlyph < 0 || glyphLength <= 0)
-            continue;
-
-        if (fill) {
-            controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
-            gc->platformContext()->adjustTextRenderMode(&fillPaint);
-            platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, fillPaint);
-        }
-
-        if (stroke) {
-            controller.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
-            gc->platformContext()->adjustTextRenderMode(&strokePaint);
-            platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, strokePaint);
-        }
-    }
-#endif
 }
 
 void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
@@ -225,15 +192,10 @@ void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const
 
 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */, GlyphOverflow* /* glyphOverflow */) const
 {
-#if USE(HARFBUZZ_NG)
     HarfBuzzShaper shaper(this, run);
     if (!shaper.shape())
         return 0;
     return shaper.totalWidth();
-#else
-    ComplexTextController controller(this, run, 0, 0);
-    return controller.widthOfFullRun();
-#endif
 }
 
 // Return the code point index for the given |x| offset into the text run.
@@ -244,19 +206,10 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat,
     // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
     int targetX = static_cast<int>(xFloat);
 
-#if USE(HARFBUZZ_NG)
     HarfBuzzShaper shaper(this, run);
     if (!shaper.shape())
         return 0;
     return shaper.offsetForPosition(targetX);
-#else
-    // (Mac code ignores includePartialGlyphs, and they don't know what it's
-    // supposed to do, so we just ignore it as well.)
-    ComplexTextController controller(this, run, 0, 0);
-    if (run.rtl())
-        controller.setupForRTL();
-    return controller.offsetForPosition(targetX);
-#endif
 }
 
 // Return the rectangle for selecting the given range of code-points in the TextRun.
@@ -264,17 +217,10 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run,
                                             const FloatPoint& point, int height,
                                             int from, int to) const
 {
-#if USE(HARFBUZZ_NG)
     HarfBuzzShaper shaper(this, run);
     if (!shaper.shape())
         return FloatRect();
     return shaper.selectionRect(point, height, from, to);
-#else
-    ComplexTextController controller(this, run, 0, 0);
-    if (run.rtl())
-        controller.setupForRTL();
-    return controller.selectionRect(point, height, from, to);
-#endif
 }
 
 } // namespace WebCore
index d10611a..40e5652 100644 (file)
 #include "FontPlatformDataHarfBuzz.h"
 
 #include "FontCache.h"
+#include "HarfBuzzNGFace.h"
 #include "NotImplemented.h"
 #include "SkAdvancedTypefaceMetrics.h"
 #include "SkFontHost.h"
 #include "SkPaint.h"
 #include "SkTypeface.h"
 
-#if USE(HARFBUZZ_NG)
-#include "HarfBuzzNGFace.h"
-#else
-#include "HarfBuzzSkia.h"
-#endif
-
 #include <public/linux/WebFontInfo.h>
 #include <public/linux/WebFontRenderStyle.h>
 #include <public/linux/WebSandboxSupport.h>
@@ -273,7 +268,6 @@ bool FontPlatformData::isFixedPitch() const
     return false;
 }
 
-#if USE(HARFBUZZ_NG)
 HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
 {
     if (!m_harfbuzzFace)
@@ -281,15 +275,6 @@ HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
 
     return m_harfbuzzFace.get();
 }
-#else
-HarfbuzzFace* FontPlatformData::harfbuzzFace() const
-{
-    if (!m_harfbuzzFace)
-        m_harfbuzzFace = HarfbuzzFace::create(const_cast<FontPlatformData*>(this));
-
-    return m_harfbuzzFace.get();
-}
-#endif
 
 void FontPlatformData::getRenderStyleForStrike(const char* font, int sizeAndStyle)
 {
index ceb8d22..8fea154 100644 (file)
@@ -47,12 +47,7 @@ typedef uint32_t SkFontID;
 namespace WebCore {
 
 class FontDescription;
-
-#if USE(HARFBUZZ_NG)
 class HarfBuzzNGFace;
-#else
-class HarfbuzzFace;
-#endif
 
 // -----------------------------------------------------------------------------
 // FontPlatformData is the handle which WebKit has on a specific face. A face
@@ -112,11 +107,7 @@ public:
     String description() const;
 #endif
 
-#if USE(HARFBUZZ_NG)
     HarfBuzzNGFace* harfbuzzFace() const;
-#else
-    HarfbuzzFace* harfbuzzFace() const;
-#endif
 
     // The returned styles are all actual styles without FontRenderStyle::NoPreference.
     const FontRenderStyle& fontRenderStyle() const { return m_style; }
@@ -144,11 +135,7 @@ private:
     bool m_fakeItalic;
     FontOrientation m_orientation;
     FontRenderStyle m_style;
-#if USE(HARFBUZZ_NG)
     mutable RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
-#else
-    mutable RefPtr<HarfbuzzFace> m_harfbuzzFace;
-#endif
 
     SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
 };
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp
deleted file mode 100644 (file)
index 1e8867b..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HarfBuzzSkia.h"
-
-#include "FontPlatformData.h"
-
-#include "SkFontHost.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-#include "SkPoint.h"
-#include "SkRect.h"
-#include "SkUtils.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/OwnArrayPtr.h>
-
-extern "C" {
-#include "harfbuzz-shaper.h"
-}
-
-// This file implements the callbacks which Harfbuzz requires by using Skia
-// calls. See the Harfbuzz source for references about what these callbacks do.
-
-namespace WebCore {
-
-static HB_Fixed SkiaScalarToHarfbuzzFixed(SkScalar value)
-{
-    // HB_Fixed is a 26.6 fixed point format.
-    return value * 64;
-}
-
-static HB_Bool stringToGlyphs(HB_Font hbFont, const HB_UChar16* characters, hb_uint32 length, HB_Glyph* glyphs, hb_uint32* glyphsSize, HB_Bool isRTL)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
-    SkPaint paint;
-
-    font->setupPaint(&paint);
-    paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
-    unsigned codepoints = 0;
-    for (hb_uint32 i = 0; i < length; i++) {
-        if (!SkUTF16_IsHighSurrogate(characters[i]))
-            codepoints++;
-        if (codepoints > *glyphsSize)
-            return 0;
-    }
-
-    int numGlyphs = paint.textToGlyphs(characters, length * sizeof(uint16_t), reinterpret_cast<uint16_t*>(glyphs));
-
-    // HB_Glyph is 32-bit, but Skia outputs only 16-bit numbers. So our
-    // |glyphs| array needs to be converted.
-    for (int i = numGlyphs - 1; i >= 0; --i) {
-        uint16_t value;
-        // We use a memcpy to avoid breaking strict aliasing rules.
-        memcpy(&value, reinterpret_cast<char*>(glyphs) + sizeof(uint16_t) * i, sizeof(uint16_t));
-        glyphs[i] = value;
-    }
-
-    *glyphsSize = numGlyphs;
-    return 1;
-}
-
-static void glyphsToAdvances(HB_Font hbFont, const HB_Glyph* glyphs, hb_uint32 numGlyphs, HB_Fixed* advances, int flags)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
-    SkPaint paint;
-
-    font->setupPaint(&paint);
-    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
-    OwnArrayPtr<uint16_t> glyphs16 = adoptArrayPtr(new uint16_t[numGlyphs]);
-    if (!glyphs16.get())
-        return;
-    for (unsigned i = 0; i < numGlyphs; ++i)
-        glyphs16[i] = glyphs[i];
-    paint.getTextWidths(glyphs16.get(), numGlyphs * sizeof(uint16_t), reinterpret_cast<SkScalar*>(advances));
-
-    // The |advances| values which Skia outputs are SkScalars, which are floats
-    // in Chromium. However, Harfbuzz wants them in 26.6 fixed point format.
-    // These two formats are both 32-bits long.
-    for (unsigned i = 0; i < numGlyphs; ++i) {
-        float value;
-        // We use a memcpy to avoid breaking strict aliasing rules.
-        memcpy(&value, reinterpret_cast<char*>(advances) + sizeof(float) * i, sizeof(float));
-        advances[i] = SkiaScalarToHarfbuzzFixed(value);
-    }
-}
-
-static HB_Bool canRender(HB_Font hbFont, const HB_UChar16* characters, hb_uint32 length)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
-    SkPaint paint;
-
-    font->setupPaint(&paint);
-    paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
-    OwnArrayPtr<uint16_t> glyphs16 = adoptArrayPtr(new uint16_t[length]);
-    if (!glyphs16.get())
-        return 0;
-    int numGlyphs = paint.textToGlyphs(characters, length * sizeof(uint16_t), glyphs16.get());
-
-    bool canRender = true;
-    for (int i = 0; i < numGlyphs; ++i) {
-        if (!glyphs16[i]) {
-            canRender = false;
-            break;
-        }
-    }
-
-    return canRender;
-}
-
-static HB_Error getOutlinePoint(HB_Font hbFont, HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed* xPos, HB_Fixed* yPos, hb_uint32* resultingNumPoints)
-{
-    // We cannot provide the right position of outline points from point index.
-    // Just return HB_Err_Ok with resultingNumPoints = 0 so that harfbuzz
-    // falls back on using design coordinate value pair.
-    // See https://bugs.webkit.org/show_bug.cgi?id=60079 for more details.
-    *resultingNumPoints = 0;
-    return HB_Err_Ok;
-}
-
-static void getGlyphMetrics(HB_Font hbFont, HB_Glyph glyph, HB_GlyphMetrics* metrics)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
-    SkPaint paint;
-
-    font->setupPaint(&paint);
-    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-    uint16_t glyph16 = glyph;
-    SkScalar width;
-    SkRect bounds;
-    paint.getTextWidths(&glyph16, sizeof(glyph16), &width, &bounds);
-
-    metrics->x = SkiaScalarToHarfbuzzFixed(bounds.fLeft);
-    metrics->y = SkiaScalarToHarfbuzzFixed(bounds.fTop);
-    metrics->width = SkiaScalarToHarfbuzzFixed(bounds.width());
-    metrics->height = SkiaScalarToHarfbuzzFixed(bounds.height());
-
-    metrics->xOffset = SkiaScalarToHarfbuzzFixed(width);
-    // We can't actually get the |y| correct because Skia doesn't export
-    // the vertical advance. However, nor we do ever render vertical text at
-    // the moment so it's unimportant.
-    metrics->yOffset = 0;
-}
-
-static HB_Fixed getFontMetric(HB_Font hbFont, HB_FontMetric metric)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
-    SkPaint paint;
-
-    font->setupPaint(&paint);
-    SkPaint::FontMetrics skiaMetrics;
-    paint.getFontMetrics(&skiaMetrics);
-
-    switch (metric) {
-    case HB_FontAscent:
-        return SkiaScalarToHarfbuzzFixed(-skiaMetrics.fAscent);
-    // We don't support getting the rest of the metrics and Harfbuzz doesn't seem to need them.
-    default:
-        return 0;
-    }
-}
-
-HB_FontClass harfbuzzSkiaClass = {
-    stringToGlyphs,
-    glyphsToAdvances,
-    canRender,
-    getOutlinePoint,
-    getGlyphMetrics,
-    getFontMetric,
-};
-
-HB_Font_* allocHarfbuzzFont()
-{
-    HB_Font_* font = reinterpret_cast<HB_Font_*>(fastMalloc(sizeof(HB_Font_)));
-    memset(font, 0, sizeof(HB_Font_));
-    font->klass = &harfbuzzSkiaClass;
-    font->userData = 0;
-
-    return font;
-}
-
-HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag tag, HB_Byte* buffer, HB_UInt* len)
-{
-    FontPlatformData* font = reinterpret_cast<FontPlatformData*>(voidface);
-
-    const size_t tableSize = SkFontHost::GetTableSize(font->uniqueID(), tag);
-    if (!tableSize)
-        return HB_Err_Invalid_Argument;
-    // If Harfbuzz specified a 0 buffer then it's asking for the size of the table.
-    if (!buffer) {
-        *len = tableSize;
-        return HB_Err_Ok;
-    }
-
-    if (*len < tableSize)
-        return HB_Err_Invalid_Argument;
-    SkFontHost::GetTableData(font->uniqueID(), tag, 0, tableSize, buffer);
-    return HB_Err_Ok;
-}
-
-typedef pair<HB_FaceRec_*, unsigned> FaceCacheEntry;
-typedef HashMap<unsigned int, FaceCacheEntry, WTF::IntHash<unsigned int>, WTF::UnsignedWithZeroKeyHashTraits<unsigned int> > HarfbuzzFaceCache;
-static HarfbuzzFaceCache* gHarfbuzzFaceCache = 0;
-
-static HB_FaceRec_* getCachedHarfbuzzFace(FontPlatformData* platformData)
-{
-    if (!gHarfbuzzFaceCache)
-        gHarfbuzzFaceCache = new HarfbuzzFaceCache;
-    SkFontID uniqueID = platformData->uniqueID();
-    HarfbuzzFaceCache::iterator result = gHarfbuzzFaceCache->find(uniqueID);
-    if (result == gHarfbuzzFaceCache->end()) {
-        FaceCacheEntry entry(HB_NewFace(platformData, harfbuzzSkiaGetTable), 1);
-        gHarfbuzzFaceCache->set(uniqueID, entry);
-        return entry.first;
-    }
-    ++(result.get()->value.second);
-    return result.get()->value.first;
-}
-
-static void releaseCachedHarfbuzzFace(SkFontID uniqueID)
-{
-    HarfbuzzFaceCache::iterator result = gHarfbuzzFaceCache->find(uniqueID);
-    ASSERT(result != gHarfbuzzFaceCache->end());
-    ASSERT(result.get()->value.second > 0);
-    --(result.get()->value.second);
-    if (!(result.get()->value.second)) {
-        HB_FreeFace(result.get()->value.first);
-        gHarfbuzzFaceCache->remove(uniqueID);
-    }
-}
-
-HarfbuzzFace::HarfbuzzFace(FontPlatformData* platformData)
-    : m_uniqueID(platformData->uniqueID())
-{
-    m_harfbuzzFace = getCachedHarfbuzzFace(platformData);
-}
-
-HarfbuzzFace::~HarfbuzzFace()
-{
-    releaseCachedHarfbuzzFace(m_uniqueID);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h
deleted file mode 100644 (file)
index 316b443..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HarfBuzzSkia_h
-#define HarfBuzzSkia_h
-
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-struct HB_FaceRec_;
-struct HB_Font_;
-
-namespace WebCore {
-
-class FontPlatformData;
-
-class HarfbuzzFace : public RefCounted<HarfbuzzFace> {
-public:
-    static PassRefPtr<HarfbuzzFace> create(FontPlatformData* platformData)
-    {
-        return adoptRef(new HarfbuzzFace(platformData));
-    }
-
-    ~HarfbuzzFace();
-
-    HB_FaceRec_* face() const { return m_harfbuzzFace; }
-
-private:
-    explicit HarfbuzzFace(FontPlatformData*);
-
-    uint32_t m_uniqueID;
-    HB_FaceRec_* m_harfbuzzFace;
-};
-
-// FIXME: Remove this asymmetric alloc/free function.
-// We'll remove this once we move to the new Harfbuzz API.
-HB_Font_* allocHarfbuzzFont();
-
-} // namespace WebCore
-
-#endif
index 4fc0981..456a36f 100644 (file)
@@ -251,7 +251,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
     return SkScalarToFloat(width);
 }
 
-#if USE(HARFBUZZ_NG)
+#if USE(HARFBUZZ)
 bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
 {
     if (!m_combiningCharacterSequenceSupport)
index fd02f0a..0f32866 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-30  Dominik Röttsches  <dominik.rottsches@intel.com>
+
+        [HarfBuzz] Remove the HarfBuzz-old code
+        https://bugs.webkit.org/show_bug.cgi?id=108077
+
+        Reviewed by Benjamin Poulain.
+
+        Rename WTF_USE_HARFBUZZ_NG to WTF_USE_HARFBUZZ since there
+        won't be a distinction between ng and non-ng HarfBuzz after
+        removing the old code.
+
+        * features.gypi:
+
 2013-01-30  Jochen Eisinger  <jochen@chromium.org>
 
         [chromium] WebConsoleMessage is missing LevelDebug (chromium bug 172416)
index c244ad9..1df4db1 100644 (file)
       }],
       ['use_x11==1 or OS=="android"', {
         'feature_defines': [
-          'WTF_USE_HARFBUZZ_NG=1',
+          'WTF_USE_HARFBUZZ=1',
         ],
       }],
       ['chromeos==1', {
index ff63b52..1a397b6 100644 (file)
@@ -142,7 +142,7 @@ endif ()
 find_package(Freetype 2.4.2 REQUIRED)
 find_package(HarfBuzz 0.9.2 REQUIRED)
 add_definitions(-DWTF_USE_FREETYPE=1)
-add_definitions(-DWTF_USE_HARFBUZZ_NG=1)
+add_definitions(-DWTF_USE_HARFBUZZ=1)
 
 if (ENABLE_WEBKIT2 AND ENABLE_NETSCAPE_PLUGIN_API)
     set(ENABLE_PLUGIN_PROCESS 1)