Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: Source/core/rendering/RenderThemeChromiumMac.mm

Issue 205743004: Expand system font values during font property parsing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and fix up unittest use of systemFont() Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumMac.h ('k') | Source/core/rendering/RenderThemeChromiumSkia.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumMac.h ('k') | Source/core/rendering/RenderThemeChromiumSkia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698