+#include <UIKit/UIKit.h>
+#include "iPhonePrivate.h"
+
+#include "UCPlatform.h"
+
#include <UICaboodle/BrowserView.h>
#include <UICaboodle/UCLocalize.h>
-#import <QuartzCore/CALayer.h>
+//#include <QuartzCore/CALayer.h>
// XXX: fix the minimum requirement
extern NSString * const kCAFilterNearest;
#include <WebCore/WebCoreThread.h>
-#include <WebKit/WebPreferences-WebPrivate.h>
+
+#include <WebKit/WebPolicyDelegate.h>
+#include <WebKit/WebPreferences.h>
+
+#include <WebKit/DOMCSSPrimitiveValue.h>
+#include <WebKit/DOMCSSStyleDeclaration.h>
+#include <WebKit/DOMDocument.h>
+#include <WebKit/DOMHTMLBodyElement.h>
+#include <WebKit/DOMRGBColor.h>
+
+//#include <WebCore/Page.h>
+//#include <WebCore/Settings.h>
#include "substrate.h"
static Class $UIFormAssistant;
static Class $UIWebBrowserView;
-@interface NSString (UIKit)
-- (NSString *) stringByAddingPercentEscapes;
-@end
-
/* Indirect Delegate {{{ */
-@interface IndirectDelegate : NSObject {
+@interface IndirectDelegate : NSObject <
+ HookProtocol
+> {
_transient volatile id delegate_;
}
return nil;
}
+- (void) didDismissModalViewController {
+ if (delegate_ != nil)
+ return [delegate_ didDismissModalViewController];
+}
+
- (IMP) methodForSelector:(SEL)sel {
if (IMP method = [super methodForSelector:sel])
return method;
/* }}} */
@interface WebView (UICaboodle)
-- (void) setScriptDebugDelegate:(id)delegate;
++ (BOOL) _canHandleRequest:(NSURLRequest *)request;
- (void) _setFormDelegate:(id)delegate;
+- (void) _setLayoutInterval:(float)interval;
+- (void) setScriptDebugDelegate:(id)delegate;
- (void) _setUIKitDelegate:(id)delegate;
+- (void) _setUsesLoaderCache:(BOOL)uses;
- (void) setWebMailDelegate:(id)delegate;
-- (void) _setLayoutInterval:(float)interval;
+@end
+
+@interface WebPreferences (Apple)
++ (void) _setInitialDefaultTextEncodingToSystemEncoding;
+- (void) _setLayoutInterval:(NSInteger)interval;
+- (void) setOfflineWebApplicationCacheEnabled:(BOOL)enabled;
@end
@implementation WebScriptObject (UICaboodle)
-- (unsigned) count {
+- (NSUInteger) count {
id length([self valueForKey:@"length"]);
if ([length respondsToSelector:@selector(intValue)])
return [length intValue];
@end
+@interface BrowserView : UIView {
+@private
+ UIWebDocumentView *documentView;
+}
+@property (nonatomic, retain) UIWebDocumentView *documentView;
+@end
+
+@implementation BrowserView
+
+@synthesize documentView;
+
+- (void)dealloc {
+ [documentView release];
+ [super dealloc];
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ if ([documentView respondsToSelector:@selector(setMinimumSize:)])
+ [documentView setMinimumSize:documentView.bounds.size];
+}
+
+@end
+
#define ShowInternals 0
-#define LogBrowser 0
+#define LogBrowser 1
#define lprintf(args...) fprintf(stderr, args)
-@implementation BrowserView
+@implementation BrowserController
#if ShowInternals
#include "UICaboodle/UCInternal.h"
#endif
+ (void) _initialize {
- [WebView enableWebThread];
+ //[WebView enableWebThread];
WebPreferences *preferences([WebPreferences standardPreferences]);
[preferences setCacheModel:WebCacheModelDocumentBrowser];
- (void) dealloc {
#if LogBrowser
- NSLog(@"[BrowserView dealloc]");
+ NSLog(@"[BrowserController dealloc]");
#endif
if (challenge_ != nil)
[sensitive_ release];
if (title_ != nil)
[title_ release];
+ if (reloaditem_ != nil)
+ [reloaditem_ release];
+ if (loadingitem_ != nil)
+ [loadingitem_ release];
+
[super dealloc];
}
if ([request_ HTTPBody] == nil && [request_ HTTPBodyStream] == nil)
[self loadRequest:request_];
else {
- UIActionSheet *sheet = [[[UIActionSheet alloc]
+ UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:UCLocalize("RESUBMIT_FORM")
- buttons:[NSArray arrayWithObjects:UCLocalize("CANCEL"), UCLocalize("SUBMIT"), nil]
- defaultButtonIndex:0
+ message:nil
delegate:self
- context:@"submit"
+ cancelButtonTitle:UCLocalize("CANCEL")
+ otherButtonTitles:UCLocalize("SUBMIT"), nil
] autorelease];
-
- [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
- [sheet setNumberOfRows:1];
- [sheet popupAlertAnimated:YES];
+ [alert setContext:@"submit"];
+ [alert show];
}
}
[self view:sender didSetFrame:frame];
}
-- (void) pushPage:(RVPage *)page {
+- (void) pushPage:(CYViewController *)page {
[page setDelegate:delegate_];
- [self setBackButtonTitle:title_];
- [book_ pushPage:page];
+ [[self navigationItem] setTitle:title_];
+ [[self navigationController] pushViewController:page animated:YES];
}
- (void) _pushPage {
return;
// WTR: [self autorelease];
pushed_ = true;
- [book_ pushPage:self];
+ [[self navigationController] pushViewController:self animated:YES];
}
-- (void) swapPage:(RVPage *)page {
+- (void) swapPage:(CYViewController *)page {
[page setDelegate:delegate_];
- if (pushed_)
- [book_ swapPage:page];
- else
- [book_ pushPage:page];
+ if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
+
+ [[self navigationController] pushViewController:page animated:NO];
}
- (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
NSLog(@"getSpecial:%@", url);
#endif
- if (RVPage *page = [delegate_ pageForURL:url hasTag:NULL]) {
+ if (CYViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
if (swap)
[self swapPage:page];
else
- (void) _promptForSensitive:(NSMutableArray *)array {
NSString *name([array objectAtIndex:0]);
- UIActionSheet *sheet = [[[UIActionSheet alloc]
+ UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:nil
- buttons:[NSArray arrayWithObjects:UCLocalize("YES"), UCLocalize("NO"), nil]
- defaultButtonIndex:0
+ message:nil
delegate:indirect_
- context:@"sensitive"
+ cancelButtonTitle:UCLocalize("NO")
+ otherButtonTitles:UCLocalize("YES"), nil
] autorelease];
- [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
NSString *host(@"XXX");
- [sheet setNumberOfRows:1];
- [sheet setBodyText:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
- [sheet popupAlertAnimated:YES];
+ [alert setContext:@"sensitive"];
+ [alert setMessage:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
+ [alert show];
NSRunLoop *loop([NSRunLoop currentRunLoop]);
NSDate *future([NSDate distantFuture]);
return;
[self retain];
- UIActionSheet *sheet = [[[UIActionSheet alloc]
+ UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:nil
- buttons:[NSArray arrayWithObjects:UCLocalize("OK"), nil]
- defaultButtonIndex:0
+ message:message
delegate:self
- context:@"alert"
+ cancelButtonTitle:UCLocalize("OK")
+ otherButtonTitles:nil
] autorelease];
-
- [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
- [sheet setBodyText:message];
- [sheet popupAlertAnimated:YES];
+ [alert setContext:@"alert"];
+ [alert show];
}
- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
return NO;
[self retain];
- UIActionSheet *sheet = [[[UIActionSheet alloc]
+ UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:nil
- buttons:[NSArray arrayWithObjects:UCLocalize("OK"), UCLocalize("CANCEL"), nil]
- defaultButtonIndex:0
+ message:message
delegate:indirect_
- context:@"confirm"
+ cancelButtonTitle:UCLocalize("CANCEL")
+ otherButtonTitles:UCLocalize("OK"), nil
] autorelease];
- [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
-
- [sheet setNumberOfRows:1];
- [sheet setBodyText:message];
- [sheet popupAlertAnimated:YES];
+ [alert setContext:@"confirm"];
+ [alert show];
NSRunLoop *loop([NSRunLoop currentRunLoop]);
NSDate *future([NSDate distantFuture]);
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
- [self reloadButtons];
+ [self applyRightButton];
}
- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
- [self reloadButtons];
+ [self applyRightButton];
}
- (void) setFinishHook:(id)function {
}
- (void) _openMailToURL:(NSURL *)url {
- [UIApp openURL:url];// asPanel:YES];
+ [[UIApplication sharedApplication] openURL:url];// asPanel:YES];
}
- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
}
- (void) webViewClose:(WebView *)sender {
- [book_ close];
+ [self close];
}
- (void) close {
- [book_ close];
+ [[self navigationController] dismissModalViewControllerAnimated:YES];
}
- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
if ([scheme isEqualToString:@"mailto"])
[self _openMailToURL:url];
else {
- RVBook *book([[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
- [book setHook:indirect_];
+ UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
+ [navigation setHook:indirect_];
- RVPage *page([delegate_ pageForURL:url hasTag:NULL]);
+ CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
if (page == nil) {
/* XXX: call createWebViewWithRequest instead? */
- [self setBackButtonTitle:title_];
-
- BrowserView *browser([[[class_ alloc] initWithBook:book] autorelease]);
+ BrowserController *browser([[[class_ alloc] init] autorelease]);
[browser loadURL:url];
page = browser;
}
- [book setDelegate:delegate_];
+ [navigation setDelegate:delegate_];
[page setDelegate:delegate_];
- [book setPage:page];
- [book_ pushBook:book];
+ [navigation setViewControllers:[NSArray arrayWithObject:page]];
+ UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("CLOSE")
+ style:UIBarButtonItemStylePlain
+ target:page
+ action:@selector(close)
+ ];
+ [[page navigationItem] setLeftBarButtonItem:closeItem];
+ [closeItem release];
+
+ [[self navigationController] presentModalViewController:navigation animated:YES];
}
} else goto unknown;
WebView *webview([document_ webView]);
if (frame == [webview mainFrame])
- [UIApp openURL:[request URL]];
+ [[UIApplication sharedApplication] openURL:[request URL]];
}
}
)) {
url = open;
open:
- [UIApp openURL:url];
+ [[UIApplication sharedApplication] openURL:url];
goto ignore;
}
- int store(_not(int));
+ NSInteger store(_not(NSInteger));
if (NSURL *itms = [url itmsURL:&store]) {
#if LogBrowser
- NSLog(@"itms#%@#%u#%@", url, store, itms);
+ NSLog(@"itms#%@#%d#%@", url, (int) store, itms);
#endif
if (capability != nil && (
//lprintf("Status:%s\n", [text UTF8String]);
}
-- (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
- NSString *context([sheet context]);
+- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
+ NSString *context([alert context]);
if ([context isEqualToString:@"alert"]) {
[self autorelease];
- [sheet dismiss];
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
} else if ([context isEqualToString:@"confirm"]) {
switch (button) {
case 1:
break;
}
- [sheet dismiss];
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
} else if ([context isEqualToString:@"sensitive"]) {
switch (button) {
case 1:
break;
}
- [sheet dismiss];
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
} else if ([context isEqualToString:@"challenge"]) {
id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
switch (button) {
case 1: {
- NSString *username([[sheet textFieldAtIndex:0] text]);
- NSString *password([[sheet textFieldAtIndex:1] text]);
+ NSString *username([[alert textFieldAtIndex:0] text]);
+ NSString *password([[alert textFieldAtIndex:1] text]);
NSURLCredential *credential([NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]);
[challenge_ release];
challenge_ = nil;
- [sheet dismiss];
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
} else if ([context isEqualToString:@"submit"]) {
switch (button) {
case 1:
_nodefault
}
- [sheet dismiss];
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
}
}
if (realm == nil)
realm = @"";
- UIActionSheet *sheet = [[[UIActionSheet alloc]
+ UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:realm
- buttons:[NSArray arrayWithObjects:UCLocalize("LOGIN"), UCLocalize("CANCEL"), nil]
- defaultButtonIndex:0
+ message:nil
delegate:self
- context:@"challenge"
+ cancelButtonTitle:UCLocalize("CANCEL")
+ otherButtonTitles:UCLocalize("LOGIN"), nil
] autorelease];
- [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+ [alert setContext:@"challenge"];
+ [alert setNumberOfRows:1];
- [sheet setNumberOfRows:1];
+ [alert addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
+ [alert addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
- [sheet addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
- [sheet addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
-
- UITextField *username([sheet textFieldAtIndex:0]); {
+ UITextField *username([alert textFieldAtIndex:0]); {
UITextInputTraits *traits([username textInputTraits]);
[traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[traits setAutocorrectionType:UITextAutocorrectionTypeNo];
[traits setReturnKeyType:UIReturnKeyNext];
}
- UITextField *password([sheet textFieldAtIndex:1]); {
+ UITextField *password([alert textFieldAtIndex:1]); {
UITextInputTraits *traits([password textInputTraits]);
[traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[traits setAutocorrectionType:UITextAutocorrectionTypeNo];
[traits setSecureTextEntry:YES];
}
- [sheet popupAlertAnimated:YES];
+ [alert show];
}
- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
NSNumber *value([features objectForKey:@"width"]);
float width(value == nil ? 0 : [value floatValue]);
- RVBook *book(!popup_ ? book_ : [[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
+ UCNavigationController *navigation(!popup_ ? [self navigationController] : [[[UCNavigationController alloc] init] autorelease]);
/* XXX: deal with cydia:// pages */
- BrowserView *browser([[[class_ alloc] initWithBook:book forWidth:width] autorelease]);
+ BrowserController *browser([[[class_ alloc] initWithWidth:width] autorelease]);
if (features != nil && popup_) {
- [book setDelegate:delegate_];
- [book setHook:indirect_];
+ [navigation setDelegate:delegate_];
+ [navigation setHook:indirect_];
[browser setDelegate:delegate_];
[browser loadRequest:request];
- [book setPage:browser];
- [book_ pushBook:book];
- } else if (request == nil) {
- [self setBackButtonTitle:title_];
+ [navigation setViewControllers:[NSArray arrayWithObject:browser]];
+ UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("CLOSE")
+ style:UIBarButtonItemStylePlain
+ target:browser
+ action:@selector(close)
+ ];
+ [[browser navigationItem] setLeftBarButtonItem:closeItem];
+ [closeItem release];
+
+ [[self navigationController] presentModalViewController:navigation animated:YES];
+ } /*else if (request == nil) {
+ [[self navigationItem] setTitle:title_];
[browser setDelegate:delegate_];
[browser retain];
- } else {
+ }*/ else {
[self pushPage:browser];
[browser loadRequest:request];
}
return;
title_ = [title retain];
- [book_ reloadTitleForPage:self];
+ [[self navigationItem] setTitle:title_];
}
- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
special_ = nil;
}
- [book_ reloadTitleForPage:self];
+ [[self navigationItem] setTitle:title_];
if (Wildcat_) {
CGRect webrect = [scroller_ bounds];
}
}
- [self reloadButtons];
+ [self _startLoading];
+}
+
+- (UIBarButtonItemStyle) rightButtonStyle {
+ if (style_ == nil) normal:
+ return UIBarButtonItemStylePlain;
+ else if ([style_ isEqualToString:@"Normal"])
+ return UIBarButtonItemStylePlain;
+ else if ([style_ isEqualToString:@"Highlighted"])
+ return UIBarButtonItemStyleDone;
+ else goto normal;
+}
+
+- (UIBarButtonItem *) customButton {
+ UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
+ initWithTitle:button_
+ style:[self rightButtonStyle]
+ target:self
+ action:@selector(customButtonClicked)
+ ];
+
+ return [customItem autorelease];
+}
+
+- (UIBarButtonItem *) rightButton {
+ return reloaditem_;
+}
+
+- (void) applyLoadingTitle {
+ [[self navigationItem] setTitle:UCLocalize("LOADING")];
+}
+
+- (void) applyRightButton {
+ if ([self isLoading]) {
+ [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
+ [[loadingitem_ view] addSubview:indicator_];
+ [self applyLoadingTitle];
+ } else if (button_) {
+ [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
+ } else {
+ [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
+ }
+}
+
+- (void) _startLoading {
+ [self applyRightButton];
}
- (void) _finishLoading {
return;
if (finish_ != nil)
[self callFunction:finish_];
- [self reloadButtons];
+
+ [self applyRightButton];
+ if (![self isLoading]) [[self navigationItem] setTitle:title_];
}
- (bool) isLoading {
return [loading_ count] != 0;
}
-- (void) reloadButtons {
- if ([self isLoading])
- [indicator_ startAnimation];
- else
- [indicator_ stopAnimation];
- [super reloadButtons];
-}
-
- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
}
if ([frame parentFrame] == nil) {
if (DOMDocument *document = [frame DOMDocument])
if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
- for (DOMHTMLBodyElement *body in bodies) {
+ for (DOMHTMLBodyElement *body in (id) bodies) {
DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
bool colored(false);
UIColor *uic(nil);
if (red == 0xc7 && green == 0xce && blue == 0xd5)
- uic = [UIColor pinStripeColor];
+ uic = [UIColor groupTableViewBackgroundColor];
else if (alpha != 0)
uic = [UIColor
colorWithRed:(red / 255)
}
if (!colored)
- [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
+ [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
break;
}
}
[self _setTileDrawingEnabled:YES];
}
-- (id) initWithBook:(RVBook *)book forWidth:(float)width ofClass:(Class)_class {
- if ((self = [super initWithBook:book]) != nil) {
+- (id) initWithWidth:(float)width ofClass:(Class)_class {
+ if ((self = [super init]) != nil) {
class_ = _class;
loading_ = [[NSMutableSet alloc] initWithCapacity:3];
popup_ = false;
- struct CGRect bounds = [self bounds];
+ BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
+ [self setView:actualView];
+
+ struct CGRect bounds = [[self view] bounds];
scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
- [self addSubview:scroller_];
+ [[self view] addSubview:scroller_];
[scroller_ setFixedBackgroundPattern:YES];
- [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
+ [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
[scroller_ setScrollingEnabled:YES];
[scroller_ setClipsSubviews:YES];
[preferences _setLayoutInterval:0];
}
+ actualView.documentView = document_;
+ [actualView release];
+
[self setViewportWidth:width];
[document_ setDelegate:self];
WebThreadUnlock();
CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
- indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(bounds.size.width - 39, 12, indsize.width, indsize.height)];
+ indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
[indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
+ [indicator_ startAnimation];
+
+ reloaditem_ = [[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("RELOAD")
+ style:[self rightButtonStyle]
+ target:self
+ action:@selector(reloadButtonClicked)
+ ];
+
+ loadingitem_ = [[UIBarButtonItem alloc]
+ initWithTitle:@" "
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(reloadButtonClicked)
+ ];
+ [[loadingitem_ view] addSubview:indicator_];
- [self setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
- [document_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+ [document_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
- /*UIWebView *test([[[UIWebView alloc] initWithFrame:[self bounds]] autorelease]);
+ /*UIWebView *test([[[UIWebView alloc] initWithFrame:[[self view] bounds]] autorelease]);
[test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.saurik.com/"]]];
- [self addSubview:test];*/
+ [[self view] addSubview:test];*/
} return self;
}
-- (id) initWithBook:(RVBook *)book forWidth:(float)width {
- return [self initWithBook:book forWidth:width ofClass:[self class]];
+- (id) initWithWidth:(float)width {
+ return [self initWithWidth:width ofClass:[self class]];
}
-- (id) initWithBook:(RVBook *)book {
- return [self initWithBook:book forWidth:0];
+- (id) init {
+ return [self initWithWidth:0];
}
- (NSString *) stringByEvaluatingJavaScriptFromString:(NSString *)script {
WebView *webview([document_ webView]);
WebFrame *frame([webview mainFrame]);
+ WebPreferences *preferences([webview preferences]);
+
+ bool maybe([preferences javaScriptCanOpenWindowsAutomatically]);
+ [preferences setJavaScriptCanOpenWindowsAutomatically:NO];
- id _private(MSHookIvar<id>(webview, "_private"));
+ /*id _private(MSHookIvar<id>(webview, "_private"));
WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page"));
WebCore::Settings *settings(page == NULL ? NULL : page->settings());
else {
no = settings->JavaScriptCanOpenWindowsAutomatically();
settings->setJavaScriptCanOpenWindowsAutomatically(true);
- }
+ }*/
- if (UIWindow *window = [self window])
+ if (UIWindow *window = [[self view] window])
if (UIResponder *responder = [window firstResponder])
[responder resignFirstResponder];
JSGlobalContextRef context([frame globalContext]);
JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
- if (settings != NULL)
- settings->setJavaScriptCanOpenWindowsAutomatically(no);
+ /*if (settings != NULL)
+ settings->setJavaScriptCanOpenWindowsAutomatically(no);*/
+
+ [preferences setJavaScriptCanOpenWindowsAutomatically:maybe];
WebThreadUnlock();
}
-- (void) didCloseBook:(RVBook *)book {
+- (void) didDismissModalViewController {
if (closer_ != nil)
[self callFunction:closer_];
}
-- (void) __rightButtonClicked {
+- (void) reloadButtonClicked {
reloading_ = true;
[self reloadURL];
}
-- (void) _rightButtonClicked {
+- (void) _customButtonClicked {
+ [self reloadButtonClicked];
+}
+
+- (void) customButtonClicked {
#if !AlwaysReload
if (function_ != nil)
[self callFunction:function_];
else
#endif
- [self __rightButtonClicked];
-}
-
-- (id) _rightButtonTitle {
- return UCLocalize("RELOAD");
-}
-
-- (id) rightButtonTitle {
- return [self isLoading] ? @"" : button_ != nil ? button_ : [self _rightButtonTitle];
-}
-
-- (UINavigationButtonStyle) rightButtonStyle {
- if (style_ == nil) normal:
- return UINavigationButtonStyleNormal;
- else if ([style_ isEqualToString:@"Normal"])
- return UINavigationButtonStyleNormal;
- else if ([style_ isEqualToString:@"Back"])
- return UINavigationButtonStyleBack;
- else if ([style_ isEqualToString:@"Highlighted"])
- return UINavigationButtonStyleHighlighted;
- else if ([style_ isEqualToString:@"Destructive"])
- return UINavigationButtonStyleDestructive;
- else goto normal;
-}
-
-- (NSString *) title {
- return title_ == nil ? UCLocalize("LOADING") : title_;
-}
-
-- (NSString *) backButtonTitle {
- return UCLocalize("BROWSER");
+ [self _customButtonClicked];
}
- (void) setPageActive:(BOOL)active {
if (!active)
[indicator_ removeFromSuperview];
else
- [[book_ navigationBar] addSubview:indicator_];
-}
-
-- (void) resetViewAnimated:(BOOL)animated {
+ [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
}
- (void) setPushed:(bool)pushed {