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

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

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/RenderTheme.h ('k') | Source/core/rendering/RenderThemeChromiumFontProvider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderTheme.cpp
diff --git a/Source/core/rendering/RenderTheme.cpp b/Source/core/rendering/RenderTheme.cpp
index 972bcf6c11a8177510972e7bc259e6dcc554732b..bdb0677ea7bf27b7439cad0f28a12584eee8eb42 100644
--- a/Source/core/rendering/RenderTheme.cpp
+++ b/Source/core/rendering/RenderTheme.cpp
@@ -989,6 +989,61 @@ void RenderTheme::platformColorsDidChange()
Page::scheduleForcedStyleRecalcForAllPages();
}
+static FontDescription& getCachedFontDescription(CSSValueID systemFontID)
+{
+ DEFINE_STATIC_LOCAL(FontDescription, caption, ());
+ DEFINE_STATIC_LOCAL(FontDescription, icon, ());
+ DEFINE_STATIC_LOCAL(FontDescription, menu, ());
+ DEFINE_STATIC_LOCAL(FontDescription, messageBox, ());
+ DEFINE_STATIC_LOCAL(FontDescription, smallCaption, ());
+ DEFINE_STATIC_LOCAL(FontDescription, statusBar, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitMiniControl, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitSmallControl, ());
+ DEFINE_STATIC_LOCAL(FontDescription, webkitControl, ());
+ switch (systemFontID) {
+ case CSSValueCaption:
+ return caption;
+ case CSSValueIcon:
+ return icon;
+ case CSSValueMenu:
+ return menu;
+ case CSSValueMessageBox:
+ return messageBox;
+ case CSSValueSmallCaption:
+ return smallCaption;
+ case CSSValueStatusBar:
+ return statusBar;
+ case CSSValueWebkitMiniControl:
+ return webkitMiniControl;
+ case CSSValueWebkitSmallControl:
+ return webkitSmallControl;
+ case CSSValueWebkitControl:
+ return webkitControl;
+ default:
+ ASSERT_NOT_REACHED();
+ return caption;
+ }
+}
+
+void RenderTheme::systemFont(CSSValueID systemFontID, FontDescription& fontDescription)
+{
+ fontDescription = getCachedFontDescription(systemFontID);
+ if (fontDescription.isAbsoluteSize())
+ return;
+
+ FontStyle fontStyle = FontStyleNormal;
+ FontWeight fontWeight = FontWeightNormal;
+ float fontSize = 0;
+ AtomicString fontFamily;
+ systemFont(systemFontID, fontStyle, fontWeight, fontSize, fontFamily);
+ fontDescription.setStyle(fontStyle);
+ fontDescription.setWeight(fontWeight);
+ fontDescription.setSpecifiedSize(fontSize);
+ fontDescription.setIsAbsoluteSize(true);
+ fontDescription.firstFamily().setFamily(fontFamily);
+ fontDescription.setGenericFamily(FontDescription::NoFamily);
+}
+
Color RenderTheme::systemColor(CSSValueID cssValueId) const
{
switch (cssValueId) {
« no previous file with comments | « Source/core/rendering/RenderTheme.h ('k') | Source/core/rendering/RenderThemeChromiumFontProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698