X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/754456f50dfc16895f42e9e6db4c22297e8ada2e..d331bfc3c3efdde44dfd4e81c50703e51f958a2f:/CyteKit/WebViewController.mm?ds=sidebyside diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index f047ed37..7d91177f 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -45,11 +45,6 @@ static Class $MFMailComposeViewController; float CYScrollViewDecelerationRateNormal; -@interface WebView (Apple) -- (void) _setLayoutInterval:(float)interval; -- (void) _setAllowsMessaging:(BOOL)allows; -@end - @interface WebFrame (Cydia) - (void) cydia$updateHeight; @end @@ -589,7 +584,7 @@ float CYScrollViewDecelerationRateNormal; } } - [self setPageColor:uic]; + [super setPageColor:uic]; [scroller_ setBackgroundColor:color_]; break; } @@ -873,7 +868,7 @@ float CYScrollViewDecelerationRateNormal; width_ = width; class_ = _class; - [self setPageColor:nil]; + [super setPageColor:nil]; allowsNavigationAction_ = true; @@ -947,7 +942,7 @@ float CYScrollViewDecelerationRateNormal; [preferences _setLayoutInterval:0]; [preferences setCacheModel:WebCacheModelDocumentBrowser]; - [preferences setJavaScriptCanOpenWindowsAutomatically:YES]; + [preferences setJavaScriptCanOpenWindowsAutomatically:NO]; if ([preferences respondsToSelector:@selector(setOfflineWebApplicationCacheEnabled:)]) [preferences setOfflineWebApplicationCacheEnabled:YES]; @@ -992,7 +987,7 @@ float CYScrollViewDecelerationRateNormal; } [webview_ setOpaque:NO]; - [webview_ setBackgroundColor:color_]; + [webview_ setBackgroundColor:nil]; [scroller_ setFixedBackgroundPattern:YES]; [scroller_ setBackgroundColor:color_]; @@ -1004,6 +999,13 @@ float CYScrollViewDecelerationRateNormal; [self setViewportWidth:width_]; + if ([[UIColor groupTableViewBackgroundColor] isEqual:[UIColor clearColor]]) { + UITableView *table([[[UITableView alloc] initWithFrame:[webview_ bounds] style:UITableViewStyleGrouped] autorelease]); + [table setScrollsToTop:NO]; + [webview_ insertSubview:table atIndex:0]; + [table setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; + } + [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; ready_ = false; @@ -1038,16 +1040,34 @@ float CYScrollViewDecelerationRateNormal; } return self; } ++ (void) _lockJavaScript:(WebPreferences *)preferences { + WebThreadLocked lock; + [preferences setJavaScriptCanOpenWindowsAutomatically:NO]; +} + - (void) callFunction:(WebScriptObject *)function { WebThreadLocked lock; WebView *webview([[[self webView] _documentView] webView]); - WebFrame *frame([webview mainFrame]); + WebPreferences *preferences([webview preferences]); + + [preferences setJavaScriptCanOpenWindowsAutomatically:YES]; + if ([webview respondsToSelector:@selector(_preferencesChanged:)]) + [webview _preferencesChanged:preferences]; + else + [webview _preferencesChangedNotification:[NSNotification notificationWithName:@"" object:preferences]]; + WebFrame *frame([webview mainFrame]); JSGlobalContextRef context([frame globalContext]); + JSObjectRef object([function JSObject]); if ($JSObjectCallAsFunction != NULL) ($JSObjectCallAsFunction)(context, object, NULL, 0, NULL, NULL); + + // XXX: the JavaScript code submits a form, which seems to happen asynchronously + NSObject *target([CyteWebViewController class]); + [NSObject cancelPreviousPerformRequestsWithTarget:target selector:@selector(_lockJavaScript:) object:preferences]; + [target performSelector:@selector(_lockJavaScript:) withObject:preferences afterDelay:1]; } - (void) reloadButtonClicked {