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

Unified Diff: chrome/browser/ui/cocoa/custom_frame_view.mm

Issue 915313002: [Mac] Remove -[NSWindow drawRect] swizzling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nawc
Patch Set: Update test. Created 5 years, 10 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 | « chrome/browser/ui/cocoa/custom_frame_view.h ('k') | chrome/browser/ui/cocoa/custom_frame_view_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/custom_frame_view.mm
diff --git a/chrome/browser/ui/cocoa/custom_frame_view.mm b/chrome/browser/ui/cocoa/custom_frame_view.mm
index 3628c1a29fbf83e24d4acabdaf0cbcb510ef9fc3..1d19d61e389e3744a0bca783c12fa98560ada966 100644
--- a/chrome/browser/ui/cocoa/custom_frame_view.mm
+++ b/chrome/browser/ui/cocoa/custom_frame_view.mm
@@ -13,13 +13,7 @@
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
-namespace {
-BOOL gCanDrawTitle = NO;
-BOOL gCanGetCornerRadius = NO;
-} // namespace
-
@interface NSView (Swizzles)
-- (void)drawRectOriginal:(NSRect)rect;
- (NSPoint)_fullScreenButtonOriginOriginal;
@end
@@ -27,23 +21,12 @@ BOOL gCanGetCornerRadius = NO;
- (NSPoint)fullScreenButtonOriginAdjustment;
@end
-@implementation NSWindow (CustomFrameView)
-- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view {
- [view drawRectOriginal:rect];
-}
-@end
-
@interface CustomFrameView : NSView
@end
@implementation CustomFrameView
-// This is where we swizzle drawRect, and add in two methods that we
-// need. If any of these fail it shouldn't affect the functionality of the
-// others. If they all fail, we will lose window frame theming and
-// roll overs for our close widgets, but things should still function
-// correctly.
+ (void)load {
// Swizzling should only happen in the browser process. Interacting with
// AppKit will run +[borderViewClass initialize] in the renderer, which
@@ -68,33 +51,12 @@ BOOL gCanGetCornerRadius = NO;
DCHECK(borderViewClass);
if (!borderViewClass) return;
- // Exchange draw rect.
- Method m0 = class_getInstanceMethod([self class], @selector(drawRect:));
- DCHECK(m0);
- if (m0) {
- BOOL didAdd = class_addMethod(borderViewClass,
- @selector(drawRectOriginal:),
- method_getImplementation(m0),
- method_getTypeEncoding(m0));
- DCHECK(didAdd);
- if (didAdd) {
- Method m1 = class_getInstanceMethod(borderViewClass,
- @selector(drawRect:));
- Method m2 = class_getInstanceMethod(borderViewClass,
- @selector(drawRectOriginal:));
- DCHECK(m1 && m2);
- if (m1 && m2) {
- method_exchangeImplementations(m1, m2);
- }
- }
- }
-
// In Yosemite, the fullscreen button replaces the zoom button. We no longer
// need to swizzle out this AppKit private method.
if (base::mac::IsOSMavericksOrEarlier()) {
Robert Sesek 2015/03/04 19:16:26 Since we only swizzle in this case, you can move t
jackhou1 2015/03/05 04:28:08 Done.
// Swizzle the method that sets the origin for the Lion fullscreen button.
// Do nothing if it cannot be found.
- m0 = class_getInstanceMethod([self class],
+ Method m0 = class_getInstanceMethod([self class],
@selector(_fullScreenButtonOrigin));
if (m0) {
BOOL didAdd = class_addMethod(borderViewClass,
@@ -114,14 +76,6 @@ BOOL gCanGetCornerRadius = NO;
}
}
-+ (BOOL)canDrawTitle {
- return gCanDrawTitle;
-}
-
-+ (BOOL)canGetCornerRadius {
- return gCanGetCornerRadius;
-}
-
- (id)initWithFrame:(NSRect)frame {
// This class is not for instantiating.
[self doesNotRecognizeSelector:_cmd];
@@ -134,13 +88,6 @@ BOOL gCanGetCornerRadius = NO;
return nil;
}
-// Here is our custom drawing for our frame.
-- (void)drawRect:(NSRect)rect {
- // Delegate drawing to the window, whose default implementation (above) is to
- // call into the original implementation.
- [[self window] drawCustomFrameRect:rect forView:self];
-}
-
// Override to move the fullscreen button to the left of the profile avatar.
- (NSPoint)_fullScreenButtonOrigin {
NSWindow* window = [self window];
« no previous file with comments | « chrome/browser/ui/cocoa/custom_frame_view.h ('k') | chrome/browser/ui/cocoa/custom_frame_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698