-- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
- return [webview_ webView:sender shouldScrollToPoint:point forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
- return [webview_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
- return [webview_ webView:sender needsScrollNotifications:notifications forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
- return [webview_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
- return [webview_ webView:sender didReceiveDocTypeForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- if ([frame parentFrame] == nil)
- [self _finishLoading];
- return [webview_ webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- if ([frame parentFrame] != nil)
- return;
- [self _finishLoading];
-
- [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
- [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
- [[error localizedDescription] stringByAddingPercentEscapes]
- ]]];
-}
-
-- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
-#if ForSaurik
- lprintf("Console:%s\n", [[dictionary description] UTF8String]);
-#endif
-}
-
-- (id) initWithBook:(RVBook *)book {
- if ((self = [super initWithBook:book]) != nil) {
- loading_ = false;
-
- struct CGRect bounds = [self bounds];
-
- UIImageView *pinstripe = [[[UIImageView alloc] initWithFrame:bounds] autorelease];
- [pinstripe setImage:[UIImage applicationImageNamed:@"pinstripe.png"]];
- [self addSubview:pinstripe];
-
- scroller_ = [[UIScroller alloc] initWithFrame:bounds];
- [self addSubview:scroller_];
-
- [scroller_ setScrollingEnabled:YES];
- [scroller_ setAdjustForContentSizeChange:YES];
- [scroller_ setClipsSubviews:YES];
- [scroller_ setAllowsRubberBanding:YES];
- [scroller_ setScrollDecelerationFactor:0.99];
- [scroller_ setDelegate:self];
-
- CGRect webrect = [scroller_ bounds];
- webrect.size.height = 0;
-
- WebView *webview;
-
-#if RecycleWebViews
- webview_ = [Documents_ lastObject];
- if (webview_ != nil) {
- webview_ = [webview_ retain];
- webview = [webview_ webView];
- [Documents_ removeLastObject];
- [webview_ setFrame:webrect];
- } else {
-#else
- if (true) {
-#endif
- webview_ = [[UIWebDocumentView alloc] initWithFrame:webrect];
- webview = [webview_ webView];
-
- [webview_ setTileSize:CGSizeMake(webrect.size.width, 500)];
-
- [webview_ setAllowsMessaging:YES];
-
- [webview_ setTilingEnabled:YES];
- [webview_ setDrawsGrid:NO];
- [webview_ setLogsTilingChanges:NO];
- [webview_ setTileMinificationFilter:kCAFilterNearest];
- [webview_ setDetectsPhoneNumbers:NO];
- [webview_ setAutoresizes:YES];
-
- [webview_ setViewportSize:CGSizeMake(980, -1) forDocumentTypes:0x10];
- [webview_ setViewportSize:CGSizeMake(320, -1) forDocumentTypes:0x2];
- [webview_ setViewportSize:CGSizeMake(320, -1) forDocumentTypes:0x8];
-
- [webview_ _setDocumentType:0x4];
-
- [webview_ setZoomsFocusedFormControl:YES];
- [webview_ setContentsPosition:7];
- [webview_ setEnabledGestures:0xa];
- [webview_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
- [webview_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
-
- [webview_ setSmoothsFonts:YES];
-
- [webview _setUsesLoaderCache:YES];
- [webview setGroupName:@"Cydia"];
- //[webview _setLayoutInterval:0.5];
- }
-
- [webview_ setDelegate:self];
- [webview_ setGestureDelegate:self];
- [scroller_ addSubview:webview_];
-
- //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-
- CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
- indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(281, 12, indsize.width, indsize.height)];
- [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
-
- Package *package([[Database sharedInstance] packageWithName:@"cydia"]);
- NSString *application = package == nil ? @"Cydia" : [NSString
- stringWithFormat:@"Cydia/%@",
- [package installed]
- ]; [webview setApplicationNameForUserAgent:application];
-
- indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
-
- [webview setFrameLoadDelegate:self];
- [webview setResourceLoadDelegate:indirect_];
- [webview setUIDelegate:self];
- [webview setScriptDebugDelegate:self];
- [webview setPolicyDelegate:self];
-
- urls_ = [[NSMutableArray alloc] initWithCapacity:16];
-
- [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
- [scroller_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
- [pinstripe setAutoresizingMask:UIViewAutoresizingFlexibleHeight];