summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MobileCydia.app/package.js46
-rw-r--r--MobileCydia.mm134
-rw-r--r--UICaboodle/BrowserView.h69
-rw-r--r--UICaboodle/BrowserView.mm1559
-rw-r--r--control2
-rw-r--r--iPhonePrivate.h270
6 files changed, 644 insertions, 1436 deletions
diff --git a/MobileCydia.app/package.js b/MobileCydia.app/package.js
index b9f85ff..4d016d4 100644
--- a/MobileCydia.app/package.js
+++ b/MobileCydia.app/package.js
@@ -45,7 +45,7 @@ swap_ = function (on, off, time) {
};
};
-var special_ = function () {
+$(function () {
if (package == null)
return;
@@ -285,46 +285,4 @@ var special_ = function () {
else
$("#source-description").html($.xml(description));
}
-};
-
-$(special_);
-
-var special = function () {
- $(".deleted").removeClass("deleted");
- $(".inserted").remove();
-
- $("#icon")[0].className = 'flip-0';
- $("#thumb")[0].className = 'flip-180';
-
- /* XXX: this could be better */
- $("#rating-href").href(null);
- $("#rating-none").css("display", "none");
- $("#rating-done").css("display", "none");
-
- var notice = $("#notice-src");
-
- notice[0].outerHTML = '<iframe' +
- ' class="notice"' +
- ' id="notice-src"' +
- ' frameborder="0"' +
- ' width="320"' +
- ' height="0"' +
- ' target="_top"' +
- '></iframe>';
-
- var depiction = $("#depiction-src");
-
- depiction[0].outerHTML = '<iframe' +
- ' class="depiction"' +
- ' id="depiction-src"' +
- ' frameborder="0"' +
- ' width="320"' +
- ' height="0"' +
- ' target="_top"' +
- ' onload_="loaded()"' +
- '></iframe>';
-
- special_();
-};
-
-cydia.setSpecial(special);
+});
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 60edfa0..1772f17 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -380,12 +380,10 @@ static const CFStringCompareFlags LaxCompareFlags_ = kCFCompareCaseInsensitive |
#define ForSaurik (0 && !ForRelease)
#define LogBrowser (0 && !ForRelease)
#define TrackResize (0 && !ForRelease)
-#define ManualRefresh (0 && !ForRelease)
+#define ManualRefresh (1 && !ForRelease)
#define ShowInternals (0 && !ForRelease)
#define IgnoreInstall (0 && !ForRelease)
-#define RecycleWebViews 0
-#define RecyclePackageViews (0 && ForRelease)
-#define AlwaysReload (1 && !ForRelease)
+#define AlwaysReload (0 && !ForRelease)
#if !TraceLogging
#undef _trace
@@ -1074,10 +1072,6 @@ static bool Changed_;
static NSDate *now_;
static bool IsWildcat_;
-
-#if RecycleWebViews
-static NSMutableArray *Documents_;
-#endif
/* }}} */
/* Display Helpers {{{ */
@@ -3695,14 +3689,10 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
return @"getPackageById";
else if (selector == @selector(installPackages:))
return @"installPackages";
- else if (selector == @selector(setAutoPopup:))
- return @"setAutoPopup";
else if (selector == @selector(setButtonImage:withStyle:toFunction:))
return @"setButtonImage";
else if (selector == @selector(setButtonTitle:withStyle:toFunction:))
return @"setButtonTitle";
- else if (selector == @selector(setFinishHook:))
- return @"setFinishHook";
else if (selector == @selector(setPopupHook:))
return @"setPopupHook";
else if (selector == @selector(setSpecial:))
@@ -3813,10 +3803,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[delegate_ performSelectorOnMainThread:@selector(installPackages:) withObject:packages waitUntilDone:NO];
}
-- (void) setAutoPopup:(BOOL)popup {
- [indirect_ setAutoPopup:popup];
-}
-
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
[indirect_ setButtonImage:button withStyle:style toFunction:function];
}
@@ -3838,10 +3824,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
Changed_ = true;
}
-- (void) setFinishHook:(id)function {
- [indirect_ setFinishHook:function];
-}
-
- (void) setPopupHook:(id)function {
[indirect_ setPopupHook:function];
}
@@ -3887,8 +3869,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
- (void) setHeaders:(NSDictionary *)headers forHost:(NSString *)host {
}
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- [super webView:sender didClearWindowObject:window forFrame:frame];
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+ [super webView:view didClearWindowObject:window forFrame:frame];
WebDataSource *source([frame dataSource]);
NSURLResponse *response([source response]);
@@ -3924,8 +3906,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[request setValue:Role_ forHTTPHeaderField:@"X-Role"];
}
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
- NSMutableURLRequest *copy = [request mutableCopy];
+- (NSURLRequest *) webView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source {
+ NSMutableURLRequest *copy([[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source] mutableCopy]);
[self _setMoreHeaders:copy];
return copy;
}
@@ -3939,7 +3921,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
if ((self = [super initWithWidth:0 ofClass:[CYBrowserController class]]) != nil) {
cydia_ = [[CydiaObject alloc] initWithDelegate:indirect_];
- WebView *webview([document_ webView]);
+ WebView *webview([[webview_ _documentView] webView]);
Package *package([[Database sharedInstance] packageWithName:@"cydia"]);
@@ -4022,8 +4004,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
return nil;
}
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- [super webView:sender didClearWindowObject:window forFrame:frame];
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+ [super webView:view didClearWindowObject:window forFrame:frame];
[window setValue:changes_ forKey:@"changes"];
[window setValue:issues_ forKey:@"issues"];
[window setValue:sizes_ forKey:@"sizes"];
@@ -5134,6 +5116,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
NSString *name_;
bool commercial_;
NSMutableArray *buttons_;
+ UIBarButtonItem *button_;
}
- (id) initWithDatabase:(Database *)database;
@@ -5148,7 +5131,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[package_ release];
if (name_ != nil)
[name_ release];
+
[buttons_ release];
+
+ if (button_ != nil)
+ [button_ release];
+
[super dealloc];
}
@@ -5186,12 +5174,8 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
}
}
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- return [super webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- [super webView:sender didClearWindowObject:window forFrame:frame];
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+ [super webView:view didClearWindowObject:window forFrame:frame];
[window setValue:package_ forKey:@"package"];
}
@@ -5248,13 +5232,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
}
- (UIBarButtonItem *) rightButton {
- int count = [buttons_ count];
- return [[[UIBarButtonItem alloc]
- initWithTitle:count == 0 ? nil : count != 1 ? UCLocalize("MODIFY") : [buttons_ objectAtIndex:0]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(customButtonClicked)
- ] autorelease];
+ return button_;
}
#endif
@@ -5297,30 +5275,24 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[buttons_ addObject:UCLocalize("REINSTALL")];
if (![package_ uninstalled])
[buttons_ addObject:UCLocalize("REMOVE")];
+ }
- if (special_ != NULL) {
- CGRect frame([document_ frame]);
- frame.size.height = 0;
- [document_ setFrame:frame];
-
- if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
- [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
- else
- [scroller_ scrollRectToVisible:CGRectZero animated:NO];
-
- WebThreadLock();
- [[[document_ webView] windowScriptObject] setValue:package_ forKey:@"package"];
-
- [self setButtonTitle:nil withStyle:nil toFunction:nil];
-
- [self setFinishHook:nil];
- [self setPopupHook:nil];
- WebThreadUnlock();
+ if (button_ != nil)
+ [button_ release];
- //[self yieldToSelector:@selector(callFunction:) withObject:special_];
- [super callFunction:special_];
- }
+ NSString *title;
+ switch ([buttons_ count]) {
+ case 0: title = nil; break;
+ case 1: title = [buttons_ objectAtIndex:0]; break;
+ default: title = UCLocalize("MODIFY"); break;
}
+
+ button_ = [[UIBarButtonItem alloc]
+ initWithTitle:title
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(customButtonClicked)
+ ];
}
- (bool) isLoading {
@@ -7419,9 +7391,9 @@ freeing the view controllers on tab change */
[super dealloc];
}
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
// XXX: dude!
- [super webView:sender didClearWindowObject:window forFrame:frame];
+ [super webView:view didClearWindowObject:window forFrame:frame];
}
- (id) initWithDatabase:(Database *)database package:(NSString *)package {
@@ -7903,10 +7875,6 @@ typedef enum {
InstalledController *installed_;
id queueDelegate_;
-#if RecyclePackageViews
- NSMutableArray *details_;
-#endif
-
bool loaded_;
}
@@ -8343,10 +8311,6 @@ static _finline void _setHomePage(Cydia *self) {
- (void) setPackageController:(PackageController *)view {
WebThreadLock();
[view setPackage:nil];
-#if RecyclePackageViews
- if ([details_ count] < 3)
- [details_ addObject:view];
-#endif
WebThreadUnlock();
}
@@ -8355,25 +8319,7 @@ static _finline void _setHomePage(Cydia *self) {
}
- (PackageController *) packageController {
-#if RecyclePackageViews
- PackageController *view;
- size_t count([details_ count]);
-
- if (count == 0) {
- view = [self _packageController];
- renew:
- [details_ addObject:[self _packageController]];
- } else {
- view = [[[details_ lastObject] retain] autorelease];
- [details_ removeLastObject];
- if (count == 1)
- goto renew;
- }
-
- return view;
-#else
return [self _packageController];
-#endif
}
// Returns the navigation controller for the queuing badge.
@@ -8682,12 +8628,6 @@ static _finline void _setHomePage(Cydia *self) {
[self reloadData];
-#if RecyclePackageViews
- details_ = [[NSMutableArray alloc] initWithCapacity:4];
- [details_ addObject:[self _packageController]];
- [details_ addObject:[self _packageController]];
-#endif
-
PrintTimes();
_setHomePage(self);
@@ -8931,10 +8871,6 @@ int main(int argc, char *argv[]) { _pooled
}
/* }}} */
-#if RecycleWebViews
- Documents_ = [[[NSMutableArray alloc] initWithCapacity:4] autorelease];
-#endif
-
Finishes_ = [NSArray arrayWithObjects:@"return", @"reopen", @"restart", @"reload", @"reboot", nil];
if (substrate && access("/Library/MobileSubstrate/DynamicLibraries/SimulatedKeyEvents.dylib", F_OK) == 0)
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index c61fef4..2f0e4eb 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -24,6 +24,26 @@
@class Database;
@class IndirectDelegate;
+@protocol CYWebViewDelegate <UIWebViewDelegate>
+- (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener;
+- (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener;
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame;
+- (NSURLRequest *) webView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source;
+- (void) webViewClose:(WebView *)view;
+- (bool) webView:(WebView *)view shouldRunJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
+- (bool) webView:(WebView *)view shouldRunJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
+- (bool) webView:(WebView *)view shouldRunJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame;
+@end
+
+@interface CYWebView : UIWebView
+- (id<CYWebViewDelegate>) delegate;
+@end
+
@interface WebScriptObject (UICaboodle)
- (NSUInteger) count;
- (id) objectAtIndex:(unsigned)index;
@@ -34,10 +54,13 @@
@end
@interface BrowserController : CYViewController <
- HookProtocol
+ CYWebViewDelegate,
+ HookProtocol,
+ UIWebViewDelegate
> {
- UIScroller *scroller_;
- UIWebDocumentView *document_;
+ CYWebView *webview_;
+ UIScrollView *scroller_;
+
UIProgressIndicator *indicator_;
IndirectDelegate *indirect_;
NSURLAuthenticationChallenge *challenge_;
@@ -45,32 +68,23 @@
bool error_;
NSURLRequest *request_;
- NSNumber *confirm_;
NSNumber *sensitive_;
+
NSString *title_;
NSMutableSet *loading_;
- bool reloading_;
- NSString *button_;
+ // XXX: NSString * or UIImage *
+ id custom_;
NSString *style_;
WebScriptObject *function_;
WebScriptObject *closer_;
- WebScriptObject *special_;
- WebScriptObject *finish_;
-
- bool pushed_;
float width_;
- bool popup_;
-
- CGSize size_;
- bool editing_;
-
Class class_;
- id reloaditem_;
- id loadingitem_;
+ UIBarButtonItem *reloaditem_;
+ UIBarButtonItem *loadingitem_;
}
+ (void) _initialize;
@@ -82,39 +96,28 @@
- (void) reloadURL;
- (bool) isLoading;
-- (void) fixScroller;
-
-- (WebView *) webView;
-- (UIWebDocumentView *) documentView;
-
- (id) init;
- (id) initWithWidth:(float)width;
- (id) initWithWidth:(float)width ofClass:(Class)_class;
-- (NSString *) stringByEvaluatingJavaScriptFromString:(NSString *)script;
- (void) callFunction:(WebScriptObject *)function;
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
-
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source;
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
+- (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source;
+ (float) defaultWidth;
-- (void) setViewportWidth:(float)width;
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
-- (void) setFinishHook:(id)function;
- (void) setPopupHook:(id)function;
-- (bool) promptForSensitive:(NSString *)name;
-- (bool) allowSensitiveRequests;
-
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button;
- (void) customButtonClicked;
- (void) applyRightButton;
-- (void) _startLoading;
+- (void) _didStartLoading;
+- (void) _didFinishLoading;
+
- (void) close;
@end
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm
index e2dee3b..8b361f5 100644
--- a/UICaboodle/BrowserView.mm
+++ b/UICaboodle/BrowserView.mm
@@ -28,12 +28,23 @@ extern NSString * const kCAFilterNearest;
#define ForSaurik 0
-static bool Wildcat_;
+template <typename Type_>
+static inline void CYRelease(Type_ &value) {
+ if (value != nil) {
+ [value release];
+ value = nil;
+ }
+}
-static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
-static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
-static Class $UIFormAssistant;
-static Class $UIWebBrowserView;
+@interface WebView (Apple)
+- (void) _setLayoutInterval:(float)interval;
+@end
+
+@interface WebPreferences (Apple)
++ (void) _setInitialDefaultTextEncodingToSystemEncoding;
+- (void) _setLayoutInterval:(NSInteger)interval;
+- (void) setOfflineWebApplicationCacheEnabled:(BOOL)enabled;
+@end
/* Indirect Delegate {{{ */
@interface IndirectDelegate : NSObject <
@@ -57,52 +68,6 @@ static Class $UIWebBrowserView;
return self;
}
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
- if (delegate_ != nil)
- return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
- if (delegate_ != nil)
- return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
-}
-
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
- if (delegate_ != nil)
- return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
- return nil;
-}
-
- (void) didDismissModalViewController {
if (delegate_ != nil)
return [delegate_ didDismissModalViewController];
@@ -143,22 +108,6 @@ static Class $UIWebBrowserView;
@end
/* }}} */
-@interface WebView (UICaboodle)
-+ (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;
-@end
-
-@interface WebPreferences (Apple)
-+ (void) _setInitialDefaultTextEncodingToSystemEncoding;
-- (void) _setLayoutInterval:(NSInteger)interval;
-- (void) setOfflineWebApplicationCacheEnabled:(BOOL)enabled;
-@end
-
@implementation WebScriptObject (UICaboodle)
- (NSUInteger) count {
@@ -175,141 +124,233 @@ static Class $UIWebBrowserView;
@end
-@interface BrowserView : UIView {
-@private
- UIWebDocumentView *documentView;
+// CYWebPolicyDecision* {{{
+enum CYWebPolicyDecision {
+ CYWebPolicyDecisionUnknown,
+ CYWebPolicyDecisionDownload,
+ CYWebPolicyDecisionIgnore,
+ CYWebPolicyDecisionUse,
+};
+
+@interface CYWebPolicyDecisionMediator : NSObject <
+ WebPolicyDecisionListener
+> {
+ id<WebPolicyDecisionListener> listener_;
+ CYWebPolicyDecision decision_;
}
-@property (nonatomic, retain) UIWebDocumentView *documentView;
+
+- (id) initWithListener:(id<WebPolicyDecisionListener>)listener;
+
+- (CYWebPolicyDecision) decision;
+- (bool) decided;
+- (bool) decide;
+
@end
-@implementation BrowserView
+@implementation CYWebPolicyDecisionMediator
-@synthesize documentView;
+- (id) initWithListener:(id<WebPolicyDecisionListener>)listener {
+ if ((self = [super init]) != nil) {
+ listener_ = listener;
+ } return self;
+}
-- (void)dealloc {
- [documentView release];
- [super dealloc];
+- (CYWebPolicyDecision) decision {
+ return decision_;
+}
+
+- (bool) decided {
+ return decision_ != CYWebPolicyDecisionUnknown;
}
-- (void)layoutSubviews {
- [super layoutSubviews];
- if ([documentView respondsToSelector:@selector(setMinimumSize:)])
- [documentView setMinimumSize:documentView.bounds.size];
+- (bool) decide {
+ switch (decision_) {
+ case CYWebPolicyDecisionUnknown:
+ default:
+ return false;
+
+ case CYWebPolicyDecisionDownload: [listener_ download]; break;
+ case CYWebPolicyDecisionIgnore: [listener_ ignore]; break;
+ case CYWebPolicyDecisionUse: [listener_ use]; break;
+ }
+
+ return true;
+}
+
+- (void) download {
+ decision_ = CYWebPolicyDecisionDownload;
+}
+
+- (void) ignore {
+ decision_ = CYWebPolicyDecisionIgnore;
+}
+
+- (void) use {
+ decision_ = CYWebPolicyDecisionUse;
}
@end
+// }}}
-#define ShowInternals 0
-#define LogBrowser 1
+@implementation CYWebView : UIWebView
-#define lprintf(args...) fprintf(stderr, args)
+- (id) initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame]) != nil) {
+ } return self;
+}
-@implementation BrowserController
+- (void) dealloc {
+ [super dealloc];
+}
-#if ShowInternals
-#include "UICaboodle/UCInternal.h"
-#endif
+- (id<CYWebViewDelegate>) delegate {
+ return (id<CYWebViewDelegate>) [super delegate];
+}
-+ (void) _initialize {
- //[WebView enableWebThread];
+/*- (WebView *) webView:(WebView *)view createWebViewWithRequest:(NSURLRequest *)request {
+ NSLog(@"createWebViewWithRequest:%@", request);
+ WebView *created(nil); // XXX
+ if (created == nil && [super respondsToSelector:@selector(webView:createWebViewWithRequest:)])
+ return [super webView:view createWebViewWithRequest:request];
+ else
+ return created;
+}*/
- WebPreferences *preferences([WebPreferences standardPreferences]);
- [preferences setCacheModel:WebCacheModelDocumentBrowser];
- [preferences setOfflineWebApplicationCacheEnabled:YES];
+- (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
+ CYWebPolicyDecisionMediator *mediator([[[CYWebPolicyDecisionMediator alloc] initWithListener:listener] autorelease]);
+ [[self delegate] webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator];
+ if (![mediator decided] && [super respondsToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)])
+ [super webView:view decidePolicyForNavigationAction:action request:request frame:frame decisionListener:mediator];
+ [mediator decide];
+}
- [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+- (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
+ CYWebPolicyDecisionMediator *mediator([[[CYWebPolicyDecisionMediator alloc] initWithListener:listener] autorelease]);
+ [[self delegate] webView:view decidePolicyForNewWindowAction:action request:request newFrameName:frame decisionListener:mediator];
+ if (![mediator decided] && [super respondsToSelector:@selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:)])
+ [super webView:view decidePolicyForNewWindowAction:action request:request newFrameName:frame decisionListener:mediator];
+ [mediator decide];
+}
- $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
- $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
- $UIFormAssistant = objc_getClass("UIFormAssistant");
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didClearWindowObject:window forFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didClearWindowObject:forFrame:)])
+ [super webView:view didClearWindowObject:window forFrame:frame];
+}
- $UIWebBrowserView = objc_getClass("UIWebBrowserView");
- if ($UIWebBrowserView == nil) {
- Wildcat_ = false;
- $UIWebBrowserView = objc_getClass("UIWebDocumentView");
- } else {
- Wildcat_ = true;
- }
+- (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didFailLoadWithError:error forFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
+ [super webView:view didFailLoadWithError:error forFrame:frame];
}
-- (void) dealloc {
-#if LogBrowser
- NSLog(@"[BrowserController dealloc]");
-#endif
+- (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didFailProvisionalLoadWithError:error forFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didFailProvisionalLoadWithError:forFrame:)])
+ [super webView:view didFailProvisionalLoadWithError:error forFrame:frame];
+}
- if (challenge_ != nil)
- [challenge_ release];
+- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didFinishLoadForFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didFinishLoadForFrame:)])
+ [super webView:view didFinishLoadForFrame:frame];
+}
- WebThreadLock();
+- (void) webView:(WebView *)view didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didReceiveTitle:title forFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didReceiveTitle:forFrame:)])
+ [super webView:view didReceiveTitle:title forFrame:frame];
+}
- WebView *webview = [document_ webView];
- [webview setFrameLoadDelegate:nil];
- [webview setResourceLoadDelegate:nil];
- [webview setUIDelegate:nil];
- [webview setScriptDebugDelegate:nil];
- [webview setPolicyDelegate:nil];
+- (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame {
+ [[self delegate] webView:view didStartProvisionalLoadForFrame:frame];
+ if ([super respondsToSelector:@selector(webView:didStartProvisionalLoadForFrame:)])
+ [super webView:view didStartProvisionalLoadForFrame:frame];
+}
- /* XXX: these are set by UIWebDocumentView
- [webview setDownloadDelegate:nil];
- [webview _setFormDelegate:nil];
- [webview _setUIKitDelegate:nil];
- [webview setEditingDelegate:nil];*/
+- (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source {
+ if ([super respondsToSelector:@selector(webView:resource:willSendRequest:redirectResponse:)])
+ request = [super webView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
+ return [[self delegate] webView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source];
+}
- /* XXX: no one sets this, ever
- [webview setWebMailDelegate:nil];*/
+- (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ if ([super respondsToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:)])
+ if ([[self delegate] webView:view shouldRunJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame])
+ [super webView:view runJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame];
+}
- [document_ setDelegate:nil];
- [document_ setGestureDelegate:nil];
+- (BOOL) webView:(WebView *)view runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ if ([super respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:)])
+ if ([[self delegate] webView:view shouldRunJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame])
+ return [super webView:view runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame];
+ return NO;
+}
- if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
- [document_ setFormEditingDelegate:nil];
+- (NSString *) webView:(WebView *)view runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame {
+ if ([super respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:)])
+ if ([[self delegate] webView:view shouldRunJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame])
+ return [super webView:view runJavaScriptTextInputPanelWithPrompt:prompt defaultText:text initiatedByFrame:frame];
+ return nil;
+}
- [document_ setInteractionDelegate:nil];
+- (void) webViewClose:(WebView *)view {
+ [[self delegate] webViewClose:view];
+ if ([super respondsToSelector:@selector(webViewClose:)])
+ [super webViewClose:view];
+}
- [indirect_ setDelegate:nil];
+@end
- //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+#define ShowInternals 0
+#define LogBrowser 1
+
+#define lprintf(args...) fprintf(stderr, args)
- [webview close];
+@implementation BrowserController
-#if RecycleWebViews
- [document_ removeFromSuperview];
- [Documents_ addObject:[document_ autorelease]];
-#else
- [document_ release];
+#if ShowInternals
+#include "UICaboodle/UCInternal.h"
#endif
++ (void) _initialize {
+ [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+}
+
+- (void) dealloc {
+#if LogBrowser
+ NSLog(@"[BrowserController dealloc]");
+#endif
+
+ [webview_ setDelegate:nil];
+
+ [indirect_ setDelegate:nil];
[indirect_ release];
- WebThreadUnlock();
+ if (challenge_ != nil)
+ [challenge_ release];
- [scroller_ setDelegate:nil];
+ //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- if (button_ != nil)
- [button_ release];
+ if (custom_ != nil)
+ [custom_ release];
if (style_ != nil)
[style_ release];
+
if (function_ != nil)
[function_ release];
- if (finish_ != nil)
- [finish_ release];
if (closer_ != nil)
[closer_ release];
- if (special_ != nil)
- [special_ release];
- [scroller_ release];
- [indicator_ release];
- if (confirm_ != nil)
- [confirm_ release];
if (sensitive_ != nil)
[sensitive_ release];
if (title_ != nil)
[title_ release];
- if (reloaditem_ != nil)
- [reloaditem_ release];
- if (loadingitem_ != nil)
- [loadingitem_ release];
+
+ [reloaditem_ release];
+ [loadingitem_ release];
+
+ [indicator_ release];
[super dealloc];
}
@@ -327,11 +368,10 @@ static Class $UIWebBrowserView;
}
- (void) loadRequest:(NSURLRequest *)request {
- pushed_ = true;
error_ = false;
WebThreadLock();
- [document_ loadRequest:request];
+ [webview_ loadRequest:request];
WebThreadUnlock();
}
@@ -349,476 +389,268 @@ static Class $UIWebBrowserView;
cancelButtonTitle:UCLocalize("CANCEL")
otherButtonTitles:UCLocalize("SUBMIT"), nil
] autorelease];
+
[alert setContext:@"submit"];
[alert show];
}
}
-- (WebView *) webView {
- return [document_ webView];
-}
-
-- (UIWebDocumentView *) documentView {
- return document_;
-}
+- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
+ if (custom_ != nil)
+ [custom_ autorelease];
+ custom_ = button == nil ? nil : [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain];
-/* XXX: WebThreadLock? */
-- (void) _fixScroller:(CGRect)bounds {
- float extra;
+ if (style_ != nil)
+ [style_ autorelease];
+ style_ = style == nil ? nil : [style retain];
- if (!editing_ || $UIFormAssistant == nil)
- extra = 0;
- else {
- UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
- CGRect peripheral([assistant peripheralFrame]);
-#if LogBrowser
- NSLog(@"per:%f", peripheral.size.height);
-#endif
- extra = peripheral.size.height;
- }
+ if (function_ != nil)
+ [function_ autorelease];
+ function_ = function == nil ? nil : [function retain];
- CGRect subrect([scroller_ frame]);
- subrect.size.height -= extra;
+ [self applyRightButton];
+}
- if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
- [scroller_ setScrollerIndicatorSubrect:subrect];
+- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
+ if (custom_ != nil)
+ [custom_ autorelease];
+ custom_ = button == nil ? nil : [button retain];
- [document_ setValue:[NSValue valueWithSize:CGSizeMake(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
+ if (style_ != nil)
+ [style_ autorelease];
+ style_ = style == nil ? nil : [style retain];
- CGSize size(size_);
- size.height += extra;
- [scroller_ setContentSize:size];
+ if (function_ != nil)
+ [function_ autorelease];
+ function_ = function == nil ? nil : [function retain];
- if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
- [scroller_ releaseRubberBandIfNecessary];
+ [self applyRightButton];
}
-- (void) fixScroller {
- CGRect bounds([document_ documentBounds]);
-#if TrackResize
- NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
-#endif
- [self _fixScroller:bounds];
+- (void) setPopupHook:(id)function {
+ if (closer_ != nil)
+ [closer_ autorelease];
+ closer_ = function == nil ? nil : [function retain];
}
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
- size_ = frame.size;
-#if TrackResize
- NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
-#endif
- [self _fixScroller:frame];
+- (void) setViewportWidth:(float)width {
+ width_ = width != 0 ? width : [[self class] defaultWidth];
+ [[webview_ _documentView] setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
}
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
- [self view:sender didSetFrame:frame];
+- (void) _openMailToURL:(NSURL *)url {
+ [[UIApplication sharedApplication] openURL:url];// asPanel:YES];
}
-- (void) pushPage:(CYViewController *)page {
- [page setDelegate:delegate_];
- [[self navigationItem] setTitle:title_];
- [[self navigationController] pushViewController:page animated:YES];
+- (bool) _allowJavaScriptPanel {
+ return true;
}
-- (void) _pushPage {
- if (pushed_)
+- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
+ [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
+ [self _didFinishLoading];
+
+ if ([error code] == NSURLErrorCancelled)
return;
- // WTR: [self autorelease];
- pushed_ = true;
- [[self navigationController] pushViewController:self animated:YES];
-}
-- (void) swapPage:(CYViewController *)page {
- [page setDelegate:delegate_];
- if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
+ if ([frame parentFrame] == nil) {
+ [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
+ [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
+ [[error localizedDescription] stringByAddingPercentEscapes]
+ ]]];
- [[self navigationController] pushViewController:page animated:NO];
+ error_ = true;
+ }
}
-- (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
+// CYWebViewDelegate {{{
+- (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
#if LogBrowser
- NSLog(@"getSpecial:%@", url);
+ NSLog(@"decidePolicyForNavigationAction:%@ request:%@ frame:%@", action, request, frame);
#endif
- if (CYViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
- if (swap)
- [self swapPage:page];
+ if (!error_ && [frame parentFrame] == nil) {
+ if (request_ != nil)
+ [request_ autorelease];
+ if (request == nil)
+ request_ = nil;
else
- [self pushPage:page];
-
- return true;
- } else
- return false;
-}
-
-- (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
+ request_ = [request retain];
+ }
}
-- (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
- [self fixScroller];
-}
+- (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
+#if LogBrowser
+ NSLog(@"decidePolicyForNewWindowAction:%@ request:%@ newFrameName:%@", action, request, frame);
+#endif
-- (void) webViewShow:(WebView *)sender {
- /* XXX: this is where I cry myself to sleep */
-}
+ NSURL *url([request URL]);
+ if (url == nil)
+ return;
-- (bool) _allowJavaScriptPanel {
- return true;
-}
+ if ([frame isEqualToString:@"_open"])
+ [delegate_ openURL:url];
-- (bool) allowSensitiveRequests {
- return [self _allowJavaScriptPanel];
-}
+ NSString *scheme([[url scheme] lowercaseString]);
+ if ([scheme isEqualToString:@"mailto"])
+ [self _openMailToURL:url];
-- (void) _promptForSensitive:(NSMutableArray *)array {
- NSString *name([array objectAtIndex:0]);
+ CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
- UIAlertView *alert = [[[UIAlertView alloc]
- initWithTitle:nil
- message:nil
- delegate:indirect_
- cancelButtonTitle:UCLocalize("NO")
- otherButtonTitles:UCLocalize("YES"), nil
- ] autorelease];
-
- NSString *host(@"XXX");
+ if (page == nil) {
+ BrowserController *browser([[[class_ alloc] init] autorelease]);
+ [browser loadRequest:request];
+ page = browser;
+ }
- [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];
+ [page setDelegate:delegate_];
- NSRunLoop *loop([NSRunLoop currentRunLoop]);
- NSDate *future([NSDate distantFuture]);
+ if (![frame isEqualToString:@"_popup"]) {
+ [[self navigationItem] setTitle:title_];
- while (sensitive_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
+ [[self navigationController] pushViewController:page animated:YES];
+ } else {
+ UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
- NSNumber *sensitive([sensitive_ autorelease]);
- sensitive_ = nil;
+ [navigation setHook:indirect_];
+ [navigation setDelegate:delegate_];
- [self autorelease];
- [array replaceObjectAtIndex:0 withObject:sensitive];
-}
+ [navigation setViewControllers:[NSArray arrayWithObject:page]];
-- (bool) promptForSensitive:(NSString *)name {
- if (![self allowSensitiveRequests])
- return false;
+ [[page navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("CLOSE")
+ style:UIBarButtonItemStylePlain
+ target:page
+ action:@selector(close)
+ ] autorelease]];
- NSMutableArray *array([NSMutableArray arrayWithCapacity:1]);
- [array addObject:name];
+ [[self navigationController] presentModalViewController:navigation animated:YES];
+ }
- [self performSelectorOnMainThread:@selector(_promptForSensitive:) withObject:array waitUntilDone:YES];
- return [[array lastObject] boolValue];
+ [listener ignore];
}
-- (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
- if (![self _allowJavaScriptPanel])
- return;
- [self retain];
-
- UIAlertView *alert = [[[UIAlertView alloc]
- initWithTitle:nil
- message:message
- delegate:self
- cancelButtonTitle:UCLocalize("OK")
- otherButtonTitles:nil
- ] autorelease];
- [alert setContext:@"alert"];
- [alert show];
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
}
-- (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
- if (![self _allowJavaScriptPanel])
- return NO;
- [self retain];
-
- UIAlertView *alert = [[[UIAlertView alloc]
- initWithTitle:nil
- message:message
- delegate:indirect_
- cancelButtonTitle:UCLocalize("CANCEL")
- otherButtonTitles:UCLocalize("OK"), nil
- ] autorelease];
-
- [alert setContext:@"confirm"];
- [alert show];
-
- NSRunLoop *loop([NSRunLoop currentRunLoop]);
- NSDate *future([NSDate distantFuture]);
-
- while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
-
- NSNumber *confirm([confirm_ autorelease]);
- confirm_ = nil;
+- (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+#if LogBrowser
+ NSLog(@"didFailLoadWithError:%@ forFrame:%@", error, frame);
+#endif
- [self autorelease];
- return [confirm boolValue];
+ [self _didFailWithError:error forFrame:frame];
}
-- (void) setAutoPopup:(BOOL)popup {
- popup_ = popup;
-}
+- (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
+#if LogBrowser
+ NSLog(@"didFailProvisionalLoadWithError:%@ forFrame:%@", error, frame);
+#endif
-- (void) setSpecial:(id)function {
- if (special_ != nil)
- [special_ autorelease];
- special_ = function == nil ? nil : [function retain];
+ [self _didFailWithError:error forFrame:frame];
}
-- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
- if (button_ != nil)
- [button_ autorelease];
- button_ = button == nil ? nil : [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain];
-
- if (style_ != nil)
- [style_ autorelease];
- style_ = style == nil ? nil : [style retain];
+- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame {
+ [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
- if (function_ != nil)
- [function_ autorelease];
- function_ = function == nil ? nil : [function retain];
+ if ([frame parentFrame] == nil) {
+ if (DOMDocument *document = [frame DOMDocument])
+ if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
+ for (DOMHTMLBodyElement *body in (id) bodies) {
+ DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
- [self applyRightButton];
-}
+ bool colored(false);
-- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
- if (button_ != nil)
- [button_ autorelease];
- button_ = button == nil ? nil : [button retain];
+ if (DOMCSSPrimitiveValue *color = static_cast<DOMCSSPrimitiveValue *>([style getPropertyCSSValue:@"background-color"])) {
+ if ([color primitiveType] == DOM_CSS_RGBCOLOR) {
+ DOMRGBColor *rgb([color getRGBColorValue]);
- if (style_ != nil)
- [style_ autorelease];
- style_ = style == nil ? nil : [style retain];
+ float red([[rgb red] getFloatValue:DOM_CSS_NUMBER]);
+ float green([[rgb green] getFloatValue:DOM_CSS_NUMBER]);
+ float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]);
+ float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]);
- if (function_ != nil)
- [function_ autorelease];
- function_ = function == nil ? nil : [function retain];
+ UIColor *uic(nil);
- [self applyRightButton];
-}
+ if (red == 0xc7 && green == 0xce && blue == 0xd5)
+ uic = [UIColor groupTableViewBackgroundColor];
+ else if (alpha != 0)
+ uic = [UIColor
+ colorWithRed:(red / 255)
+ green:(green / 255)
+ blue:(blue / 255)
+ alpha:alpha
+ ];
-- (void) setFinishHook:(id)function {
- if (finish_ != nil)
- [finish_ autorelease];
- finish_ = function == nil ? nil : [function retain];
-}
+ if (uic != nil) {
+ colored = true;
+ [scroller_ setBackgroundColor:uic];
+ }
+ }
+ }
-- (void) setPopupHook:(id)function {
- if (closer_ != nil)
- [closer_ autorelease];
- closer_ = function == nil ? nil : [function retain];
-}
+ if (!colored)
+ [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
+ break;
+ }
+ }
-- (void) _openMailToURL:(NSURL *)url {
- [[UIApplication sharedApplication] openURL:url];// asPanel:YES];
+ [self _didFinishLoading];
}
-- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
- editing_ = true;
-}
+- (void) webView:(WebView *)view didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
+ if ([frame parentFrame] != nil)
+ return;
-- (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
- [self fixScroller];
+ title_ = [title retain];
+ [[self navigationItem] setTitle:title_];
}
-- (void) webViewDidEndEditingFormElements:(WebView *)sender {
- editing_ = false;
- [self fixScroller];
-}
+- (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame {
+ [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
-- (void) webViewClose:(WebView *)sender {
- [self close];
-}
+ if ([frame parentFrame] == nil) {
+ CYRelease(title_);
+ CYRelease(custom_);
+ CYRelease(style_);
+ CYRelease(function_);
+ CYRelease(closer_);
+
+ // XXX: do we still need to do this?
+ [[self navigationItem] setTitle:nil];
+ }
-- (void) close {
- [[self navigationController] dismissModalViewControllerAnimated:YES];
+ [self _didStartLoading];
}
-- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+- (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source {
+ return request;
}
-- (void) webView:(WebView *)sender unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame {
- NSLog(@"err:%@", error);
+- (bool) webView:(WebView *)view shouldRunJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ return [self _allowJavaScriptPanel];
}
-- (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
-#if LogBrowser
- NSLog(@"nwa:%@", name);
-#endif
-
- if (NSURL *url = [request URL]) {
- if (name == nil) unknown: {
- if (![self getSpecial:url swap:NO]) {
- NSString *scheme([[url scheme] lowercaseString]);
- if ([scheme isEqualToString:@"mailto"])
- [self _openMailToURL:url];
- else goto use;
- }
- } else if ([name isEqualToString:@"_open"])
- [delegate_ openURL:url];
- else if ([name isEqualToString:@"_popup"]) {
- NSString *scheme([[url scheme] lowercaseString]);
- if ([scheme isEqualToString:@"mailto"])
- [self _openMailToURL:url];
- else {
- UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
- [navigation setHook:indirect_];
-
- CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
- if (page == nil) {
- /* XXX: call createWebViewWithRequest instead? */
-
- BrowserController *browser([[[class_ alloc] init] autorelease]);
- [browser loadURL:url];
- page = browser;
- }
-
- [navigation setDelegate:delegate_];
- [page setDelegate:delegate_];
-
- [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;
-
- [listener ignore];
- } else use:
- [listener use];
+- (bool) webView:(WebView *)view shouldRunJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
+ return [self _allowJavaScriptPanel];
}
-- (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];
-
- WebView *webview([document_ webView]);
- if (frame == [webview mainFrame])
- [[UIApplication sharedApplication] openURL:[request URL]];
- }
+- (bool) webView:(WebView *)view shouldRunJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame {
+ return [self _allowJavaScriptPanel];
}
-- (void) webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
- if (request == nil) ignore: {
- [listener ignore];
- return;
- }
-
- NSURL *url([request URL]);
- NSString *host([url host]);
-
- if (url == nil) use: {
- if (!error_ && [frame parentFrame] == nil) {
- if (request_ != nil)
- [request_ autorelease];
- request_ = [request retain];
-#if LogBrowser
- NSLog(@"dpn:%@", request_);
-#endif
- }
-
- [listener use];
-
- WebView *webview([document_ webView]);
- if (frame == [webview mainFrame])
- [self _pushPage];
- return;
- }
-#if LogBrowser
- else NSLog(@"nav:%@:%@", url, [action description]);
-#endif
-
- const NSArray *capability;
-
- if ($GSSystemCopyCapability != NULL) {
- capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(kGSDisplayIdentifiersCapability));
- capability = [capability autorelease];
- } else if ($GSSystemGetCapability != NULL) {
- capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(kGSDisplayIdentifiersCapability));
- } else
- capability = nil;
-
- NSURL *open(nil);
-
- if (capability != nil && (
- [url isGoogleMapsURL] && [capability containsObject:@"com.apple.Maps"] && (open = [url mapsURL]) != nil||
- [host hasSuffix:@"youtube.com"] && [capability containsObject:@"com.apple.youtube"] && (open = [url youTubeURL]) != nil ||
- [url respondsToSelector:@selector(phobosURL)] && (open = [url phobosURL]) != nil
- )) {
- url = open;
- open:
- [[UIApplication sharedApplication] openURL:url];
- goto ignore;
- }
-
- NSInteger store(_not(NSInteger));
- if (NSURL *itms = [url itmsURL:&store]) {
-#if LogBrowser
- NSLog(@"itms#%@#%d#%@", url, (int) store, itms);
-#endif
-
- if (capability != nil && (
- store == 1 && [capability containsObject:@"com.apple.MobileStore"] ||
- store == 2 && [capability containsObject:@"com.apple.AppStore"]
- )) {
- url = itms;
- goto open;
- }
- }
-
- NSString *scheme([[url scheme] lowercaseString]);
-
- if ([scheme isEqualToString:@"tel"]) {
- // XXX: intelligence
- goto open;
- }
-
- if ([scheme isEqualToString:@"mailto"]) {
- [self _openMailToURL:url];
- goto ignore;
- }
-
- if ([self getSpecial:url swap:YES])
- goto ignore;
- else if ([WebView _canHandleRequest:request])
- goto use;
- else if ([url isSpringboardHandledURL])
- goto open;
- else
- goto use;
+- (void) webViewClose:(WebView *)view {
+ [self close];
}
+// }}}
-- (void) webView:(WebView *)sender setStatusText:(NSString *)text {
- //lprintf("Status:%s\n", [text UTF8String]);
+- (void) close {
+ [[self navigationController] dismissModalViewControllerAnimated:YES];
}
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
NSString *context([alert context]);
- if ([context isEqualToString:@"alert"]) {
- [self autorelease];
- [alert dismissWithClickedButtonIndex:-1 animated:YES];
- } else if ([context isEqualToString:@"confirm"]) {
- switch (button) {
- case 1:
- confirm_ = [NSNumber numberWithBool:YES];
- break;
-
- case 2:
- confirm_ = [NSNumber numberWithBool:NO];
- break;
- }
-
- [alert dismissWithClickedButtonIndex:-1 animated:YES];
- } else if ([context isEqualToString:@"sensitive"]) {
+ if ([context isEqualToString:@"sensitive"]) {
switch (button) {
case 1:
sensitive_ = [NSNumber numberWithBool:YES];
@@ -862,7 +694,7 @@ static Class $UIWebBrowserView;
case 2:
if (request_ != nil) {
WebThreadLock();
- [document_ loadRequest:request_];
+ [webview_ loadRequest:request_];
WebThreadUnlock();
}
break;
@@ -874,186 +706,6 @@ static Class $UIWebBrowserView;
}
}
-- (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
- challenge_ = [challenge retain];
-
- NSURLProtectionSpace *space([challenge protectionSpace]);
- NSString *realm([space realm]);
- if (realm == nil)
- realm = @"";
-
- UIAlertView *alert = [[[UIAlertView alloc]
- initWithTitle:realm
- message:nil
- delegate:self
- cancelButtonTitle:UCLocalize("CANCEL")
- otherButtonTitles:UCLocalize("LOGIN"), nil
- ] autorelease];
-
- [alert setContext:@"challenge"];
- [alert setNumberOfRows:1];
-
- [alert addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
- [alert addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
-
- UITextField *username([alert textFieldAtIndex:0]); {
- UITextInputTraits *traits([username textInputTraits]);
- [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
- [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
- [traits setKeyboardType:UIKeyboardTypeASCIICapable];
- [traits setReturnKeyType:UIReturnKeyNext];
- }
-
- UITextField *password([alert textFieldAtIndex:1]); {
- UITextInputTraits *traits([password textInputTraits]);
- [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
- [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
- [traits setKeyboardType:UIKeyboardTypeASCIICapable];
- // XXX: UIReturnKeyDone
- [traits setReturnKeyType:UIReturnKeyNext];
- [traits setSecureTextEntry:YES];
- }
-
- [alert show];
-}
-
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
- return request;
-}
-
-- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features {
-//- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)gesture {
-#if LogBrowser
- NSLog(@"cwv:%@ (%@): %@", request, title_, features == nil ? @"{}" : [features description]);
- //NSLog(@"cwv:%@ (%@): %@", request, title_, gesture ? @"Yes" : @"No");
-#endif
-
- NSNumber *value([features objectForKey:@"width"]);
- float width(value == nil ? 0 : [value floatValue]);
-
- UCNavigationController *navigation(!popup_ ? [self navigationController] : [[[UCNavigationController alloc] init] autorelease]);
-
- /* XXX: deal with cydia:// pages */
- BrowserController *browser([[[class_ alloc] initWithWidth:width] autorelease]);
-
- if (features != nil && popup_) {
- [navigation setDelegate:delegate_];
- [navigation setHook:indirect_];
- [browser setDelegate:delegate_];
-
- [browser loadRequest:request];
-
- [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 {
- [self pushPage:browser];
- [browser loadRequest:request];
- }
-
- return [browser webView];
-}
-
-- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
- return [self webView:sender createWebViewWithRequest:request windowFeatures:nil];
- //return [self webView:sender createWebViewWithRequest:request userGesture:YES];
-}
-
-- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
- if ([frame parentFrame] != nil)
- return;
-
- title_ = [title retain];
- [[self navigationItem] setTitle:title_];
-}
-
-- (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
- /*if ([loading_ count] == 0)
- [self retain];*/
- [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
-
- if ([frame parentFrame] == nil) {
- [document_ resignFirstResponder];
-
- reloading_ = false;
-
- if (title_ != nil) {
- [title_ release];
- title_ = nil;
- }
-
- if (button_ != nil) {
- [button_ release];
- button_ = nil;
- }
-
- if (style_ != nil) {
- [style_ release];
- style_ = nil;
- }
-
- if (function_ != nil) {
- [function_ release];
- function_ = nil;
- }
-
- if (finish_ != nil) {
- [finish_ release];
- finish_ = nil;
- }
-
- if (closer_ != nil) {
- [closer_ release];
- closer_ = nil;
- }
-
- if (special_ != nil) {
- [special_ release];
- special_ = nil;
- }
-
- [[self navigationItem] setTitle:title_];
-
- if (Wildcat_) {
- CGRect webrect = [scroller_ bounds];
- webrect.size.height = 1;
- [document_ setFrame:webrect];
- }
-
- if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
- [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
- else
- [scroller_ scrollRectToVisible:CGRectZero animated:NO];
-
- if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
- [scroller_ setZoomScale:1 duration:0];
- else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
- [scroller_ _setZoomScale:1 duration:0];
- /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
- [scroller_ setZoomScale:1 animated:NO];*/
-
- if (!Wildcat_) {
- CGRect webrect = [scroller_ bounds];
- webrect.size.height = 0;
- [document_ setFrame:webrect];
- }
- }
-
- [self _startLoading];
-}
-
- (UIBarButtonItemStyle) rightButtonStyle {
if (style_ == nil) normal:
return UIBarButtonItemStylePlain;
@@ -1065,14 +717,12 @@ static Class $UIWebBrowserView;
}
- (UIBarButtonItem *) customButton {
- UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
- initWithTitle:button_
+ return [[[UIBarButtonItem alloc]
+ initWithTitle:custom_
style:[self rightButtonStyle]
target:self
action:@selector(customButtonClicked)
- ];
-
- return [customItem autorelease];
+ ] autorelease];
}
- (UIBarButtonItem *) rightButton {
@@ -1086,423 +736,108 @@ static Class $UIWebBrowserView;
- (void) applyRightButton {
if ([self isLoading]) {
[[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
+ // XXX: why do we do this again here?
[[loadingitem_ view] addSubview:indicator_];
[self applyLoadingTitle];
- } else if (button_) {
+ } else if (custom_ != nil) {
[[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
} else {
[[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
}
}
-- (void) _startLoading {
+- (void) _didStartLoading {
[self applyRightButton];
}
-- (void) _finishLoading {
- size_t count([loading_ count]);
- /*if (count == 0)
- [self autorelease];*/
- if (reloading_ || count != 0)
+- (void) _didFinishLoading {
+ if ([loading_ count] != 0)
return;
- if (finish_ != nil)
- [self callFunction:finish_];
[self applyRightButton];
- if (![self isLoading]) [[self navigationItem] setTitle:title_];
+
+ // XXX: wtf?
+ if (![self isLoading])
+ [[self navigationItem] setTitle:title_];
}
- (bool) isLoading {
return [loading_ count] != 0;
}
-- (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
- return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
- return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
- return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
- [self _pushPage];
- return [document_ webView:sender didCommitLoadForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
- return [document_ webView:sender didReceiveDocTypeForFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
- [self _finishLoading];
-
- if ([frame parentFrame] == nil) {
- if (DOMDocument *document = [frame DOMDocument])
- if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
- for (DOMHTMLBodyElement *body in (id) bodies) {
- DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
-
- bool colored(false);
-
- if (DOMCSSPrimitiveValue *color = static_cast<DOMCSSPrimitiveValue *>([style getPropertyCSSValue:@"background-color"])) {
- if ([color primitiveType] == DOM_CSS_RGBCOLOR) {
- DOMRGBColor *rgb([color getRGBColorValue]);
-
- float red([[rgb red] getFloatValue:DOM_CSS_NUMBER]);
- float green([[rgb green] getFloatValue:DOM_CSS_NUMBER]);
- float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]);
- float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]);
-
- UIColor *uic(nil);
-
- if (red == 0xc7 && green == 0xce && blue == 0xd5)
- uic = [UIColor groupTableViewBackgroundColor];
- else if (alpha != 0)
- uic = [UIColor
- colorWithRed:(red / 255)
- green:(green / 255)
- blue:(blue / 255)
- alpha:alpha
- ];
-
- if (uic != nil) {
- colored = true;
- [scroller_ setBackgroundColor:uic];
- }
- }
- }
-
- if (!colored)
- [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
- break;
- }
- }
-
- return [document_ webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
- _trace();
- /*if ([frame parentFrame] == nil)
- [self autorelease];*/
-
- [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
- [self _finishLoading];
-
- if (reloading_)
- return;
-
- if ([frame parentFrame] == nil) {
- [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
- [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
- [[error localizedDescription] stringByAddingPercentEscapes]
- ]]];
-
- error_ = true;
- }
-}
-
-- (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [self _didFailWithError:error forFrame:frame];
- if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
- [document_ webView:sender didFailLoadWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
- [self _didFailWithError:error forFrame:frame];
-}
-
-- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
-#if LogBrowser || ForSaurik
- lprintf("Console:%s\n", [[dictionary description] UTF8String]);
-#endif
-}
-
-- (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
-#if LogBrowser || ForSaurik
- lprintf("Console:%s\n", [[dictionary description] UTF8String]);
-#endif
- if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
- [document_ webView:sender didReceiveMessage:dictionary];
-}
-
-- (void) webView:(id)sender willCloseFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
- [document_ webView:sender willCloseFrame:frame];
-}
-
-- (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
- [document_ webView:sender didFinishDocumentLoadForFrame:frame];
-}
-
-- (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
- if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
- [document_ webView:sender didFirstLayoutInFrame:frame];
-}
-
-- (void) webViewFormEditedStatusHasChanged:(id)changed {
- if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
- [document_ webViewFormEditedStatusHasChanged:changed];
-}
-
-- (void) webView:(id)sender formStateDidFocusNode:(id)formState {
- if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
- [document_ webView:sender formStateDidFocusNode:formState];
-}
-
-- (void) webView:(id)sender formStateDidBlurNode:(id)formState {
- if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
- [document_ webView:sender formStateDidBlurNode:formState];
-}
-
-/* XXX: fix this stupid include file
-- (void) webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)database {
- [origin setQuota:0x500000];
-}*/
-
-- (void) webViewDidLayout:(id)sender {
- [document_ webViewDidLayout:sender];
-}
-
-- (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
- [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
-}
-
-- (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
- [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
-}
-
-- (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
- [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
-}
-
-- (void) webView:(id)sender attachRootLayer:(id)layer {
- [document_ webView:sender attachRootLayer:layer];
-}
+- (id) initWithWidth:(float)width ofClass:(Class)_class {
+ if ((self = [super init]) != nil) {
+ class_ = _class;
+ loading_ = [[NSMutableSet alloc] initWithCapacity:5];
-- (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
- return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
-}
+ indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
-- (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
- [document_ webView:sender willShowFullScreenForPlugInView:view];
-}
+ webview_ = [[[CYWebView alloc] initWithFrame:[[self view] bounds]] autorelease];
+ [webview_ setDelegate:self];
+ [self setView:webview_];
-- (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
- [document_ webView:sender didHideFullScreenForPlugInView:view];
-}
+ if ([webview_ respondsToSelector:@selector(setDataDetectorTypes:)])
+ [webview_ setDataDetectorTypes:UIDataDetectorTypeAutomatic];
+ else
+ [webview_ setDetectsPhoneNumbers:NO];
-- (void) webView:(id)sender willAddPlugInView:(id)view {
- [document_ webView:sender willAddPlugInView:view];
-}
+ [webview_ setScalesPageToFit:YES];
-- (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
- [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
-}
+ UIWebDocumentView *document([webview_ _documentView]);
-- (void) webViewDidPreventDefaultForEvent:(id)sender {
- [document_ webViewDidPreventDefaultForEvent:sender];
-}
+ // XXX: I think this improves scrolling; the hardcoded-ness sucks
+ [document setTileSize:CGSizeMake(320, 500)];
-- (void) _setTileDrawingEnabled:(BOOL)enabled {
- //[document_ setTileDrawingEnabled:enabled];
-}
+ [document setBackgroundColor:[UIColor clearColor]];
+ [document setDrawsBackground:NO];
-- (void) setViewportWidth:(float)width {
- width_ = width != 0 ? width : [[self class] defaultWidth];
- [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
-}
+ WebView *webview([document webView]);
+ WebPreferences *preferences([webview preferences]);
-- (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
- [self _setTileDrawingEnabled:NO];
-}
+ // XXX: I have no clue if I actually /want/ this modification
+ if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
+ [webview _setLayoutInterval:0];
+ else if ([preferences respondsToSelector:@selector(_setLayoutInterval:)])
+ [preferences _setLayoutInterval:0];
-- (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
- [self _setTileDrawingEnabled:YES];
- [document_ redrawScaledDocument];
-}
+ [preferences setCacheModel:WebCacheModelDocumentBrowser];
+ [preferences setOfflineWebApplicationCacheEnabled:YES];
-- (void) scrollerWillStartDragging:(UIScroller *)scroller {
- [self _setTileDrawingEnabled:NO];
-}
+ if ([webview_ respondsToSelector:@selector(_scrollView)]) {
+ scroller_ = [webview_ _scrollView];
-- (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
- [self _setTileDrawingEnabled:YES];
-}
+ [scroller_ setDirectionalLockEnabled:YES];
+ [scroller_ setDecelerationRate:UIScrollViewDecelerationRateNormal];
+ [scroller_ setDelaysContentTouches:NO];
-- (void) scrollerDidEndDragging:(UIScroller *)scroller {
- [self _setTileDrawingEnabled:YES];
-}
+ [scroller_ setCanCancelContentTouches:YES];
+ } else if ([webview_ respondsToSelector:@selector(_scroller)]) {
+ UIScroller *scroller([webview_ _scroller]);
+ scroller_ = (UIScrollView *) scroller;
-- (id) initWithWidth:(float)width ofClass:(Class)_class {
- if ((self = [super init]) != nil) {
- class_ = _class;
- loading_ = [[NSMutableSet alloc] initWithCapacity:3];
- popup_ = false;
+ [scroller setDirectionalScrolling:YES];
+ [scroller setScrollDecelerationFactor:UIScrollViewDecelerationRateNormal]; /* 0.989324 */
+ [scroller setScrollHysteresis:0]; /* 8 */
- BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
- [self setView:actualView];
+ [scroller setThumbDetectionEnabled:NO];
- struct CGRect bounds = [[self view] bounds];
+ // use NO with UIApplicationUseLegacyEvents(YES)
+ [scroller setEventMode:YES];
- scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
- [[self view] addSubview:scroller_];
+ // XXX: this is handled by setBounces, right?
+ //[scroller setAllowsRubberBanding:YES];
+ }
[scroller_ setFixedBackgroundPattern:YES];
[scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
-
- [scroller_ setScrollingEnabled:YES];
[scroller_ setClipsSubviews:YES];
- if (!Wildcat_)
- [scroller_ setAllowsRubberBanding:YES];
-
- [scroller_ setDelegate:self];
[scroller_ setBounces:YES];
-
- if (!Wildcat_) {
- [scroller_ setScrollHysteresis:8];
- [scroller_ setThumbDetectionEnabled:NO];
- [scroller_ setDirectionalScrolling:YES];
- //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
- [scroller_ setEventMode:YES];
- }
-
- if (Wildcat_) {
- UIScrollView *scroller((UIScrollView *)scroller_);
- //[scroller setDirectionalLockEnabled:NO];
- [scroller setDelaysContentTouches:NO];
- //[scroller setScrollsToTop:NO];
- //[scroller setCanCancelContentTouches:NO];
- }
-
- [scroller_ setShowBackgroundShadow:NO]; /* YES */
- //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
-
- if (!Wildcat_)
- [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
-
- CGRect webrect = [scroller_ bounds];
- webrect.size.height = 0;
-
- WebView *webview;
-
- WebThreadLock();
-
-#if RecycleWebViews
- document_ = [Documents_ lastObject];
- if (document_ != nil) {
- document_ = [document_ retain];
- webview = [document_ webView];
- [Documents_ removeLastObject];
- [document_ setFrame:webrect];
- } else {
-#else
- if (true) {
-#endif
- document_ = [[$UIWebBrowserView alloc] initWithFrame:webrect];
- webview = [document_ webView];
-
- // XXX: this is terribly (too?) expensive
- //[document_ setDrawsBackground:NO];
- [webview setPreferencesIdentifier:@"Cydia"];
-
- [document_ setTileSize:CGSizeMake(webrect.size.width, 500)];
-
- if ([document_ respondsToSelector:@selector(enableReachability)])
- [document_ enableReachability];
- if ([document_ respondsToSelector:@selector(setAllowsMessaging:)])
- [document_ setAllowsMessaging:YES];
- if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
- [document_ useSelectionAssistantWithMode:0];
-
- [document_ setTilingEnabled:YES];
- [document_ setDrawsGrid:NO];
- [document_ setLogsTilingChanges:NO];
- [document_ setTileMinificationFilter:kCAFilterNearest];
-
- if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
- /* XXX: abstractify */
- [document_ setDataDetectorTypes:0x80000000];
- else
- [document_ setDetectsPhoneNumbers:NO];
-
- [document_ setAutoresizes:YES];
-
- [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
- [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
- [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
- //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
-
- [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
-
- [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
- [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
- [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
-
- [document_ _setDocumentType:0x4];
-
- if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
- [document_ setZoomsFocusedFormControl:YES];
- [document_ setContentsPosition:7];
- [document_ setEnabledGestures:0xa];
- [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
- [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
-
- [document_ setSmoothsFonts:YES];
- [document_ setAllowsImageSheet:YES];
- [webview _setUsesLoaderCache:YES];
-
- [webview setGroupName:@"CydiaGroup"];
-
- WebPreferences *preferences([webview preferences]);
-
- if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
- [webview _setLayoutInterval:0];
- else
- [preferences _setLayoutInterval:0];
- }
-
- actualView.documentView = document_;
- [actualView release];
+ [scroller_ setScrollingEnabled:YES];
+ [scroller_ setShowBackgroundShadow:NO];
[self setViewportWidth:width];
- [document_ setDelegate:self];
- [document_ setGestureDelegate:self];
-
- if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
- [document_ setFormEditingDelegate:self];
-
- [document_ setInteractionDelegate:self];
-
- [scroller_ addSubview:document_];
-
- //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-
- indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
-
- [webview setFrameLoadDelegate:indirect_];
- [webview setPolicyDelegate:indirect_];
- [webview setResourceLoadDelegate:indirect_];
- [webview setUIDelegate:indirect_];
-
- /* XXX: do not turn this on under penalty of extreme pain */
- [webview setScriptDebugDelegate:nil];
-
- WebThreadUnlock();
-
- CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
- 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]
@@ -1516,15 +851,15 @@ static Class $UIWebBrowserView;
target:self
action:@selector(reloadButtonClicked)
];
+
+ CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
+ indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
+ [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
+ [indicator_ startAnimation];
[[loadingitem_ view] addSubview:indicator_];
- [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
+ [webview_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
- [document_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
-
- /*UIWebView *test([[[UIWebView alloc] initWithFrame:[[self view] bounds]] autorelease]);
- [test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.saurik.com/"]]];
- [[self view] addSubview:test];*/
} return self;
}
@@ -1536,18 +871,15 @@ static Class $UIWebBrowserView;
return [self initWithWidth:0];
}
-- (NSString *) stringByEvaluatingJavaScriptFromString:(NSString *)script {
- WebThreadLock();
- WebView *webview([document_ webView]);
- NSString *string([webview stringByEvaluatingJavaScriptFromString:script]);
- WebThreadUnlock();
- return string;
+- (void) didDismissModalViewController {
+ if (closer_ != nil)
+ [self callFunction:closer_];
}
- (void) callFunction:(WebScriptObject *)function {
WebThreadLock();
- WebView *webview([document_ webView]);
+ WebView *webview([[webview_ _documentView] webView]);
WebFrame *frame([webview mainFrame]);
WebPreferences *preferences([webview preferences]);
@@ -1582,13 +914,7 @@ static Class $UIWebBrowserView;
WebThreadUnlock();
}
-- (void) didDismissModalViewController {
- if (closer_ != nil)
- [self callFunction:closer_];
-}
-
- (void) reloadButtonClicked {
- reloading_ = true;
[self reloadURL];
}
@@ -1605,17 +931,6 @@ static Class $UIWebBrowserView;
[self _customButtonClicked];
}
-- (void) setPageActive:(BOOL)active {
- if (!active)
- [indicator_ removeFromSuperview];
- else
- [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
-}
-
-- (void) setPushed:(bool)pushed {
- pushed_ = pushed;
-}
-
+ (float) defaultWidth {
return 980;
}
diff --git a/control b/control
index 5c86fbe..5ece8cb 100644
--- a/control
+++ b/control
@@ -5,7 +5,7 @@ Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
Architecture: iphoneos-arm
Version: 1.0.3229-1
Replaces: com.sosiphone.addcydia
-Depends: apr-lib, apt7-lib, apt7-key, darwintools, pcre, sed, shell-cmds, system-cmds, uikittools (>= 1.0.3198)
+Depends: apr-lib, apt7-lib, apt7-key, darwintools, pcre, sed, shell-cmds, system-cmds, uikittools (>= 1.0.3198), firmware (>= 4.0)
Pre-Depends: dpkg (>= 1.14.25-8)
Conflicts: com.sosiphone.addcydia
Description: graphical iPhone front-end for APT
diff --git a/iPhonePrivate.h b/iPhonePrivate.h
index bf61360..6dc893b 100644
--- a/iPhonePrivate.h
+++ b/iPhonePrivate.h
@@ -32,9 +32,117 @@ typedef enum {
UIProgressIndicatorStyleTinyWhite,
} UIProgressIndicatorStyle;
// }}}
-// @class *; {{{
+// #define * * {{{
+#define UIDataDetectorTypeAutomatic 0x80000000
+// }}}
+// @class Web*; {{{
+@class WebDataSource;
+@class WebScriptObject;
@class WebView;
// }}}
+// @protocol *; {{{
+@protocol WebPolicyDecisionListener;
+// }}}
+
+// @interface * : UIView {{{
+@interface UIFormAssistant : UIView
++ (UIFormAssistant *) sharedFormAssistant;
+- (CGRect) peripheralFrame;
+@end
+
+@interface UIKeyboard : UIView
++ (void) initImplementationNow;
+@end
+
+@interface UIProgressBar : UIView
++ (CGSize) defaultSize;
+- (void) setProgress:(float)progress;
+- (void) setStyle:(NSInteger)style;
+@end
+
+@interface UIProgressHUD : UIView
+- (id) initWithWindow:(UIWindow *)window;
+- (void) setText:(NSString *)text;
+- (void) show:(BOOL)show;
+@end
+
+@interface UIProgressIndicator : UIView
++ (CGSize) defaultSizeForStyle:(NSUInteger)style;
+- (NSUInteger) activityIndicatorViewStyle;
+- (void) setStyle:(UIProgressIndicatorStyle)style;
+- (void) startAnimation;
+@end
+
+@interface UIScroller : UIView
+- (CGSize) contentSize;
+- (void) setDirectionalScrolling:(BOOL)directional;
+- (void) setEventMode:(NSInteger)mode;
+- (void) setOffset:(CGPoint)offset;
+- (void) setScrollDecelerationFactor:(float)factor;
+- (void) setScrollHysteresis:(float)hysteresis;
+- (void) setThumbDetectionEnabled:(BOOL)enabled;
+@end
+
+@interface UITextLabel : UIView
+- (void) setCentersHorizontally:(BOOL)centers;
+- (void) setColor:(UIColor *)color;
+- (void) setFont:(UIFont *)font;
+- (void) setText:(NSString *)text;
+@end
+
+@interface UIWebDocumentView : UIView
+- (CGRect) documentBounds;
+- (void) enableReachability;
+- (void) loadRequest:(NSURLRequest *)request;
+- (void) redrawScaledDocument;
+- (void) setAllowsImageSheet:(BOOL)allows;
+- (void) setAllowsMessaging:(BOOL)allows;
+- (void) setAutoresizes:(BOOL)autoresizes;
+- (void) setContentsPosition:(NSInteger)position;
+- (void) setDataDetectorTypes:(NSUInteger)types;
+- (void) setDetectsPhoneNumbers:(BOOL)detects;
+- (void) setDrawsBackground:(BOOL)draws;
+- (void) _setDocumentType:(NSInteger)type;
+- (void) setDrawsGrid:(BOOL)draws;
+- (void) setInitialScale:(float)scale forDocumentTypes:(NSInteger)types;
+- (void) setLogsTilingChanges:(BOOL)logs;
+- (void) setMinimumScale:(float)scale forDocumentTypes:(NSInteger)types;
+- (void) setMinimumSize:(CGSize)size;
+- (void) setMaximumScale:(float)scale forDocumentTypes:(NSInteger)tpyes;
+- (void) setSmoothsFonts:(BOOL)smooths;
+- (void) setTileMinificationFilter:(NSString *)filter;
+- (void) setTileSize:(CGSize)size;
+- (void) setTilingEnabled:(BOOL)enabled;
+- (void) setViewportSize:(CGSize)size forDocumentTypes:(NSInteger)types;
+- (void) setZoomsFocusedFormControl:(BOOL)zooms;
+- (void) useSelectionAssistantWithMode:(NSInteger)mode;
+- (WebView *) webView;
+@end
+// }}}
+// @interface *Button : * {{{
+@interface UINavigationButton : UIButton
+- (id) initWithTitle:(NSString *)title style:(UINavigationButtonStyle)style;
+- (void) setBarStyle:(UIBarStyle)style;
+@end
+
+@interface UIPushButton : UIControl
+- (id) backgroundForState:(NSUInteger)state;
+- (void) setAutosizesToFit:(BOOL)autosizes;
+- (void) setBackground:(id)background forState:(NSUInteger)state;
+- (void) setDrawsShadow:(BOOL)draws;
+- (void) setStretchBackground:(BOOL)stretch;
+- (void) setTitle:(NSString *)title;
+- (void) setTitleFont:(UIFont *)font;
+@end
+
+@interface UIThreePartButton : UIPushButton
+@end
+// }}}
+// @interface * : NS* {{{
+@interface WebDefaultUIKitDelegate : NSObject
++ (WebDefaultUIKitDelegate *) sharedUIKitDelegate;
+@end
+// }}}
// @interface NS* (*) {{{
@interface NSString (Apple)
@@ -111,6 +219,11 @@ typedef enum {
- (UIBarStyle) _barStyle:(BOOL)style;
@end
+@interface UIScrollView (Apple)
+- (void) setScrollingEnabled:(BOOL)enabled;
+- (void) setShowBackgroundShadow:(BOOL)show;
+@end
+
@interface UISearchBar (Apple)
- (UITextField *) searchField;
@end
@@ -136,7 +249,10 @@ typedef enum {
@end
@interface UIView (Apple)
+- (UIScroller *) _scroller;
+- (void) setClipsSubviews:(BOOL)clips;
- (void) setEnabledGestures:(NSInteger)gestures;
+- (void) setFixedBackgroundPattern:(BOOL)fixed;
- (void) setGestureDelegate:(id)delegate;
- (void) setNeedsDisplayOnBoundsChange:(BOOL)needs;
- (void) setValue:(NSValue *)value forGestureAttribute:(NSInteger)attribute;
@@ -153,145 +269,25 @@ typedef enum {
- (void) makeKey:(UIApplication *)application;
- (void) orderFront:(UIApplication *)application;
@end
-// }}}
-
-// @interface * : UIView {{{
-@interface UIFormAssistant : UIView
-+ (UIFormAssistant *) sharedFormAssistant;
-- (CGRect) peripheralFrame;
-@end
-
-@interface UIKeyboard : UIView
-+ (void) initImplementationNow;
-@end
-
-@interface UIProgressBar : UIView
-+ (CGSize) defaultSize;
-- (void) setProgress:(float)progress;
-- (void) setStyle:(NSInteger)style;
-@end
-
-@interface UIProgressHUD : UIView
-- (id) initWithWindow:(UIWindow *)window;
-- (void) setText:(NSString *)text;
-- (void) show:(BOOL)show;
-@end
-
-@interface UIProgressIndicator : UIView
-+ (CGSize) defaultSizeForStyle:(NSUInteger)style;
-- (NSUInteger) activityIndicatorViewStyle;
-- (void) setStyle:(UIProgressIndicatorStyle)style;
-- (void) startAnimation;
-@end
-
-@interface UIScroller : UIView
-- (CGSize) contentSize;
-- (BOOL) releaseRubberBandIfNecessary;
-- (void) scrollPointVisibleAtTopLeft:(CGPoint)point;
-- (void) scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;
-- (void) setAdjustForContentSizeChange:(BOOL)adjust;
-- (void) setAllowsRubberBanding:(BOOL)allows;
-- (void) setBounces:(BOOL)bounces;
-- (void) setClipsSubviews:(BOOL)clips;
-- (void) setContentSize:(CGSize)size;
-- (void) setDelegate:(id)delegate;
-- (void) setDirectionalScrolling:(BOOL)directional;
-- (void) setEventMode:(NSInteger)mode;
-- (void) setFixedBackgroundPattern:(BOOL)fixed;
-- (void) setOffset:(CGPoint)offset;
-- (void) setScrollHysteresis:(float)hysteresis;
-- (void) setScrollerIndicatorSubrect:(CGRect)rect;
-- (void) setScrollingEnabled:(BOOL)enabled;
-- (void) setShowBackgroundShadow:(BOOL)shows;
-- (void) setThumbDetectionEnabled:(BOOL)enabled;
-@end
-
-@interface UITextLabel : UIView
-- (void) setCentersHorizontally:(BOOL)centers;
-- (void) setColor:(UIColor *)color;
-- (void) setFont:(UIFont *)font;
-- (void) setText:(NSString *)text;
-@end
-@interface UIWebDocumentView : UIView
-- (CGRect) documentBounds;
-- (void) enableReachability;
-- (void) loadRequest:(NSURLRequest *)request;
-- (void) redrawScaledDocument;
+@interface UIWebView (Apple)
+- (UIWebDocumentView *) _documentView;
+- (UIScrollView *) _scrollView;
- (UIScroller *) _scroller;
-- (void) setAllowsImageSheet:(BOOL)allows;
-- (void) setAllowsMessaging:(BOOL)allows;
-- (void) setAutoresizes:(BOOL)autoresizes;
-- (void) setContentsPosition:(NSInteger)position;
-- (void) setDataDetectorTypes:(NSUInteger)types;
-- (void) setDelegate:(id)delegate;
-- (void) setDetectsPhoneNumbers:(BOOL)detects;
-- (void) _setDocumentType:(NSInteger)type;
-- (void) setDrawsGrid:(BOOL)draws;
-- (void) setFormEditingDelegate:(id)delegate;
-- (void) setInitialScale:(float)scale forDocumentTypes:(NSInteger)types;
-- (void) setInteractionDelegate:(id)delegate;
-- (void) setLogsTilingChanges:(BOOL)logs;
-- (void) setMinimumScale:(float)scale forDocumentTypes:(NSInteger)types;
-- (void) setMinimumSize:(CGSize)size;
-- (void) setMaximumScale:(float)scale forDocumentTypes:(NSInteger)tpyes;
-- (void) setSmoothsFonts:(BOOL)smooths;
-- (void) setTileMinificationFilter:(NSString *)filter;
-- (void) setTileSize:(CGSize)size;
-- (void) setTilingEnabled:(BOOL)enabled;
-- (void) setViewportSize:(CGSize)size forDocumentTypes:(NSInteger)types;
-- (void) setZoomsFocusedFormControl:(BOOL)zooms;
-- (void) useSelectionAssistantWithMode:(NSInteger)mode;
-- (WebView *) webView;
-- (void) webView:(WebView *)view attachRootLayer:(id)layer;
-- (void) webView:(WebView *)view didCommitLoadForFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didFailLoadWithError:(id)error forFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didFinishDocumentLoadForFrame:(WebFrame *)frame;
+//- (WebView *) webView:(WebView *)view createWebViewWithRequest:(NSURLRequest *)request;
+- (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener;
+- (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener;
+- (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
+- (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
- (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didFirstLayoutInFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didFirstVisuallyNonEmptyLayoutInFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didHideFullScreenForPlugInView:(id)plugin;
-- (void) webView:(WebView *)view didObserveDeferredContentChange:(NSInteger)change forFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didReceiveDocTypeForFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view didReceiveMessage:(id)message;
-- (void) webView:(WebView *)view didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view formStateDidBlurNode:(id)state;
-- (void) webView:(WebView *)view formStateDidFocusNode:(id)state;
-- (void) webView:(WebView *)view needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame;
-- (id) webView:(WebView *)view plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package;
-- (void) webView:(WebView *)view restoreStateFromHistoryItem:(id)item forFrame:(WebFrame *)frame force:(BOOL)force;
-- (void) webView:(WebView *)view saveStateToHistoryItem:(id)item forFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view willAddPlugInView:(id)plugin;
-- (void) webView:(WebView *)view willCloseFrame:(WebFrame *)frame;
-- (void) webView:(WebView *)view willShowFullScreenForPlugInView:(id)plugin;
-- (BOOL) webView:(WebView *)view shouldScrollToPoint:(CGPoint)point forFrame:(WebFrame *)frame;
-- (void) webViewDidLayout:(WebView *)view;
-- (void) webViewDidPreventDefaultForEvent:(WebView *)view;
-- (void) webViewFormEditedStatusHasChanged:(WebView *)changed;
-@end
-// }}}
-// @interface *Button : * {{{
-@interface UINavigationButton : UIButton
-- (id) initWithTitle:(NSString *)title style:(UINavigationButtonStyle)style;
-- (void) setBarStyle:(UIBarStyle)style;
-@end
-
-@interface UIPushButton : UIControl
-- (id) backgroundForState:(NSUInteger)state;
-- (void) setAutosizesToFit:(BOOL)autosizes;
-- (void) setBackground:(id)background forState:(NSUInteger)state;
-- (void) setDrawsShadow:(BOOL)draws;
-- (void) setStretchBackground:(BOOL)stretch;
-- (void) setTitle:(NSString *)title;
-- (void) setTitleFont:(UIFont *)font;
-@end
-
-@interface UIThreePartButton : UIPushButton
-@end
-// }}}
-// @interface * : NS* {{{
-@interface WebDefaultUIKitDelegate : NSObject
-+ (WebDefaultUIKitDelegate *) sharedUIKitDelegate;
+- (void) webView:(WebView *)view didReceiveTitle:(id)title forFrame:(id)frame;
+- (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame;
+- (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source;
+- (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
+- (BOOL) webView:(WebView *)view runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
+- (NSString *) webView:(WebView *)view runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame;
+- (void) webViewClose:(WebView *)view;
@end
// }}}