]> git.saurik.com Git - cydia.git/commitdiff
Fixed the weird zoom-related sizing bug I had accumulated on the Facebook login page...
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 28 Feb 2009 08:01:19 +0000 (08:01 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:09:49 +0000 (07:09 +0000)
UICaboodle/BrowserView.m
UICaboodle/RVBook.h
UICaboodle/RVBook.mm

index 2742e60fb18ce6025cc0d8af0d04401de2128fce..68427d254e5c126aaa445f5e5241b018d60bd237 100644 (file)
 }
 
 - (void) _fixScroller {
+    CGRect bounds([webview_ documentBounds]);
+#if ForSaurik
+    NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
+#endif
+
     float extra;
     if (!editing_)
         extra = 0;
     else {
         UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
         CGRect peripheral([assistant peripheralFrame]);
+#if ForSaurik
         NSLog(@"per:%f", peripheral.size.height);
+#endif
         extra = peripheral.size.height;
     }
 
     subrect.size.height -= extra;
     [scroller_ setScrollerIndicatorSubrect:subrect];
 
+    NSSize visible(NSMakeSize(subrect.size.width, subrect.size.height));
+    [webview_ setValue:[NSValue valueWithSize:visible] forGestureAttribute:UIGestureAttributeVisibleSize];
+
     CGSize size(size_);
     size.height += extra;
     [scroller_ setContentSize:size];
+
+    [scroller_ releaseRubberBandIfNecessary];
 }
 
 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
     size_ = frame.size;
+#if ForSaurik
+    NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
+#endif
     [self _fixScroller];
 }
 
     [book_ pushPage:self];
 }
 
+- (void) swapPage:(RVPage *)page {
+    [page setDelegate:delegate_];
+    if (pushed_)
+        [book_ swapPage:page];
+    else
+        [book_ pushPage:page];
+}
+
 - (BOOL) getSpecial:(NSURL *)url {
 #if ForSaurik
     NSLog(@"getSpecial:%@", url);
         return false;
 
     if (page != nil)
-        [self pushPage:page];
+        [self swapPage:page];
     return true;
 }
 
         [listener use];
 }
 
-- (void) webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
+- (void) webView:(WebView *)sender decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
     if ([WebView canShowMIMEType:type])
         [listener use];
     else {
         // XXX: handle more mime types!
         [listener ignore];
-        if (frame == [webView mainFrame])
+
+        WebView *webview([webview_ webView]);
+        if (frame == [webview mainFrame])
             [UIApp openURL:[request URL]];
     }
 }
         }
 
         [listener use];
+
+        WebView *webview([webview_ webView]);
+        if (frame == [webview mainFrame])
+            [self _pushPage];
         return;
     }
 #if ForSaurik
 #endif
 
     NSNumber *value([features objectForKey:@"width"]);
-    float width(value == nil ? [BrowserView defaultWidth] : [value floatValue]);
+    float width(value == nil ? 0 : [value floatValue]);
 
     RVBook *book(!popup_ ? book_ : [[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
 
     if ([frame parentFrame] != nil)
         return;
 
+    [webview_ resignFirstResponder];
+
     reloading_ = false;
     loading_ = true;
     [self reloadButtons];
     [book_ reloadTitleForPage:self];
 
     [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
+    [scroller_ setZoomScale:1 duration:0];
 
     CGRect webrect = [scroller_ bounds];
     webrect.size.height = 0;
 }
 
 - (void) setViewportWidth:(float)width {
-    width_ = width;
+    width_ = width ? width != 0 : [[self class] defaultWidth];
     [webview_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
 }
 
 }
 
 - (id) initWithBook:(RVBook *)book {
-    return [self initWithBook:book forWidth:[[self class] defaultWidth]];
+    return [self initWithBook:book forWidth:0];
 }
 
 - (void) didFinishGesturesInView:(UIView *)view forEvent:(id)event {
index a7781e7b827db8ead16dd2dc5aa35a98ccd5ba8e..730f7bbd295772c738ca88b4acc8882f7f70055a 100644 (file)
@@ -42,6 +42,8 @@
 
 - (void) setPage:(RVPage *)page;
 
+- (void) swapPage:(RVPage *)page;
+- (void) pushPage:(RVPage *)page animated:(BOOL)animated;
 - (void) pushPage:(RVPage *)page;
 - (void) popPages:(unsigned)pages;
 
index b639958bf452e41d1d93daf65cc729a89f95a101..d7a39490cdc1eebb45a33a8a9e872bb321345d93 100644 (file)
     [navbar_ enableAnimation];
 }
 
-- (void) pushPage:(RVPage *)page {
-    if ([pages_ count] != 0)
-        [[pages_ lastObject] setPageActive:NO];
+- (void) swapPage:(RVPage *)page {
+    if ([pages_ count] == 0)
+        return [self pushPage:page];
+
+    [[pages_ lastObject] setPageActive:NO];
+
+    [navbar_ disableAnimation];
+    resetting_ = true;
+    [navbar_ popNavigationItem];
+    resetting_ = false;
 
+    [self pushPage:page animated:NO];
+    [navbar_ enableAnimation];
+}
+
+- (void) pushPage:(RVPage *)page animated:(BOOL)animated {
     NSString *title = [self getTitleForPage:page];
 
     NSString *backButtonTitle = [page backButtonTitle];
     [navitem setBackButtonTitle:backButtonTitle];
     [navbar_ pushNavigationItem:navitem];
 
-    BOOL animated = [pages_ count] == 0 ? NO : YES;
     [page setFrame:[transition_ bounds]];
     [transition_ transition:(animated ? 1 : 0) toView:page];
     [page setPageActive:YES];
     [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO];
 }
 
+- (void) pushPage:(RVPage *)page {
+    if ([pages_ count] != 0)
+        [[pages_ lastObject] setPageActive:NO];
+    [self pushPage:page animated:([pages_ count] == 0 ? NO : YES)];
+}
+
 - (void) pushBook:(RVBook *)book {
     [delegate_ popUpBook:book];
 }