OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Google, Inc. | 3 * Copyright (C) 2008, 2009 Google, Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 FontWeight700, | 231 FontWeight700, |
232 FontWeight800, | 232 FontWeight800, |
233 FontWeight800, | 233 FontWeight800, |
234 FontWeight900, | 234 FontWeight900, |
235 FontWeight900, | 235 FontWeight900, |
236 FontWeight900 | 236 FontWeight900 |
237 }; | 237 }; |
238 return fontWeights[appKitFontWeight - 1]; | 238 return fontWeights[appKitFontWeight - 1]; |
239 } | 239 } |
240 | 240 |
241 void RenderThemeChromiumMac::systemFont(CSSValueID cssValueId, FontDescription&
fontDescription) const | 241 static inline NSFont* systemNSFont(CSSValueID systemFontID) |
242 { | 242 { |
243 DEFINE_STATIC_LOCAL(FontDescription, systemFont, ()); | 243 switch (systemFontID) { |
244 DEFINE_STATIC_LOCAL(FontDescription, smallSystemFont, ()); | 244 case CSSValueSmallCaption: |
245 DEFINE_STATIC_LOCAL(FontDescription, menuFont, ()); | 245 return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
246 DEFINE_STATIC_LOCAL(FontDescription, labelFont, ()); | 246 case CSSValueMenu: |
247 DEFINE_STATIC_LOCAL(FontDescription, miniControlFont, ()); | 247 return [NSFont menuFontOfSize:[NSFont systemFontSize]]; |
248 DEFINE_STATIC_LOCAL(FontDescription, smallControlFont, ()); | 248 case CSSValueStatusBar: |
249 DEFINE_STATIC_LOCAL(FontDescription, controlFont, ()); | 249 return [NSFont labelFontOfSize:[NSFont labelFontSize]]; |
| 250 case CSSValueWebkitMiniControl: |
| 251 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSM
iniControlSize]]; |
| 252 case CSSValueWebkitSmallControl: |
| 253 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSS
mallControlSize]]; |
| 254 case CSSValueWebkitControl: |
| 255 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSR
egularControlSize]]; |
| 256 default: |
| 257 return [NSFont systemFontOfSize:[NSFont systemFontSize]]; |
| 258 } |
| 259 } |
250 | 260 |
251 FontDescription* cachedDesc; | 261 void RenderThemeChromiumMac::systemFont(CSSValueID systemFontID, FontStyle& font
Style, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const |
252 NSFont* font = nil; | 262 { |
253 switch (cssValueId) { | 263 NSFont* font = systemNSFont(systemFontID); |
254 case CSSValueSmallCaption: | 264 if (!font) |
255 cachedDesc = &smallSystemFont; | 265 return; |
256 if (!smallSystemFont.isAbsoluteSize()) | |
257 font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | |
258 break; | |
259 case CSSValueMenu: | |
260 cachedDesc = &menuFont; | |
261 if (!menuFont.isAbsoluteSize()) | |
262 font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; | |
263 break; | |
264 case CSSValueStatusBar: | |
265 cachedDesc = &labelFont; | |
266 if (!labelFont.isAbsoluteSize()) | |
267 font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; | |
268 break; | |
269 case CSSValueWebkitMiniControl: | |
270 cachedDesc = &miniControlFont; | |
271 if (!miniControlFont.isAbsoluteSize()) | |
272 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSMiniControlSize]]; | |
273 break; | |
274 case CSSValueWebkitSmallControl: | |
275 cachedDesc = &smallControlFont; | |
276 if (!smallControlFont.isAbsoluteSize()) | |
277 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSSmallControlSize]]; | |
278 break; | |
279 case CSSValueWebkitControl: | |
280 cachedDesc = &controlFont; | |
281 if (!controlFont.isAbsoluteSize()) | |
282 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:NSRegularControlSize]]; | |
283 break; | |
284 default: | |
285 cachedDesc = &systemFont; | |
286 if (!systemFont.isAbsoluteSize()) | |
287 font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; | |
288 } | |
289 | 266 |
290 if (font) { | 267 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
291 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 268 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle
Italic : FontStyleNormal; |
292 cachedDesc->setIsAbsoluteSize(true); | 269 fontWeight = toFontWeight([fontManager weightOfFont:font]); |
293 cachedDesc->setGenericFamily(FontDescription::NoFamily); | 270 fontSize = [font pointSize]; |
294 cachedDesc->firstFamily().setFamily([font webCoreFamilyName]); | 271 fontFamily = [font webCoreFamilyName]; |
295 cachedDesc->setSpecifiedSize([font pointSize]); | |
296 cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); | |
297 cachedDesc->setStyle([fontManager traitsOfFont:font] & NSItalicFontMask
? FontStyleItalic : FontStyleNormal); | |
298 } | |
299 fontDescription = *cachedDesc; | |
300 } | 272 } |
301 | 273 |
302 static RGBA32 convertNSColorToColor(NSColor *color) | 274 static RGBA32 convertNSColorToColor(NSColor *color) |
303 { | 275 { |
304 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; | 276 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; |
305 if (colorInColorSpace) { | 277 if (colorInColorSpace) { |
306 static const double scaleFactor = nextafter(256.0, 0.0); | 278 static const double scaleFactor = nextafter(256.0, 0.0); |
307 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), | 279 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), |
308 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), | 280 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), |
309 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); | 281 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); |
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 | 1843 |
1872 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const | 1844 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const |
1873 { | 1845 { |
1874 ControlPart part = style->appearance(); | 1846 ControlPart part = style->appearance(); |
1875 if (part == CheckboxPart || part == RadioPart) | 1847 if (part == CheckboxPart || part == RadioPart) |
1876 return style->effectiveZoom() != 1; | 1848 return style->effectiveZoom() != 1; |
1877 return false; | 1849 return false; |
1878 } | 1850 } |
1879 | 1851 |
1880 } // namespace blink | 1852 } // namespace blink |
OLD | NEW |