| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 FontWeight700, | 248 FontWeight700, |
| 249 FontWeight800, | 249 FontWeight800, |
| 250 FontWeight800, | 250 FontWeight800, |
| 251 FontWeight900, | 251 FontWeight900, |
| 252 FontWeight900, | 252 FontWeight900, |
| 253 FontWeight900 | 253 FontWeight900 |
| 254 }; | 254 }; |
| 255 return fontWeights[appKitFontWeight - 1]; | 255 return fontWeights[appKitFontWeight - 1]; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void RenderThemeChromiumMac::systemFont(CSSValueID cssValueId, FontDescription&
fontDescription) const | 258 static inline NSFont* systemNSFont(CSSValueID systemFontID) |
| 259 { | 259 { |
| 260 DEFINE_STATIC_LOCAL(FontDescription, systemFont, ()); | 260 switch (systemFontID) { |
| 261 DEFINE_STATIC_LOCAL(FontDescription, smallSystemFont, ()); | 261 case CSSValueSmallCaption: |
| 262 DEFINE_STATIC_LOCAL(FontDescription, menuFont, ()); | 262 return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
| 263 DEFINE_STATIC_LOCAL(FontDescription, labelFont, ()); | 263 case CSSValueMenu: |
| 264 DEFINE_STATIC_LOCAL(FontDescription, miniControlFont, ()); | 264 return [NSFont menuFontOfSize:[NSFont systemFontSize]]; |
| 265 DEFINE_STATIC_LOCAL(FontDescription, smallControlFont, ()); | 265 case CSSValueStatusBar: |
| 266 DEFINE_STATIC_LOCAL(FontDescription, controlFont, ()); | 266 return [NSFont labelFontOfSize:[NSFont labelFontSize]]; |
| 267 case CSSValueWebkitMiniControl: |
| 268 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSM
iniControlSize]]; |
| 269 case CSSValueWebkitSmallControl: |
| 270 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSS
mallControlSize]]; |
| 271 case CSSValueWebkitControl: |
| 272 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSR
egularControlSize]]; |
| 273 default: |
| 274 return [NSFont systemFontOfSize:[NSFont systemFontSize]]; |
| 275 } |
| 276 } |
| 267 | 277 |
| 268 FontDescription* cachedDesc; | 278 void RenderThemeChromiumMac::systemFont(CSSValueID systemFontID, FontStyle& font
Style, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const |
| 269 NSFont* font = nil; | 279 { |
| 270 switch (cssValueId) { | 280 NSFont* font = systemNSFont(systemFontID); |
| 271 case CSSValueSmallCaption: | 281 if (!font) |
| 272 cachedDesc = &smallSystemFont; | 282 return; |
| 273 if (!smallSystemFont.isAbsoluteSize()) | |
| 274 font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | |
| 275 break; | |
| 276 case CSSValueMenu: | |
| 277 cachedDesc = &menuFont; | |
| 278 if (!menuFont.isAbsoluteSize()) | |
| 279 font = [NSFont menuFontOfSize:[NSFont systemFontSize]]; | |
| 280 break; | |
| 281 case CSSValueStatusBar: | |
| 282 cachedDesc = &labelFont; | |
| 283 if (!labelFont.isAbsoluteSize()) | |
| 284 font = [NSFont labelFontOfSize:[NSFont labelFontSize]]; | |
| 285 break; | |
| 286 case CSSValueWebkitMiniControl: | |
| 287 cachedDesc = &miniControlFont; | |
| 288 if (!miniControlFont.isAbsoluteSize()) | |
| 289 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSMiniControlSize]]; | |
| 290 break; | |
| 291 case CSSValueWebkitSmallControl: | |
| 292 cachedDesc = &smallControlFont; | |
| 293 if (!smallControlFont.isAbsoluteSize()) | |
| 294 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSSmallControlSize]]; | |
| 295 break; | |
| 296 case CSSValueWebkitControl: | |
| 297 cachedDesc = &controlFont; | |
| 298 if (!controlFont.isAbsoluteSize()) | |
| 299 font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControl
Size:NSRegularControlSize]]; | |
| 300 break; | |
| 301 default: | |
| 302 cachedDesc = &systemFont; | |
| 303 if (!systemFont.isAbsoluteSize()) | |
| 304 font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; | |
| 305 } | |
| 306 | 283 |
| 307 if (font) { | 284 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 308 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 285 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle
Italic : FontStyleNormal; |
| 309 cachedDesc->setIsAbsoluteSize(true); | 286 fontWeight = toFontWeight([fontManager weightOfFont:font]); |
| 310 cachedDesc->setGenericFamily(FontDescription::NoFamily); | 287 fontSize = [font pointSize]; |
| 311 cachedDesc->firstFamily().setFamily([font webCoreFamilyName]); | 288 fontFamily = [font webCoreFamilyName]; |
| 312 cachedDesc->setSpecifiedSize([font pointSize]); | |
| 313 cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font])); | |
| 314 cachedDesc->setStyle([fontManager traitsOfFont:font] & NSItalicFontMask)
; | |
| 315 } | |
| 316 fontDescription = *cachedDesc; | |
| 317 } | 289 } |
| 318 | 290 |
| 319 static RGBA32 convertNSColorToColor(NSColor *color) | 291 static RGBA32 convertNSColorToColor(NSColor *color) |
| 320 { | 292 { |
| 321 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; | 293 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; |
| 322 if (colorInColorSpace) { | 294 if (colorInColorSpace) { |
| 323 static const double scaleFactor = nextafter(256.0, 0.0); | 295 static const double scaleFactor = nextafter(256.0, 0.0); |
| 324 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), | 296 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), |
| 325 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), | 297 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), |
| 326 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); | 298 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 | 1870 |
| 1899 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const | 1871 bool RenderThemeChromiumMac::shouldUseFallbackTheme(RenderStyle* style) const |
| 1900 { | 1872 { |
| 1901 ControlPart part = style->appearance(); | 1873 ControlPart part = style->appearance(); |
| 1902 if (part == CheckboxPart || part == RadioPart) | 1874 if (part == CheckboxPart || part == RadioPart) |
| 1903 return style->effectiveZoom() != 1; | 1875 return style->effectiveZoom() != 1; |
| 1904 return false; | 1876 return false; |
| 1905 } | 1877 } |
| 1906 | 1878 |
| 1907 } // namespace WebCore | 1879 } // namespace WebCore |
| OLD | NEW |