}
- (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 {
[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];
}