Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: Source/core/layout/LayoutThemeMac.mm

Issue 1299653004: Revert "Reland 2: mac: Use a placeholder string for the family name of the system font." (branch 248 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@2485
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/layout/LayoutThemeMac.h ('k') | Source/platform/blink_platform.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
41 #import "platform/mac/WebCoreNSCellExtras.h" 40 #import "platform/mac/WebCoreNSCellExtras.h"
42 #import "platform/text/PlatformLocale.h" 41 #import "platform/text/PlatformLocale.h"
43 #import "platform/text/StringTruncator.h" 42 #import "platform/text/StringTruncator.h"
44 #import <AvailabilityMacros.h> 43 #import <AvailabilityMacros.h>
45 #import <Carbon/Carbon.h> 44 #import <Carbon/Carbon.h>
46 #import <Cocoa/Cocoa.h> 45 #import <Cocoa/Cocoa.h>
47 #import <math.h> 46 #import <math.h>
48 47
49 // The methods in this file are specific to the Mac OS X platform. 48 // The methods in this file are specific to the Mac OS X platform.
50 49
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const 231 void LayoutThemeMac::systemFont(CSSValueID systemFontID, FontStyle& fontStyle, F ontWeight& fontWeight, float& fontSize, AtomicString& fontFamily) const
233 { 232 {
234 NSFont* font = systemNSFont(systemFontID); 233 NSFont* font = systemNSFont(systemFontID);
235 if (!font) 234 if (!font)
236 return; 235 return;
237 236
238 NSFontManager *fontManager = [NSFontManager sharedFontManager]; 237 NSFontManager *fontManager = [NSFontManager sharedFontManager];
239 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle Italic : FontStyleNormal; 238 fontStyle = ([fontManager traitsOfFont:font] & NSItalicFontMask) ? FontStyle Italic : FontStyleNormal;
240 fontWeight = toFontWeight([fontManager weightOfFont:font]); 239 fontWeight = toFontWeight([fontManager weightOfFont:font]);
241 fontSize = [font pointSize]; 240 fontSize = [font pointSize];
242 fontFamily = @"BlinkMacSystemFont"; 241 fontFamily = [font webCoreFamilyName];
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";
250 } 242 }
251 243
252 static RGBA32 convertNSColorToColor(NSColor *color) 244 static RGBA32 convertNSColorToColor(NSColor *color)
253 { 245 {
254 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo rSpace]; 246 NSColor *colorInColorSpace = [color colorUsingColorSpaceName:NSDeviceRGBColo rSpace];
255 if (colorInColorSpace) { 247 if (colorInColorSpace) {
256 static const double scaleFactor = nextafter(256.0, 0.0); 248 static const double scaleFactor = nextafter(256.0, 0.0);
257 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp onent]), 249 return makeRGB(static_cast<int>(scaleFactor * [colorInColorSpace redComp onent]),
258 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]), 250 static_cast<int>(scaleFactor * [colorInColorSpace greenComponent]),
259 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); 251 static_cast<int>(scaleFactor * [colorInColorSpace blueComponent]));
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 style.setHeight(Length(size.height(), Fixed)); 585 style.setHeight(Length(size.height(), Fixed));
594 } 586 }
595 587
596 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize controlSize) const 588 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize controlSize) const
597 { 589 {
598 FontDescription fontDescription; 590 FontDescription fontDescription;
599 fontDescription.setIsAbsoluteSize(true); 591 fontDescription.setIsAbsoluteSize(true);
600 fontDescription.setGenericFamily(FontDescription::SerifFamily); 592 fontDescription.setGenericFamily(FontDescription::SerifFamily);
601 593
602 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize :controlSize]]; 594 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize :controlSize]];
603 fontDescription.firstFamily().setFamily(@"BlinkMacSystemFont"); 595 fontDescription.firstFamily().setFamily([font webCoreFamilyName]);
604 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); 596 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom());
605 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); 597 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom());
606 598
607 // Reset line height. 599 // Reset line height.
608 style.setLineHeight(ComputedStyle::initialLineHeight()); 600 style.setLineHeight(ComputedStyle::initialLineHeight());
609 601
610 // TODO(esprehn): The fontSelector manual management is buggy and error pron e. 602 // TODO(esprehn): The fontSelector manual management is buggy and error pron e.
611 FontSelector* fontSelector = style.font().fontSelector(); 603 FontSelector* fontSelector = style.font().fontSelector();
612 if (style.setFontDescription(fontDescription)) 604 if (style.setFontDescription(fontDescription))
613 style.font().update(fontSelector); 605 style.font().update(fontSelector);
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 1158
1167 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const 1159 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const
1168 { 1160 {
1169 ControlPart part = style.appearance(); 1161 ControlPart part = style.appearance();
1170 if (part == CheckboxPart || part == RadioPart) 1162 if (part == CheckboxPart || part == RadioPart)
1171 return style.effectiveZoom() != 1; 1163 return style.effectiveZoom() != 1;
1172 return false; 1164 return false;
1173 } 1165 }
1174 1166
1175 } // namespace blink 1167 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutThemeMac.h ('k') | Source/platform/blink_platform.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698