| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 NSFont* font = systemNSFont(systemFontID); | 243 NSFont* font = systemNSFont(systemFontID); |
| 244 if (!font) | 244 if (!font) |
| 245 return; | 245 return; |
| 246 | 246 |
| 247 NSFontManager* fontManager = [NSFontManager sharedFontManager]; | 247 NSFontManager* fontManager = [NSFontManager sharedFontManager]; |
| 248 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) | 248 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) |
| 249 ? FontStyleItalic | 249 ? FontStyleItalic |
| 250 : FontStyleNormal; | 250 : FontStyleNormal; |
| 251 fontWeight = toFontWeight([fontManager weightOfFont:font]); | 251 fontWeight = toFontWeight([fontManager weightOfFont:font]); |
| 252 fontSize = [font pointSize]; | 252 fontSize = [font pointSize]; |
| 253 fontFamily = @"BlinkMacSystemFont"; | 253 fontFamily = FontFamilyNames::system_ui; |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool LayoutThemeMac::needsHackForTextControlWithFontFamily( | 256 bool LayoutThemeMac::needsHackForTextControlWithFontFamily( |
| 257 const AtomicString& family) const { | 257 const AtomicString& family) const { |
| 258 // This hack is only applied on OSX 10.9. | 258 // This hack is only applied on OSX 10.9. |
| 259 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 | 259 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 |
| 260 return IsOS10_9() && family == "BlinkMacSystemFont"; | 260 return IsOS10_9() && family == FontFamilyNames::system_ui; |
| 261 } | 261 } |
| 262 | 262 |
| 263 static RGBA32 convertNSColorToColor(NSColor* color) { | 263 static RGBA32 convertNSColorToColor(NSColor* color) { |
| 264 NSColor* colorInColorSpace = | 264 NSColor* colorInColorSpace = |
| 265 [color colorUsingColorSpaceName:NSDeviceRGBColorSpace]; | 265 [color colorUsingColorSpaceName:NSDeviceRGBColorSpace]; |
| 266 if (colorInColorSpace) { | 266 if (colorInColorSpace) { |
| 267 static const double scaleFactor = nextafter(256.0, 0.0); | 267 static const double scaleFactor = nextafter(256.0, 0.0); |
| 268 return makeRGB( | 268 return makeRGB( |
| 269 static_cast<int>(scaleFactor * [colorInColorSpace redComponent]), | 269 static_cast<int>(scaleFactor * [colorInColorSpace redComponent]), |
| 270 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), | 270 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // FIXME: This is horrible, but there is not much else that can be done. | 471 // FIXME: This is horrible, but there is not much else that can be done. |
| 472 // Menu lists cannot draw properly when scaled. They can't really draw | 472 // Menu lists cannot draw properly when scaled. They can't really draw |
| 473 // properly when transformed either. We can't detect the transform case | 473 // properly when transformed either. We can't detect the transform case |
| 474 // at style adjustment time so that will just have to stay broken. We | 474 // at style adjustment time so that will just have to stay broken. We |
| 475 // can however detect that we're zooming. If zooming is in effect we | 475 // can however detect that we're zooming. If zooming is in effect we |
| 476 // treat it like the control is styled. | 476 // treat it like the control is styled. |
| 477 if (style.effectiveZoom() != 1.0f) | 477 if (style.effectiveZoom() != 1.0f) |
| 478 return true; | 478 return true; |
| 479 if (!fontSizeMatchesToControlSize(style)) | 479 if (!fontSizeMatchesToControlSize(style)) |
| 480 return true; | 480 return true; |
| 481 if (style.getFontDescription().family().family() != "BlinkMacSystemFont") | 481 if (style.getFontDescription().family().family() != |
| 482 FontFamilyNames::system_ui) |
| 482 return true; | 483 return true; |
| 483 if (!style.height().isIntrinsicOrAuto()) | 484 if (!style.height().isIntrinsicOrAuto()) |
| 484 return true; | 485 return true; |
| 485 // NSPopUpButtonCell on macOS 10.9 doesn't support | 486 // NSPopUpButtonCell on macOS 10.9 doesn't support |
| 486 // NSUserInterfaceLayoutDirectionRightToLeft. | 487 // NSUserInterfaceLayoutDirectionRightToLeft. |
| 487 if (IsOS10_9() && style.direction() == RTL) | 488 if (IsOS10_9() && style.direction() == RTL) |
| 488 return true; | 489 return true; |
| 489 } | 490 } |
| 490 // Some other cells don't work well when scaled. | 491 // Some other cells don't work well when scaled. |
| 491 if (style.effectiveZoom() != 1) { | 492 if (style.effectiveZoom() != 1) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 638 } |
| 638 | 639 |
| 639 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, | 640 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, |
| 640 NSControlSize controlSize) const { | 641 NSControlSize controlSize) const { |
| 641 FontDescription fontDescription; | 642 FontDescription fontDescription; |
| 642 fontDescription.setIsAbsoluteSize(true); | 643 fontDescription.setIsAbsoluteSize(true); |
| 643 fontDescription.setGenericFamily(FontDescription::SerifFamily); | 644 fontDescription.setGenericFamily(FontDescription::SerifFamily); |
| 644 | 645 |
| 645 NSFont* font = [NSFont | 646 NSFont* font = [NSFont |
| 646 systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]]; | 647 systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]]; |
| 647 fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont"); | 648 fontDescription.firstFamily().setFamily(FontFamilyNames::system_ui); |
| 648 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); | 649 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); |
| 649 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); | 650 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); |
| 650 | 651 |
| 651 // Reset line height. | 652 // Reset line height. |
| 652 style.setLineHeight(ComputedStyle::initialLineHeight()); | 653 style.setLineHeight(ComputedStyle::initialLineHeight()); |
| 653 | 654 |
| 654 // TODO(esprehn): The fontSelector manual management is buggy and error prone. | 655 // TODO(esprehn): The fontSelector manual management is buggy and error prone. |
| 655 FontSelector* fontSelector = style.font().getFontSelector(); | 656 FontSelector* fontSelector = style.font().getFontSelector(); |
| 656 if (style.setFontDescription(fontDescription)) | 657 if (style.setFontDescription(fontDescription)) |
| 657 style.font().update(fontSelector); | 658 style.font().update(fontSelector); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const { | 1104 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const { |
| 1104 ControlPart part = style.appearance(); | 1105 ControlPart part = style.appearance(); |
| 1105 if (part == CheckboxPart || part == RadioPart) | 1106 if (part == CheckboxPart || part == RadioPart) |
| 1106 return style.effectiveZoom() != 1; | 1107 return style.effectiveZoom() != 1; |
| 1107 return false; | 1108 return false; |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 } // namespace blink | 1111 } // namespace blink |
| OLD | NEW |