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

Side by Side Diff: ui/gfx/platform_font_mac.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/platform_font_mac.h" 5 #include "ui/gfx/platform_font_mac.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/font.h" 14 #include "ui/gfx/font.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 17
18 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
19 // PlatformFontMac, public: 19 // PlatformFontMac, public:
20 20
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int font_size, 117 int font_size,
118 int style) { 118 int style) {
119 font_name_ = font_name; 119 font_name_ = font_name;
120 font_size_ = font_size; 120 font_size_ = font_size;
121 style_ = style; 121 style_ = style;
122 CalculateMetrics(); 122 CalculateMetrics();
123 } 123 }
124 124
125 void PlatformFontMac::CalculateMetrics() { 125 void PlatformFontMac::CalculateMetrics() {
126 NSFont* font = GetNativeFont(); 126 NSFont* font = GetNativeFont();
127 scoped_nsobject<NSLayoutManager> layout_manager( 127 base::scoped_nsobject<NSLayoutManager> layout_manager(
128 [[NSLayoutManager alloc] init]); 128 [[NSLayoutManager alloc] init]);
129 height_ = [layout_manager defaultLineHeightForFont:font]; 129 height_ = [layout_manager defaultLineHeightForFont:font];
130 ascent_ = [font ascender]; 130 ascent_ = [font ascender];
131 average_width_ = 131 average_width_ =
132 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]); 132 NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]);
133 } 133 }
134 134
135 //////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////
136 // PlatformFont, public: 136 // PlatformFont, public:
137 137
138 // static 138 // static
139 PlatformFont* PlatformFont::CreateDefault() { 139 PlatformFont* PlatformFont::CreateDefault() {
140 return new PlatformFontMac; 140 return new PlatformFontMac;
141 } 141 }
142 142
143 // static 143 // static
144 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) { 144 PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont native_font) {
145 return new PlatformFontMac(native_font); 145 return new PlatformFontMac(native_font);
146 } 146 }
147 147
148 // static 148 // static
149 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 149 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
150 int font_size) { 150 int font_size) {
151 return new PlatformFontMac(font_name, font_size); 151 return new PlatformFontMac(font_name, font_size);
152 } 152 }
153 153
154 } // namespace gfx 154 } // namespace gfx
155 155
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698