Title: [145903] trunk/Source/WebCore
Revision
145903
Author
commit-qu...@webkit.org
Date
2013-03-15 06:52:17 -0700 (Fri, 15 Mar 2013)

Log Message

[BlackBerry] Remove PlatformSupport
https://bugs.webkit.org/show_bug.cgi?id=112438

Patch by Alberto Garcia <agar...@igalia.com> on 2013-03-15
Reviewed by Rob Buis.

This class only contains getFontFamilyForCharacters(), which was
moved from PlatformSupport to FontCache in r129257.

This patch does the same for the BlackBerry port.

* platform/graphics/FontCache.h:
(FontCache):
* platform/graphics/blackberry/FontCacheBlackBerry.cpp:
(WebCore::FontCache::getFontFamilyForCharacters):
(WebCore):
(WebCore::FontCache::getFontDataForCharacters):
* platform/graphics/blackberry/PlatformSupport.cpp: Removed.
* platform/graphics/blackberry/PlatformSupport.h: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145902 => 145903)


--- trunk/Source/WebCore/ChangeLog	2013-03-15 13:50:32 UTC (rev 145902)
+++ trunk/Source/WebCore/ChangeLog	2013-03-15 13:52:17 UTC (rev 145903)
@@ -1,5 +1,26 @@
 2013-03-15  Alberto Garcia  <agar...@igalia.com>
 
+        [BlackBerry] Remove PlatformSupport
+        https://bugs.webkit.org/show_bug.cgi?id=112438
+
+        Reviewed by Rob Buis.
+
+        This class only contains getFontFamilyForCharacters(), which was
+        moved from PlatformSupport to FontCache in r129257.
+
+        This patch does the same for the BlackBerry port.
+
+        * platform/graphics/FontCache.h:
+        (FontCache):
+        * platform/graphics/blackberry/FontCacheBlackBerry.cpp:
+        (WebCore::FontCache::getFontFamilyForCharacters):
+        (WebCore):
+        (WebCore::FontCache::getFontDataForCharacters):
+        * platform/graphics/blackberry/PlatformSupport.cpp: Removed.
+        * platform/graphics/blackberry/PlatformSupport.h: Removed.
+
+2013-03-15  Alberto Garcia  <agar...@igalia.com>
+
         [BlackBerry] FontPlatformData: remove TextOrientation parameter
         https://bugs.webkit.org/show_bug.cgi?id=112135
 

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (145902 => 145903)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2013-03-15 13:50:32 UTC (rev 145902)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2013-03-15 13:52:17 UTC (rev 145903)
@@ -125,7 +125,11 @@
         bool isBold;
         bool isItalic;
     };
+#if PLATFORM(BLACKBERRY)
+    static void getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, const FontDescription&, SimpleFontFamily*);
+#else
     static void getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, SimpleFontFamily*);
+#endif
 
 private:
     FontCache();

Modified: trunk/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp (145902 => 145903)


--- trunk/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp	2013-03-15 13:50:32 UTC (rev 145902)
+++ trunk/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp	2013-03-15 13:52:17 UTC (rev 145903)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 Alp Toker <a...@atoker.com>
+ * Copyright (C) 2009-2010, Google Inc. All rights reserved.
  * Copyright (C) 2010 Igalia S.L.
  * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
  *
@@ -30,13 +31,13 @@
 #include "ITypeUtils.h"
 #include "Logging.h"
 #include "NotImplemented.h"
-#include "PlatformSupport.h"
 #include "SimpleFontData.h"
 
 #include <BlackBerryPlatformGraphicsContext.h>
 #include <fontconfig/fontconfig.h>
 #include <fs_api.h>
 #include <unicode/locid.h>
+#include <unistd.h>
 #include <wtf/Assertions.h>
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/CString.h>
@@ -50,11 +51,101 @@
         CRASH();
 }
 
+void FontCache::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, const FontDescription& description, SimpleFontFamily* family)
+{
+    FcCharSet* cset = FcCharSetCreate();
+    for (size_t i = 0; i < numCharacters; ++i) {
+        if (U16_IS_SURROGATE(characters[i])
+            && U16_IS_SURROGATE_LEAD(characters[i])
+            && i != numCharacters - 1
+            && U16_IS_TRAIL(characters[i + 1])) {
+            FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
+            i++;
+        } else
+            FcCharSetAddChar(cset, characters[i]);
+    }
+    FcPattern* pattern = FcPatternCreate();
+
+    FcValue fcvalue;
+    fcvalue.type = FcTypeCharSet;
+    fcvalue.u.c = cset;
+    FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeBool;
+    fcvalue.u.b = FcTrue;
+    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeInteger;
+    fcvalue.u.i = (description.weight() >= FontWeightBold) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+    FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
+
+    fcvalue.type = FcTypeInteger;
+    fcvalue.u.i = (description.italic() == FontItalicOn) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+    FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
+
+    FcConfigSubstitute(0, pattern, FcMatchPattern);
+    FcDefaultSubstitute(pattern);
+
+    FcResult result;
+    FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
+    FcPatternDestroy(pattern);
+    FcCharSetDestroy(cset);
+
+    if (!fontSet) {
+        family->name = String();
+        family->isBold = false;
+        family->isItalic = false;
+        return;
+    }
+
+    // Older versions of fontconfig have a bug where they cannot select
+    // only scalable fonts so we have to manually filter the results.
+    for (int i = 0; i < fontSet->nfont; ++i) {
+        FcPattern* current = fontSet->fonts[i];
+        FcBool isScalable;
+
+        if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+            || !isScalable)
+            continue;
+
+        // fontconfig can also return fonts which are unreadable
+        FcChar8* cFilename;
+        if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
+            continue;
+
+        if (access(reinterpret_cast<char*>(cFilename), R_OK))
+            continue;
+
+        FcChar8* familyName;
+        if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) {
+            const char* charFamily = reinterpret_cast<char*>(familyName);
+            family->name = String::fromUTF8(charFamily, strlen(charFamily));
+        }
+
+        int weight;
+        if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch)
+            family->isBold = weight >= FC_WEIGHT_BOLD;
+        else
+            family->isBold = false;
+
+        int slant;
+        if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch)
+            family->isItalic = slant != FC_SLANT_ROMAN;
+        else
+            family->isItalic = false;
+
+        FcFontSetDestroy(fontSet);
+        return;
+    }
+
+    FcFontSetDestroy(fontSet);
+}
+
 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
 {
     icu::Locale locale = icu::Locale::getDefault();
-    PlatformSupport::FontFamily family;
-    PlatformSupport::getFontFamilyForCharacters(characters, length, locale.getLanguage(), font.fontDescription(), &family);
+    FontCache::SimpleFontFamily family;
+    FontCache::getFontFamilyForCharacters(characters, length, locale.getLanguage(), font.fontDescription(), &family);
     if (family.name.isEmpty())
         return 0;
 

Deleted: trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.cpp (145902 => 145903)


--- trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.cpp	2013-03-15 13:50:32 UTC (rev 145902)
+++ trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.cpp	2013-03-15 13:52:17 UTC (rev 145903)
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2009-2010, Google Inc. All rights reserved.
- * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. 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 "PlatformSupport.h"
-
-#include "FontDescription.h"
-
-#include <fontconfig/fontconfig.h>
-#include <string.h>
-#include <unicode/utf16.h>
-#include <unistd.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-void PlatformSupport::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, const FontDescription& description, FontFamily* family)
-{
-    FcCharSet* cset = FcCharSetCreate();
-    for (size_t i = 0; i < numCharacters; ++i) {
-        if (U16_IS_SURROGATE(characters[i])
-            && U16_IS_SURROGATE_LEAD(characters[i])
-            && i != numCharacters - 1
-            && U16_IS_TRAIL(characters[i + 1])) {
-            FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
-            i++;
-        } else
-            FcCharSetAddChar(cset, characters[i]);
-    }
-    FcPattern* pattern = FcPatternCreate();
-
-    FcValue fcvalue;
-    fcvalue.type = FcTypeCharSet;
-    fcvalue.u.c = cset;
-    FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeBool;
-    fcvalue.u.b = FcTrue;
-    FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeInteger;
-    fcvalue.u.i = (description.weight() >= FontWeightBold) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
-    FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
-
-    fcvalue.type = FcTypeInteger;
-    fcvalue.u.i = (description.italic() == FontItalicOn) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
-    FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
-
-    FcConfigSubstitute(0, pattern, FcMatchPattern);
-    FcDefaultSubstitute(pattern);
-
-    FcResult result;
-    FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
-    FcPatternDestroy(pattern);
-    FcCharSetDestroy(cset);
-
-    if (!fontSet) {
-        family->name = String();
-        family->isBold = false;
-        family->isItalic = false;
-        return;
-    }
-
-    // Older versions of fontconfig have a bug where they cannot select
-    // only scalable fonts so we have to manually filter the results.
-    for (int i = 0; i < fontSet->nfont; ++i) {
-        FcPattern* current = fontSet->fonts[i];
-        FcBool isScalable;
-
-        if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
-            || !isScalable)
-            continue;
-
-        // fontconfig can also return fonts which are unreadable
-        FcChar8* cFilename;
-        if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
-            continue;
-
-        if (access(reinterpret_cast<char*>(cFilename), R_OK))
-            continue;
-
-        FcChar8* familyName;
-        if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) {
-            const char* charFamily = reinterpret_cast<char*>(familyName);
-            family->name = String::fromUTF8(charFamily, strlen(charFamily));
-        }
-
-        int weight;
-        if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch)
-            family->isBold = weight >= FC_WEIGHT_BOLD;
-        else
-            family->isBold = false;
-
-        int slant;
-        if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch)
-            family->isItalic = slant != FC_SLANT_ROMAN;
-        else
-            family->isItalic = false;
-
-        FcFontSetDestroy(fontSet);
-        return;
-    }
-
-    FcFontSetDestroy(fontSet);
-}
-
-}; // namespace WebCore

Deleted: trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.h (145902 => 145903)


--- trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.h	2013-03-15 13:50:32 UTC (rev 145902)
+++ trunk/Source/WebCore/platform/graphics/blackberry/PlatformSupport.h	2013-03-15 13:52:17 UTC (rev 145903)
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- * Copyright (c) 2011, Research In Motion. 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 PlatformSupport_h
-#define PlatformSupport_h
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-struct FontRenderStyle;
-class FontDescription;
-
-// This is a minimal version of the Chromium PlatformSupport/WebFontInfo classes used for font support.
-class PlatformSupport {
-public:
-    struct FontFamily {
-        String name;
-        bool isBold;
-        bool isItalic;
-    };
-    static void getFontFamilyForCharacters(const UChar*, size_t numCharacters, const char* preferredLocale, const FontDescription&, FontFamily*);
-};
-
-} // namespace WebCore
-
-#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to