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

Unified Diff: base/mac/foundation_util.mm

Issue 1927003004: Mac: Introduce "StaticCast" variants of base::mac::FooCastStrict, which do not typecheck in Release (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/foundation_util.h ('k') | ui/gfx/render_text_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/foundation_util.mm
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index 6ae5df3389977a2268567f062d540d5d11418434..92ae6633f56acfe9898f9d61f472af6424e632b8 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -18,6 +18,10 @@
#include "build/build_config.h"
#if !defined(OS_IOS)
+#import <AppKit/AppKit.h>
+#endif
+
+#if !defined(OS_IOS)
extern "C" {
CFTypeID SecACLGetTypeID();
CFTypeID SecTrustedApplicationGetTypeID();
@@ -316,7 +320,7 @@ NSFont* CFToNSCast(CTFontRef cf_val) {
DCHECK(!cf_val ||
CTFontGetTypeID() == CFGetTypeID(cf_val) ||
(_CFIsObjC(CTFontGetTypeID(), cf_val) &&
- [ns_val isKindOfClass:NSClassFromString(@"NSFont")]));
+ [ns_val isKindOfClass:[NSFont class]]));
Nico 2016/04/29 02:50:57 Splitting these NSClassFromString("foo") -> [foo c
tapted 2016/04/29 03:17:45 Done.
return ns_val;
}
@@ -324,7 +328,7 @@ CTFontRef NSToCFCast(NSFont* ns_val) {
CTFontRef cf_val = reinterpret_cast<CTFontRef>(ns_val);
DCHECK(!cf_val ||
CTFontGetTypeID() == CFGetTypeID(cf_val) ||
- [ns_val isKindOfClass:NSClassFromString(@"NSFont")]);
+ [ns_val isKindOfClass:[NSFont class]]);
return cf_val;
}
#endif
@@ -342,13 +346,6 @@ CFCast<TypeCF##Ref>(const CFTypeRef& cf_val) { \
return (TypeCF##Ref)(cf_val); \
} \
return NULL; \
-} \
-\
-template<> TypeCF##Ref \
-CFCastStrict<TypeCF##Ref>(const CFTypeRef& cf_val) { \
- TypeCF##Ref rv = CFCast<TypeCF##Ref>(cf_val); \
- DCHECK(cf_val == NULL || rv); \
- return rv; \
}
CF_CAST_DEFN(CFArray);
@@ -388,18 +385,11 @@ CFCast<CTFontRef>(const CFTypeRef& cf_val) {
return NULL;
id<NSObject> ns_val = reinterpret_cast<id>(const_cast<void*>(cf_val));
- if ([ns_val isKindOfClass:NSClassFromString(@"NSFont")]) {
+ if ([ns_val isKindOfClass:[NSFont class]]) {
return (CTFontRef)(cf_val);
}
return NULL;
}
-
-template<> CTFontRef
-CFCastStrict<CTFontRef>(const CFTypeRef& cf_val) {
- CTFontRef rv = CFCast<CTFontRef>(cf_val);
- DCHECK(cf_val == NULL || rv);
- return rv;
-}
#endif
#if !defined(OS_IOS)
« no previous file with comments | « base/mac/foundation_util.h ('k') | ui/gfx/render_text_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698