[Cocoa] Remove Yosemite-specific font lookup code
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2017 06:11:02 +0000 (06:11 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2017 06:11:02 +0000 (06:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168682

Reviewed by Zalan Bujtas.

Source/WebCore:

No new tests because there is no behavior change.

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::platformFontLookupWithFamily):
(WebCore::fontWithFamily):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformInvalidateFontCache):
(WebCore::acceptableChoice): Deleted.
(WebCore::betterChoice): Deleted.
(WebCore::desiredFamilyToAvailableFamilyMap): Deleted.
(WebCore::hasDesiredFamilyToAvailableFamilyMapping): Deleted.
(WebCore::rememberDesiredFamilyToAvailableFamilyMapping): Deleted.
(WebCore::toAppKitFontWeight): Deleted.
(WebCore::appkitWeightToFontWeight): Deleted.
(WebCore::toNSFontTraits): Deleted.
(WebCore::platformFontWithFamily): Deleted.

Source/WTF:

* wtf/Platform.h:

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(fontWhitelist):
(adjustFonts):
(createWebViewAndOffscreenWindow):
(drt_NSFontManager_availableFontFamilies): Deleted.
(drt_NSFontManager_availableFonts): Deleted.
(swizzleNSFontManagerMethods): Deleted.
* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
(WTR::activateFonts):
(WTR::allowedFontFamilySet): Deleted.
(WTR::systemHiddenFontFamilySet): Deleted.
(WTR::wtr_NSFontManager_availableFontFamilies): Deleted.
(WTR::wtr_NSFontManager_availableFonts): Deleted.
(WTR::swizzleNSFontManagerMethods): Deleted.
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::generateWhitelist):
(WTR::TestController::platformInitializeContext):

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

Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/mac/FontCacheMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm

index 8f1cbe7..5933b28 100644 (file)
@@ -1,3 +1,12 @@
+2017-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Remove Yosemite-specific font lookup code
+        https://bugs.webkit.org/show_bug.cgi?id=168682
+
+        Reviewed by Zalan Bujtas.
+
+        * wtf/Platform.h:
+
 2017-02-22  Keith Miller  <keith_miller@apple.com>
 
         Remove the demand executable allocator
index 8727f1b..434999e 100644 (file)
 #define ENABLE_CSS3_TEXT_DECORATION_SKIP_INK 1
 #endif
 
-#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101000)
-#define ENABLE_PLATFORM_FONT_LOOKUP 1
-#endif
-
 #if COMPILER(MSVC)
 #undef __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
index b56e30d..289f4ea 100644 (file)
@@ -1,3 +1,27 @@
+2017-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Remove Yosemite-specific font lookup code
+        https://bugs.webkit.org/show_bug.cgi?id=168682
+
+        Reviewed by Zalan Bujtas.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::platformFontLookupWithFamily):
+        (WebCore::fontWithFamily):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::platformInvalidateFontCache):
+        (WebCore::acceptableChoice): Deleted.
+        (WebCore::betterChoice): Deleted.
+        (WebCore::desiredFamilyToAvailableFamilyMap): Deleted.
+        (WebCore::hasDesiredFamilyToAvailableFamilyMapping): Deleted.
+        (WebCore::rememberDesiredFamilyToAvailableFamilyMapping): Deleted.
+        (WebCore::toAppKitFontWeight): Deleted.
+        (WebCore::appkitWeightToFontWeight): Deleted.
+        (WebCore::toNSFontTraits): Deleted.
+        (WebCore::platformFontWithFamily): Deleted.
+
 2017-02-22  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Clicking on the video doesn't toggle playback state in fullscreen on macOS
index f51f0ab..4679d26 100644 (file)
@@ -791,7 +791,6 @@ void FontCache::setFontWhitelist(const Vector<String>& inputWhitelist)
         whitelist.add(item);
 }
 
-#if ENABLE(PLATFORM_FONT_LOOKUP)
 static bool isSystemFont(const AtomicString& family)
 {
     return family.length() >= 1 && family[0] == '.';
@@ -805,7 +804,6 @@ static RetainPtr<CTFontRef> platformFontLookupWithFamily(const AtomicString& fam
 
     return adoptCF(CTFontCreateForCSS(family.string().createCFString().get(), toCoreTextFontWeight(weight), requestedTraits, size));
 }
-#endif
 
 static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size)
 {
@@ -813,13 +811,8 @@ static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSym
         return nullptr;
 
     auto foundFont = platformFontWithFamilySpecialCase(family, weight, desiredTraits, size);
-    if (!foundFont) {
-#if ENABLE(PLATFORM_FONT_LOOKUP)
+    if (!foundFont)
         foundFont = platformFontLookupWithFamily(family, desiredTraits, weight, size);
-#else
-        foundFont = platformFontWithFamily(family, desiredTraits, weight, textRenderingMode, size);
-#endif
-    }
     return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, variationSettings);
 }
 
index 13cfb95..5327f63 100644 (file)
@@ -52,146 +52,6 @@ namespace WebCore {
 
 #if PLATFORM(MAC)
 
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-
-#define SYNTHESIZED_FONT_TRAITS (NSBoldFontMask | NSItalicFontMask)
-
-#define IMPORTANT_FONT_TRAITS (0 \
-    | NSCompressedFontMask \
-    | NSCondensedFontMask \
-    | NSExpandedFontMask \
-    | NSItalicFontMask \
-    | NSNarrowFontMask \
-    | NSPosterFontMask \
-    | NSSmallCapsFontMask \
-)
-
-static bool acceptableChoice(NSFontTraitMask desiredTraits, NSFontTraitMask candidateTraits)
-{
-    desiredTraits &= ~SYNTHESIZED_FONT_TRAITS;
-    return (candidateTraits & desiredTraits) == desiredTraits;
-}
-
-static bool betterChoice(NSFontTraitMask desiredTraits, int desiredWeight, NSFontTraitMask chosenTraits, int chosenWeight, NSFontTraitMask candidateTraits, int candidateWeight)
-{
-    if (!acceptableChoice(desiredTraits, candidateTraits))
-        return false;
-
-    // A list of the traits we care about.
-    // The top item in the list is the worst trait to mismatch; if a font has this
-    // and we didn't ask for it, we'd prefer any other font in the family.
-    const NSFontTraitMask masks[] = {
-        NSPosterFontMask,
-        NSSmallCapsFontMask,
-        NSItalicFontMask,
-        NSCompressedFontMask,
-        NSCondensedFontMask,
-        NSExpandedFontMask,
-        NSNarrowFontMask,
-        0
-    };
-
-    int i = 0;
-    NSFontTraitMask mask;
-    while ((mask = masks[i++])) {
-        bool desired = desiredTraits & mask;
-        bool chosenHasUnwantedTrait = desired != (chosenTraits & mask);
-        bool candidateHasUnwantedTrait = desired != (candidateTraits & mask);
-        if (!candidateHasUnwantedTrait && chosenHasUnwantedTrait)
-            return true;
-        if (!chosenHasUnwantedTrait && candidateHasUnwantedTrait)
-            return false;
-    }
-
-    int chosenWeightDeltaMagnitude = abs(chosenWeight - desiredWeight);
-    int candidateWeightDeltaMagnitude = abs(candidateWeight - desiredWeight);
-
-    // If both are the same distance from the desired weight, prefer the candidate if it is further from medium.
-    if (chosenWeightDeltaMagnitude == candidateWeightDeltaMagnitude)
-        return abs(candidateWeight - 6) > abs(chosenWeight - 6);
-
-    // Otherwise, prefer the one closer to the desired weight.
-    return candidateWeightDeltaMagnitude < chosenWeightDeltaMagnitude;
-}
-
-// Keep a cache for mapping desired font families to font families actually available on the system for performance.
-using AvailableFamilyMap = HashMap<std::pair<AtomicString, NSFontTraitMask>, AtomicString>;
-static AvailableFamilyMap& desiredFamilyToAvailableFamilyMap()
-{
-    ASSERT(isMainThread());
-    static NeverDestroyed<AvailableFamilyMap> map;
-    return map;
-}
-
-static bool hasDesiredFamilyToAvailableFamilyMapping(const AtomicString& desiredFamily, NSFontTraitMask desiredTraits, NSString*& availableFamily)
-{
-    AtomicString value = desiredFamilyToAvailableFamilyMap().get(std::make_pair(desiredFamily, desiredTraits));
-    availableFamily = value.isEmpty() ? nil : static_cast<NSString*>(value);
-    return !value.isNull();
-}
-
-static inline void rememberDesiredFamilyToAvailableFamilyMapping(const AtomicString& desiredFamily, NSFontTraitMask desiredTraits, NSString* availableFamily)
-{
-    static const unsigned maxCacheSize = 128;
-    auto& familyMapping = desiredFamilyToAvailableFamilyMap();
-    ASSERT(familyMapping.size() <= maxCacheSize);
-    if (familyMapping.size() >= maxCacheSize)
-        familyMapping.remove(familyMapping.begin());
-
-    // Store nil as an emptyAtom to distinguish from missing values (nullAtom).
-    AtomicString value = availableFamily ? AtomicString(availableFamily) : emptyAtom;
-    familyMapping.add(std::make_pair(desiredFamily, desiredTraits), value);
-}
-
-static int toAppKitFontWeight(FontWeight fontWeight)
-{
-    static const int appKitFontWeights[] = {
-        2, // FontWeight100
-        3, // FontWeight200
-        4, // FontWeight300
-        5, // FontWeight400
-        6, // FontWeight500
-        8, // FontWeight600
-        9, // FontWeight700
-        10, // FontWeight800
-        12, // FontWeight900
-    };
-    return appKitFontWeights[fontWeight];
-}
-
-static inline FontWeight appkitWeightToFontWeight(NSInteger appKitWeight)
-{
-    if (appKitWeight == 1)
-        return FontWeight100;
-    if (appKitWeight == 2)
-        return FontWeight200;
-    if (appKitWeight <= 4)
-        return FontWeight300;
-    if (appKitWeight == 5)
-        return FontWeight400;
-    if (appKitWeight == 6)
-        return FontWeight500;
-    if (appKitWeight <= 8)
-        return FontWeight600;
-    if (appKitWeight == 9)
-        return FontWeight700;
-    if (appKitWeight <= 11)
-        return FontWeight800;
-    return FontWeight900;
-}
-
-static NSFontTraitMask toNSFontTraits(CTFontSymbolicTraits traits)
-{
-    NSFontTraitMask result = 0;
-    if (traits & kCTFontBoldTrait)
-        result |= NSBoldFontMask;
-    if (traits & kCTFontItalicTrait)
-        result |= NSItalicFontMask;
-    return result;
-}
-
-#endif // PLATFORM_FONT_LOOKUP
-
 static CGFloat toNSFontWeight(FontWeight fontWeight)
 {
     static const CGFloat nsFontWeights[] = {
@@ -247,136 +107,8 @@ RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& famil
     return nullptr;
 }
 
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, CTFontSymbolicTraits requestedTraits, FontWeight weight, TextRenderingMode, float size)
-{
-    NSFontManager *fontManager = [NSFontManager sharedFontManager];
-    NSString *availableFamily;
-    int chosenWeight;
-    NSFont *font;
-
-    NSFontTraitMask desiredTraits = toNSFontTraits(requestedTraits);
-    NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0);
-    if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) {
-        if (!availableFamily) {
-            // We already know the desired font family does not map to any available font family.
-            return nil;
-        }
-    }
-
-    if (!availableFamily) {
-        NSString *desiredFamily = family;
-
-        // Do a simple case insensitive search for a matching font family.
-        // NSFontManager requires exact name matches.
-        // This addresses the problem of matching arial to Arial, etc., but perhaps not all the issues.
-        for (availableFamily in [fontManager availableFontFamilies]) {
-            if ([desiredFamily caseInsensitiveCompare:availableFamily] == NSOrderedSame)
-                break;
-        }
-
-        if (!availableFamily) {
-            // Match by PostScript name.
-            NSFont *nameMatchedFont = nil;
-            for (NSString *availableFont in [fontManager availableFonts]) {
-                if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
-                    nameMatchedFont = [NSFont fontWithName:availableFont size:size];
-
-                    // Special case Osaka-Mono. According to <rdar://problem/3999467>, we need to
-                    // treat Osaka-Mono as fixed pitch.
-                    if ([desiredFamily caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame && !desiredTraitsForNameMatch)
-                        return toCTFont(nameMatchedFont);
-
-                    NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
-                    if ((traits & desiredTraitsForNameMatch) == desiredTraitsForNameMatch)
-                        return toCTFont([fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraitsForNameMatch]);
-
-                    availableFamily = [nameMatchedFont familyName];
-                    break;
-                }
-            }
-        }
-
-        rememberDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily);
-        if (!availableFamily)
-            return nil;
-    }
-
-    // Found a family, now figure out what weight and traits to use.
-    bool choseFont = false;
-    chosenWeight = 0;
-    NSFontTraitMask chosenTraits = 0;
-    NSString *chosenFullName = 0;
-
-    int appKitDesiredWeight = toAppKitFontWeight(weight);
-    NSArray *fonts = [fontManager availableMembersOfFontFamily:availableFamily];
-    for (NSArray *fontInfo in fonts) {
-        // Array indices must be hard coded because of lame AppKit API.
-        NSString *fontFullName = [fontInfo objectAtIndex:0];
-        NSInteger fontWeight = [[fontInfo objectAtIndex:2] intValue];
-        NSFontTraitMask fontTraits = [[fontInfo objectAtIndex:3] unsignedIntValue];
-
-        BOOL newWinner;
-        if (!choseFont)
-            newWinner = acceptableChoice(desiredTraits, fontTraits);
-        else
-            newWinner = betterChoice(desiredTraits, appKitDesiredWeight, chosenTraits, chosenWeight, fontTraits, fontWeight);
-
-        if (newWinner) {
-            choseFont = YES;
-            chosenWeight = fontWeight;
-            chosenTraits = fontTraits;
-            chosenFullName = fontFullName;
-
-            if (chosenWeight == appKitDesiredWeight && (chosenTraits & IMPORTANT_FONT_TRAITS) == (desiredTraits & IMPORTANT_FONT_TRAITS))
-                break;
-        }
-    }
-
-    if (!choseFont)
-        return nil;
-
-    font = [NSFont fontWithName:chosenFullName size:size];
-
-    if (!font)
-        return nil;
-
-    NSFontTraitMask actualTraits = 0;
-    if (desiredTraits & NSFontItalicTrait)
-        actualTraits = [fontManager traitsOfFont:font];
-    FontWeight actualWeight = appkitWeightToFontWeight([fontManager weightOfFont:font]);
-
-    bool syntheticBold = isFontWeightBold(weight) && isFontWeightBold(actualWeight);
-    bool syntheticOblique = (desiredTraits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
-
-    // There are some malformed fonts that will be correctly returned by -fontWithFamily:traits:weight:size: as a match for a particular trait,
-    // though -[NSFontManager traitsOfFont:] incorrectly claims the font does not have the specified trait. This could result in applying 
-    // synthetic bold on top of an already-bold font, as reported in <http://bugs.webkit.org/show_bug.cgi?id=6146>. To work around this
-    // problem, if we got an apparent exact match, but the requested traits aren't present in the matched font, we'll try to get a font from 
-    // the same family without those traits (to apply the synthetic traits to later).
-    NSFontTraitMask nonSyntheticTraits = desiredTraits;
-
-    if (syntheticBold)
-        nonSyntheticTraits &= ~NSBoldFontMask;
-
-    if (syntheticOblique)
-        nonSyntheticTraits &= ~NSItalicFontMask;
-
-    if (nonSyntheticTraits != desiredTraits) {
-        NSFont *fontWithoutSyntheticTraits = [fontManager fontWithFamily:availableFamily traits:nonSyntheticTraits weight:chosenWeight size:size];
-        if (fontWithoutSyntheticTraits)
-            font = fontWithoutSyntheticTraits;
-    }
-
-    return toCTFont(font);
-}
-#endif
-
 void platformInvalidateFontCache()
 {
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-    desiredFamilyToAvailableFamilyMap().clear();
-#endif
 }
 
 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
index 7536814..238fce1 100644 (file)
@@ -1,3 +1,28 @@
+2017-02-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Remove Yosemite-specific font lookup code
+        https://bugs.webkit.org/show_bug.cgi?id=168682
+
+        Reviewed by Zalan Bujtas.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (fontWhitelist):
+        (adjustFonts):
+        (createWebViewAndOffscreenWindow):
+        (drt_NSFontManager_availableFontFamilies): Deleted.
+        (drt_NSFontManager_availableFonts): Deleted.
+        (swizzleNSFontManagerMethods): Deleted.
+        * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
+        (WTR::activateFonts):
+        (WTR::allowedFontFamilySet): Deleted.
+        (WTR::systemHiddenFontFamilySet): Deleted.
+        (WTR::wtr_NSFontManager_availableFontFamilies): Deleted.
+        (WTR::wtr_NSFontManager_availableFonts): Deleted.
+        (WTR::swizzleNSFontManagerMethods): Deleted.
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::generateWhitelist):
+        (WTR::TestController::platformInitializeContext):
+
 2017-02-22  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         AutoInstaller should not skip the install step if the package is downloaded but not installed
index 7571146..a434b36 100644 (file)
@@ -428,68 +428,6 @@ static NSSet *allowedFontFamilySet()
     return fontFamilySet;
 }
 
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-static IMP appKitAvailableFontFamiliesIMP;
-static IMP appKitAvailableFontsIMP;
-
-static NSArray *drt_NSFontManager_availableFontFamilies(id self, SEL _cmd)
-{
-    static NSArray *availableFontFamilies;
-    if (availableFontFamilies)
-        return availableFontFamilies;
-    
-    NSArray *availableFamilies = wtfCallIMP<id>(appKitAvailableFontFamiliesIMP, self, _cmd);
-
-    NSMutableSet *prunedFamiliesSet = [NSMutableSet setWithArray:availableFamilies];
-    [prunedFamiliesSet intersectSet:allowedFontFamilySet()];
-
-    availableFontFamilies = [[prunedFamiliesSet allObjects] retain];
-    return availableFontFamilies;
-}
-
-static NSArray *drt_NSFontManager_availableFonts(id self, SEL _cmd)
-{
-    static NSArray *availableFonts;
-    if (availableFonts)
-        return availableFonts;
-    
-    NSSet *allowedFamilies = allowedFontFamilySet();
-    NSMutableArray *availableFontList = [[NSMutableArray alloc] initWithCapacity:[allowedFamilies count] * 2];
-    for (NSString *fontFamily in allowedFontFamilySet()) {
-        NSArray* fontsForFamily = [[NSFontManager sharedFontManager] availableMembersOfFontFamily:fontFamily];
-        for (NSArray* fontInfo in fontsForFamily) {
-            // Font name is the first entry in the array.
-            [availableFontList addObject:[fontInfo objectAtIndex:0]];
-        }
-    }
-
-    availableFonts = availableFontList;
-    return availableFonts;
-}
-
-static void swizzleNSFontManagerMethods()
-{
-    Method availableFontFamiliesMethod = class_getInstanceMethod(objc_getClass("NSFontManager"), @selector(availableFontFamilies));
-    ASSERT(availableFontFamiliesMethod);
-    if (!availableFontFamiliesMethod) {
-        NSLog(@"Failed to swizzle the \"availableFontFamilies\" method on NSFontManager");
-        return;
-    }
-    
-    appKitAvailableFontFamiliesIMP = method_setImplementation(availableFontFamiliesMethod, (IMP)drt_NSFontManager_availableFontFamilies);
-
-    Method availableFontsMethod = class_getInstanceMethod(objc_getClass("NSFontManager"), @selector(availableFonts));
-    ASSERT(availableFontsMethod);
-    if (!availableFontsMethod) {
-        NSLog(@"Failed to swizzle the \"availableFonts\" method on NSFontManager");
-        return;
-    }
-    
-    appKitAvailableFontsIMP = method_setImplementation(availableFontsMethod, (IMP)drt_NSFontManager_availableFonts);
-}
-
-#else
-
 static NSArray *fontWhitelist()
 {
     static NSArray *availableFonts;
@@ -509,7 +447,6 @@ static NSArray *fontWhitelist()
     availableFonts = availableFontList;
     return availableFonts;
 }
-#endif
 
 // Activating system copies of these fonts overrides any others that could be preferred, such as ones
 // in /Library/Fonts/Microsoft, and which don't always have the same metrics.
@@ -588,9 +525,6 @@ static void activateTestingFonts()
 
 static void adjustFonts()
 {
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-    swizzleNSFontManagerMethods();
-#endif
     activateSystemCoreWebFonts();
     activateTestingFonts();
 }
@@ -780,7 +714,7 @@ WebView *createWebViewAndOffscreenWindow()
     [WebView registerURLSchemeAsLocal:@"feeds"];
     [WebView registerURLSchemeAsLocal:@"feedsearch"];
     
-#if PLATFORM(MAC) && ENABLE(PLATFORM_FONT_LOOKUP)
+#if PLATFORM(MAC)
     [WebView _setFontWhitelist:fontWhitelist()];
 #endif
 
index 5a49e46..78b5beb 100644 (file)
@@ -45,206 +45,6 @@ namespace WTR {
 
 #if USE(APPKIT)
 
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-static NSSet *allowedFontFamilySet()
-{
-    static NSSet *fontFamilySet = [[NSSet setWithObjects:
-        @"Ahem",
-        @"Al Bayan",
-        @"American Typewriter",
-        @"Andale Mono",
-        @"Apple Braille",
-        @"Apple Color Emoji",
-        @"Apple Chancery",
-        @"Apple Garamond BT",
-        @"Apple LiGothic",
-        @"Apple LiSung",
-        @"Apple Symbols",
-        @"AppleGothic",
-        @"AppleMyungjo",
-        @"Arial Black",
-        @"Arial Hebrew",
-        @"Arial Narrow",
-        @"Arial Rounded MT Bold",
-        @"Arial Unicode MS",
-        @"Arial",
-        @"Avenir Next",
-        @"Ayuthaya",
-        @"Baghdad",
-        @"Baskerville",
-        @"BiauKai",
-        @"Big Caslon",
-        @"Brush Script MT",
-        @"Chalkboard",
-        @"Chalkduster",
-        @"Charcoal CY",
-        @"Cochin",
-        @"Comic Sans MS",
-        @"Copperplate",
-        @"Corsiva Hebrew",
-        @"Courier New",
-        @"Courier",
-        @"DecoType Naskh",
-        @"Devanagari MT",
-        @"Didot",
-        @"Euphemia UCAS",
-        @"Futura",
-        @"GB18030 Bitmap",
-        @"Geeza Pro",
-        @"Geneva CY",
-        @"Geneva",
-        @"Georgia",
-        @"Gill Sans",
-        @"Gujarati MT",
-        @"GungSeo",
-        @"Gurmukhi MT",
-        @"HeadLineA",
-        @"Hei",
-        @"Heiti SC",
-        @"Heiti TC",
-        @"Helvetica CY",
-        @"Helvetica Neue",
-        @"Helvetica",
-        @"Herculanum",
-        @"Hiragino Kaku Gothic Pro",
-        @"Hiragino Kaku Gothic ProN",
-        @"Hiragino Kaku Gothic Std",
-        @"Hiragino Kaku Gothic StdN",
-        @"Hiragino Maru Gothic Pro",
-        @"Hiragino Maru Gothic ProN",
-        @"Hiragino Mincho Pro",
-        @"Hiragino Mincho ProN",
-        @"Hiragino Sans GB",
-        @"Hoefler Text",
-        @"Impact",
-        @"InaiMathi",
-        @"Kai",
-        @"Kailasa",
-        @"Kokonor",
-        @"Krungthep",
-        @"KufiStandardGK",
-        @"LastResort",
-        @"LiHei Pro",
-        @"LiSong Pro",
-        @"Lucida Grande",
-        @"Marker Felt",
-        @"Menlo",
-        @"Microsoft Sans Serif",
-        @"Monaco",
-        @"Mshtakan",
-        @"Nadeem",
-        @"New Peninim MT",
-        @"Optima",
-        @"Osaka",
-        @"Papyrus",
-        @"PCMyungjo",
-        @"PilGi",
-        @"Plantagenet Cherokee",
-        @"Raanana",
-        @"Sathu",
-        @"Silom",
-        @"Skia",
-        @"Songti SC",
-        @"Songti TC",
-        @"STFangsong",
-        @"STHeiti",
-        @"STIXGeneral",
-        @"STIXSizeOneSym",
-        @"STKaiti",
-        @"STSong",
-        @"Symbol",
-        @"Tahoma",
-        @"Thonburi",
-        @"Times New Roman",
-        @"Times",
-        @"Trebuchet MS",
-        @"Verdana",
-        @"Webdings",
-        @"WebKit WeightWatcher",
-        @"FontWithFeaturesOTF",
-        @"FontWithFeaturesTTF",
-        @"Wingdings 2",
-        @"Wingdings 3",
-        @"Wingdings",
-        @"Zapf Dingbats",
-        @"Zapfino",
-        nil] retain];
-    
-    return fontFamilySet;
-}
-
-static NSSet *systemHiddenFontFamilySet()
-{
-    static NSSet *fontFamilySet = [[NSSet setWithObjects:
-        @".LucidaGrandeUI",
-        nil] retain];
-
-    return fontFamilySet;
-}
-
-static IMP appKitAvailableFontFamiliesIMP;
-static IMP appKitAvailableFontsIMP;
-
-static NSArray *wtr_NSFontManager_availableFontFamilies(id self, SEL _cmd)
-{
-    static NSArray *availableFontFamilies;
-    if (availableFontFamilies)
-        return availableFontFamilies;
-    
-    NSArray *availableFamilies = wtfCallIMP<id>(appKitAvailableFontFamiliesIMP, self, _cmd);
-
-    NSMutableSet *prunedFamiliesSet = [NSMutableSet setWithArray:availableFamilies];
-    [prunedFamiliesSet intersectSet:allowedFontFamilySet()];
-
-    availableFontFamilies = [[prunedFamiliesSet allObjects] retain];
-    return availableFontFamilies;
-}
-
-static NSArray *wtr_NSFontManager_availableFonts(id self, SEL _cmd)
-{
-    static NSArray *availableFonts;
-    if (availableFonts)
-        return availableFonts;
-    
-    NSSet *allowedFamilies = allowedFontFamilySet();
-    NSMutableArray *availableFontList = [[NSMutableArray alloc] initWithCapacity:[allowedFamilies count] * 2];
-    for (NSString *fontFamily in allowedFontFamilySet()) {
-        NSArray* fontsForFamily = [[NSFontManager sharedFontManager] availableMembersOfFontFamily:fontFamily];
-        for (NSArray* fontInfo in fontsForFamily) {
-            // Font name is the first entry in the array.
-            [availableFontList addObject:[fontInfo objectAtIndex:0]];
-        }
-    }
-
-    for (NSString *hiddenFontFamily in systemHiddenFontFamilySet())
-        [availableFontList addObject:hiddenFontFamily];
-
-    availableFonts = availableFontList;
-    return availableFonts;
-}
-
-static void swizzleNSFontManagerMethods()
-{
-    Method availableFontFamiliesMethod = class_getInstanceMethod(objc_getClass("NSFontManager"), @selector(availableFontFamilies));
-    ASSERT(availableFontFamiliesMethod);
-    if (!availableFontFamiliesMethod) {
-        NSLog(@"Failed to swizzle the \"availableFontFamilies\" method on NSFontManager");
-        return;
-    }
-    
-    appKitAvailableFontFamiliesIMP = method_setImplementation(availableFontFamiliesMethod, (IMP)wtr_NSFontManager_availableFontFamilies);
-
-    Method availableFontsMethod = class_getInstanceMethod(objc_getClass("NSFontManager"), @selector(availableFonts));
-    ASSERT(availableFontsMethod);
-    if (!availableFontsMethod) {
-        NSLog(@"Failed to swizzle the \"availableFonts\" method on NSFontManager");
-        return;
-    }
-    
-    appKitAvailableFontsIMP = method_setImplementation(availableFontsMethod, (IMP)wtr_NSFontManager_availableFonts);
-}
-#endif
-
 // Activating system copies of these fonts overrides any others that could be preferred, such as ones
 // in /Library/Fonts/Microsoft, and which don't always have the same metrics.
 // FIXME: Switch to a solution from <rdar://problem/19553550> once it's available.
@@ -322,9 +122,6 @@ void activateFonts()
     }
 
 #if USE(APPKIT)
-#if !ENABLE(PLATFORM_FONT_LOOKUP)
-    swizzleNSFontManagerMethods();
-#endif
     activateSystemCoreWebFonts();
 #endif // USE(APPKIT)
 }
index d95ca7e..2cd0cbc 100644 (file)
@@ -143,7 +143,6 @@ void TestController::platformConfigureViewForTest(const TestInvocation& test)
 #endif
 }
 
-#if ENABLE(PLATFORM_FONT_LOOKUP)
 static NSSet *allowedFontFamilySet()
 {
     static NSSet *fontFamilySet = [[NSSet setWithObjects:
@@ -299,7 +298,6 @@ static WKRetainPtr<WKArrayRef> generateWhitelist()
 
     return adoptWK(result);
 }
-#endif
 
 void TestController::platformInitializeContext()
 {
@@ -312,9 +310,7 @@ void TestController::platformInitializeContext()
                                           diskPath:nil]);
     [NSURLCache setSharedURLCache:sharedCache.get()];
 
-#if ENABLE(PLATFORM_FONT_LOOKUP)
     WKContextSetFontWhitelist(m_context.get(), generateWhitelist().get());
-#endif
 }
 
 void TestController::setHidden(bool hidden)