]> git.saurik.com Git - cydia.git/blobdiff - UICaboodle/BrowserView.mm
iPhone 4 hi-res.
[cydia.git] / UICaboodle / BrowserView.mm
index e08c291fa7726b37ffb3dd43cad4d17b8466a686..13e6b08c4503489ec6fe7d77854483a1501c1a1f 100644 (file)
@@ -10,6 +10,15 @@ extern NSString * const kCAFilterNearest;
 
 #include "substrate.h"
 
+#define ForSaurik 0
+
+static bool Wildcat_;
+
+static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
+static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
+static Class $UIFormAssistant;
+static Class $UIWebBrowserView;
+
 @interface NSString (UIKit)
 - (NSString *) stringByAddingPercentEscapes;
 @end
@@ -139,77 +148,6 @@ extern NSString * const kCAFilterNearest;
 
 @end
 
-#if 0
-/* Mail Composition {{{ */
-@interface MailToView : PopUpView {
-    MailComposeController *controller_;
-}
-
-- (id) initWithView:(UIView *)view delegate:(id)delegate url:(NSURL *)url;
-
-@end
-
-@implementation MailToView
-
-- (void) dealloc {
-    [controller_ release];
-    [super dealloc];
-}
-
-- (void) mailComposeControllerWillAttemptToSend:(MailComposeController *)controller {
-    NSLog(@"will");
-}
-
-- (void) mailComposeControllerDidAttemptToSend:(MailComposeController *)controller mailDelivery:(id)delivery {
-    NSLog(@"did:%@", delivery);
-// [UIApp setStatusBarShowsProgress:NO];
-if ([controller error]){
-NSArray *buttons = [NSArray arrayWithObjects:UCLocalize("OK"), nil];
-UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize("ERROR") buttons:buttons defaultButtonIndex:0 delegate:self context:self];
-[mailAlertSheet setBodyText:[controller error]];
-[mailAlertSheet popupAlertAnimated:YES];
-}
-}
-
-- (void) showError {
-    NSLog(@"%@", [controller_ error]);
-    NSArray *buttons = [NSArray arrayWithObjects:UCLocalize("OK"), nil];
-    UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize("ERROR") buttons:buttons defaultButtonIndex:0 delegate:self context:self];
-    [mailAlertSheet setBodyText:[controller_ error]];
-    [mailAlertSheet popupAlertAnimated:YES];
-}
-
-- (void) deliverMessage { _pooled
-    setuid(501);
-    setgid(501);
-
-    if (![controller_ deliverMessage])
-        [self performSelectorOnMainThread:@selector(showError) withObject:nil waitUntilDone:NO];
-}
-
-- (void) mailComposeControllerCompositionFinished:(MailComposeController *)controller {
-    if ([controller_ needsDelivery])
-        [NSThread detachNewThreadSelector:@selector(deliverMessage) toTarget:self withObject:nil];
-    else
-        [self cancel];
-}
-
-- (id) initWithView:(UIView *)view delegate:(id)delegate url:(NSURL *)url {
-    if ((self = [super initWithView:view delegate:delegate]) != nil) {
-        controller_ = [[MailComposeController alloc] initForContentSize:[overlay_ bounds].size];
-        [controller_ setDelegate:self];
-        [controller_ initializeUI];
-        [controller_ setupForURL:url];
-
-        UIView *view([controller_ view]);
-        [overlay_ addSubview:view];
-    } return self;
-}
-
-@end
-/* }}} */
-#endif
-
 #define ShowInternals 0
 #define LogBrowser 0
 
@@ -222,7 +160,6 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 #endif
 
 + (void) _initialize {
-    NSLog(@"INITIALIZING");
     [WebView enableWebThread];
 
     WebPreferences *preferences([WebPreferences standardPreferences]);
@@ -230,6 +167,18 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     [preferences setOfflineWebApplicationCacheEnabled:YES];
 
     [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+
+    $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
+    $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
+    $UIFormAssistant = objc_getClass("UIFormAssistant");
+
+    $UIWebBrowserView = objc_getClass("UIWebBrowserView");
+    if ($UIWebBrowserView == nil) {
+        Wildcat_ = false;
+        $UIWebBrowserView = objc_getClass("UIWebDocumentView");
+    } else {
+        Wildcat_ = true;
+    }
 }
 
 - (void) dealloc {
@@ -260,7 +209,10 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
     [webview_ setDelegate:nil];
     [webview_ setGestureDelegate:nil];
-    [webview_ setFormEditingDelegate:nil];
+
+    if ([webview_ respondsToSelector:@selector(setFormEditingDelegate:)])
+        [webview_ setFormEditingDelegate:nil];
+
     [webview_ setInteractionDelegate:nil];
 
     [indirect_ setDelegate:nil];
@@ -310,7 +262,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     [self loadRequest:[NSURLRequest
         requestWithURL:url
         cachePolicy:policy
-        timeoutInterval:30.0
+        timeoutInterval:120.0
     ]];
 }
 
@@ -342,6 +294,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
             context:@"submit"
         ] autorelease];
 
+        [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+
         [sheet setNumberOfRows:1];
         [sheet popupAlertAnimated:YES];
     }
@@ -358,10 +312,11 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 /* XXX: WebThreadLock? */
 - (void) _fixScroller:(CGRect)bounds {
     float extra;
-    if (!editing_)
+
+    if (!editing_ || $UIFormAssistant == nil)
         extra = 0;
     else {
-        UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
+        UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
         CGRect peripheral([assistant peripheralFrame]);
 #if LogBrowser
         NSLog(@"per:%f", peripheral.size.height);
@@ -371,16 +326,18 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
     CGRect subrect([scroller_ frame]);
     subrect.size.height -= extra;
-    [scroller_ setScrollerIndicatorSubrect:subrect];
 
-    NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height));
-    [webview_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize];
+    if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
+        [scroller_ setScrollerIndicatorSubrect:subrect];
+
+    [webview_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
 
     CGSize size(size_);
     size.height += extra;
     [scroller_ setContentSize:size];
 
-    [scroller_ releaseRubberBandIfNecessary];
+    if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
+        [scroller_ releaseRubberBandIfNecessary];
 }
 
 - (void) fixScroller {
@@ -471,6 +428,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         context:@"sensitive"
     ] autorelease];
 
+    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+
     NSString *host(@"XXX");
 
     [sheet setNumberOfRows:1];
@@ -513,6 +472,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         context:@"alert"
     ] autorelease];
 
+    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+
     [sheet setBodyText:message];
     [sheet popupAlertAnimated:YES];
 }
@@ -530,6 +491,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         context:@"confirm"
     ] autorelease];
 
+    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+
     [sheet setNumberOfRows:1];
     [sheet setBodyText:message];
     [sheet popupAlertAnimated:YES];
@@ -601,12 +564,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 }
 
 - (void) _openMailToURL:(NSURL *)url {
-// XXX: this makes me sad
-#if 0
-    [[[MailToView alloc] initWithView:underlay_ delegate:self url:url] autorelease];
-#else
     [UIApp openURL:url];// asPanel:YES];
-#endif
 }
 
 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
@@ -704,6 +662,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     }
 
     NSURL *url([request URL]);
+    NSString *host([url host]);
 
     if (url == nil) use: {
         if (!error_ && [frame parentFrame] == nil) {
@@ -728,16 +687,22 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
     const NSArray *capability;
 
-#if 0 // XXX:3:GSSystemCopyCapability
-    capability = reinterpret_cast<const NSArray *>(GSSystemGetCapability(kGSDisplayIdentifiersCapability));
-#else
-    capability = nil;
-#endif
+    if ($GSSystemCopyCapability != NULL) {
+        capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(kGSDisplayIdentifiersCapability));
+        capability = [capability autorelease];
+    } else if ($GSSystemGetCapability != NULL) {
+        capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(kGSDisplayIdentifiersCapability));
+    } else
+        capability = nil;
+
+    NSURL *open(nil);
 
     if (capability != nil && (
-        [capability containsObject:@"com.apple.Maps"] && [url mapsURL] ||
-        [capability containsObject:@"com.apple.youtube"] && [url youTubeURL]
+        [url isGoogleMapsURL] && [capability containsObject:@"com.apple.Maps"] && (open = [url mapsURL]) != nil||
+        [host hasSuffix:@"youtube.com"] && [capability containsObject:@"com.apple.youtube"] && (open = [url youTubeURL]) != nil ||
+        [url respondsToSelector:@selector(phobosURL)] && (open = [url phobosURL]) != nil
     )) {
+        url = open;
       open:
         [UIApp openURL:url];
         goto ignore;
@@ -831,8 +796,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
                 [sender cancelAuthenticationChallenge:challenge_];
             break;
 
-            default:
-                _assert(false);
+            _nodefault
         }
 
         [challenge_ release];
@@ -852,8 +816,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
                 }
             break;
 
-            default:
-                _assert(false);
+            _nodefault
         }
 
         [sheet dismiss];
@@ -876,6 +839,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         context:@"challenge"
     ] autorelease];
 
+    [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+
     [sheet setNumberOfRows:1];
 
     [sheet addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
@@ -956,8 +921,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 }
 
 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
-    if ([loading_ count] == 0)
-        [self retain];
+    /*if ([loading_ count] == 0)
+        [self retain];*/
     [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
 
     if ([frame parentFrame] == nil) {
@@ -1002,7 +967,16 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
         [book_ reloadTitleForPage:self];
 
-        [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
+        if (Wildcat_) {
+            CGRect webrect = [scroller_ bounds];
+            webrect.size.height = 1;
+            [webview_ setFrame:webrect];
+        }
+
+        if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
+            [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
+        else
+            [scroller_ scrollRectToVisible:CGRectZero animated:NO];
 
         if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
             [scroller_ setZoomScale:1 duration:0];
@@ -1011,9 +985,11 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
             [scroller_ setZoomScale:1 animated:NO];*/
 
-        CGRect webrect = [scroller_ bounds];
-        webrect.size.height = 0;
-        [webview_ setFrame:webrect];
+        if (!Wildcat_) {
+            CGRect webrect = [scroller_ bounds];
+            webrect.size.height = 0;
+            [webview_ setFrame:webrect];
+        }
     }
 
     [self reloadButtons];
@@ -1021,8 +997,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
 - (void) _finishLoading {
     size_t count([loading_ count]);
-    if (count == 0)
-        [self autorelease];
+    /*if (count == 0)
+        [self autorelease];*/
     if (reloading_ || count != 0)
         return;
     if (finish_ != nil)
@@ -1113,8 +1089,9 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 }
 
 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
-    if ([frame parentFrame] == nil)
-        [self autorelease];
+    _trace();
+    /*if ([frame parentFrame] == nil)
+        [self autorelease];*/
 
     [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
     [self _finishLoading];
@@ -1134,6 +1111,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
     [self _didFailWithError:error forFrame:frame];
+    if ([webview_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
+        [webview_ webView:sender didFailLoadWithError:error forFrame:frame];
 }
 
 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
@@ -1146,17 +1125,99 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 #endif
 }
 
+- (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
+#if LogBrowser || ForSaurik
+    lprintf("Console:%s\n", [[dictionary description] UTF8String]);
+#endif
+    if ([webview_ respondsToSelector:@selector(webView:didReceiveMessage:)])
+        [webview_ webView:sender didReceiveMessage:dictionary];
+}
+
+- (void) webView:(id)sender willCloseFrame:(id)frame {
+    if ([webview_ respondsToSelector:@selector(webView:willCloseFrame:)])
+        [webview_ webView:sender willCloseFrame:frame];
+}
+
+- (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
+    if ([webview_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
+        [webview_ webView:sender didFinishDocumentLoadForFrame:frame];
+}
+
+- (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
+    if ([webview_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
+        [webview_ webView:sender didFirstLayoutInFrame:frame];
+}
+
+- (void) webViewFormEditedStatusHasChanged:(id)changed {
+    if ([webview_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
+        [webview_ webViewFormEditedStatusHasChanged:changed];
+}
+
+- (void) webView:(id)sender formStateDidFocusNode:(id)formState {
+    if ([webview_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
+        [webview_ webView:sender formStateDidFocusNode:formState];
+}
+
+- (void) webView:(id)sender formStateDidBlurNode:(id)formState {
+    if ([webview_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
+        [webview_ webView:sender formStateDidBlurNode:formState];
+}
+
 /* XXX: fix this stupid include file
 - (void) webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)database {
     [origin setQuota:0x500000];
 }*/
 
+- (void) webViewDidLayout:(id)sender {
+    [webview_ webViewDidLayout:sender];
+}
+
+- (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
+    [webview_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
+}
+
+- (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
+    [webview_ webView:sender saveStateToHistoryItem:item forFrame:frame];
+}
+
+- (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
+    [webview_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
+}
+
+- (void) webView:(id)sender attachRootLayer:(id)layer {
+    [webview_ webView:sender attachRootLayer:layer];
+}
+
+- (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
+    return [webview_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
+}
+
+- (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
+    [webview_ webView:sender willShowFullScreenForPlugInView:view];
+}
+
+- (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
+    [webview_ webView:sender didHideFullScreenForPlugInView:view];
+}
+
+- (void) webView:(id)sender willAddPlugInView:(id)view {
+    [webview_ webView:sender willAddPlugInView:view];
+}
+
+- (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
+    [webview_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
+}
+
+- (void) webViewDidPreventDefaultForEvent:(id)sender {
+    [webview_ webViewDidPreventDefaultForEvent:sender];
+}
+
 - (void) _setTileDrawingEnabled:(BOOL)enabled {
     //[webview_ setTileDrawingEnabled:enabled];
 }
 
 - (void) setViewportWidth:(float)width {
-    width_ = width ? width != 0 : [[self class] defaultWidth];
+    width_ = width != 0 ? width : [[self class] defaultWidth];
     [webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
 }
 
@@ -1189,7 +1250,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
         struct CGRect bounds = [self bounds];
 
-        scroller_ = [[UIScroller alloc] initWithFrame:bounds];
+        scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
         [self addSubview:scroller_];
 
         [scroller_ setFixedBackgroundPattern:YES];
@@ -1197,18 +1258,34 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
         [scroller_ setScrollingEnabled:YES];
         [scroller_ setClipsSubviews:YES];
-        [scroller_ setAllowsRubberBanding:YES];
+
+        if (!Wildcat_)
+            [scroller_ setAllowsRubberBanding:YES];
 
         [scroller_ setDelegate:self];
         [scroller_ setBounces:YES];
-        [scroller_ setScrollHysteresis:8];
-        [scroller_ setThumbDetectionEnabled:NO];
-        [scroller_ setDirectionalScrolling:YES];
-        [scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
-        [scroller_ setEventMode:YES];
+
+        if (!Wildcat_) {
+            [scroller_ setScrollHysteresis:8];
+            [scroller_ setThumbDetectionEnabled:NO];
+            [scroller_ setDirectionalScrolling:YES];
+            //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
+            [scroller_ setEventMode:YES];
+        }
+
+        if (Wildcat_) {
+            UIScrollView *scroller((UIScrollView *)scroller_);
+            //[scroller setDirectionalLockEnabled:NO];
+            [scroller setDelaysContentTouches:NO];
+            //[scroller setScrollsToTop:NO];
+            //[scroller setCanCancelContentTouches:NO];
+        }
+
         [scroller_ setShowBackgroundShadow:NO]; /* YES */
-        [scroller_ setAllowsRubberBanding:YES]; /* Vertical */
-        [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
+        //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
+
+        if (!Wildcat_)
+            [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
 
         CGRect webrect = [scroller_ bounds];
         webrect.size.height = 0;
@@ -1228,7 +1305,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 #else
         if (true) {
 #endif
-            webview_ = [[UIWebDocumentView alloc] initWithFrame:webrect];
+            webview_ = [[$UIWebBrowserView alloc] initWithFrame:webrect];
             webview = [webview_ webView];
 
             // XXX: this is terribly (too?) expensive
@@ -1239,9 +1316,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
             if ([webview_ respondsToSelector:@selector(enableReachability)])
                 [webview_ enableReachability];
-
-            [webview_ setAllowsMessaging:YES];
-
+            if ([webview_ respondsToSelector:@selector(setAllowsMessaging:)])
+                [webview_ setAllowsMessaging:YES];
             if ([webview_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
                 [webview_ useSelectionAssistantWithMode:0];
 
@@ -1271,7 +1347,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
             [webview_ _setDocumentType:0x4];
 
-            if ([webview_ respondsToSelector:@selector(UIWebDocumentView:)])
+            if ([webview_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
                 [webview_ setZoomsFocusedFormControl:YES];
             [webview_ setContentsPosition:7];
             [webview_ setEnabledGestures:0xa];
@@ -1296,7 +1372,10 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
         [webview_ setDelegate:self];
         [webview_ setGestureDelegate:self];
-        [webview_ setFormEditingDelegate:self];
+
+        if ([webview_ respondsToSelector:@selector(setFormEditingDelegate:)])
+            [webview_ setFormEditingDelegate:self];
+
         [webview_ setInteractionDelegate:self];
 
         [scroller_ addSubview:webview_];
@@ -1316,11 +1395,13 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         WebThreadUnlock();
 
         CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
-        indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
+        indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(bounds.size.width - 39, 12, indsize.width, indsize.height)];
         [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
 
-        [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
-        [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
+        [self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+        [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+        [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
+        [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
 
         /*UIWebView *test([[[UIWebView alloc] initWithFrame:[self bounds]] autorelease]);
         [test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.saurik.com/"]]];