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

Unified Diff: Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp

Issue 677103002: Expand system font values during property parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove isExpandedShorthandForAll. Created 6 years, 2 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
Index: Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp
diff --git a/Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp b/Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp
index 810f724330d53f6c5c274d36fb7c487156359dfd..775b489b60c026d9660d5167833e0a8d6604b921 100644
--- a/Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp
+++ b/Source/core/rendering/RenderThemeChromiumFontProviderWin.cpp
@@ -41,24 +41,6 @@
namespace blink {
-static FontDescription& smallSystemFont()
-{
- DEFINE_STATIC_LOCAL(FontDescription, font, ());
- return font;
-}
-
-static FontDescription& menuFont()
-{
- DEFINE_STATIC_LOCAL(FontDescription, font, ());
- return font;
-}
-
-static FontDescription& labelFont()
-{
- DEFINE_STATIC_LOCAL(FontDescription, font, ());
- return font;
-}
-
// Converts |points| to pixels. One point is 1/72 of an inch.
static float pointsToPixels(float points)
{
@@ -118,74 +100,51 @@ static float systemFontSize(const LOGFONT& font)
}
// static
-void RenderThemeChromiumFontProvider::systemFont(CSSValueID valueID, FontDescription& fontDescription)
+void RenderThemeChromiumFontProvider::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamily)
{
- // This logic owes much to RenderThemeSafari.cpp.
- FontDescription* cachedDesc = 0;
- AtomicString faceName;
- float fontSize = 0;
- switch (valueID) {
- case CSSValueSmallCaption:
- cachedDesc = &smallSystemFont();
- if (!smallSystemFont().isAbsoluteSize()) {
- NONCLIENTMETRICS metrics;
- getNonClientMetrics(&metrics);
- faceName = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen(metrics.lfSmCaptionFont.lfFaceName));
- fontSize = systemFontSize(metrics.lfSmCaptionFont);
- }
+ fontStyle = FontStyleNormal;
+ fontWeight = FontWeightNormal;
+
+ switch (systemFontID) {
+ case CSSValueSmallCaption: {
+ NONCLIENTMETRICS metrics;
+ getNonClientMetrics(&metrics);
+ fontSize = systemFontSize(metrics.lfSmCaptionFont);
+ fontFamily = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen(metrics.lfSmCaptionFont.lfFaceName));
break;
- case CSSValueMenu:
- cachedDesc = &menuFont();
- if (!menuFont().isAbsoluteSize()) {
- NONCLIENTMETRICS metrics;
- getNonClientMetrics(&metrics);
- faceName = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metrics.lfMenuFont.lfFaceName));
- fontSize = systemFontSize(metrics.lfMenuFont);
- }
+ }
+ case CSSValueMenu: {
+ NONCLIENTMETRICS metrics;
+ getNonClientMetrics(&metrics);
+ fontSize = systemFontSize(metrics.lfMenuFont);
+ fontFamily = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metrics.lfMenuFont.lfFaceName));
break;
- case CSSValueStatusBar:
- cachedDesc = &labelFont();
- if (!labelFont().isAbsoluteSize()) {
- NONCLIENTMETRICS metrics;
- getNonClientMetrics(&metrics);
- faceName = metrics.lfStatusFont.lfFaceName;
- fontSize = systemFontSize(metrics.lfStatusFont);
- }
+ }
+ case CSSValueStatusBar: {
+ NONCLIENTMETRICS metrics;
+ getNonClientMetrics(&metrics);
+ fontSize = systemFontSize(metrics.lfStatusFont);
+ fontFamily = metrics.lfStatusFont.lfFaceName;
break;
+ }
case CSSValueWebkitMiniControl:
case CSSValueWebkitSmallControl:
case CSSValueWebkitControl:
- faceName = defaultGUIFont();
// Why 2 points smaller? Because that's what Gecko does.
fontSize = s_defaultFontSize - pointsToPixels(2);
+ fontFamily = defaultGUIFont();
break;
default:
- faceName = defaultGUIFont();
fontSize = s_defaultFontSize;
+ fontFamily = defaultGUIFont();
break;
}
-
- if (!cachedDesc)
- cachedDesc = &fontDescription;
-
- if (fontSize) {
- cachedDesc->firstFamily().setFamily(faceName);
- cachedDesc->setIsAbsoluteSize(true);
- cachedDesc->setGenericFamily(FontDescription::NoFamily);
- cachedDesc->setSpecifiedSize(fontSize);
- cachedDesc->setWeight(FontWeightNormal);
- cachedDesc->setStyle(FontStyleNormal);
- }
- fontDescription = *cachedDesc;
}
// static
void RenderThemeChromiumFontProvider::setDefaultFontSize(int fontSize)
{
s_defaultFontSize = static_cast<float>(fontSize);
-
- // Reset cached fonts.
- smallSystemFont() = menuFont() = labelFont() = FontDescription();
}
} // namespace blink
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumFontProviderLinux.cpp ('k') | Source/core/rendering/RenderThemeChromiumMac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698