Fix flash of page while resizing devtools NSSplitView divider.

This commit is contained in:
Cheng Zhao 2013-12-12 17:26:04 +08:00
parent 837bd784aa
commit 39f5f52423
2 changed files with 36 additions and 4 deletions

View file

@ -2,7 +2,8 @@
@class BRYInspectableWebContentsViewPrivate; @class BRYInspectableWebContentsViewPrivate;
@interface BRYInspectableWebContentsView : NSView <NSWindowDelegate> { @interface BRYInspectableWebContentsView
: NSView<NSWindowDelegate, NSSplitViewDelegate> {
@private @private
BRYInspectableWebContentsViewPrivate *_private; BRYInspectableWebContentsViewPrivate *_private;
} }

View file

@ -10,10 +10,34 @@
using namespace brightray; 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 { @interface BRYInspectableWebContentsViewPrivate : NSObject {
@public @public
InspectableWebContentsViewMac *inspectableWebContentsView; InspectableWebContentsViewMac *inspectableWebContentsView;
NSSplitView *splitView; GraySplitView *splitView;
NSWindow *window; NSWindow *window;
BOOL visible; BOOL visible;
} }
@ -45,7 +69,8 @@ void SetActive(content::WebContents* web_contents, bool active) {
_private = [[BRYInspectableWebContentsViewPrivate alloc] init]; _private = [[BRYInspectableWebContentsViewPrivate alloc] init];
_private->inspectableWebContentsView = inspectableWebContentsView; _private->inspectableWebContentsView = inspectableWebContentsView;
_private->splitView = [[NSSplitView alloc] init]; _private->splitView = [[GraySplitView alloc] init];
_private->splitView.delegate = self;
[self addSubview:_private->splitView]; [self addSubview:_private->splitView];
_private->splitView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; _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]; [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 #pragma mark - NSWindowDelegate
- (BOOL)windowShouldClose:(id)sender { - (BOOL)windowShouldClose:(id)sender {
@ -221,4 +252,4 @@ void SetActive(content::WebContents* web_contents, bool active) {
@end @end
@implementation BRYInspectableWebContentsViewPrivate @implementation BRYInspectableWebContentsViewPrivate
@end @end