Diff
Modified: trunk/Source/WebCore/ChangeLog (188574 => 188575)
--- trunk/Source/WebCore/ChangeLog 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/ChangeLog 2015-08-18 04:55:22 UTC (rev 188575)
@@ -1,3 +1,32 @@
+2015-08-17 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Address post-commit review
+ https://bugs.webkit.org/show_bug.cgi?id=147864
+
+ Reviewed by Darin Adler.
+
+ Create helper functions to cast between NSFont*s and CTFontRefs.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/FontPlatformData.h:
+ (WebCore::toCTFont):
+ (WebCore::toNSFont):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::Font::platformCreateScaledFont):
+ (WebCore::Font::compositeFontReferenceFont):
+ * platform/graphics/mac/FontCacheMac.mm:
+ (WebCore::FontCache::platformPurgeInactiveFontData):
+ (WebCore::lookupCTFont):
+ (WebCore::FontCache::systemFallbackForCharacters):
+ (WebCore::FontCache::createFontPlatformData):
+ * platform/mac/DragImageMac.mm:
+ (WebCore::fontFromNSFont):
+ (WebCore::widthWithFont):
+ (WebCore::drawAtPoint):
+ * platform/spi/mac/NSFontSPI.h:
+
2015-08-17 Alex Christensen <achristen...@webkit.org>
WinCairo build fix after r188566
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (188574 => 188575)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2015-08-18 04:55:22 UTC (rev 188575)
@@ -244,6 +244,19 @@
#endif
};
+#if USE(APPKIT)
+// NSFonts and CTFontRefs are toll-free-bridged.
+inline CTFontRef toCTFont(NSFont *font)
+{
+ return (CTFontRef)font;
+}
+
+inline NSFont *toNSFont(CTFontRef font)
+{
+ return (NSFont *)font;
+}
+#endif
+
} // namespace WebCore
#endif // FontPlatformData_h
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (188574 => 188575)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-08-18 04:55:22 UTC (rev 188575)
@@ -324,7 +324,7 @@
#if USE(APPKIT)
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- FontPlatformData scaledFontData(reinterpret_cast<CTFontRef>([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toSize:size]), size, false, false, m_platformData.orientation());
+ FontPlatformData scaledFontData(toCTFont([[NSFontManager sharedFontManager] convertFont:m_platformData.nsFont() toSize:size]), size, false, false, m_platformData.orientation());
if (scaledFontData.font()) {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (188574 => 188575)
--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm 2015-08-18 04:55:22 UTC (rev 188575)
@@ -474,10 +474,10 @@
void FontCache::platformPurgeInactiveFontData()
{
- Vector<RetainPtr<CTFontRef>> toRemove;
+ Vector<CTFontRef> toRemove;
for (auto& font : fallbackDedupSet()) {
if (CFGetRetainCount(font.get()) == 1)
- toRemove.append(font);
+ toRemove.append(font.get());
}
for (auto& font : toRemove)
fallbackDedupSet().remove(font);
@@ -489,7 +489,7 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1090
UNUSED_PARAM(locale);
if (!font) {
- font = reinterpret_cast<CTFontRef>([NSFont userFontOfSize:fontSize]);
+ font = toCTFont([NSFont userFontOfSize:fontSize]);
bool acceptable = true;
RetainPtr<CFCharacterSetRef> characterSet = adoptCF(CTFontCopyCharacterSet(font));
@@ -527,7 +527,7 @@
// FontCascade::drawGlyphBuffer() requires that there are no duplicate Font objects which refer to the same thing. This is enforced in
// FontCache::fontForPlatformData(), where our equality check is based on hashing the FontPlatformData, whose hash includes the raw CoreText
// font pointer.
- NSFont *substituteFont = reinterpret_cast<NSFont *>(const_cast<__CTFont*>(fallbackDedupSet().add(result).iterator->get()));
+ NSFont *substituteFont = toNSFont(fallbackDedupSet().add(result).iterator->get());
// Use the family name from the AppKit-supplied substitute font, requesting the
// traits, weight, and size we want. One way this does better than the original
@@ -575,7 +575,7 @@
substituteFontTraits = [fontManager traitsOfFont:substituteFont];
substituteFontWeight = [fontManager weightOfFont:substituteFont];
- FontPlatformData alternateFont(reinterpret_cast<CTFontRef>(substituteFont), platformData.size(),
+ FontPlatformData alternateFont(toCTFont(substituteFont), platformData.size(),
!isPlatformFont && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
!isPlatformFont && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
platformData.m_orientation);
@@ -703,7 +703,7 @@
bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && isAppKitFontWeightBold(toAppKitFontWeight(fontDescription.weight())) && !isAppKitFontWeightBold(actualWeight);
bool syntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
- return std::make_unique<FontPlatformData>(reinterpret_cast<CTFontRef>(platformFont), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
+ return std::make_unique<FontPlatformData>(toCTFont(platformFont), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/mac/DragImageMac.mm (188574 => 188575)
--- trunk/Source/WebCore/platform/mac/DragImageMac.mm 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/platform/mac/DragImageMac.mm 2015-08-18 04:55:22 UTC (rev 188575)
@@ -168,7 +168,7 @@
CFRelease(currentFont);
currentFont = font;
CFRetain(currentFont);
- currentRenderer = FontCascade(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]));
+ currentRenderer = FontCascade(FontPlatformData(toCTFont(font), [font pointSize]));
return currentRenderer;
}
@@ -191,7 +191,7 @@
[string getCharacters:buffer.data()];
if (canUseFastRenderer(buffer.data(), length)) {
- FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]));
+ FontCascade webCoreFont(FontPlatformData(toCTFont(font), [font pointSize]));
TextRun run(StringView(buffer.data(), length));
run.disableRoundingHacks();
return webCoreFont.width(run);
@@ -223,7 +223,7 @@
if (!flipped)
CGContextScaleCTM(cgContext, 1, -1);
- FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]), Antialiased);
+ FontCascade webCoreFont(FontPlatformData(toCTFont(font), [font pointSize]), Antialiased);
TextRun run(StringView(buffer.data(), length));
run.disableRoundingHacks();
Modified: trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h (188574 => 188575)
--- trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h 2015-08-18 04:13:57 UTC (rev 188574)
+++ trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h 2015-08-18 04:55:22 UTC (rev 188575)
@@ -34,7 +34,7 @@
#else
-@interface NSFont (Private)
+@interface NSFont ()
+ (NSFont *)systemFontOfSize:(CGFloat)size weight:(CGFloat)weight;
@end