mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Open no longer blocks until page is loaded
This commit is contained in:
@@ -12,7 +12,7 @@ class ClientHandler;
|
||||
CefRefPtr<ClientHandler> _clientHandler;
|
||||
}
|
||||
|
||||
- (AtomController *)open:(NSString *)path;
|
||||
- (void)open:(NSString *)path;
|
||||
- (IBAction)runSpecs:(id)sender;
|
||||
- (IBAction)runBenchmarks:(id)sender;
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
|
||||
}
|
||||
|
||||
- (AtomController *)open:(NSString *)path {
|
||||
return [[AtomController alloc] initWithPath:path atomContext:[self atomContext]];
|
||||
- (void)open:(NSString *)path {
|
||||
[[AtomController alloc] initWithPath:path atomContext:[self atomContext]];
|
||||
}
|
||||
|
||||
- (IBAction)runSpecs:(id)sender {
|
||||
|
||||
@@ -10,8 +10,6 @@ class ClientHandler;
|
||||
NSString *_bootstrapScript;
|
||||
NSString *_pathToOpen;
|
||||
|
||||
BOOL _loaded;
|
||||
|
||||
CefRefPtr<CefV8Context> _atomContext;
|
||||
CefRefPtr<ClientHandler> _clientHandler;
|
||||
}
|
||||
@@ -22,10 +20,8 @@ class ClientHandler;
|
||||
- (id)initBenchmarksWithAtomContext:(CefRefPtr<CefV8Context>)atomContext;
|
||||
|
||||
- (void)createBrowser;
|
||||
- (void)blockUntilBrowserLoaded;
|
||||
|
||||
@property (nonatomic, retain) IBOutlet NSView *webView;
|
||||
@property (nonatomic, readonly) CefRefPtr<ClientHandler> clientHandler;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
@implementation AtomController
|
||||
|
||||
@synthesize webView=_webView;
|
||||
@synthesize clientHandler=_clientHandler;
|
||||
|
||||
- (void)dealloc {
|
||||
[_bootstrapScript release];
|
||||
@@ -21,7 +20,6 @@
|
||||
self = [super initWithWindowNibName:@"ClientWindow"];
|
||||
_bootstrapScript = [bootstrapScript retain];
|
||||
_atomContext = atomContext;
|
||||
_loaded = false;
|
||||
|
||||
[self.window makeKeyAndOrderFront:nil];
|
||||
[self createBrowser];
|
||||
@@ -62,16 +60,8 @@
|
||||
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
|
||||
}
|
||||
|
||||
- (void)blockUntilBrowserLoaded {
|
||||
NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
|
||||
while (!_loaded) {
|
||||
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark BrowserDelegate
|
||||
- (void)loadStart {
|
||||
_loaded = false;
|
||||
CefRefPtr<CefV8Context> context = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
|
||||
@@ -91,10 +81,6 @@
|
||||
context->Exit();
|
||||
}
|
||||
|
||||
- (void)loadEnd {
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
- (bool)keyEventOfType:(cef_handler_keyevent_type_t)type
|
||||
code:(int)code
|
||||
modifiers:(int)modifiers
|
||||
|
||||
@@ -235,11 +235,7 @@ bool NativeHandler::Execute(const CefString& name,
|
||||
}
|
||||
else if (name == "open") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
AtomController *atomController = [(Atom *)NSApp open:path];
|
||||
[atomController blockUntilBrowserLoaded];
|
||||
|
||||
CefRefPtr<ClientHandler> clientHandler = [atomController clientHandler];
|
||||
retval = clientHandler->GetBrowser()->GetMainFrame()->GetV8Context()->GetGlobal();
|
||||
[NSApp open:path];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,21 +14,18 @@ class Keymap
|
||||
bindDefaultKeys: ->
|
||||
@bindKeys "*",
|
||||
'meta-n': 'new-window'
|
||||
'meta-o': 'open'
|
||||
'meta-,': 'open-user-configuration'
|
||||
'meta-o': 'open'
|
||||
|
||||
@_newWindow = => $native.newWindow()
|
||||
@_openUserConfiguration = => atom.open(atom.userConfigurationPath)
|
||||
@_open = =>
|
||||
url = $native.openDialog()
|
||||
atom.open(url) if url
|
||||
@_openUserConfiguration = =>
|
||||
openedWindow = atom.open(atom.userConfigurationPath)
|
||||
defaultConfiguration = "# This is run when a window is loaded!\nconsole.log('see!')"
|
||||
openedWindow.rootView.editor.buffer.setText defaultConfiguration unless fs.exists(atom.userConfigurationPath)
|
||||
|
||||
$(document).on 'new-window', @_newWindow
|
||||
$(document).on 'open', @_open
|
||||
$(document).on 'open-user-configuration', @_openUserConfiguration
|
||||
$(document).on 'open', @_open
|
||||
|
||||
unbindDefaultKeys: ->
|
||||
$(document).unbind 'new-window', @_newWindow
|
||||
|
||||
Reference in New Issue
Block a user