| 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 19 matching lines...) Expand all Loading... |
| 30 #import "core/layout/LayoutView.h" | 30 #import "core/layout/LayoutView.h" |
| 31 #import "core/paint/MediaControlsPainter.h" | 31 #import "core/paint/MediaControlsPainter.h" |
| 32 #import "core/style/AuthorStyleInfo.h" | 32 #import "core/style/AuthorStyleInfo.h" |
| 33 #import "core/style/ShadowList.h" | 33 #import "core/style/ShadowList.h" |
| 34 #import "platform/LayoutTestSupport.h" | 34 #import "platform/LayoutTestSupport.h" |
| 35 #import "platform/PlatformResourceLoader.h" | 35 #import "platform/PlatformResourceLoader.h" |
| 36 #import "platform/graphics/BitmapImage.h" | 36 #import "platform/graphics/BitmapImage.h" |
| 37 #import "platform/mac/ColorMac.h" | 37 #import "platform/mac/ColorMac.h" |
| 38 #import "platform/mac/LocalCurrentGraphicsContext.h" | 38 #import "platform/mac/LocalCurrentGraphicsContext.h" |
| 39 #import "platform/mac/ThemeMac.h" | 39 #import "platform/mac/ThemeMac.h" |
| 40 #import "platform/mac/VersionUtilMac.h" |
| 40 #import "platform/mac/WebCoreNSCellExtras.h" | 41 #import "platform/mac/WebCoreNSCellExtras.h" |
| 41 #import "platform/text/PlatformLocale.h" | 42 #import "platform/text/PlatformLocale.h" |
| 42 #import "platform/text/StringTruncator.h" | 43 #import "platform/text/StringTruncator.h" |
| 43 #import <AvailabilityMacros.h> | 44 #import <AvailabilityMacros.h> |
| 44 #import <Carbon/Carbon.h> | 45 #import <Carbon/Carbon.h> |
| 45 #import <Cocoa/Cocoa.h> | 46 #import <Cocoa/Cocoa.h> |
| 46 #import <math.h> | 47 #import <math.h> |
| 47 | 48 |
| 48 // The methods in this file are specific to the Mac OS X platform. | 49 // The methods in this file are specific to the Mac OS X platform. |
| 49 | 50 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F
ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const | 232 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F
ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const |
| 232 { | 233 { |
| 233 NSFont* font = systemNSFont(systemFontID); | 234 NSFont* font = systemNSFont(systemFontID); |
| 234 if (!font) | 235 if (!font) |
| 235 return; | 236 return; |
| 236 | 237 |
| 237 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 238 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
| 238 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle
Italic : FontStyleNormal; | 239 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle
Italic : FontStyleNormal; |
| 239 fontWeight = toFontWeight([fontManager weightOfFont:font]); | 240 fontWeight = toFontWeight([fontManager weightOfFont:font]); |
| 240 fontSize = [font pointSize]; | 241 fontSize = [font pointSize]; |
| 241 fontFamily = [font webCoreFamilyName]; | 242 fontFamily = @"BlinkMacSystemFont"; |
| 243 } |
| 244 |
| 245 bool LayoutThemeMac::needsHackForTextControlWithFontFamily(const AtomicString& f
amily) const |
| 246 { |
| 247 // This hack is only applied on OSX 10.9 and earlier. |
| 248 // https://code.google.com/p/chromium/issues/detail?id=515989#c8 |
| 249 return IsOSMavericksOrEarlier() && family == "BlinkMacSystemFont"; |
| 242 } | 250 } |
| 243 | 251 |
| 244 static RGBA32 convertNSColorToColor(NSColor *color) | 252 static RGBA32 convertNSColorToColor(NSColor *color) |
| 245 { | 253 { |
| 246 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; | 254 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo
rSpace]; |
| 247 if (colorInColorSpace) { | 255 if (colorInColorSpace) { |
| 248 static const double scaleFactor = nextafter(256.0, 0.0); | 256 static const double scaleFactor = nextafter(256.0, 0.0); |
| 249 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), | 257 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp
onent]), |
| 250 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), | 258 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), |
| 251 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); | 259 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 style.setHeight(Length(size.height(), Fixed)); | 593 style.setHeight(Length(size.height(), Fixed)); |
| 586 } | 594 } |
| 587 | 595 |
| 588 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
controlSize) const | 596 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
controlSize) const |
| 589 { | 597 { |
| 590 FontDescription fontDescription; | 598 FontDescription fontDescription; |
| 591 fontDescription.setIsAbsoluteSize(true); | 599 fontDescription.setIsAbsoluteSize(true); |
| 592 fontDescription.setGenericFamily(FontDescription::SerifFamily); | 600 fontDescription.setGenericFamily(FontDescription::SerifFamily); |
| 593 | 601 |
| 594 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; | 602 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; |
| 595 fontDescription.firstFamily().setFamily([font webCoreFamilyName]); | 603 fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont"); |
| 596 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); | 604 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); |
| 597 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); | 605 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); |
| 598 | 606 |
| 599 // Reset line height. | 607 // Reset line height. |
| 600 style.setLineHeight(ComputedStyle::initialLineHeight()); | 608 style.setLineHeight(ComputedStyle::initialLineHeight()); |
| 601 | 609 |
| 602 // TODO(esprehn): The fontSelector manual management is buggy and error pron
e. | 610 // TODO(esprehn): The fontSelector manual management is buggy and error pron
e. |
| 603 FontSelector* fontSelector = style.font().fontSelector(); | 611 FontSelector* fontSelector = style.font().fontSelector(); |
| 604 if (style.setFontDescription(fontDescription)) | 612 if (style.setFontDescription(fontDescription)) |
| 605 style.font().update(fontSelector); | 613 style.font().update(fontSelector); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 | 1166 |
| 1159 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const | 1167 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const |
| 1160 { | 1168 { |
| 1161 ControlPart part = style.appearance(); | 1169 ControlPart part = style.appearance(); |
| 1162 if (part == CheckboxPart || part == RadioPart) | 1170 if (part == CheckboxPart || part == RadioPart) |
| 1163 return style.effectiveZoom() != 1; | 1171 return style.effectiveZoom() != 1; |
| 1164 return false; | 1172 return false; |
| 1165 } | 1173 } |
| 1166 | 1174 |
| 1167 } // namespace blink | 1175 } // namespace blink |
| OLD | NEW |