Bug 1005888 - Remove unused #ifdef for gfx/thebes/gfxFT2FontList.cpp. r=jfkthame
☠☠ backed out by 616163ca1aa5 ☠ ☠
authorVivien Nicolas <vnicolas@mozilla.com>
Wed, 04 Jun 2014 20:11:05 +0200
changeset 205883 e7124b07804b86f825ae2e991832b32cf69ae11c
parent 205882 5c901d7e88bc651bdcbc9d1427a2ba5342166d7a
child 205884 59df0cdacc15bfec459c8e8e0c989bc164caed5c
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1005888
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1005888 - Remove unused #ifdef for gfx/thebes/gfxFT2FontList.cpp. r=jfkthame
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFT2FontList.h
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -1,41 +1,27 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MemoryReporting.h"
 
-#if (MOZ_WIDGET_GTK == 2)
-#include "gfxPlatformGtk.h"
-#define gfxToolkitPlatform gfxPlatformGtk
-#elif defined(MOZ_WIDGET_QT)
-#include <qfontinfo.h>
-#include "gfxQtPlatform.h"
-#define gfxToolkitPlatform gfxQtPlatform
-#elif defined(XP_WIN)
-#include "gfxWindowsPlatform.h"
-#define gfxToolkitPlatform gfxWindowsPlatform
-#elif defined(ANDROID)
 #include "mozilla/dom/ContentChild.h"
 #include "gfxAndroidPlatform.h"
 #include "mozilla/Omnijar.h"
 #include "nsIInputStream.h"
 #include "nsNetUtil.h"
 #define gfxToolkitPlatform gfxAndroidPlatform
-#endif
 
-#ifdef ANDROID
 #include "nsXULAppAPI.h"
 #include <dirent.h>
 #include <android/log.h>
 #define ALOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
-#endif
 
 #include "ft2build.h"
 #include FT_FREETYPE_H
 #include FT_TRUETYPE_TAGS_H
 #include FT_TRUETYPE_TABLES_H
 #include "cairo-ft.h"
 
 #include "gfxFT2FontList.h"
@@ -53,21 +39,16 @@
 #include "nsISimpleEnumerator.h"
 #include "nsIMemory.h"
 #include "gfxFontConstants.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/scache/StartupCache.h"
 #include <sys/stat.h>
 
-#ifdef XP_WIN
-#include "nsIWindowsRegKey.h"
-#include <windows.h>
-#endif
-
 using namespace mozilla;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo *
 GetFontInfoLog()
 {
     static PRLogModuleInfo *sLog;
     if (!sLog)
@@ -80,20 +61,16 @@ GetFontInfoLog()
 #define LOG(args) PR_LOG(GetFontInfoLog(), PR_LOG_DEBUG, args)
 #define LOG_ENABLED() PR_LOG_TEST(GetFontInfoLog(), PR_LOG_DEBUG)
 
 static cairo_user_data_key_t sFTUserFontDataKey;
 
 static __inline void
 BuildKeyNameFromFontName(nsAString &aName)
 {
-#ifdef XP_WIN
-    if (aName.Length() >= LF_FACESIZE)
-        aName.Truncate(LF_FACESIZE - 1);
-#endif
     ToLowerCase(aName);
 }
 
 // Helper to access the FT_Face for a given FT2FontEntry,
 // creating a temporary face if the entry does not have one yet.
 // This allows us to read font names, tables, etc if necessary
 // without permanently instantiating a freetype face and consuming
 // memory long-term.
@@ -958,21 +935,17 @@ gfxFT2FontList::AppendFacesFromFontFile(
     if (!faceList.IsEmpty() && 0 == statRetval &&
         s.st_mtime == timestamp && s.st_size == filesize)
     {
         LOG(("using cached font info for %s", aFileName.get()));
         AppendFacesFromCachedFaceList(aFileName, aStdFile, faceList);
         return;
     }
 
-#ifdef XP_WIN
-    FT_Library ftLibrary = gfxWindowsPlatform::GetPlatform()->GetFTLibrary();
-#elif defined(ANDROID)
     FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary();
-#endif
     FT_Face dummy;
     if (FT_Err_Ok == FT_New_Face(ftLibrary, aFileName.get(), -1, &dummy)) {
         LOG(("reading font info via FreeType for %s", aFileName.get()));
         nsCString faceList;
         timestamp = s.st_mtime;
         filesize = s.st_size;
         for (FT_Long i = 0; i < dummy->num_faces; i++) {
             FT_Face face;
@@ -1165,60 +1138,16 @@ FinalizeFamilyMemberList(nsStringHashKey
     family->CheckForSimpleFamily();
 
     return PL_DHASH_NEXT;
 }
 
 void
 gfxFT2FontList::FindFonts()
 {
-#ifdef XP_WIN
-    nsTArray<nsString> searchPaths(3);
-    nsTArray<nsString> fontPatterns(3);
-    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.ttf"));
-    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.ttc"));
-    fontPatterns.AppendElement(NS_LITERAL_STRING("\\*.otf"));
-    wchar_t pathBuf[256];
-    SHGetSpecialFolderPathW(0, pathBuf, CSIDL_WINDOWS, 0);
-    searchPaths.AppendElement(pathBuf);
-    SHGetSpecialFolderPathW(0, pathBuf, CSIDL_FONTS, 0);
-    searchPaths.AppendElement(pathBuf);
-    nsCOMPtr<nsIFile> resDir;
-    NS_GetSpecialDirectory(NS_APP_RES_DIR, getter_AddRefs(resDir));
-    if (resDir) {
-        resDir->Append(NS_LITERAL_STRING("fonts"));
-        nsAutoString resPath;
-        resDir->GetPath(resPath);
-        searchPaths.AppendElement(resPath);
-    }
-    WIN32_FIND_DATAW results;
-    for (uint32_t i = 0;  i < searchPaths.Length(); i++) {
-        const nsString& path(searchPaths[i]);
-        for (uint32_t j = 0; j < fontPatterns.Length(); j++) { 
-            nsAutoString pattern(path);
-            pattern.Append(fontPatterns[j]);
-            HANDLE handle = FindFirstFileExW(pattern.get(),
-                                             FindExInfoStandard,
-                                             &results,
-                                             FindExSearchNameMatch,
-                                             nullptr,
-                                             0);
-            bool moreFiles = handle != INVALID_HANDLE_VALUE;
-            while (moreFiles) {
-                nsAutoString filePath(path);
-                filePath.Append('\\');
-                filePath.Append(results.cFileName);
-                AppendFacesFromFontFile(NS_ConvertUTF16toUTF8(filePath));
-                moreFiles = FindNextFile(handle, &results);
-            }
-            if (handle != INVALID_HANDLE_VALUE)
-                FindClose(handle);
-        }
-    }
-#elif defined(ANDROID)
     gfxFontCache *fc = gfxFontCache::GetCache();
     if (fc)
         fc->AgeAllGenerations();
     mPrefFonts.Clear();
     mCodepointsWithNoFonts.reset();
 
     mCodepointsWithNoFonts.SetRange(0,0x1f);     // C0 controls
     mCodepointsWithNoFonts.SetRange(0x7f,0x9f);  // C1 controls
@@ -1254,17 +1183,16 @@ gfxFT2FontList::FindFonts()
     root.AppendLiteral("/fonts");
 
     FindFontsInDir(root, &fnc);
 
     if (mFontFamilies.Count() == 0) {
         // if we can't find/read the font directory, we are doomed!
         NS_RUNTIMEABORT("Could not read the system fonts directory");
     }
-#endif // XP_WIN && ANDROID
 
     // Look for fonts stored in omnijar, unless we're on a low-memory
     // device where we don't want to spend the RAM to decompress them.
     // (Prefs may disable this, or force-enable it even with low memory.)
     bool lowmem;
     nsCOMPtr<nsIMemory> mem = nsMemory::GetGlobalMemoryService();
     if ((NS_SUCCEEDED(mem->IsLowMemoryPlatform(&lowmem)) && !lowmem &&
          Preferences::GetBool("gfx.bundled_fonts.enabled")) ||
@@ -1286,17 +1214,16 @@ gfxFT2FontList::FindFonts()
     }
 
     // Finalize the families by sorting faces into standard order
     // and marking "simple" families.
     // Passing non-null userData here says that we want faces to be sorted.
     mFontFamilies.Enumerate(FinalizeFamilyMemberList, this);
 }
 
-#ifdef ANDROID
 void
 gfxFT2FontList::FindFontsInDir(const nsCString& aDir, FontNameCache *aFNC)
 {
     static const char* sStandardFonts[] = {
         "DroidSans.ttf",
         "DroidSans-Bold.ttf",
         "DroidSerif-Regular.ttf",
         "DroidSerif-Bold.ttf",
@@ -1343,17 +1270,16 @@ gfxFT2FontList::FindFontsInDir(const nsC
             // and the file is unchanged, we won't actually need to read it.
             // If the file is new/changed, this will update the FontNameCache.
             AppendFacesFromFontFile(s, isStdFont, aFNC);
         }
     }
 
     closedir(d);
 }
-#endif
 
 void
 gfxFT2FontList::AppendFaceFromFontListEntry(const FontListEntry& aFLE,
                                             bool aStdFile)
 {
     FT2FontEntry* fe = FT2FontEntry::CreateFontEntry(aFLE);
     if (fe) {
         fe->mStandardFace = aStdFile;
@@ -1501,26 +1427,17 @@ gfxFT2FontList::LookupLocalFont(const gf
     }
 
     return fe;
 }
 
 gfxFontFamily*
 gfxFT2FontList::GetDefaultFont(const gfxFontStyle* aStyle)
 {
-#ifdef XP_WIN
-    HGDIOBJ hGDI = ::GetStockObject(SYSTEM_FONT);
-    LOGFONTW logFont;
-    if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) {
-        nsAutoString resolvedName;
-        if (ResolveFontName(nsDependentString(logFont.lfFaceName), resolvedName)) {
-            return FindFamily(resolvedName);
-        }
-    }
-#elif defined(MOZ_WIDGET_GONK)
+#ifdef MOZ_WIDGET_GONK
     nsAutoString resolvedName;
     if (ResolveFontName(NS_LITERAL_STRING("Fira Sans OT"), resolvedName)) {
         return FindFamily(resolvedName);
     }
 #elif defined(MOZ_WIDGET_ANDROID)
     nsAutoString resolvedName;
     if (ResolveFontName(NS_LITERAL_STRING("Roboto"), resolvedName) ||
         ResolveFontName(NS_LITERAL_STRING("Droid Sans"), resolvedName)) {
--- a/gfx/thebes/gfxFT2FontList.h
+++ b/gfx/thebes/gfxFT2FontList.h
@@ -2,21 +2,16 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_FT2FONTLIST_H
 #define GFX_FT2FONTLIST_H
 
 #include "mozilla/MemoryReporting.h"
-
-#ifdef XP_WIN
-#include "gfxWindowsPlatform.h"
-#include <windows.h>
-#endif
 #include "gfxPlatformFontList.h"
 
 namespace mozilla {
     namespace dom {
         class FontListEntry;
     };
 };
 using mozilla::dom::FontListEntry;
@@ -148,16 +143,14 @@ protected:
 
     void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex,
                        bool aStdFile, FT_Face aFace, nsCString& aFaceList);
 
     void FindFonts();
 
     void FindFontsInOmnijar(FontNameCache *aCache);
 
-#ifdef ANDROID
     void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC);
-#endif
 
     nsTHashtable<nsStringHashKey> mSkipSpaceLookupCheckFamilies;
 };
 
 #endif /* GFX_FT2FONTLIST_H */