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

Side by Side Diff: ui/base/resource/resource_bundle.h

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for review issues. Created 4 years, 9 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
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 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ScaleFactor scale_factor) const; 239 ScaleFactor scale_factor) const;
240 240
241 // Get a localized string given a message id. Returns an empty 241 // Get a localized string given a message id. Returns an empty
242 // string if the message_id is not found. 242 // string if the message_id is not found.
243 base::string16 GetLocalizedString(int message_id); 243 base::string16 GetLocalizedString(int message_id);
244 244
245 // Returns a font list derived from the platform-specific "Base" font list. 245 // Returns a font list derived from the platform-specific "Base" font list.
246 // The result is always cached and exists for the lifetime of the process. 246 // The result is always cached and exists for the lifetime of the process.
247 const gfx::FontList& GetFontListWithDelta( 247 const gfx::FontList& GetFontListWithDelta(
248 int size_delta, 248 int size_delta,
249 gfx::Font::FontStyle style = gfx::Font::NORMAL); 249 gfx::Font::FontStyle style = gfx::Font::NORMAL,
250 gfx::Font::Weight weight = gfx::Font::Weight::NORMAL);
250 251
251 // Returns the primary font from the FontList given by GetFontListWithDelta(). 252 // Returns the primary font from the FontList given by GetFontListWithDelta().
252 const gfx::Font& GetFontWithDelta( 253 const gfx::Font& GetFontWithDelta(
253 int size_delta, 254 int size_delta,
254 gfx::Font::FontStyle style = gfx::Font::NORMAL); 255 gfx::Font::FontStyle style = gfx::Font::NORMAL);
255 256
256 // Deprecated. Returns fonts using hard-coded size deltas implied by |style|. 257 // Deprecated. Returns fonts using hard-coded size deltas implied by |style|.
257 const gfx::FontList& GetFontList(FontStyle style); 258 const gfx::FontList& GetFontList(FontStyle style);
258 const gfx::Font& GetFont(FontStyle style); 259 const gfx::Font& GetFont(FontStyle style);
259 260
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 MDResourceAccess); 308 MDResourceAccess);
308 309
309 friend class ResourceBundleMacImageTest; 310 friend class ResourceBundleMacImageTest;
310 friend class ResourceBundleImageTest; 311 friend class ResourceBundleImageTest;
311 friend class ResourceBundleTest; 312 friend class ResourceBundleTest;
312 friend class ChromeBrowserMainMacBrowserTest; 313 friend class ChromeBrowserMainMacBrowserTest;
313 314
314 class ResourceBundleImageSource; 315 class ResourceBundleImageSource;
315 friend class ResourceBundleImageSource; 316 friend class ResourceBundleImageSource;
316 317
318 struct FontKey;
319
317 typedef base::hash_map<int, base::string16> IdToStringMap; 320 typedef base::hash_map<int, base::string16> IdToStringMap;
318 321
319 // Ctor/dtor are private, since we're a singleton. 322 // Ctor/dtor are private, since we're a singleton.
320 explicit ResourceBundle(Delegate* delegate); 323 explicit ResourceBundle(Delegate* delegate);
321 ~ResourceBundle(); 324 ~ResourceBundle();
322 325
323 // Shared initialization. 326 // Shared initialization.
324 static void InitSharedInstance(Delegate* delegate); 327 static void InitSharedInstance(Delegate* delegate);
325 328
326 // Free skia_images_. 329 // Free skia_images_.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // ownership of the pointers. 429 // ownership of the pointers.
427 typedef std::map<int, gfx::Image> ImageMap; 430 typedef std::map<int, gfx::Image> ImageMap;
428 ImageMap images_; 431 ImageMap images_;
429 432
430 gfx::Image empty_image_; 433 gfx::Image empty_image_;
431 434
432 // The various font lists used, as a map from a signed size delta from the 435 // The various font lists used, as a map from a signed size delta from the
433 // platform base font size, plus style, to the FontList. Cached to avoid 436 // platform base font size, plus style, to the FontList. Cached to avoid
434 // repeated GDI creation/destruction and font derivation. 437 // repeated GDI creation/destruction and font derivation.
435 // Must be accessed only while holding |images_and_fonts_lock_|. 438 // Must be accessed only while holding |images_and_fonts_lock_|.
436 std::map<std::pair<int, gfx::Font::FontStyle>, gfx::FontList> font_cache_; 439 std::map<FontKey, gfx::FontList> font_cache_;
437 440
438 base::FilePath overridden_pak_path_; 441 base::FilePath overridden_pak_path_;
439 442
440 IdToStringMap overridden_locale_strings_; 443 IdToStringMap overridden_locale_strings_;
441 444
442 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 445 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
443 }; 446 };
444 447
445 } // namespace ui 448 } // namespace ui
446 449
447 // TODO(beng): Someday, maybe, get rid of this. 450 // TODO(beng): Someday, maybe, get rid of this.
448 using ui::ResourceBundle; 451 using ui::ResourceBundle;
449 452
450 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 453 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698