| Differences between
and this patch
- a/Source/WebCore/ChangeLog +23 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2014-10-21  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
2
3
        Use std::unique_ptr | std::make_unique in FontCacheFoo
4
        https://bugs.webkit.org/show_bug.cgi?id=137905
5
6
        Reviewed by Darin Adler.
7
8
        Clean up PassOwnPtr|OwnPtr using std::unique_ptr|std::make_unique.
9
10
        No new tests, no behavior changes.
11
12
        * platform/graphics/FontCache.cpp:
13
        (WebCore::FontCache::getCachedFontPlatformData):
14
        * platform/graphics/FontCache.h:
15
        * platform/graphics/freetype/FontCacheFreeType.cpp:
16
        (WebCore::FontCache::createFontPlatformData):
17
        * platform/graphics/ios/FontCacheIOS.mm:
18
        (WebCore::FontCache::createFontPlatformData):
19
        * platform/graphics/mac/FontCacheMac.mm:
20
        (WebCore::FontCache::createFontPlatformData):
21
        * platform/graphics/win/FontCacheWin.cpp:
22
        (WebCore::FontCache::createFontPlatformData):
23
1
2014-10-21  Jer Noble  <jer.noble@apple.com>
24
2014-10-21  Jer Noble  <jer.noble@apple.com>
2
25
3
        [EME][Mac] Update to match new AVStreamSession API and requirements.
26
        [EME][Mac] Update to match new AVStreamSession API and requirements.
- a/Source/WebCore/platform/graphics/FontCache.cpp -2 / +2 lines
Lines 141-147 struct FontPlatformDataCacheKeyHash { a/Source/WebCore/platform/graphics/FontCache.cpp_sec1
141
141
142
struct FontPlatformDataCacheKeyTraits : WTF::SimpleClassHashTraits<FontPlatformDataCacheKey> { };
142
struct FontPlatformDataCacheKeyTraits : WTF::SimpleClassHashTraits<FontPlatformDataCacheKey> { };
143
143
144
typedef HashMap<FontPlatformDataCacheKey, OwnPtr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
144
typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
145
145
146
static FontPlatformDataCache* gFontPlatformDataCache = 0;
146
static FontPlatformDataCache* gFontPlatformDataCache = 0;
147
147
Lines 257-263 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fo a/Source/WebCore/platform/graphics/FontCache.cpp_sec2
257
                it = gFontPlatformDataCache->find(key);
257
                it = gFontPlatformDataCache->find(key);
258
                ASSERT(it != gFontPlatformDataCache->end());
258
                ASSERT(it != gFontPlatformDataCache->end());
259
                if (fontPlatformDataForAlternateName)
259
                if (fontPlatformDataForAlternateName)
260
                    it->value = adoptPtr(new FontPlatformData(*fontPlatformDataForAlternateName));
260
                    it->value = std::make_unique<FontPlatformData>(*fontPlatformDataForAlternateName);
261
            }
261
            }
262
        }
262
        }
263
    }
263
    }
- a/Source/WebCore/platform/graphics/FontCache.h -1 / +1 lines
Lines 185-191 private: a/Source/WebCore/platform/graphics/FontCache.h_sec1
185
    FontPlatformData* getCustomFallbackFont(const UInt32, const FontDescription&);
185
    FontPlatformData* getCustomFallbackFont(const UInt32, const FontDescription&);
186
    PassRefPtr<SimpleFontData> getSystemFontFallbackForCharacters(const FontDescription&, const SimpleFontData*, const UChar* characters, int length);
186
    PassRefPtr<SimpleFontData> getSystemFontFallbackForCharacters(const FontDescription&, const SimpleFontData*, const UChar* characters, int length);
187
#endif
187
#endif
188
    PassOwnPtr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family);
188
    std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family);
189
#if PLATFORM(COCOA)
189
#if PLATFORM(COCOA)
190
    PassRefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
190
    PassRefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
191
#endif
191
#endif
- a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp -3 / +3 lines
Lines 164-170 int fontWeightToFontconfigWeight(FontWeight weight) a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp_sec1
164
    }
164
    }
165
}
165
}
166
166
167
PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
167
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
168
{
168
{
169
    // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
169
    // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
170
    // says that we must find an exact match for font family, slant (italic or oblique can be used)
170
    // says that we must find an exact match for font family, slant (italic or oblique can be used)
Lines 215-225 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp_sec2
215
    // Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
215
    // Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
216
    // supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
216
    // supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
217
    // If this font doesn't have one of these three encodings, don't select it.
217
    // If this font doesn't have one of these three encodings, don't select it.
218
    OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(resultPattern.get(), fontDescription));
218
    auto platformData = std::make_unique<FontPlatformData>(resultPattern.get(), fontDescription);
219
    if (!platformData->hasCompatibleCharmap())
219
    if (!platformData->hasCompatibleCharmap())
220
        return nullptr;
220
        return nullptr;
221
221
222
    return platformData.release();
222
    return platformData;
223
}
223
}
224
224
225
}
225
}
- a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm -2 / +2 lines
Lines 621-627 static uint16_t toCTFontWeight(FontWeight fontWeight) a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm_sec1
621
    }
621
    }
622
}
622
}
623
623
624
PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
624
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
625
{
625
{
626
    // Special case for "Courier" font. We used to have only an oblique variant on iOS, so prior to
626
    // Special case for "Courier" font. We used to have only an oblique variant on iOS, so prior to
627
    // iOS 6.0, we disallowed its use here. We'll fall back on "Courier New". <rdar://problem/5116477&10850227>
627
    // iOS 6.0, we disallowed its use here. We'll fall back on "Courier New". <rdar://problem/5116477&10850227>
Lines 654-660 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm_sec2
654
    bool syntheticBold = (traits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold) && !isAppleColorEmoji;
654
    bool syntheticBold = (traits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold) && !isAppleColorEmoji;
655
    bool syntheticOblique = (traits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic) && !isAppleColorEmoji;
655
    bool syntheticOblique = (traits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic) && !isAppleColorEmoji;
656
656
657
    FontPlatformData* result = new FontPlatformData(ctFont.get(), size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
657
    auto* result = std::make_unique<FontPlatformData>(ctFont.get(), size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
658
    if (isAppleColorEmoji)
658
    if (isAppleColorEmoji)
659
        result->m_isEmoji = true;
659
        result->m_isEmoji = true;
660
    return adoptPtr(result);
660
    return adoptPtr(result);
- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm -3 / +2 lines
Lines 219-225 void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec1
219
    [WebFontCache getTraits:traitsMasks inFamily:familyName];
219
    [WebFontCache getTraits:traitsMasks inFamily:familyName];
220
}
220
}
221
221
222
PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
222
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
223
{
223
{
224
    NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
224
    NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
225
    NSInteger weight = toAppKitFontWeight(fontDescription.weight());
225
    NSInteger weight = toAppKitFontWeight(fontDescription.weight());
Lines 239-246 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec2
239
    bool syntheticBold = isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
239
    bool syntheticBold = isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
240
    bool syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
240
    bool syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
241
241
242
    OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platformFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant()));
242
    return std::make_unique<FontPlatformData>(platformFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
243
    return platformData.release();
244
}
243
}
245
244
246
} // namespace WebCore
245
} // namespace WebCore
- a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp -5 / +4 lines
Lines 545-551 void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp_sec1
545
    copyToVector(procData.m_traitsMasks, traitsMasks);
545
    copyToVector(procData.m_traitsMasks, traitsMasks);
546
}
546
}
547
547
548
PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
548
std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
549
{
549
{
550
    bool isLucidaGrande = false;
550
    bool isLucidaGrande = false;
551
    static AtomicString lucidaStr("Lucida Grande");
551
    static AtomicString lucidaStr("Lucida Grande");
Lines 574-580 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp_sec2
574
    bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight);
574
    bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight);
575
    bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
575
    bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
576
576
577
    FontPlatformData* result = new FontPlatformData(WTF::move(hfont), fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
577
    auto result = std::make_unique<FontPlatformData>(WTF::move(hfont), fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
578
578
579
#if USE(CG)
579
#if USE(CG)
580
    bool fontCreationFailed = !result->cgFont();
580
    bool fontCreationFailed = !result->cgFont();
Lines 586-596 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp_sec3
586
        // The creation of the CGFontRef failed for some reason.  We already asserted in debug builds, but to make
586
        // The creation of the CGFontRef failed for some reason.  We already asserted in debug builds, but to make
587
        // absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next
587
        // absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next
588
        // font.
588
        // font.
589
        delete result;
590
        return nullptr;
589
        return nullptr;
591
    }        
590
    }
592
591
593
    return adoptPtr(result);
592
    return result;
594
}
593
}
595
594
596
}
595
}

Return to Bug 137905