]> git.saurik.com Git - cydia.git/commitdiff
Implemented form editing and custom viewport sizes.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 25 Feb 2009 11:27:21 +0000 (11:27 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:09:49 +0000 (07:09 +0000)
UICaboodle/BrowserView.h
UICaboodle/BrowserView.m

index a3e1830bf86fedb1932a1fece3bb3d4097f34478..2cb91dae62f022dddb30d97dbe2b9ee255ace925 100644 (file)
@@ -60,6 +60,9 @@
 
     float width_;
     bool popup_;
+
+    CGSize size_;
+    bool editing_;
 }
 
 - (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button;
@@ -80,6 +83,7 @@
 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
 
 + (float) defaultWidth;
+- (void) setViewportWidth:(float)width;
 
 - (id) _rightButtonTitle;
 
index f3c1e3a6aa488e06e31102bdf0b3c72a1bbceb29..39599b9346428fd3151b2a82d7676be6743d2777 100644 (file)
@@ -79,6 +79,8 @@
         return @"setButtonImage";
     else if (selector == @selector(setButtonTitle:withStyle:toFunction:))
         return @"setButtonTitle";
+    else if (selector == @selector(setViewportWidth:))
+        return @"setViewportWidth";
     else if (selector == @selector(supports:))
         return @"supports";
     else if (selector == @selector(du:))
     [indirect_ setButtonTitle:button withStyle:style toFunction:function];
 }
 
+- (void) setViewportWidth:(float)width {
+    [indirect_ setViewportWidth:width];
+}
+
 @end
 /* }}} */
 
 
     [webview_ setDelegate:nil];
     [webview_ setGestureDelegate:nil];
+    [webview_ setFormEditingDelegate:nil];
+    [webview_ setInteractionDelegate:nil];
 
     //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
 
     return webview_;
 }
 
+- (void) _fixScroller {
+    float extra;
+    if (!editing_)
+        extra = 0;
+    else {
+        UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
+        CGRect peripheral([assistant peripheralFrame]);
+        NSLog(@"per:%f", peripheral.size.height);
+        extra = peripheral.size.height;
+    }
+
+    CGRect subrect([scroller_ frame]);
+    subrect.size.height -= extra;
+    [scroller_ setScrollerIndicatorSubrect:subrect];
+
+    CGSize size(size_);
+    size.height += extra;
+    [scroller_ setContentSize:size];
+}
+
 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
-    [scroller_ setContentSize:frame.size];
+    size_ = frame.size;
+    [self _fixScroller];
 }
 
 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
     function_ = function == nil ? nil : [function retain];
 }
 
+- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
+    editing_ = true;
+}
+
+- (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
+    [self _fixScroller];
+}
+
+- (void) webViewDidEndEditingFormElements:(WebView *)sender {
+    editing_ = false;
+    [self _fixScroller];
+}
+
 - (void) webViewClose:(WebView *)sender {
     [book_ close];
 }
 #endif
 }
 
+- (void) setViewportWidth:(float)width {
+    width_ = width;
+    [webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+}
+
 - (id) initWithBook:(RVBook *)book forWidth:(float)width {
     if ((self = [super initWithBook:book]) != nil) {
         loading_ = false;
-        width_ = width;
         popup_ = false;
 
         struct CGRect bounds = [self bounds];
             [webview _setLayoutInterval:0];
         }
 
-        [webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+        [self setViewportWidth:width];
 
         [webview_ setDelegate:self];
         [webview_ setGestureDelegate:self];
+        [webview_ setFormEditingDelegate:self];
+        [webview_ setInteractionDelegate:self];
+
         [scroller_ addSubview:webview_];
 
         //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];