Diff
Modified: trunk/Source/WebCore/ChangeLog (200562 => 200563)
--- trunk/Source/WebCore/ChangeLog 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/ChangeLog 2016-05-08 22:54:42 UTC (rev 200563)
@@ -1,3 +1,44 @@
+2016-05-08 Myles C. Maxfield <[email protected]>
+
+ [OS X] Migrate our Font classes entirely off of NSFont
+ https://bugs.webkit.org/show_bug.cgi?id=157464
+
+ Reviewed by Darin Adler.
+
+ Because NSFont and CTFont are toll-free-bridged, we don't need NSFont at all anywhere.
+
+ No new tests because there is no behavior change.
+
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute):
+ (textMarkerRangeFromRange):
+ (visiblePositionForStartOfTextMarkerRange):
+ (visiblePositionForEndOfTextMarkerRange):
+ (AXAttributedStringRangeIsValid):
+ (AXAttributeStringSetFont):
+ (CreateCGColorIfDifferent):
+ (AXAttributeStringSetStyle):
+ (textMarkerRangeFromVisiblePositions):
+ * bindings/objc/DOM.mm:
+ (-[DOMElement _font]):
+ * bindings/objc/DOMPrivate.h:
+ * editing/cocoa/HTMLConverter.mm:
+ (_font):
+ (WebCore::editingAttributedStringFromRange):
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::fontAttributesForSelectionStart):
+ * platform/graphics/Font.h:
+ (WebCore::Font::getCTFont):
+ (WebCore::Font::getNSFont): Deleted.
+ * platform/graphics/FontPlatformData.h:
+ (WebCore::FontPlatformData::nsFont): Deleted.
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::Font::determinePitch):
+ (WebCore::advanceForColorBitmapFont):
+ (WebCore::Font::platformWidthForGlyph):
+ (WebCore::renderingStyle): Deleted.
+ * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+
2016-05-08 Chris Dumez <[email protected]>
[Bindings] Simplify [RequiresExistingAtomicString] IDL extended attribute handling
Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (200562 => 200563)
--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -724,7 +724,7 @@
if ([searchTextParameter isKindOfClass:[NSString class]])
searchText = searchTextParameter;
- AccessibilityObject *startElement = nullptr;
+ AccessibilityObject* startElement = nullptr;
if ([startElementParameter isKindOfClass:[WebAccessibilityObjectWrapper class]])
startElement = [startElementParameter accessibilityObject];
@@ -831,7 +831,7 @@
return textMarkerRangeFromRange(m_object->axObjectCache(), range);
}
-static id textMarkerRangeFromRange(AXObjectCache *cache, const RefPtr<Range> range)
+static id textMarkerRangeFromRange(AXObjectCache* cache, const RefPtr<Range> range)
{
id startTextMarker = startOrEndTextmarkerForRange(cache, range, true);
id endTextMarker = startOrEndTextmarkerForRange(cache, range, false);
@@ -980,12 +980,12 @@
return visiblePositionForTextMarker(m_object->axObjectCache(), textMarker);
}
-static VisiblePosition visiblePositionForStartOfTextMarkerRange(AXObjectCache *cache, id textMarkerRange)
+static VisiblePosition visiblePositionForStartOfTextMarkerRange(AXObjectCache* cache, id textMarkerRange)
{
return visiblePositionForTextMarker(cache, AXTextMarkerRangeStart(textMarkerRange));
}
-static VisiblePosition visiblePositionForEndOfTextMarkerRange(AXObjectCache *cache, id textMarkerRange)
+static VisiblePosition visiblePositionForEndOfTextMarkerRange(AXObjectCache* cache, id textMarkerRange)
{
return visiblePositionForTextMarker(cache, AXTextMarkerRangeEnd(textMarkerRange));
}
@@ -1000,23 +1000,23 @@
// When modifying attributed strings, the range can come from a source which may provide faulty information (e.g. the spell checker).
// To protect against such cases the range should be validated before adding or removing attributes.
-static BOOL AXAttributedStringRangeIsValid(NSAttributedString* attrString, NSRange range)
+static BOOL AXAttributedStringRangeIsValid(NSAttributedString *attrString, NSRange range)
{
return (range.location < [attrString length] && NSMaxRange(range) <= [attrString length]);
}
-static void AXAttributeStringSetFont(NSMutableAttributedString* attrString, NSString* attribute, NSFont* font, NSRange range)
+static void AXAttributeStringSetFont(NSMutableAttributedString *attrString, NSString *attribute, CTFontRef font, NSRange range)
{
if (!AXAttributedStringRangeIsValid(attrString, range))
return;
-
+
if (font) {
- NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
- [font fontName] , NSAccessibilityFontNameKey,
- [font familyName] , NSAccessibilityFontFamilyKey,
- [font displayName] , NSAccessibilityVisibleNameKey,
- [NSNumber numberWithFloat:[font pointSize]] , NSAccessibilityFontSizeKey,
- nil];
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ static_cast<NSString *>(adoptCF(CTFontCopyPostScriptName(font)).get()), NSAccessibilityFontNameKey,
+ static_cast<NSString *>(adoptCF(CTFontCopyFamilyName(font)).get()), NSAccessibilityFontFamilyKey,
+ static_cast<NSString *>(adoptCF(CTFontCopyDisplayName(font)).get()), NSAccessibilityVisibleNameKey,
+ [NSNumber numberWithFloat:CTFontGetSize(font)], NSAccessibilityFontSizeKey,
+ nil];
[attrString addAttribute:attribute value:dict range:range];
} else
@@ -1024,10 +1024,10 @@
}
-static CGColorRef CreateCGColorIfDifferent(NSColor* nsColor, CGColorRef existingColor)
+static CGColorRef CreateCGColorIfDifferent(NSColor *nsColor, CGColorRef existingColor)
{
// get color information assuming NSDeviceRGBColorSpace
- NSColor* rgbColor = [nsColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
+ NSColor *rgbColor = [nsColor colorUsingColorSpaceName:NSDeviceRGBColorSpace];
if (rgbColor == nil)
rgbColor = [NSColor blackColor];
CGFloat components[4];
@@ -1079,7 +1079,7 @@
const RenderStyle& style = renderer->style();
// set basic font info
- AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style.fontCascade().primaryFont().getNSFont(), range);
+ AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style.fontCascade().primaryFont().getCTFont(), range);
// set basic colors
AXAttributeStringSetColor(attrString, NSAccessibilityForegroundColorTextAttribute, nsColor(style.visitedDependentColor(CSSPropertyColor)), range);
@@ -1348,7 +1348,7 @@
return [attrString autorelease];
}
-static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, const VisiblePosition& startPosition, const VisiblePosition& endPosition)
+static id textMarkerRangeFromVisiblePositions(AXObjectCache* cache, const VisiblePosition& startPosition, const VisiblePosition& endPosition)
{
id startTextMarker = textMarkerForVisiblePosition(cache, startPosition);
id endTextMarker = textMarkerForVisiblePosition(cache, endPosition);
Modified: trunk/Source/WebCore/bindings/objc/DOM.mm (200562 => 200563)
--- trunk/Source/WebCore/bindings/objc/DOM.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/bindings/objc/DOM.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -721,24 +721,13 @@
@implementation DOMElement (WebPrivate)
-#if !PLATFORM(IOS)
-- (NSFont *)_font
-{
- // FIXME: Could we move this function to WebCore::Element and autogenerate?
- auto renderer = core(self)->renderer();
- if (!renderer)
- return nil;
- return renderer->style().fontCascade().primaryFont().getNSFont();
-}
-#else
- (CTFontRef)_font
{
- RenderObject* renderer = core(self)->renderer();
+ auto* renderer = core(self)->renderer();
if (!renderer)
return nil;
return renderer->style().fontCascade().primaryFont().getCTFont();
}
-#endif
#if !PLATFORM(IOS)
- (NSData *)_imageTIFFRepresentation
Modified: trunk/Source/WebCore/bindings/objc/DOMPrivate.h (200562 => 200563)
--- trunk/Source/WebCore/bindings/objc/DOMPrivate.h 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/bindings/objc/DOMPrivate.h 2016-05-08 22:54:42 UTC (rev 200563)
@@ -74,11 +74,9 @@
@interface DOMElement (WebPrivate)
#if !TARGET_OS_IPHONE
-- (NSFont *)_font;
- (NSData *)_imageTIFFRepresentation;
-#else
-- (CTFontRef)_font;
#endif
+- (CTFontRef)_font;
- (NSURL *)_getURLAttribute:(NSString *)name;
- (BOOL)isFocused;
@end
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (200562 => 200563)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -1034,23 +1034,13 @@
return platformResult;
}
-#if !PLATFORM(IOS)
static PlatformFont *_font(Element& element)
{
- auto renderer = element.renderer();
+ auto* renderer = element.renderer();
if (!renderer)
return nil;
- return renderer->style().fontCascade().primaryFont().getNSFont();
+ return toNSFont(renderer->style().fontCascade().primaryFont().getCTFont());
}
-#else
-static PlatformFont *_font(Element& element)
-{
- auto renderer = element.renderer();
- if (!renderer)
- return nil;
- return (PlatformFont *)renderer->style().fontCascade().primaryFont().getCTFont();
-}
-#endif
#define UIFloatIsZero(number) (fabs(number - 0) < FLT_EPSILON)
@@ -2535,8 +2525,8 @@
[attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
if (style.textDecorationsInEffect() & TextDecorationLineThrough)
[attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
- if (NSFont *font = style.fontCascade().primaryFont().getNSFont())
- [attrs.get() setObject:font forKey:NSFontAttributeName];
+ if (auto font = style.fontCascade().primaryFont().getCTFont())
+ [attrs.get() setObject:toNSFont(font) forKey:NSFontAttributeName];
else
[attrs.get() setObject:[fontManager convertFont:WebDefaultFont() toSize:style.fontCascade().primaryFont().platformData().size()] forKey:NSFontAttributeName];
if (style.visitedDependentColor(CSSPropertyColor).alpha())
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (200562 => 200563)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -155,8 +155,8 @@
if (style->visitedDependentColor(CSSPropertyBackgroundColor).isValid() && style->visitedDependentColor(CSSPropertyBackgroundColor).alpha() != 0)
[result setObject:nsColor(style->visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
- if (style->fontCascade().primaryFont().getNSFont())
- [result setObject:style->fontCascade().primaryFont().getNSFont() forKey:NSFontAttributeName];
+ if (auto ctFont = style->fontCascade().primaryFont().getCTFont())
+ [result setObject:toNSFont(ctFont) forKey:NSFontAttributeName];
if (style->visitedDependentColor(CSSPropertyColor).isValid() && style->visitedDependentColor(CSSPropertyColor) != Color::black)
[result setObject:nsColor(style->visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
Modified: trunk/Source/WebCore/platform/graphics/Font.h (200562 => 200563)
--- trunk/Source/WebCore/platform/graphics/Font.h 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2016-05-08 22:54:42 UTC (rev 200563)
@@ -172,15 +172,11 @@
String description() const;
#endif
-#if USE(APPKIT)
- NSFont* getNSFont() const { return m_platformData.nsFont(); }
-#endif
-
#if PLATFORM(IOS)
- CTFontRef getCTFont() const { return m_platformData.font(); }
bool shouldNotBeUsedForArabic() const { return m_shouldNotBeUsedForArabic; };
#endif
#if PLATFORM(COCOA)
+ CTFontRef getCTFont() const { return m_platformData.font(); }
CFDictionaryRef getCFStringAttributes(bool enableKerning, FontOrientation) const;
const BitVector& glyphsSupportedBySmallCaps() const;
const BitVector& glyphsSupportedByAllSmallCaps() const;
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (200562 => 200563)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2016-05-08 22:54:42 UTC (rev 200563)
@@ -130,12 +130,7 @@
RetainPtr<CFTypeRef> objectForEqualityCheck() const;
bool hasCustomTracking() const { return isSystemFont(); }
-
-#if USE(APPKIT)
- // FIXME: Remove this when all NSFont usage is removed.
- NSFont *nsFont() const { return (NSFont *)m_font.get(); }
#endif
-#endif
#if PLATFORM(WIN) || PLATFORM(COCOA)
bool isSystemFont() const { return m_isSystemFont; }
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (200562 => 200563)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -525,10 +525,16 @@
return createDerivativeFont(scaledFont.get(), size, m_platformData.orientation(), fontTraits, m_platformData.syntheticBold(), m_platformData.syntheticOblique());
}
+static inline bool caseInsensitiveCompare(CFStringRef a, CFStringRef b)
+{
+ return a && CFStringCompare(a, b, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
+}
+
void Font::determinePitch()
{
-#if USE(APPKIT)
- NSFont* f = m_platformData.nsFont();
+ CTFontRef ctFont = m_platformData.font();
+ ASSERT(ctFont);
+
// Special case Osaka-Mono.
// According to <rdar://problem/3999467>, we should treat Osaka-Mono as fixed pitch.
// Note that the AppKit does not report Osaka-Mono as fixed pitch.
@@ -541,18 +547,11 @@
// According to <rdar://problem/5454704>, we should not treat MonotypeCorsiva as fixed pitch.
// Note that AppKit does report MonotypeCorsiva as fixed pitch.
- NSString *name = [f fontName];
- m_treatAsFixedPitch = ([f isFixedPitch] || [f _isFakeFixedPitch] || [name caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame) && [name caseInsensitiveCompare:@"MS-PGothic"] != NSOrderedSame && [name caseInsensitiveCompare:@"MonotypeCorsiva"] != NSOrderedSame;
-#else
- CTFontRef ctFont = m_platformData.font();
- m_treatAsFixedPitch = false;
- if (!ctFont)
- return; // CTFont is null in the case of SVG fonts for example.
-
RetainPtr<CFStringRef> fullName = adoptCF(CTFontCopyFullName(ctFont));
RetainPtr<CFStringRef> familyName = adoptCF(CTFontCopyFamilyName(ctFont));
- m_treatAsFixedPitch = CGFontIsFixedPitch(m_platformData.cgFont()) || (fullName && (CFStringCompare(fullName.get(), CFSTR("Osaka-Mono"), kCFCompareCaseInsensitive) == kCFCompareEqualTo || CFStringCompare(fullName.get(), CFSTR("MS-PGothic"), kCFCompareCaseInsensitive) == kCFCompareEqualTo));
+ m_treatAsFixedPitch = (CTFontGetSymbolicTraits(ctFont) & kCTFontMonoSpaceTrait) || CGFontIsFixedPitch(m_platformData.cgFont()) || (caseInsensitiveCompare(fullName.get(), CFSTR("Osaka-Mono")) || caseInsensitiveCompare(fullName.get(), CFSTR("MS-PGothic")) || caseInsensitiveCompare(fullName.get(), CFSTR("MonotypeCorsiva")));
+#if PLATFORM(IOS)
if (familyName && CFStringCompare(familyName.get(), CFSTR("Courier New"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
// Special case Courier New to not be treated as fixed pitch, as this will make use of a hacked space width which is undesireable for iPhone (see rdar://6269783).
m_treatAsFixedPitch = false;
@@ -571,43 +570,14 @@
return boundingBox;
}
-static inline CGFontRenderingStyle renderingStyle(const FontPlatformData& platformData)
-{
-#if USE(APPKIT)
- CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization;
- NSFont *font = platformData.nsFont();
- if (font) {
- switch ([font renderingMode]) {
- case NSFontIntegerAdvancementsRenderingMode:
- style = 0;
- break;
- case NSFontAntialiasedIntegerAdvancementsRenderingMode:
- style = kCGFontRenderingStyleAntialiasing;
- break;
- default:
- break;
- }
- }
- return style;
-
-#else
- UNUSED_PARAM(platformData);
- return kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
-#endif
-}
-
static inline Optional<CGSize> advanceForColorBitmapFont(const FontPlatformData& platformData, Glyph glyph)
{
-#if PLATFORM(MAC)
- NSFont *font = platformData.nsFont();
+ CTFontRef font = platformData.font();
if (!font || !platformData.isColorBitmapFont())
return Nullopt;
- return NSSizeToCGSize([font advancementForGlyph:glyph]);
-#else
- UNUSED_PARAM(platformData);
- UNUSED_PARAM(glyph);
- return Nullopt;
-#endif
+ CGSize advance;
+ CTFontGetAdvancesForGlyphs(font, kCTFontOrientationDefault, &glyph, &advance, 1);
+ return advance;
}
static inline bool canUseFastGlyphAdvanceGetter(const FontPlatformData& platformData, Glyph glyph, CGSize& advance, bool& populatedAdvance)
@@ -630,7 +600,8 @@
if ((horizontal || m_isBrokenIdeographFallback) && canUseFastGlyphAdvanceGetter(this->platformData(), glyph, advance, populatedAdvance)) {
float pointSize = platformData().size();
CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
- if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, renderingStyle(platformData()), &glyph, 1, &advance)) {
+ CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
+ if (!CGFontGetGlyphAdvancesForStyle(platformData().cgFont(), &m, style, &glyph, 1, &advance)) {
RetainPtr<CFStringRef> fullName = adoptCF(CGFontCopyFullName(platformData().cgFont()));
LOG_ERROR("Unable to cache glyph widths for %@ %f", fullName.get(), pointSize);
advance.width = 0;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (200562 => 200563)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -29,9 +29,7 @@
#import "WebCoreSystemInterface.h"
#import <wtf/text/WTFString.h>
-#if !PLATFORM(IOS)
-#import <AppKit/NSFont.h>
-#else
+#if PLATFORM(IOS)
#import "CoreGraphicsSPI.h"
#import <CoreText/CoreText.h>
#endif
Modified: trunk/Source/WebKit/mac/ChangeLog (200562 => 200563)
--- trunk/Source/WebKit/mac/ChangeLog 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-05-08 22:54:42 UTC (rev 200563)
@@ -1,3 +1,17 @@
+2016-05-08 Myles C. Maxfield <[email protected]>
+
+ [OS X] Migrate our Font classes entirely off of NSFont
+ https://bugs.webkit.org/show_bug.cgi?id=157464
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/PopupMenuMac.mm:
+ (PopupMenuMac::populate):
+ (PopupMenuMac::show):
+ * WebView/WebHTMLView.mm:
+ (fontNameForDescription):
+ (-[WebHTMLView _addToStyle:fontA:fontB:]):
+
2016-05-06 Joseph Pecoraro <[email protected]>
Rename HitTestRequest DisallowShadowContent to DisallowUserAgentShadowContent
Modified: trunk/Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm (200562 => 200563)
--- trunk/Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -81,12 +81,12 @@
PopupMenuStyle style = m_client->itemStyle(i);
RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] init]);
if (style.font() != FontCascade()) {
- NSFont *font = style.font().primaryFont().getNSFont();
+ RetainPtr<CTFontRef> font = style.font().primaryFont().getCTFont();
if (!font) {
CGFloat size = style.font().primaryFont().platformData().size();
- font = style.font().weight() < FontWeightBold ? [NSFont systemFontOfSize:size] : [NSFont boldSystemFontOfSize:size];
+ font = adoptCF(CTFontCreateUIFontForLanguage(style.font().weight() < FontWeightBold ? kCTFontUIFontSystem : kCTFontUIFontEmphasizedSystem, size, nullptr));
}
- [attributes setObject:font forKey:NSFontAttributeName];
+ [attributes setObject:toNSFont(font.get()) forKey:NSFontAttributeName];
}
RetainPtr<NSMutableParagraphStyle> paragraphStyle = adoptNS([[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
@@ -154,13 +154,13 @@
[m_popup selectItemAtIndex:index];
[m_popup setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
- NSMenu* menu = [m_popup menu];
+ NSMenu *menu = [m_popup menu];
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
[menu setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
#endif
NSPoint location;
- NSFont* font = m_client->menuStyle().font().primaryFont().getNSFont();
+ CTFontRef font = m_client->menuStyle().font().primaryFont().getCTFont();
// These values were borrowed from AppKit to match their placement of the menu.
const int popOverHorizontalAdjust = -10;
@@ -172,8 +172,8 @@
titleFrame = r;
float vertOffset = roundf((NSMaxY(r) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
// Adjust for fonts other than the system font.
- NSFont* defaultFont = [NSFont systemFontOfSize:[font pointSize]];
- vertOffset += [font descender] - [defaultFont descender];
+ auto defaultFont = adoptCF(CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, CTFontGetSize(font), nil));
+ vertOffset += CTFontGetDescent(font) - CTFontGetDescent(defaultFont.get());
vertOffset = fminf(NSHeight(r), vertOffset);
float horizontalOffset = textDirection == LTR ? popOverHorizontalAdjust : 0;
@@ -215,7 +215,7 @@
#pragma clang diagnostic pop
}
- WKPopupMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font, controlSize, !m_client->menuStyle().hasDefaultAppearance());
+ WKPopupMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), index, toNSFont(font), controlSize, !m_client->menuStyle().hasDefaultAppearance());
[m_popup dismissPopUp];
[dummyView removeFromSuperview];
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (200562 => 200563)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -5599,14 +5599,14 @@
return [[NSFontManager sharedFontManager] fontWithFamily:@"Times" traits:NSFontItalicTrait weight:STANDARD_BOLD_WEIGHT size:12.0f];
}
-static NSString *fontNameForDescription(NSString *familyName, BOOL italic, BOOL bold)
+static RetainPtr<CFStringRef> fontNameForDescription(NSString *familyName, BOOL italic, BOOL bold)
{
// Find the font the same way the rendering code would later if it encountered this CSS.
FontDescription fontDescription;
fontDescription.setIsItalic(italic);
fontDescription.setWeight(bold ? FontWeight900 : FontWeight500);
RefPtr<Font> font = FontCache::singleton().fontForFamily(fontDescription, familyName);
- return [font->platformData().nsFont() fontName];
+ return adoptCF(CTFontCopyPostScriptName(font->getCTFont()));
}
- (void)_addToStyle:(DOMCSSStyleDeclaration *)style fontA:(NSFont *)a fontB:(NSFont *)b
@@ -5645,8 +5645,10 @@
// the Postscript name.
// If we don't find a font with the same Postscript name, then we'll have to use the
// Postscript name to make the CSS specific enough.
- if (![fontNameForDescription(aFamilyName, aIsItalic, aIsBold) isEqualToString:[a fontName]])
- familyNameForCSS = [a fontName];
+ auto fontName = fontNameForDescription(aFamilyName, aIsItalic, aIsBold);
+ auto aName = [a fontName];
+ if (!fontName || !aName || !CFEqual(fontName.get(), static_cast<CFStringRef>(aName)))
+ familyNameForCSS = aName;
// FIXME: Need more sophisticated escaping code if we want to handle family names
// with characters like single quote or backslash in their names.
Modified: trunk/Source/WebKit2/ChangeLog (200562 => 200563)
--- trunk/Source/WebKit2/ChangeLog 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit2/ChangeLog 2016-05-08 22:54:42 UTC (rev 200563)
@@ -1,3 +1,15 @@
+2016-05-08 Myles C. Maxfield <[email protected]>
+
+ [OS X] Migrate our Font classes entirely off of NSFont
+ https://bugs.webkit.org/show_bug.cgi?id=157464
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
+ (WebKit::WebPopupMenu::setUpPlatformData):
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::fontAtSelection):
+
2016-05-06 Joseph Pecoraro <[email protected]>
Rename HitTestRequest DisallowShadowContent to DisallowUserAgentShadowContent
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm (200562 => 200563)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -39,15 +39,19 @@
{
#if USE(APPKIT)
// FIXME: font will be nil here for custom fonts, we should fix that.
- NSFont *font = m_popupClient->menuStyle().font().primaryFont().getNSFont();
+ CTFontRef font = m_popupClient->menuStyle().font().primaryFont().getCTFont();
if (!font)
return;
-
- CFDictionaryRef fontDescriptorAttributes = (CFDictionaryRef)[[font fontDescriptor] fontAttributes];
- if (!fontDescriptorAttributes)
+
+ auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(font));
+ if (!fontDescriptor)
return;
+
+ auto attributes = adoptCF(CTFontDescriptorCopyAttributes(fontDescriptor.get()));
+ if (!attributes)
+ return;
- data.fontInfo.fontAttributeDictionary = fontDescriptorAttributes;
+ data.fontInfo.fontAttributeDictionary = attributes.get();
data.shouldPopOver = m_popupClient->shouldPopOver();
data.hideArrows = !m_popupClient->menuStyle().hasDefaultAppearance();
data.menuSize = m_popupClient->menuStyle().menuSize();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (200562 => 200563)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-05-08 21:56:57 UTC (rev 200562)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-05-08 22:54:42 UTC (rev 200563)
@@ -363,11 +363,11 @@
Frame& frame = m_page->focusController().focusedOrMainFrame();
if (!frame.selection().selection().isNone()) {
- const Font* font = frame.editor().fontForSelection(selectionHasMultipleFonts);
- NSFont *nsFont = font ? font->getNSFont() : nil;
- if (nsFont) {
- fontName = nsFont.fontName;
- fontSize = nsFont.pointSize;
+ if (auto* font = frame.editor().fontForSelection(selectionHasMultipleFonts)) {
+ if (auto ctFont = font->getCTFont()) {
+ fontName = adoptCF(CTFontCopyPostScriptName(ctFont)).get();
+ fontSize = CTFontGetSize(ctFont);
+ }
}
}
send(Messages::WebPageProxy::FontAtSelectionCallback(fontName, fontSize, selectionHasMultipleFonts, callbackID));