[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 13:26:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 142ac3f7fefab40c4d7873d7e1be929dea8fc7ab
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 15 19:52:35 2010 +0000

    2010-09-14  Martin Robinson  <mrobinson at igalia.com>
    
            Reviewed by Xan Lopez.
    
            [GTK] Fully separate Pango and FreeType font backends
            https://bugs.webkit.org/show_bug.cgi?id=27442
    
            Split FontPlatformData.h into separate versions for Pango, FreeType and WinCairo.
            Include the correct file via #ifdef'd includes, like the Chromium port. Also split
            FontCacheCairo.cpp into Pango and FreeType versions, as they had almost no code in
            common. Finally, rename FontPlatformDataCairo to FontPlatformDataFreeType, as this
            compilation unit is used only by the FreeType backend. This change is important to
            prevent upcoming fixes to the FreeType backend from affecting other backends.
    
            No new tests as functionality has not changed.
    
            * CMakeListsEfl.txt: Update source lists.
            * GNUmakefile.am: Update source lists.
            * platform/graphics/cairo/FontCacheCairo.cpp: Removed.
            * platform/graphics/cairo/FontCacheFreeType.cpp: Added.
            (WebCore::FontCache::platformInit):
            (WebCore::FontCache::getFontDataForCharacters):
            (WebCore::FontCache::getSimilarFontPlatformData):
            (WebCore::FontCache::getLastResortFallbackFont):
            (WebCore::FontCache::getTraitsInFamily):
            (WebCore::isWellKnownFontName):
            (WebCore::FontCache::createFontPlatformData):
            * platform/graphics/cairo/FontPlatformData.h:
            * platform/graphics/cairo/FontPlatformDataFreeType.cpp: Renamed from WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp.
            (WebCore::FontPlatformData::FontPlatformData):
            (WebCore::FontPlatformData::operator=):
            (WebCore::FontPlatformData::init):
            (WebCore::FontPlatformData::~FontPlatformData):
            (WebCore::FontPlatformData::isFixedPitch):
            (WebCore::FontPlatformData::operator==):
            (WebCore::FontPlatformData::description):
            * platform/graphics/cairo/FontPlatformDataFreeType.h: Added.
            (WebCore::FontPlatformData::FontPlatformData):
            (WebCore::FontPlatformData::size):
            (WebCore::FontPlatformData::setSize):
            (WebCore::FontPlatformData::syntheticBold):
            (WebCore::FontPlatformData::syntheticOblique):
            (WebCore::FontPlatformData::scaledFont):
            (WebCore::FontPlatformData::hash):
            (WebCore::FontPlatformData::isHashTableDeletedValue):
            (WebCore::FontPlatformData::hashTableDeletedFontValue):
            * platform/graphics/gtk/FontCachePango.cpp: Added.
            (WebCore::FontCache::platformInit):
            (WebCore::FontCache::getFontDataForCharacters):
            (WebCore::FontCache::getSimilarFontPlatformData):
            (WebCore::FontCache::getLastResortFallbackFont):
            (WebCore::FontCache::getTraitsInFamily):
            (WebCore::FontCache::createFontPlatformData):
            * platform/graphics/gtk/FontPlatformDataPango.h: Added.
            (WebCore::FontPlatformData::FontPlatformData):
            (WebCore::FontPlatformData::size):
            (WebCore::FontPlatformData::setSize):
            (WebCore::FontPlatformData::syntheticBold):
            (WebCore::FontPlatformData::syntheticOblique):
            (WebCore::FontPlatformData::scaledFont):
            (WebCore::FontPlatformData::hash):
            (WebCore::FontPlatformData::isHashTableDeletedValue):
            (WebCore::FontPlatformData::hashTableDeletedFontValue):
            * platform/graphics/win/FontPlatformDataCairoWin.h: Added.
            (WebCore::FontPlatformData::FontPlatformData):
            (WebCore::FontPlatformData::hfont):
            (WebCore::FontPlatformData::useGDI):
            (WebCore::FontPlatformData::fontFace):
            (WebCore::FontPlatformData::size):
            (WebCore::FontPlatformData::setSize):
            (WebCore::FontPlatformData::syntheticBold):
            (WebCore::FontPlatformData::syntheticOblique):
            (WebCore::FontPlatformData::scaledFont):
            (WebCore::FontPlatformData::hash):
            (WebCore::FontPlatformData::isHashTableDeletedValue):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67567 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/CMakeListsEfl.txt b/WebCore/CMakeListsEfl.txt
index 530acf3..66fb485 100644
--- a/WebCore/CMakeListsEfl.txt
+++ b/WebCore/CMakeListsEfl.txt
@@ -66,9 +66,9 @@ IF (WTF_PLATFORM_CAIRO)
   )
   LIST(APPEND WebCore_SOURCES
     platform/graphics/cairo/FontCacheCairo.cpp
-    platform/graphics/cairo/FontCairo.cpp
+    platform/graphics/cairo/FontCairoFreeType.cpp
     platform/graphics/cairo/FontCustomPlatformData.cpp
-    platform/graphics/cairo/FontPlatformDataCairo.cpp
+    platform/graphics/cairo/FontPlatformDataFreeType.cpp
     platform/graphics/cairo/OwnPtrCairo.cpp
     platform/graphics/cairo/PlatformRefPtrCairo.cpp
     platform/graphics/cairo/GlyphPageTreeNodeCairo.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e6920e0..4e06beb 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,79 @@
+2010-09-14  Martin Robinson  <mrobinson at igalia.com>
+
+        Reviewed by Xan Lopez.
+
+        [GTK] Fully separate Pango and FreeType font backends
+        https://bugs.webkit.org/show_bug.cgi?id=27442
+
+        Split FontPlatformData.h into separate versions for Pango, FreeType and WinCairo.
+        Include the correct file via #ifdef'd includes, like the Chromium port. Also split
+        FontCacheCairo.cpp into Pango and FreeType versions, as they had almost no code in
+        common. Finally, rename FontPlatformDataCairo to FontPlatformDataFreeType, as this
+        compilation unit is used only by the FreeType backend. This change is important to
+        prevent upcoming fixes to the FreeType backend from affecting other backends.
+
+        No new tests as functionality has not changed.
+
+        * CMakeListsEfl.txt: Update source lists.
+        * GNUmakefile.am: Update source lists.
+        * platform/graphics/cairo/FontCacheCairo.cpp: Removed.
+        * platform/graphics/cairo/FontCacheFreeType.cpp: Added.
+        (WebCore::FontCache::platformInit):
+        (WebCore::FontCache::getFontDataForCharacters):
+        (WebCore::FontCache::getSimilarFontPlatformData):
+        (WebCore::FontCache::getLastResortFallbackFont):
+        (WebCore::FontCache::getTraitsInFamily):
+        (WebCore::isWellKnownFontName):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/graphics/cairo/FontPlatformData.h:
+        * platform/graphics/cairo/FontPlatformDataFreeType.cpp: Renamed from WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp.
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::operator=):
+        (WebCore::FontPlatformData::init):
+        (WebCore::FontPlatformData::~FontPlatformData):
+        (WebCore::FontPlatformData::isFixedPitch):
+        (WebCore::FontPlatformData::operator==):
+        (WebCore::FontPlatformData::description):
+        * platform/graphics/cairo/FontPlatformDataFreeType.h: Added.
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::size):
+        (WebCore::FontPlatformData::setSize):
+        (WebCore::FontPlatformData::syntheticBold):
+        (WebCore::FontPlatformData::syntheticOblique):
+        (WebCore::FontPlatformData::scaledFont):
+        (WebCore::FontPlatformData::hash):
+        (WebCore::FontPlatformData::isHashTableDeletedValue):
+        (WebCore::FontPlatformData::hashTableDeletedFontValue):
+        * platform/graphics/gtk/FontCachePango.cpp: Added.
+        (WebCore::FontCache::platformInit):
+        (WebCore::FontCache::getFontDataForCharacters):
+        (WebCore::FontCache::getSimilarFontPlatformData):
+        (WebCore::FontCache::getLastResortFallbackFont):
+        (WebCore::FontCache::getTraitsInFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/graphics/gtk/FontPlatformDataPango.h: Added.
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::size):
+        (WebCore::FontPlatformData::setSize):
+        (WebCore::FontPlatformData::syntheticBold):
+        (WebCore::FontPlatformData::syntheticOblique):
+        (WebCore::FontPlatformData::scaledFont):
+        (WebCore::FontPlatformData::hash):
+        (WebCore::FontPlatformData::isHashTableDeletedValue):
+        (WebCore::FontPlatformData::hashTableDeletedFontValue):
+        * platform/graphics/win/FontPlatformDataCairoWin.h: Added.
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::hfont):
+        (WebCore::FontPlatformData::useGDI):
+        (WebCore::FontPlatformData::fontFace):
+        (WebCore::FontPlatformData::size):
+        (WebCore::FontPlatformData::setSize):
+        (WebCore::FontPlatformData::syntheticBold):
+        (WebCore::FontPlatformData::syntheticOblique):
+        (WebCore::FontPlatformData::scaledFont):
+        (WebCore::FontPlatformData::hash):
+        (WebCore::FontPlatformData::isHashTableDeletedValue):
+
 2010-09-15  Chris Fleizach  <cfleizach at apple.com>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index a372277..6230126 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -3344,7 +3344,6 @@ webcoregtk_sources += \
 	WebCore/page/gtk/EventHandlerGtk.cpp \
 	WebCore/page/gtk/FrameGtk.cpp \
 	WebCore/platform/graphics/cairo/CairoPath.h \
-	WebCore/platform/graphics/cairo/FontCacheCairo.cpp \
 	WebCore/platform/graphics/cairo/FontCairo.cpp \
 	WebCore/platform/graphics/cairo/FontCustomPlatformData.h \
 	WebCore/platform/graphics/cairo/FontPlatformData.h \
@@ -3532,13 +3531,14 @@ webcore_cppflags += -DENABLE_FAST_MOBILE_SCROLLING=1
 endif # END ENABLE_FAST_MOBILE_SCROLLING
 
 # ---
-# Freetype font backend
+# FreeType font backend
 # ---
 if USE_FREETYPE
 webcoregtk_cppflags += -DUSE_FREETYPE=1
 webcoregtk_sources += \
+	WebCore/platform/graphics/cairo/FontCacheFreeType.cpp \
 	WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp \
-	WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp \
+	WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp \
 	WebCore/platform/graphics/cairo/GlyphPageTreeNodeCairo.cpp \
 	WebCore/platform/graphics/cairo/SimpleFontDataCairo.cpp
 endif # END USE_FREETYPE
@@ -3549,6 +3549,7 @@ endif # END USE_FREETYPE
 if USE_PANGO
 webcoregtk_cppflags += -DUSE_PANGO=1
 webcoregtk_sources += \
+	WebCore/platform/graphics/gtk/FontCachePango.cpp \
 	WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp \
 	WebCore/platform/graphics/gtk/FontPlatformDataPango.cpp \
 	WebCore/platform/graphics/gtk/GlyphPageTreeNodePango.cpp \
diff --git a/WebCore/platform/graphics/cairo/FontCacheCairo.cpp b/WebCore/platform/graphics/cairo/FontCacheCairo.cpp
deleted file mode 100644
index 5d3263e..0000000
--- a/WebCore/platform/graphics/cairo/FontCacheCairo.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp at atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "CString.h"
-#include "Font.h"
-#include "OwnPtrCairo.h"
-#include "SimpleFontData.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-    if (!FontPlatformData::init())
-        ASSERT_NOT_REACHED();
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
-#if defined(USE_FREETYPE)
-    FcResult fresult;
-    FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->platformData());
-
-    // FIXME: This should not happen, apparently. We are null-checking
-    // for now just to avoid crashing.
-    if (!prim || !prim->m_pattern)
-        return 0;
-
-    if (!prim->m_fallbacks)
-        prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult);
-
-    FcFontSet* fs = prim->m_fallbacks;
-
-    for (int i = 0; i < fs->nfont; i++) {
-        FcPattern* fin = FcFontRenderPrepare(NULL, prim->m_pattern, fs->fonts[i]);
-        cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_pattern(fin);
-        FontPlatformData alternateFont(fontFace, font.fontDescription().computedPixelSize(), false, false);
-        cairo_font_face_destroy(fontFace);
-        alternateFont.m_pattern = fin;
-        SimpleFontData* sfd = getCachedFontData(&alternateFont);
-        if (sfd->containsCharacters(characters, length))
-            return sfd;
-    }
-#endif
-
-    return 0;
-}
-
-SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
-    return 0;
-}
-
-SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
-{
-    // FIXME: Would be even better to somehow get the user's default font here.
-    // For now we'll pick the default that the user would get without changing any prefs.
-    static AtomicString timesStr("Times New Roman");
-    return getCachedFontData(fontDescription, timesStr);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
-}
-
-static bool isWellKnownFontName(const AtomicString family)
-{
-    // Fonts that are used by layout tests included. The fact that
-    // they are used in Layout Tests indicate web compatibility issues
-    // if we do not handle them correctly.
-    if (equalIgnoringCase(family, "sans-serif") || equalIgnoringCase(family, "sans")
-        || equalIgnoringCase(family, "serif") || equalIgnoringCase(family, "mono")
-        || equalIgnoringCase(family, "monospace") || equalIgnoringCase(family, "cursive")
-        || equalIgnoringCase(family, "fantasy") || equalIgnoringCase(family, "Times")
-        || equalIgnoringCase(family, "Courier") || equalIgnoringCase(family, "Helvetica")
-        || equalIgnoringCase(family, "Arial") || equalIgnoringCase(family, "Lucida Grande")
-        || equalIgnoringCase(family, "Ahem") || equalIgnoringCase(family, "Georgia")
-        || equalIgnoringCase(family, "Times New Roman"))
-        return true;
-
-    return false;
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
-#if defined(USE_FREETYPE)
-    // Handle generic family types specially, because fontconfig does not know them, but we have
-    // code to fallback correctly in our platform data implementation.
-    if (!family.length() || family.startsWith("-webkit-")
-        || (fontDescription.genericFamily() != FontDescription::NoFamily)
-        || isWellKnownFontName(family))
-        return new FontPlatformData(fontDescription, family);
-
-    // First check the font exists.
-    CString familyNameString = family.string().utf8();
-    const char* fcfamily = familyNameString.data();
-
-    OwnPtr<FcPattern> pattern(FcPatternCreate());
-    if (!FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
-        return 0;
-
-    OwnPtr<FcObjectSet> objectSet(FcObjectSetCreate());
-    if (!FcObjectSetAdd(objectSet.get(), FC_FAMILY))
-        return 0;
-
-    OwnPtr<FcFontSet> fontSet(FcFontList(0, pattern.get(), objectSet.get()));
-
-    if (!fontSet)
-        return 0;
-
-    if (!fontSet->fonts)
-        return 0;
-#endif
-
-    return new FontPlatformData(fontDescription, family);
-}
-
-}
diff --git a/WebCore/platform/graphics/cairo/FontCacheFreeType.cpp b/WebCore/platform/graphics/cairo/FontCacheFreeType.cpp
new file mode 100644
index 0000000..f507ad3
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/FontCacheFreeType.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2008 Alp Toker <alp at atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "FontCache.h"
+
+#include "CString.h"
+#include "Font.h"
+#include "OwnPtrCairo.h"
+#include "SimpleFontData.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+void FontCache::platformInit()
+{
+    if (!FontPlatformData::init())
+        ASSERT_NOT_REACHED();
+}
+
+const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+{
+    FcResult fresult;
+    FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->platformData());
+
+    // FIXME: This should not happen, apparently. We are null-checking
+    // for now just to avoid crashing.
+    if (!prim || !prim->m_pattern)
+        return 0;
+
+    if (!prim->m_fallbacks)
+        prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult);
+
+    FcFontSet* fs = prim->m_fallbacks;
+
+    for (int i = 0; i < fs->nfont; i++) {
+        FcPattern* fin = FcFontRenderPrepare(NULL, prim->m_pattern, fs->fonts[i]);
+        cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_pattern(fin);
+        FontPlatformData alternateFont(fontFace, font.fontDescription().computedPixelSize(), false, false);
+        cairo_font_face_destroy(fontFace);
+        alternateFont.m_pattern = fin;
+        SimpleFontData* sfd = getCachedFontData(&alternateFont);
+        if (sfd->containsCharacters(characters, length))
+            return sfd;
+    }
+
+    return 0;
+}
+
+SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
+{
+    return 0;
+}
+
+SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
+{
+    // FIXME: Would be even better to somehow get the user's default font here.
+    // For now we'll pick the default that the user would get without changing any prefs.
+    static AtomicString timesStr("Times New Roman");
+    return getCachedFontData(fontDescription, timesStr);
+}
+
+void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
+{
+}
+
+static bool isWellKnownFontName(const AtomicString family)
+{
+    // Fonts that are used by layout tests included. The fact that
+    // they are used in Layout Tests indicate web compatibility issues
+    // if we do not handle them correctly.
+    if (equalIgnoringCase(family, "sans-serif") || equalIgnoringCase(family, "sans")
+        || equalIgnoringCase(family, "serif") || equalIgnoringCase(family, "mono")
+        || equalIgnoringCase(family, "monospace") || equalIgnoringCase(family, "cursive")
+        || equalIgnoringCase(family, "fantasy") || equalIgnoringCase(family, "Times")
+        || equalIgnoringCase(family, "Courier") || equalIgnoringCase(family, "Helvetica")
+        || equalIgnoringCase(family, "Arial") || equalIgnoringCase(family, "Lucida Grande")
+        || equalIgnoringCase(family, "Ahem") || equalIgnoringCase(family, "Georgia")
+        || equalIgnoringCase(family, "Times New Roman"))
+        return true;
+
+    return false;
+}
+
+FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+{
+    // Handle generic family types specially, because fontconfig does not know them, but we have
+    // code to fallback correctly in our platform data implementation.
+    if (!family.length() || family.startsWith("-webkit-")
+        || (fontDescription.genericFamily() != FontDescription::NoFamily)
+        || isWellKnownFontName(family))
+        return new FontPlatformData(fontDescription, family);
+
+    // First check the font exists.
+    CString familyNameString = family.string().utf8();
+    const char* fcfamily = familyNameString.data();
+
+    OwnPtr<FcPattern> pattern(FcPatternCreate());
+    if (!FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
+        return 0;
+
+    OwnPtr<FcObjectSet> objectSet(FcObjectSetCreate());
+    if (!FcObjectSetAdd(objectSet.get(), FC_FAMILY))
+        return 0;
+
+    OwnPtr<FcFontSet> fontSet(FcFontList(0, pattern.get(), objectSet.get()));
+
+    if (!fontSet)
+        return 0;
+
+    if (!fontSet->fonts)
+        return 0;
+
+    return new FontPlatformData(fontDescription, family);
+}
+
+}
diff --git a/WebCore/platform/graphics/cairo/FontPlatformData.h b/WebCore/platform/graphics/cairo/FontPlatformData.h
index fc6b9f1..e5ffef2 100644
--- a/WebCore/platform/graphics/cairo/FontPlatformData.h
+++ b/WebCore/platform/graphics/cairo/FontPlatformData.h
@@ -1,11 +1,5 @@
 /*
- * This file is part of the internal font implementation.  It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel at gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * Copyright (C) 2010 Igalia S.L.
  * All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
@@ -28,160 +22,12 @@
 #ifndef FontPlatformData_h
 #define FontPlatformData_h
 
-#include <wtf/Forward.h>
-#include <cairo.h>
-#include "FontDescription.h"
-#include "GlyphBuffer.h"
-
-#if defined(USE_FREETYPE)
-#include <cairo-ft.h>
-#include <fontconfig/fcfreetype.h>
-#elif defined(USE_PANGO)
-#include <pango/pangocairo.h>
-#elif PLATFORM(WIN)
-#include <cairo-win32.h>
-#include "RefCountedGDIHandle.h"
-#include "StringImpl.h"
-#else
-#error "Must defined a font backend"
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HFONT__* HFONT;
-#endif
-namespace WebCore {
-
-class FontPlatformData {
-public:
-    FontPlatformData(WTF::HashTableDeletedValueType)
 #if defined(USE_FREETYPE)
-        : m_pattern(hashTableDeletedFontValue())
-        , m_fallbacks(0)
+#include "FontPlatformDataFreeType.h"
 #elif defined(USE_PANGO)
-        : m_context(0)
-        , m_font(hashTableDeletedFontValue())
+#include "FontPlatformDataPango.h"
 #elif PLATFORM(WIN)
-        : m_fontFace(0)
-        , m_useGDI(false)
-        , m_font(WTF::HashTableDeletedValue)
-#else
-#error "Must defined a font backend"
+#include "FontPlatformDataCairoWin.h"
 #endif
-        , m_size(0)
-        , m_syntheticBold(false)
-        , m_syntheticOblique(false)
-        , m_scaledFont(0)
-        { }
 
-    FontPlatformData()
-#if defined(USE_FREETYPE)
-        : m_pattern(0)
-        , m_fallbacks(0)
-#elif defined(USE_PANGO)
-        : m_context(0)
-        , m_font(0)
-#elif PLATFORM(WIN)
-        : m_fontFace(0)
-        , m_useGDI(false)
-#else
-#error "Must defined a font backend"
-#endif
-        , m_size(0)
-        , m_syntheticBold(false)
-        , m_syntheticOblique(false)
-        , m_scaledFont(0)
-        { }
-
-#if PLATFORM(WIN)
-    FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI);
-#else
-    FontPlatformData(const FontDescription&, const AtomicString& family);
-#endif
-
-    FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic);
-    FontPlatformData(float size, bool bold, bool italic);
-    FontPlatformData(const FontPlatformData&);
-
-    ~FontPlatformData();
-
-#if !PLATFORM(WIN)
-    static bool init();
-#else
-    HFONT hfont() const { return m_font->handle(); }
-    bool useGDI() const { return m_useGDI; }
-    cairo_font_face_t* fontFace() const { return m_fontFace; }
-#endif
-
-    bool isFixedPitch();
-    float size() const { return m_size; }
-    void setSize(float size) { m_size = size; }
-    bool syntheticBold() const { return m_syntheticBold; }
-    bool syntheticOblique() const { return m_syntheticOblique; }
-
-    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
-
-    unsigned hash() const
-    {
-#if PLATFORM(WIN)
-        return m_font->hash();
-#else
-#if defined(USE_FREETYPE)
-        if (m_pattern)
-            return FcPatternHash(m_pattern);
-#endif
-        uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) };
-        return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
-#endif
-    }
-
-    bool operator==(const FontPlatformData&) const;
-    FontPlatformData& operator=(const FontPlatformData&);
-    bool isHashTableDeletedValue() const
-    {
-#if defined(USE_FREETYPE)
-        return m_pattern == hashTableDeletedFontValue();
-#elif defined(USE_PANGO)
-        return m_font == hashTableDeletedFontValue();
-#elif PLATFORM(WIN)
-        return m_font.isHashTableDeletedValue();
-#endif
-    }
-
-#ifndef NDEBUG
-    String description() const;
-#endif
-
-#if defined(USE_FREETYPE)
-    FcPattern* m_pattern;
-    FcFontSet* m_fallbacks;
-#elif defined(USE_PANGO)
-    static PangoFontMap* m_fontMap;
-    static GHashTable* m_hashTable;
-
-    PangoContext* m_context;
-    PangoFont* m_font;
-#elif PLATFORM(WIN)
-private:
-    void platformDataInit(HFONT, float size, HDC, WCHAR* faceName);
-
-    RefPtr<RefCountedGDIHandle<HFONT> > m_font;
-    cairo_font_face_t* m_fontFace;
-    bool m_useGDI;
-#else
-#error "Must defined a font backend"
-#endif
-    float m_size;
-    bool m_syntheticBold;
-    bool m_syntheticOblique;
-    cairo_scaled_font_t* m_scaledFont;
-private:
-#if defined(USE_FREETYPE)
-    static FcPattern *hashTableDeletedFontValue() { return reinterpret_cast<FcPattern*>(-1); }
-#elif defined(USE_PANGO)
-    static PangoFont *hashTableDeletedFontValue() { return reinterpret_cast<PangoFont*>(-1); }
-#endif
-};
-
-}
-
-#endif
+#endif // FontPlatformData_h
diff --git a/WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp b/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp
similarity index 100%
rename from WebCore/platform/graphics/cairo/FontPlatformDataCairo.cpp
rename to WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp
diff --git a/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.h b/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.h
new file mode 100644
index 0000000..20cf9cd
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc.
+ * Copyright (C) 2006 Michael Emmel mike.emmel at gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef FontPlatformDataFreeType_h
+#define FontPlatformDataFreeType_h
+
+#include "FontDescription.h"
+#include "GlyphBuffer.h"
+#include <cairo-ft.h>
+#include <cairo.h>
+#include <fontconfig/fcfreetype.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class FontPlatformData {
+public:
+    FontPlatformData(WTF::HashTableDeletedValueType)
+        : m_pattern(hashTableDeletedFontValue())
+        , m_fallbacks(0)
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData()
+        : m_pattern(0)
+        , m_fallbacks(0)
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData(const FontDescription&, const AtomicString& family);
+    FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic);
+    FontPlatformData(float size, bool bold, bool italic);
+    FontPlatformData(const FontPlatformData&);
+
+    ~FontPlatformData();
+
+    static bool init();
+    bool isFixedPitch();
+    float size() const { return m_size; }
+    void setSize(float size) { m_size = size; }
+    bool syntheticBold() const { return m_syntheticBold; }
+    bool syntheticOblique() const { return m_syntheticOblique; }
+
+    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
+
+    unsigned hash() const
+    {
+        if (m_pattern)
+            return FcPatternHash(m_pattern);
+    }
+
+    bool operator==(const FontPlatformData&) const;
+    FontPlatformData& operator=(const FontPlatformData&);
+    bool isHashTableDeletedValue() const
+    {
+        return m_pattern == hashTableDeletedFontValue();
+    }
+
+#ifndef NDEBUG
+    String description() const;
+#endif
+
+    FcPattern* m_pattern;
+    FcFontSet* m_fallbacks;
+    float m_size;
+    bool m_syntheticBold;
+    bool m_syntheticOblique;
+    cairo_scaled_font_t* m_scaledFont;
+
+private:
+    static FcPattern *hashTableDeletedFontValue() { return reinterpret_cast<FcPattern*>(-1); }
+};
+
+}
+
+#endif // FontPlatformDataFreeType_h
diff --git a/WebCore/platform/graphics/gtk/FontCachePango.cpp b/WebCore/platform/graphics/gtk/FontCachePango.cpp
new file mode 100644
index 0000000..fad29e0
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/FontCachePango.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Alp Toker <alp at atoker.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "FontCache.h"
+
+#include "CString.h"
+#include "Font.h"
+#include "OwnPtrCairo.h"
+#include "SimpleFontData.h"
+#include <wtf/Assertions.h>
+
+namespace WebCore {
+
+void FontCache::platformInit()
+{
+    if (!FontPlatformData::init())
+        ASSERT_NOT_REACHED();
+}
+
+const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+{
+    return 0;
+}
+
+SimpleFontData* FontCache::getSimilarFontPlatformData(const Font& font)
+{
+    return 0;
+}
+
+SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
+{
+    // FIXME: Would be even better to somehow get the user's default font here.
+    // For now we'll pick the default that the user would get without changing any prefs.
+    static AtomicString timesStr("Times New Roman");
+    return getCachedFontData(fontDescription, timesStr);
+}
+
+void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
+{
+}
+
+FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+{
+    return new FontPlatformData(fontDescription, family);
+}
+
+}
diff --git a/WebCore/platform/graphics/gtk/FontPlatformDataPango.h b/WebCore/platform/graphics/gtk/FontPlatformDataPango.h
new file mode 100644
index 0000000..7b1e51f
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/FontPlatformDataPango.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc.
+ * Copyright (C) 2006 Michael Emmel mike.emmel at gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef FontPlatformDataPango_h
+#define FontPlatformDataPango_h
+
+#include "FontDescription.h"
+#include "GlyphBuffer.h"
+#include <cairo.h>
+#include <pango/pangocairo.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class FontPlatformData {
+public:
+    FontPlatformData(WTF::HashTableDeletedValueType)
+        : m_context(0)
+        , m_font(hashTableDeletedFontValue())
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData()
+        : m_context(0)
+        , m_font(0)
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData(const FontDescription&, const AtomicString& family);
+    FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic);
+    FontPlatformData(float size, bool bold, bool italic);
+    FontPlatformData(const FontPlatformData&);
+    ~FontPlatformData();
+
+    static bool init();
+    bool isFixedPitch();
+    float size() const { return m_size; }
+    void setSize(float size) { m_size = size; }
+    bool syntheticBold() const { return m_syntheticBold; }
+    bool syntheticOblique() const { return m_syntheticOblique; }
+
+    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
+
+    unsigned hash() const
+    {
+        uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) };
+        return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
+    }
+
+    bool operator==(const FontPlatformData&) const;
+    FontPlatformData& operator=(const FontPlatformData&);
+    bool isHashTableDeletedValue() const
+    {
+        return m_font == hashTableDeletedFontValue();
+    }
+
+#ifndef NDEBUG
+    String description() const;
+#endif
+
+    static PangoFontMap* m_fontMap;
+    static GHashTable* m_hashTable;
+    PangoContext* m_context;
+    PangoFont* m_font;
+    float m_size;
+    bool m_syntheticBold;
+    bool m_syntheticOblique;
+    cairo_scaled_font_t* m_scaledFont;
+private:
+    static PangoFont *hashTableDeletedFontValue() { return reinterpret_cast<PangoFont*>(-1); }
+};
+
+}
+
+#endif // FontPlatformDataPango_h
diff --git a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h
new file mode 100644
index 0000000..05f9eab
--- /dev/null
+++ b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 Apple Inc.
+ * Copyright (C) 2006 Michael Emmel mike.emmel at gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2007 Pioneer Research Center USA, Inc.
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef FontPlatformDataCairoWin_h
+#define FontPlatformDataCairoWin_h
+
+#include "FontDescription.h"
+#include "GlyphBuffer.h"
+#include "RefCountedGDIHandle.h"
+#include "StringImpl.h"
+#include <cairo-win32.h>
+#include <cairo.h>
+#include <wtf/Forward.h>
+
+typedef struct HFONT__* HFONT;
+
+namespace WebCore {
+
+class FontPlatformData {
+public:
+    FontPlatformData(WTF::HashTableDeletedValueType)
+        : m_fontFace(0)
+        , m_useGDI(false)
+        , m_font(WTF::HashTableDeletedValue)
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData()
+        : m_fontFace(0)
+        , m_useGDI(false)
+        , m_size(0)
+        , m_syntheticBold(false)
+        , m_syntheticOblique(false)
+        , m_scaledFont(0)
+        { }
+
+    FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI);
+    FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic);
+    FontPlatformData(float size, bool bold, bool italic);
+    FontPlatformData(const FontPlatformData&);
+    ~FontPlatformData();
+
+    HFONT hfont() const { return m_font->handle(); }
+    bool useGDI() const { return m_useGDI; }
+    cairo_font_face_t* fontFace() const { return m_fontFace; }
+
+    bool isFixedPitch();
+    float size() const { return m_size; }
+    void setSize(float size) { m_size = size; }
+    bool syntheticBold() const { return m_syntheticBold; }
+    bool syntheticOblique() const { return m_syntheticOblique; }
+    cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
+
+    unsigned hash() const
+    {
+        return m_font->hash();
+    }
+
+    bool operator==(const FontPlatformData&) const;
+    FontPlatformData& operator=(const FontPlatformData&);
+    bool isHashTableDeletedValue() const
+    {
+        return m_font.isHashTableDeletedValue();
+    }
+
+#ifndef NDEBUG
+    String description() const;
+#endif
+
+private:
+    void platformDataInit(HFONT, float size, HDC, WCHAR* faceName);
+
+    RefPtr<RefCountedGDIHandle<HFONT> > m_font;
+    cairo_font_face_t* m_fontFace;
+    bool m_useGDI;
+    float m_size;
+    bool m_syntheticBold;
+    bool m_syntheticOblique;
+    cairo_scaled_font_t* m_scaledFont;
+};
+
+}
+
+#endif // FontPlatformDataCairoWin_h

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list