| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return oldAquaFocusRingColor; | 169 return oldAquaFocusRingColor; |
| 170 | 170 |
| 171 return systemColor(CSSValueWebkitFocusRingColor); | 171 return systemColor(CSSValueWebkitFocusRingColor); |
| 172 } | 172 } |
| 173 | 173 |
| 174 Color LayoutThemeMac::platformInactiveListBoxSelectionBackgroundColor() const | 174 Color LayoutThemeMac::platformInactiveListBoxSelectionBackgroundColor() const |
| 175 { | 175 { |
| 176 return platformInactiveSelectionBackgroundColor(); | 176 return platformInactiveSelectionBackgroundColor(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 static FontWeight toFontWeight(NSInteger appKitFontWeight) | 179 static inline CGFloat systemNSFontSize(CSSValueID systemFontID) |
| 180 { | |
| 181 ASSERT(appKitFontWeight > 0 && appKitFontWeight < 15); | |
| 182 if (appKitFontWeight > 14) | |
| 183 appKitFontWeight = 14; | |
| 184 else if (appKitFontWeight < 1) | |
| 185 appKitFontWeight = 1; | |
| 186 | |
| 187 static FontWeight fontWeights[] = { | |
| 188 FontWeight100, | |
| 189 FontWeight100, | |
| 190 FontWeight200, | |
| 191 FontWeight300, | |
| 192 FontWeight400, | |
| 193 FontWeight500, | |
| 194 FontWeight600, | |
| 195 FontWeight600, | |
| 196 FontWeight700, | |
| 197 FontWeight800, | |
| 198 FontWeight800, | |
| 199 FontWeight900, | |
| 200 FontWeight900, | |
| 201 FontWeight900 | |
| 202 }; | |
| 203 return fontWeights[appKitFontWeight - 1]; | |
| 204 } | |
| 205 | |
| 206 static inline NSFont* systemNSFont(CSSValueID systemFontID) | |
| 207 { | 180 { |
| 208 switch (systemFontID) { | 181 switch (systemFontID) { |
| 209 case CSSValueSmallCaption: | 182 case CSSValueSmallCaption: |
| 210 return [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | 183 return [NSFont smallSystemFontSize]; |
| 211 case CSSValueMenu: | 184 case CSSValueMenu: |
| 212 return [NSFont menuFontOfSize:[NSFont systemFontSize]]; | 185 return [NSFont systemFontSize]; |
| 213 case CSSValueStatusBar: | 186 case CSSValueStatusBar: |
| 214 return [NSFont labelFontOfSize:[NSFont labelFontSize]]; | 187 return [NSFont labelFontSize]; |
| 215 case CSSValueWebkitMiniControl: | 188 case CSSValueWebkitMiniControl: |
| 216 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSM
iniControlSize]]; | 189 return [NSFont systemFontSizeForControlSize:NSMiniControlSize]; |
| 217 case CSSValueWebkitSmallControl: | 190 case CSSValueWebkitSmallControl: |
| 218 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSS
mallControlSize]]; | 191 return [NSFont systemFontSizeForControlSize:NSSmallControlSize]; |
| 219 case CSSValueWebkitControl: | 192 case CSSValueWebkitControl: |
| 220 return [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSR
egularControlSize]]; | 193 return [NSFont systemFontSizeForControlSize:NSRegularControlSize]; |
| 221 default: | 194 default: |
| 222 return [NSFont systemFontOfSize:[NSFont systemFontSize]]; | 195 return [NSFont systemFontSize]; |
| 223 } | 196 } |
| 224 } | 197 } |
| 225 | 198 |
| 226 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F
ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const | 199 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F
ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const |
| 227 { | 200 { |
| 228 NSFont* font = systemNSFont(systemFontID); | 201 fontStyle = FontStyleNormal; |
| 229 if (!font) | 202 fontWeight = FontWeightNormal; |
| 230 return; | 203 fontSize = systemNSFontSize(systemFontID); |
| 231 | |
| 232 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | |
| 233 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle
Italic : FontStyleNormal; | |
| 234 fontWeight = toFontWeight([fontManager weightOfFont:font]); | |
| 235 fontSize = [font pointSize]; | |
| 236 fontFamily = @"BlinkMacSystemFont"; | 204 fontFamily = @"BlinkMacSystemFont"; |
| 237 } | 205 } |
| 238 | 206 |
| 239 bool LayoutThemeMac::needsHackForTextControlWithFontFamily(const AtomicString& f
amily) const | 207 bool LayoutThemeMac::needsHackForTextControlWithFontFamily(const AtomicString& f
amily) const |
| 240 { | 208 { |
| 241 // This hack is only applied on OSX 10.9. | 209 // This hack is only applied on OSX 10.9. |
| 242 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 | 210 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 |
| 243 return IsOSMavericks() && family == "BlinkMacSystemFont"; | 211 return IsOSMavericks() && family == "BlinkMacSystemFont"; |
| 244 } | 212 } |
| 245 | 213 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 if (style.height().isAuto() && size.height() > 0) | 562 if (style.height().isAuto() && size.height() > 0) |
| 595 style.setHeight(Length(size.height(), Fixed)); | 563 style.setHeight(Length(size.height(), Fixed)); |
| 596 } | 564 } |
| 597 | 565 |
| 598 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
controlSize) const | 566 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
controlSize) const |
| 599 { | 567 { |
| 600 FontDescription fontDescription; | 568 FontDescription fontDescription; |
| 601 fontDescription.setIsAbsoluteSize(true); | 569 fontDescription.setIsAbsoluteSize(true); |
| 602 fontDescription.setGenericFamily(FontDescription::SerifFamily); | 570 fontDescription.setGenericFamily(FontDescription::SerifFamily); |
| 603 | 571 |
| 604 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; | 572 CGFloat pointSize = [NSFont systemFontSizeForControlSize:controlSize]; |
| 605 fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont"); | 573 fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont"); |
| 606 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); | 574 fontDescription.setComputedSize(pointSize * style.effectiveZoom()); |
| 607 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); | 575 fontDescription.setSpecifiedSize(pointSize * style.effectiveZoom()); |
| 608 | 576 |
| 609 // Reset line height. | 577 // Reset line height. |
| 610 style.setLineHeight(ComputedStyle::initialLineHeight()); | 578 style.setLineHeight(ComputedStyle::initialLineHeight()); |
| 611 | 579 |
| 612 // TODO(esprehn): The fontSelector manual management is buggy and error pron
e. | 580 // TODO(esprehn): The fontSelector manual management is buggy and error pron
e. |
| 613 FontSelector* fontSelector = style.font().getFontSelector(); | 581 FontSelector* fontSelector = style.font().getFontSelector(); |
| 614 if (style.setFontDescription(fontDescription)) | 582 if (style.setFontDescription(fontDescription)) |
| 615 style.font().update(fontSelector); | 583 style.font().update(fontSelector); |
| 616 } | 584 } |
| 617 | 585 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1045 |
| 1078 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const | 1046 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const |
| 1079 { | 1047 { |
| 1080 ControlPart part = style.appearance(); | 1048 ControlPart part = style.appearance(); |
| 1081 if (part == CheckboxPart || part == RadioPart) | 1049 if (part == CheckboxPart || part == RadioPart) |
| 1082 return style.effectiveZoom() != 1; | 1050 return style.effectiveZoom() != 1; |
| 1083 return false; | 1051 return false; |
| 1084 } | 1052 } |
| 1085 | 1053 |
| 1086 } // namespace blink | 1054 } // namespace blink |
| OLD | NEW |