]> git.saurik.com Git - cydia.git/blobdiff - UICaboodle/BrowserView.mm
Use -[UIColor groupTableViewBackgroundColor] instead of -[UIColor pinStripeColor].
[cydia.git] / UICaboodle / BrowserView.mm
index 7855dcb30bf908c77d78e4258f6b09f9c8f4115e..e2dee3b5df8d40d02fe8e0ad109bc50e3ef6ce85 100644 (file)
@@ -1,12 +1,28 @@
+#include <UIKit/UIKit.h>
+#include "iPhonePrivate.h"
+
+#include "UCPlatform.h"
+
 #include <UICaboodle/BrowserView.h>
 #include <UICaboodle/UCLocalize.h>
 
 #include <UICaboodle/BrowserView.h>
 #include <UICaboodle/UCLocalize.h>
 
-#import <QuartzCore/CALayer.h>
+//#include <QuartzCore/CALayer.h>
 // XXX: fix the minimum requirement
 extern NSString * const kCAFilterNearest;
 
 #include <WebCore/WebCoreThread.h>
 // XXX: fix the minimum requirement
 extern NSString * const kCAFilterNearest;
 
 #include <WebCore/WebCoreThread.h>
-#include <WebKit/WebPreferences-WebPrivate.h>
+
+#include <WebKit/WebPolicyDelegate.h>
+#include <WebKit/WebPreferences.h>
+
+#include <WebKit/DOMCSSPrimitiveValue.h>
+#include <WebKit/DOMCSSStyleDeclaration.h>
+#include <WebKit/DOMDocument.h>
+#include <WebKit/DOMHTMLBodyElement.h>
+#include <WebKit/DOMRGBColor.h>
+
+//#include <WebCore/Page.h>
+//#include <WebCore/Settings.h>
 
 #include "substrate.h"
 
 
 #include "substrate.h"
 
@@ -19,12 +35,10 @@ static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
 static Class $UIFormAssistant;
 static Class $UIWebBrowserView;
 
 static Class $UIFormAssistant;
 static Class $UIWebBrowserView;
 
-@interface NSString (UIKit)
-- (NSString *) stringByAddingPercentEscapes;
-@end
-
 /* Indirect Delegate {{{ */
 /* Indirect Delegate {{{ */
-@interface IndirectDelegate : NSObject {
+@interface IndirectDelegate : NSObject <
+    HookProtocol
+> {
     _transient volatile id delegate_;
 }
 
     _transient volatile id delegate_;
 }
 
@@ -89,6 +103,11 @@ static Class $UIWebBrowserView;
     return nil;
 }
 
     return nil;
 }
 
+- (void) didDismissModalViewController {
+    if (delegate_ != nil)
+        return [delegate_ didDismissModalViewController];
+}
+
 - (IMP) methodForSelector:(SEL)sel {
     if (IMP method = [super methodForSelector:sel])
         return method;
 - (IMP) methodForSelector:(SEL)sel {
     if (IMP method = [super methodForSelector:sel])
         return method;
@@ -125,16 +144,24 @@ static Class $UIWebBrowserView;
 /* }}} */
 
 @interface WebView (UICaboodle)
 /* }}} */
 
 @interface WebView (UICaboodle)
-- (void) setScriptDebugDelegate:(id)delegate;
++ (BOOL) _canHandleRequest:(NSURLRequest *)request;
 - (void) _setFormDelegate:(id)delegate;
 - (void) _setFormDelegate:(id)delegate;
+- (void) _setLayoutInterval:(float)interval;
+- (void) setScriptDebugDelegate:(id)delegate;
 - (void) _setUIKitDelegate:(id)delegate;
 - (void) _setUIKitDelegate:(id)delegate;
+- (void) _setUsesLoaderCache:(BOOL)uses;
 - (void) setWebMailDelegate:(id)delegate;
 - (void) setWebMailDelegate:(id)delegate;
-- (void) _setLayoutInterval:(float)interval;
+@end
+
+@interface WebPreferences (Apple)
++ (void) _setInitialDefaultTextEncodingToSystemEncoding;
+- (void) _setLayoutInterval:(NSInteger)interval;
+- (void) setOfflineWebApplicationCacheEnabled:(BOOL)enabled;
 @end
 
 @implementation WebScriptObject (UICaboodle)
 
 @end
 
 @implementation WebScriptObject (UICaboodle)
 
-- (unsigned) count {
+- (NSUInteger) count {
     id length([self valueForKey:@"length"]);
     if ([length respondsToSelector:@selector(intValue)])
         return [length intValue];
     id length([self valueForKey:@"length"]);
     if ([length respondsToSelector:@selector(intValue)])
         return [length intValue];
@@ -279,6 +306,11 @@ static Class $UIWebBrowserView;
         [sensitive_ release];
     if (title_ != nil)
         [title_ release];
         [sensitive_ release];
     if (title_ != nil)
         [title_ release];
+    if (reloaditem_ != nil)
+        [reloaditem_ release];
+    if (loadingitem_ != nil)
+        [loadingitem_ release];
+
     [super dealloc];
 }
 
     [super dealloc];
 }
 
@@ -310,18 +342,15 @@ static Class $UIWebBrowserView;
     if ([request_ HTTPBody] == nil && [request_ HTTPBodyStream] == nil)
         [self loadRequest:request_];
     else {
     if ([request_ HTTPBody] == nil && [request_ HTTPBodyStream] == nil)
         [self loadRequest:request_];
     else {
-        UIActionSheet *sheet = [[[UIActionSheet alloc]
+        UIAlertView *alert = [[[UIAlertView alloc]
             initWithTitle:UCLocalize("RESUBMIT_FORM")
             initWithTitle:UCLocalize("RESUBMIT_FORM")
-            buttons:[NSArray arrayWithObjects:UCLocalize("CANCEL"), UCLocalize("SUBMIT"), nil]
-            defaultButtonIndex:0
+            message:nil
             delegate:self
             delegate:self
-            context:@"submit"
+            cancelButtonTitle:UCLocalize("CANCEL")
+            otherButtonTitles:UCLocalize("SUBMIT"), nil
         ] autorelease];
         ] autorelease];
-
-        [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
-        [sheet setNumberOfRows:1];
-        [sheet popupAlertAnimated:YES];
+        [alert setContext:@"submit"];
+        [alert show];
     }
 }
 
     }
 }
 
@@ -335,7 +364,7 @@ static Class $UIWebBrowserView;
 
 /* XXX: WebThreadLock? */
 - (void) _fixScroller:(CGRect)bounds {
 
 /* XXX: WebThreadLock? */
 - (void) _fixScroller:(CGRect)bounds {
-       float extra;
+    float extra;
 
     if (!editing_ || $UIFormAssistant == nil)
         extra = 0;
 
     if (!editing_ || $UIFormAssistant == nil)
         extra = 0;
@@ -354,7 +383,7 @@ static Class $UIWebBrowserView;
     if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
         [scroller_ setScrollerIndicatorSubrect:subrect];
 
     if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
         [scroller_ setScrollerIndicatorSubrect:subrect];
 
-    [document_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
+    [document_ setValue:[NSValue valueWithSize:CGSizeMake(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
 
     CGSize size(size_);
     size.height += extra;
 
     CGSize size(size_);
     size.height += extra;
@@ -384,7 +413,7 @@ static Class $UIWebBrowserView;
     [self view:sender didSetFrame:frame];
 }
 
     [self view:sender didSetFrame:frame];
 }
 
-- (void) pushPage:(UCViewController *)page {
+- (void) pushPage:(CYViewController *)page {
     [page setDelegate:delegate_];
     [[self navigationItem] setTitle:title_];
     [[self navigationController] pushViewController:page animated:YES];
     [page setDelegate:delegate_];
     [[self navigationItem] setTitle:title_];
     [[self navigationController] pushViewController:page animated:YES];
@@ -398,11 +427,11 @@ static Class $UIWebBrowserView;
     [[self navigationController] pushViewController:self animated:YES];
 }
 
     [[self navigationController] pushViewController:self animated:YES];
 }
 
-- (void) swapPage:(UCViewController *)page {
+- (void) swapPage:(CYViewController *)page {
     [page setDelegate:delegate_];
     if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
     [page setDelegate:delegate_];
     if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
-               
-       [[self navigationController] pushViewController:page animated:NO];
+
+    [[self navigationController] pushViewController:page animated:NO];
 }
 
 - (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
 }
 
 - (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
@@ -410,7 +439,7 @@ static Class $UIWebBrowserView;
     NSLog(@"getSpecial:%@", url);
 #endif
 
     NSLog(@"getSpecial:%@", url);
 #endif
 
-    if (UCViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
+    if (CYViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
         if (swap)
             [self swapPage:page];
         else
         if (swap)
             [self swapPage:page];
         else
@@ -443,21 +472,19 @@ static Class $UIWebBrowserView;
 - (void) _promptForSensitive:(NSMutableArray *)array {
     NSString *name([array objectAtIndex:0]);
 
 - (void) _promptForSensitive:(NSMutableArray *)array {
     NSString *name([array objectAtIndex:0]);
 
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
+    UIAlertView *alert = [[[UIAlertView alloc]
         initWithTitle:nil
         initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:UCLocalize("YES"), UCLocalize("NO"), nil]
-        defaultButtonIndex:0
+        message:nil
         delegate:indirect_
         delegate:indirect_
-        context:@"sensitive"
+        cancelButtonTitle:UCLocalize("NO")
+        otherButtonTitles:UCLocalize("YES"), nil
     ] autorelease];
 
     ] autorelease];
 
-    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
     NSString *host(@"XXX");
 
     NSString *host(@"XXX");
 
-    [sheet setNumberOfRows:1];
-    [sheet setBodyText:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
-    [sheet popupAlertAnimated:YES];
+    [alert setContext:@"sensitive"];
+    [alert setMessage:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
+    [alert show];
 
     NSRunLoop *loop([NSRunLoop currentRunLoop]);
     NSDate *future([NSDate distantFuture]);
 
     NSRunLoop *loop([NSRunLoop currentRunLoop]);
     NSDate *future([NSDate distantFuture]);
@@ -487,18 +514,15 @@ static Class $UIWebBrowserView;
         return;
     [self retain];
 
         return;
     [self retain];
 
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
+    UIAlertView *alert = [[[UIAlertView alloc]
         initWithTitle:nil
         initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:UCLocalize("OK"), nil]
-        defaultButtonIndex:0
+        message:message
         delegate:self
         delegate:self
-        context:@"alert"
+        cancelButtonTitle:UCLocalize("OK")
+        otherButtonTitles:nil
     ] autorelease];
     ] autorelease];
-
-    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
-    [sheet setBodyText:message];
-    [sheet popupAlertAnimated:YES];
+    [alert setContext:@"alert"];
+    [alert show];
 }
 
 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
 }
 
 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
@@ -506,19 +530,16 @@ static Class $UIWebBrowserView;
         return NO;
     [self retain];
 
         return NO;
     [self retain];
 
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
+    UIAlertView *alert = [[[UIAlertView alloc]
         initWithTitle:nil
         initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:UCLocalize("OK"), UCLocalize("CANCEL"), nil]
-        defaultButtonIndex:0
+        message:message
         delegate:indirect_
         delegate:indirect_
-        context:@"confirm"
+        cancelButtonTitle:UCLocalize("CANCEL")
+        otherButtonTitles:UCLocalize("OK"), nil
     ] autorelease];
 
     ] autorelease];
 
-    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
-    [sheet setNumberOfRows:1];
-    [sheet setBodyText:message];
-    [sheet popupAlertAnimated:YES];
+    [alert setContext:@"confirm"];
+    [alert show];
 
     NSRunLoop *loop([NSRunLoop currentRunLoop]);
     NSDate *future([NSDate distantFuture]);
 
     NSRunLoop *loop([NSRunLoop currentRunLoop]);
     NSDate *future([NSDate distantFuture]);
@@ -555,7 +576,7 @@ static Class $UIWebBrowserView;
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
-       [self applyRightButton];
+    [self applyRightButton];
 }
 
 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
 }
 
 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
@@ -571,7 +592,7 @@ static Class $UIWebBrowserView;
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
-       [self applyRightButton];
+    [self applyRightButton];
 }
 
 - (void) setFinishHook:(id)function {
 }
 
 - (void) setFinishHook:(id)function {
@@ -587,7 +608,7 @@ static Class $UIWebBrowserView;
 }
 
 - (void) _openMailToURL:(NSURL *)url {
 }
 
 - (void) _openMailToURL:(NSURL *)url {
-    [UIApp openURL:url];// asPanel:YES];
+    [[UIApplication sharedApplication] openURL:url];// asPanel:YES];
 }
 
 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
 }
 
 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
@@ -604,7 +625,7 @@ static Class $UIWebBrowserView;
 }
 
 - (void) webViewClose:(WebView *)sender {
 }
 
 - (void) webViewClose:(WebView *)sender {
-       [self close];
+    [self close];
 }
 
 - (void) close {
 }
 
 - (void) close {
@@ -641,7 +662,7 @@ static Class $UIWebBrowserView;
                 UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
                 [navigation setHook:indirect_];
 
                 UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
                 [navigation setHook:indirect_];
 
-                UCViewController *page([delegate_ pageForURL:url hasTag:NULL]);
+                CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
                 if (page == nil) {
                     /* XXX: call createWebViewWithRequest instead? */
 
                 if (page == nil) {
                     /* XXX: call createWebViewWithRequest instead? */
 
@@ -654,15 +675,15 @@ static Class $UIWebBrowserView;
                 [page setDelegate:delegate_];
 
                 [navigation setViewControllers:[NSArray arrayWithObject:page]];
                 [page setDelegate:delegate_];
 
                 [navigation setViewControllers:[NSArray arrayWithObject:page]];
-                               UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
-                               initWithTitle:UCLocalize("CLOSE")
-                                       style:UIBarButtonItemStylePlain
-                               target:page
-                               action:@selector(close)
-                           ];
-                           [[page navigationItem] setLeftBarButtonItem:closeItem];
-                           [closeItem release];
-                       
+                UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
+                    initWithTitle:UCLocalize("CLOSE")
+                    style:UIBarButtonItemStylePlain
+                    target:page
+                    action:@selector(close)
+                ];
+                [[page navigationItem] setLeftBarButtonItem:closeItem];
+                [closeItem release];
+
                 [[self navigationController] presentModalViewController:navigation animated:YES];
             }
         } else goto unknown;
                 [[self navigationController] presentModalViewController:navigation animated:YES];
             }
         } else goto unknown;
@@ -681,7 +702,7 @@ static Class $UIWebBrowserView;
 
         WebView *webview([document_ webView]);
         if (frame == [webview mainFrame])
 
         WebView *webview([document_ webView]);
         if (frame == [webview mainFrame])
-            [UIApp openURL:[request URL]];
+            [[UIApplication sharedApplication] openURL:[request URL]];
     }
 }
 
     }
 }
 
@@ -734,14 +755,14 @@ static Class $UIWebBrowserView;
     )) {
         url = open;
       open:
     )) {
         url = open;
       open:
-        [UIApp openURL:url];
+        [[UIApplication sharedApplication] openURL:url];
         goto ignore;
     }
 
         goto ignore;
     }
 
-    int store(_not(int));
+    NSInteger store(_not(NSInteger));
     if (NSURL *itms = [url itmsURL:&store]) {
 #if LogBrowser
     if (NSURL *itms = [url itmsURL:&store]) {
 #if LogBrowser
-        NSLog(@"itms#%@#%u#%@", url, store, itms);
+        NSLog(@"itms#%@#%d#%@", url, (int) store, itms);
 #endif
 
         if (capability != nil && (
 #endif
 
         if (capability != nil && (
@@ -779,12 +800,12 @@ static Class $UIWebBrowserView;
     //lprintf("Status:%s\n", [text UTF8String]);
 }
 
     //lprintf("Status:%s\n", [text UTF8String]);
 }
 
-- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
-    NSString *context([sheet context]);
+- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
+    NSString *context([alert context]);
 
     if ([context isEqualToString:@"alert"]) {
         [self autorelease];
 
     if ([context isEqualToString:@"alert"]) {
         [self autorelease];
-        [sheet dismiss];
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
     } else if ([context isEqualToString:@"confirm"]) {
         switch (button) {
             case 1:
     } else if ([context isEqualToString:@"confirm"]) {
         switch (button) {
             case 1:
@@ -796,7 +817,7 @@ static Class $UIWebBrowserView;
             break;
         }
 
             break;
         }
 
-        [sheet dismiss];
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
     } else if ([context isEqualToString:@"sensitive"]) {
         switch (button) {
             case 1:
     } else if ([context isEqualToString:@"sensitive"]) {
         switch (button) {
             case 1:
@@ -808,14 +829,14 @@ static Class $UIWebBrowserView;
             break;
         }
 
             break;
         }
 
-        [sheet dismiss];
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
     } else if ([context isEqualToString:@"challenge"]) {
         id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
 
         switch (button) {
             case 1: {
     } else if ([context isEqualToString:@"challenge"]) {
         id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
 
         switch (button) {
             case 1: {
-                NSString *username([[sheet textFieldAtIndex:0] text]);
-                NSString *password([[sheet textFieldAtIndex:1] text]);
+                NSString *username([[alert textFieldAtIndex:0] text]);
+                NSString *password([[alert textFieldAtIndex:1] text]);
 
                 NSURLCredential *credential([NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]);
 
 
                 NSURLCredential *credential([NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]);
 
@@ -832,7 +853,7 @@ static Class $UIWebBrowserView;
         [challenge_ release];
         challenge_ = nil;
 
         [challenge_ release];
         challenge_ = nil;
 
-        [sheet dismiss];
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
     } else if ([context isEqualToString:@"submit"]) {
         switch (button) {
             case 1:
     } else if ([context isEqualToString:@"submit"]) {
         switch (button) {
             case 1:
@@ -849,7 +870,7 @@ static Class $UIWebBrowserView;
             _nodefault
         }
 
             _nodefault
         }
 
-        [sheet dismiss];
+        [alert dismissWithClickedButtonIndex:-1 animated:YES];
     }
 }
 
     }
 }
 
@@ -861,22 +882,21 @@ static Class $UIWebBrowserView;
     if (realm == nil)
         realm = @"";
 
     if (realm == nil)
         realm = @"";
 
-    UIActionSheet *sheet = [[[UIActionSheet alloc]
+    UIAlertView *alert = [[[UIAlertView alloc]
         initWithTitle:realm
         initWithTitle:realm
-        buttons:[NSArray arrayWithObjects:UCLocalize("LOGIN"), UCLocalize("CANCEL"), nil]
-        defaultButtonIndex:0
+        message:nil
         delegate:self
         delegate:self
-        context:@"challenge"
+        cancelButtonTitle:UCLocalize("CANCEL")
+        otherButtonTitles:UCLocalize("LOGIN"), nil
     ] autorelease];
 
     ] autorelease];
 
-    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+    [alert setContext:@"challenge"];
+    [alert setNumberOfRows:1];
 
 
-    [sheet setNumberOfRows:1];
+    [alert addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
+    [alert addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
 
 
-    [sheet addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
-    [sheet addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
-
-    UITextField *username([sheet textFieldAtIndex:0]); {
+    UITextField *username([alert textFieldAtIndex:0]); {
         UITextInputTraits *traits([username textInputTraits]);
         [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
         [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
         UITextInputTraits *traits([username textInputTraits]);
         [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
         [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
@@ -884,7 +904,7 @@ static Class $UIWebBrowserView;
         [traits setReturnKeyType:UIReturnKeyNext];
     }
 
         [traits setReturnKeyType:UIReturnKeyNext];
     }
 
-    UITextField *password([sheet textFieldAtIndex:1]); {
+    UITextField *password([alert textFieldAtIndex:1]); {
         UITextInputTraits *traits([password textInputTraits]);
         [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
         [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
         UITextInputTraits *traits([password textInputTraits]);
         [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
         [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
@@ -894,7 +914,7 @@ static Class $UIWebBrowserView;
         [traits setSecureTextEntry:YES];
     }
 
         [traits setSecureTextEntry:YES];
     }
 
-    [sheet popupAlertAnimated:YES];
+    [alert show];
 }
 
 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
 }
 
 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
@@ -924,15 +944,15 @@ static Class $UIWebBrowserView;
         [browser loadRequest:request];
 
         [navigation setViewControllers:[NSArray arrayWithObject:browser]];
         [browser loadRequest:request];
 
         [navigation setViewControllers:[NSArray arrayWithObject:browser]];
-               UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
-               initWithTitle:UCLocalize("CLOSE")
-                       style:UIBarButtonItemStylePlain
-               target:browser
-               action:@selector(close)
-           ];
-           [[browser navigationItem] setLeftBarButtonItem:closeItem];
-           [closeItem release];
-       
+        UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
+            initWithTitle:UCLocalize("CLOSE")
+            style:UIBarButtonItemStylePlain
+            target:browser
+            action:@selector(close)
+        ];
+        [[browser navigationItem] setLeftBarButtonItem:closeItem];
+        [closeItem release];
+
         [[self navigationController] presentModalViewController:navigation animated:YES];
     } /*else if (request == nil) {
         [[self navigationItem] setTitle:title_];
         [[self navigationController] presentModalViewController:navigation animated:YES];
     } /*else if (request == nil) {
         [[self navigationItem] setTitle:title_];
@@ -1031,32 +1051,48 @@ static Class $UIWebBrowserView;
         }
     }
 
         }
     }
 
-       [self _startLoading];
+    [self _startLoading];
+}
+
+- (UIBarButtonItemStyle) rightButtonStyle {
+    if (style_ == nil) normal:
+        return UIBarButtonItemStylePlain;
+    else if ([style_ isEqualToString:@"Normal"])
+        return UIBarButtonItemStylePlain;
+    else if ([style_ isEqualToString:@"Highlighted"])
+        return UIBarButtonItemStyleDone;
+    else goto normal;
+}
+
+- (UIBarButtonItem *) customButton {
+    UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
+        initWithTitle:button_
+        style:[self rightButtonStyle]
+        target:self
+        action:@selector(customButtonClicked)
+    ];
+
+    return [customItem autorelease];
+}
+
+- (UIBarButtonItem *) rightButton {
+    return reloaditem_;
+}
+
+- (void) applyLoadingTitle {
+    [[self navigationItem] setTitle:UCLocalize("LOADING")];
 }
 
 - (void) applyRightButton {
 }
 
 - (void) applyRightButton {
-       if ([self isLoading]) {
-        UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
-               initWithTitle:@" "
-               style:UIBarButtonItemStylePlain
-               target:self
-               action:@selector(reloadButtonClicked)
-           ];
-           [[self navigationItem] setRightBarButtonItem:reloadItem];
-               [[reloadItem view] addSubview:indicator_];
-               [[self navigationItem] setTitle:UCLocalize("LOADING")];
-           [reloadItem release];
+    if ([self isLoading]) {
+        [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
+        [[loadingitem_ view] addSubview:indicator_];
+        [self applyLoadingTitle];
+    } else if (button_) {
+        [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
     } else {
     } else {
-               UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
-                       initWithTitle:button_ ?: UCLocalize("RELOAD")
-                       style:[self rightButtonStyle]
-                       target:self
-                       action:button_ ? @selector(customButtonClicked) : @selector(reloadButtonClicked)
-               ];
-               [[self navigationItem] setRightBarButtonItem:reloadItem animated:YES];
-               [[self navigationItem] setTitle:title_];
-               [reloadItem release];
-       }
+        [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
+    }
 }
 
 - (void) _startLoading {
 }
 
 - (void) _startLoading {
@@ -1072,7 +1108,8 @@ static Class $UIWebBrowserView;
     if (finish_ != nil)
         [self callFunction:finish_];
 
     if (finish_ != nil)
         [self callFunction:finish_];
 
-       [self applyRightButton];
+    [self applyRightButton];
+    if (![self isLoading]) [[self navigationItem] setTitle:title_];
 }
 
 - (bool) isLoading {
 }
 
 - (bool) isLoading {
@@ -1107,7 +1144,7 @@ static Class $UIWebBrowserView;
     if ([frame parentFrame] == nil) {
         if (DOMDocument *document = [frame DOMDocument])
             if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
     if ([frame parentFrame] == nil) {
         if (DOMDocument *document = [frame DOMDocument])
             if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
-                for (DOMHTMLBodyElement *body in bodies) {
+                for (DOMHTMLBodyElement *body in (id) bodies) {
                     DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
 
                     bool colored(false);
                     DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
 
                     bool colored(false);
@@ -1124,7 +1161,7 @@ static Class $UIWebBrowserView;
                             UIColor *uic(nil);
 
                             if (red == 0xc7 && green == 0xce && blue == 0xd5)
                             UIColor *uic(nil);
 
                             if (red == 0xc7 && green == 0xce && blue == 0xd5)
-                                uic = [UIColor pinStripeColor];
+                                uic = [UIColor groupTableViewBackgroundColor];
                             else if (alpha != 0)
                                 uic = [UIColor
                                     colorWithRed:(red / 255)
                             else if (alpha != 0)
                                 uic = [UIColor
                                     colorWithRed:(red / 255)
@@ -1141,7 +1178,7 @@ static Class $UIWebBrowserView;
                     }
 
                     if (!colored)
                     }
 
                     if (!colored)
-                        [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
+                        [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
                     break;
                 }
     }
                     break;
                 }
     }
@@ -1311,14 +1348,14 @@ static Class $UIWebBrowserView;
 
         BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
         [self setView:actualView];
 
         BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
         [self setView:actualView];
-        
+
         struct CGRect bounds = [[self view] bounds];
 
         scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
         [[self view] addSubview:scroller_];
 
         [scroller_ setFixedBackgroundPattern:YES];
         struct CGRect bounds = [[self view] bounds];
 
         scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
         [[self view] addSubview:scroller_];
 
         [scroller_ setFixedBackgroundPattern:YES];
-        [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
+        [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
 
         [scroller_ setScrollingEnabled:YES];
         [scroller_ setClipsSubviews:YES];
 
         [scroller_ setScrollingEnabled:YES];
         [scroller_ setClipsSubviews:YES];
@@ -1431,7 +1468,7 @@ static Class $UIWebBrowserView;
             else
                 [preferences _setLayoutInterval:0];
         }
             else
                 [preferences _setLayoutInterval:0];
         }
-        
+
         actualView.documentView = document_;
         [actualView release];
 
         actualView.documentView = document_;
         [actualView release];
 
@@ -1464,7 +1501,22 @@ static Class $UIWebBrowserView;
         CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
         indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
         [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
         CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
         indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
         [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
-               [indicator_ startAnimation];
+        [indicator_ startAnimation];
+
+        reloaditem_ = [[UIBarButtonItem alloc]
+            initWithTitle:UCLocalize("RELOAD")
+            style:[self rightButtonStyle]
+            target:self
+            action:@selector(reloadButtonClicked)
+        ];
+
+        loadingitem_ = [[UIBarButtonItem alloc]
+            initWithTitle:@" "
+            style:UIBarButtonItemStylePlain
+            target:self
+            action:@selector(reloadButtonClicked)
+        ];
+        [[loadingitem_ view] addSubview:indicator_];
 
         [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
         [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
 
         [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
         [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
@@ -1497,8 +1549,12 @@ static Class $UIWebBrowserView;
 
     WebView *webview([document_ webView]);
     WebFrame *frame([webview mainFrame]);
 
     WebView *webview([document_ webView]);
     WebFrame *frame([webview mainFrame]);
+    WebPreferences *preferences([webview preferences]);
+
+    bool maybe([preferences javaScriptCanOpenWindowsAutomatically]);
+    [preferences setJavaScriptCanOpenWindowsAutomatically:NO];
 
 
-    id _private(MSHookIvar<id>(webview, "_private"));
+    /*id _private(MSHookIvar<id>(webview, "_private"));
     WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page"));
     WebCore::Settings *settings(page == NULL ? NULL : page->settings());
 
     WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page"));
     WebCore::Settings *settings(page == NULL ? NULL : page->settings());
 
@@ -1508,7 +1564,7 @@ static Class $UIWebBrowserView;
     else {
         no = settings->JavaScriptCanOpenWindowsAutomatically();
         settings->setJavaScriptCanOpenWindowsAutomatically(true);
     else {
         no = settings->JavaScriptCanOpenWindowsAutomatically();
         settings->setJavaScriptCanOpenWindowsAutomatically(true);
-    }
+    }*/
 
     if (UIWindow *window = [[self view] window])
         if (UIResponder *responder = [window firstResponder])
 
     if (UIWindow *window = [[self view] window])
         if (UIResponder *responder = [window firstResponder])
@@ -1518,8 +1574,10 @@ static Class $UIWebBrowserView;
     JSGlobalContextRef context([frame globalContext]);
     JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
 
     JSGlobalContextRef context([frame globalContext]);
     JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
 
-    if (settings != NULL)
-        settings->setJavaScriptCanOpenWindowsAutomatically(no);
+    /*if (settings != NULL)
+        settings->setJavaScriptCanOpenWindowsAutomatically(no);*/
+
+    [preferences setJavaScriptCanOpenWindowsAutomatically:maybe];
 
     WebThreadUnlock();
 }
 
     WebThreadUnlock();
 }
@@ -1534,37 +1592,24 @@ static Class $UIWebBrowserView;
     [self reloadURL];
 }
 
     [self reloadURL];
 }
 
+- (void) _customButtonClicked {
+    [self reloadButtonClicked];
+}
+
 - (void) customButtonClicked {
 #if !AlwaysReload
     if (function_ != nil)
         [self callFunction:function_];
     else
 #endif
 - (void) customButtonClicked {
 #if !AlwaysReload
     if (function_ != nil)
         [self callFunction:function_];
     else
 #endif
-               [self reloadButtonClicked];
-}
-
-- (UINavigationButtonStyle) rightButtonStyle {
-    if (style_ == nil) normal:
-        return UINavigationButtonStyleNormal;
-    else if ([style_ isEqualToString:@"Normal"])
-        return UINavigationButtonStyleNormal;
-    else if ([style_ isEqualToString:@"Back"])
-        return UINavigationButtonStyleBack;
-    else if ([style_ isEqualToString:@"Highlighted"])
-        return UINavigationButtonStyleHighlighted;
-    else if ([style_ isEqualToString:@"Destructive"])
-        return UINavigationButtonStyleDestructive;
-    else goto normal;
+    [self _customButtonClicked];
 }
 
 - (void) setPageActive:(BOOL)active {
     if (!active)
         [indicator_ removeFromSuperview];
     else
 }
 
 - (void) setPageActive:(BOOL)active {
     if (!active)
         [indicator_ removeFromSuperview];
     else
-               [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
-}
-
-- (void) resetViewAnimated:(BOOL)animated {
+        [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
 }
 
 - (void) setPushed:(bool)pushed {
 }
 
 - (void) setPushed:(bool)pushed {
@@ -1575,4 +1620,4 @@ static Class $UIWebBrowserView;
     return 980;
 }
 
     return 980;
 }
 
-@end
\ No newline at end of file
+@end