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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutThemeMac.mm

Issue 2073693002: Avoid loading system fonts in LayoutThemeMac::systemFont (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do the same in setFontFromControlSize Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutThemeMac.mm
diff --git a/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm b/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm
index 302425907212e563ceb2d6ee58f703ddaacac476..bbce38e9ec8ab05867d6557c7a066bad6a3e0f4e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm
+++ b/third_party/WebKit/Source/core/layout/LayoutThemeMac.mm
@@ -176,63 +176,31 @@ Color LayoutThemeMac::platformInactiveListBoxSelectionBackgroundColor() const
return platformInactiveSelectionBackgroundColor();
}
-static FontWeight toFontWeight(NSInteger appKitFontWeight)
-{
- ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15);
- if (appKitFontWeight > 14)
- appKitFontWeight = 14;
- else if (appKitFontWeight < 1)
- appKitFontWeight = 1;
-
- static FontWeight fontWeights[] = {
- FontWeight100,
- FontWeight100,
- FontWeight200,
- FontWeight300,
- FontWeight400,
- FontWeight500,
- FontWeight600,
- FontWeight600,
- FontWeight700,
- FontWeight800,
- FontWeight800,
- FontWeight900,
- FontWeight900,
- FontWeight900
- };
- return fontWeights[appKitFontWeight - 1];
-}
-
-static inline NSFont* systemNSFont(CSSValueID systemFontID)
+static inline CGFloat systemNSFontSize(CSSValueID systemFontID)
{
switch (systemFontID) {
case CSSValueSmallCaption:
- return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+ return [NSFont smallSystemFontSize];
case CSSValueMenu:
- return [NSFont menuFontOfSize:[NSFont systemFontSize]];
+ return [NSFont systemFontSize];
case CSSValueStatusBar:
- return [NSFont labelFontOfSize:[NSFont labelFontSize]];
+ return [NSFont labelFontSize];
case CSSValueWebkitMiniControl:
- return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
+ return [NSFont systemFontSizeForControlSize:NSMiniControlSize];
case CSSValueWebkitSmallControl:
- return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
+ return [NSFont systemFontSizeForControlSize:NSSmallControlSize];
case CSSValueWebkitControl:
- return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
+ return [NSFont systemFontSizeForControlSize:NSRegularControlSize];
default:
- return [NSFont systemFontOfSize:[NSFont systemFontSize]];
+ return [NSFont systemFontSize];
}
}
void LayoutThemeMac::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];
+ fontStyle = FontStyleNormal;
+ fontWeight = FontWeightNormal;
+ fontSize = systemNSFontSize(systemFontID);
fontFamily = @"BlinkMacSystemFont";
}
@@ -601,10 +569,10 @@ void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
fontDescription.setIsAbsoluteSize(true);
fontDescription.setGenericFamily(FontDescription::SerifFamily);
- NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
+ CGFloat pointSize = [NSFont systemFontSizeForControlSize:controlSize];
fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont");
- fontDescription.setComputedSize([font pointSize] * style.effectiveZoom());
- fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom());
+ fontDescription.setComputedSize(pointSize * style.effectiveZoom());
+ fontDescription.setSpecifiedSize(pointSize * style.effectiveZoom());
// Reset line height.
style.setLineHeight(ComputedStyle::initialLineHeight());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698