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;
@interface BRYInspectableWebContentsView : NSView <NSWindowDelegate> {
@interface BRYInspectableWebContentsView
: NSView<NSWindowDelegate, NSSplitViewDelegate> {
@private
BRYInspectableWebContentsViewPrivate *_private;
}

View file

@ -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
@end