Index: Source/core/rendering/RenderThemeChromiumMac.mm |
diff --git a/Source/core/rendering/RenderThemeChromiumMac.mm b/Source/core/rendering/RenderThemeChromiumMac.mm |
index 4f41185a68ad9209384abff0f07ae11df5db3274..a683093f17a95a7e95a2111233eec6a3273d6610 100644 |
--- a/Source/core/rendering/RenderThemeChromiumMac.mm |
+++ b/Source/core/rendering/RenderThemeChromiumMac.mm |
@@ -255,65 +255,37 @@ static FontWeight toFontWeight(NSInteger appKitFontWeight) |
return fontWeights[appKitFontWeight - 1]; |
} |
-void RenderThemeChromiumMac::systemFont(CSSValueID cssValueId, FontDescription& fontDescription) const |
-{ |
- DEFINE_STATIC_LOCAL(FontDescription, systemFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, smallSystemFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, menuFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, labelFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, miniControlFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, smallControlFont, ()); |
- DEFINE_STATIC_LOCAL(FontDescription, controlFont, ()); |
- |
- FontDescription* cachedDesc; |
- NSFont* font = nil; |
- switch (cssValueId) { |
- case CSSValueSmallCaption: |
- cachedDesc = &smallSystemFont; |
- if (!smallSystemFont.isAbsoluteSize()) |
- font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
- break; |
- case CSSValueMenu: |
- cachedDesc = &menuFont; |
- if (!menuFont.isAbsoluteSize()) |
- font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; |
- break; |
- case CSSValueStatusBar: |
- cachedDesc = &labelFont; |
- if (!labelFont.isAbsoluteSize()) |
- font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; |
- break; |
- case CSSValueWebkitMiniControl: |
- cachedDesc = &miniControlFont; |
- if (!miniControlFont.isAbsoluteSize()) |
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]; |
- break; |
- case CSSValueWebkitSmallControl: |
- cachedDesc = &smallControlFont; |
- if (!smallControlFont.isAbsoluteSize()) |
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; |
- break; |
- case CSSValueWebkitControl: |
- cachedDesc = &controlFont; |
- if (!controlFont.isAbsoluteSize()) |
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; |
- break; |
- default: |
- cachedDesc = &systemFont; |
- if (!systemFont.isAbsoluteSize()) |
- font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; |
+static inline NSFont* systemNSFont(CSSValueID systemFontID) |
+{ |
+ switch (systemFontID) { |
+ case CSSValueSmallCaption: |
+ return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
+ case CSSValueMenu: |
+ return [NSFont menuFontOfSize:[NSFont systemFontSize]]; |
+ case CSSValueStatusBar: |
+ return [NSFont labelFontOfSize:[NSFont labelFontSize]]; |
+ case CSSValueWebkitMiniControl: |
+ return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]]; |
+ case CSSValueWebkitSmallControl: |
+ return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; |
+ case CSSValueWebkitControl: |
+ return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]; |
+ default: |
+ return [NSFont systemFontOfSize:[NSFont systemFontSize]]; |
} |
+} |
- if (font) { |
- NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
- cachedDesc->setIsAbsoluteSize(true); |
- cachedDesc->setGenericFamily(FontDescription::NoFamily); |
- cachedDesc->firstFamily().setFamily([font webCoreFamilyName]); |
- cachedDesc->setSpecifiedSize([font pointSize]); |
- cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); |
- cachedDesc->setStyle([fontManager traitsOfFont:font] & NSItalicFontMask); |
- } |
- fontDescription = *cachedDesc; |
+void RenderThemeChromiumMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const |
+{ |
+ NSFont* font = systemNSFont(systemFontID); |
+ if (!font) |
+ return; |
+ |
+ NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
+ fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyleItalic : FontStyleNormal; |
+ fontWeight = toFontWeight([fontManager weightOfFont:font]); |
+ fontSize = [font pointSize]; |
+ fontFamily = [font webCoreFamilyName]; |
} |
static RGBA32 convertNSColorToColor(NSColor *color) |