Index: Source/core/rendering/RenderTheme.cpp |
diff --git a/Source/core/rendering/RenderTheme.cpp b/Source/core/rendering/RenderTheme.cpp |
index b150048a564f303cdd7ad83b48a5835f45ed66cc..f07705b80733f7292781595312792a7370615a39 100644 |
--- a/Source/core/rendering/RenderTheme.cpp |
+++ b/Source/core/rendering/RenderTheme.cpp |
@@ -940,6 +940,64 @@ 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, ()); |
+ DEFINE_STATIC_LOCAL(FontDescription, defaultDescription, ()); |
+ 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; |
+ case CSSValueNone: |
+ return defaultDescription; |
+ default: |
+ ASSERT_NOT_REACHED(); |
+ return defaultDescription; |
+ } |
+} |
+ |
+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) { |