From 39f5f52423bdac75eb0bdc609f49b8b4ede4132b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 12 Dec 2013 17:26:04 +0800 Subject: [PATCH 1/2] Fix flash of page while resizing devtools NSSplitView divider. --- .../mac/bry_inspectable_web_contents_view.h | 3 +- .../mac/bry_inspectable_web_contents_view.mm | 37 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.h b/brightray/browser/mac/bry_inspectable_web_contents_view.h index 87abc98c3549..49eff626321d 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.h +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.h @@ -2,7 +2,8 @@ @class BRYInspectableWebContentsViewPrivate; -@interface BRYInspectableWebContentsView : NSView { +@interface BRYInspectableWebContentsView + : NSView { @private BRYInspectableWebContentsViewPrivate *_private; } diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.mm b/brightray/browser/mac/bry_inspectable_web_contents_view.mm index 24987e5c1c5c..d4d8b374b06e 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.mm +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.mm @@ -10,10 +10,34 @@ using namespace brightray; +@interface GraySplitView : NSSplitView { + BOOL dividerHidden_; +} +@property(assign, nonatomic) BOOL dividerHidden; +- (NSColor*)dividerColor; +- (CGFloat)dividerThickness; +@end + + +@implementation GraySplitView + +@synthesize dividerHidden = dividerHidden_; + +- (NSColor*)dividerColor { + return [NSColor darkGrayColor]; +} + +- (CGFloat)dividerThickness { + return dividerHidden_ ? 0 : [super dividerThickness]; +} + +@end + + @interface BRYInspectableWebContentsViewPrivate : NSObject { @public InspectableWebContentsViewMac *inspectableWebContentsView; - NSSplitView *splitView; + GraySplitView *splitView; NSWindow *window; BOOL visible; } @@ -45,7 +69,8 @@ void SetActive(content::WebContents* web_contents, bool active) { _private = [[BRYInspectableWebContentsViewPrivate alloc] init]; _private->inspectableWebContentsView = inspectableWebContentsView; - _private->splitView = [[NSSplitView alloc] init]; + _private->splitView = [[GraySplitView alloc] init]; + _private->splitView.delegate = self; [self addSubview:_private->splitView]; _private->splitView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; @@ -203,6 +228,12 @@ void SetActive(content::WebContents* web_contents, bool active) { [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:newWindow]; } +#pragma mark - NSSplitViewDelegate + +-(void)splitViewWillResizeSubviews:(NSNotification *)notification { + [[_private->splitView window] disableScreenUpdatesUntilFlush]; +} + #pragma mark - NSWindowDelegate - (BOOL)windowShouldClose:(id)sender { @@ -221,4 +252,4 @@ void SetActive(content::WebContents* web_contents, bool active) { @end @implementation BRYInspectableWebContentsViewPrivate -@end \ No newline at end of file +@end From e0b8935fda87460a66fadd9deab218c3cbb3b62b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 12 Dec 2013 23:33:50 +0800 Subject: [PATCH 2/2] Remove the unused dividerHidden property of GraySplitView. --- .../mac/bry_inspectable_web_contents_view.mm | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.mm b/brightray/browser/mac/bry_inspectable_web_contents_view.mm index d4d8b374b06e..72e0a851c530 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.mm +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.mm @@ -10,27 +10,14 @@ using namespace brightray; -@interface GraySplitView : NSSplitView { - BOOL dividerHidden_; -} -@property(assign, nonatomic) BOOL dividerHidden; +@interface GraySplitView : NSSplitView - (NSColor*)dividerColor; -- (CGFloat)dividerThickness; @end - @implementation GraySplitView - -@synthesize dividerHidden = dividerHidden_; - - (NSColor*)dividerColor { return [NSColor darkGrayColor]; } - -- (CGFloat)dividerThickness { - return dividerHidden_ ? 0 : [super dividerThickness]; -} - @end