return @"setButtonImage";
else if (selector == @selector(setButtonTitle:withStyle:toFunction:))
return @"setButtonTitle";
+ else if (selector == @selector(setPopupHook:))
+ return @"setPopupHook";
else if (selector == @selector(setViewportWidth:))
return @"setViewportWidth";
else if (selector == @selector(supports:))
[indirect_ setButtonTitle:button withStyle:style toFunction:function];
}
+- (void) setPopupHook:(id)function {
+ [indirect_ setPopupHook:function];
+}
+
- (void) setViewportWidth:(float)width {
[indirect_ setViewportWidth:width];
}
#endif
- (void) dealloc {
-#if ForSaurik
+#if LogBrowser
NSLog(@"[BrowserView dealloc]");
#endif
[style_ release];
if (function_ != nil)
[function_ release];
+ if (closer_ != nil)
+ [closer_ release];
[scroller_ release];
[indicator_ release];
- (void) _fixScroller {
CGRect bounds([webview_ documentBounds]);
-#if ForSaurik
+#if LogBrowser
NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
#endif
else {
UIFormAssistant *assistant([UIFormAssistant sharedFormAssistant]);
CGRect peripheral([assistant peripheralFrame]);
-#if ForSaurik
+#if LogBrowser
NSLog(@"per:%f", peripheral.size.height);
#endif
extra = peripheral.size.height;
- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
size_ = frame.size;
-#if ForSaurik
+#if LogBrowser
NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
#endif
[self _fixScroller];
}
- (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
-#if ForSaurik
+#if LogBrowser
NSLog(@"getSpecial:%@", url);
#endif
popup_ = popup;
}
+- (void) setPopupHook:(id)function {
+ if (closer_ != nil)
+ [closer_ autorelease];
+ closer_ = function == nil ? nil : [function retain];
+}
+
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
if (button_ != nil)
[button_ autorelease];
if (function_ != nil)
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
+
+ [self reloadButtons];
}
- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
if (function_ != nil)
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
+
+ [self reloadButtons];
}
- (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
}
- (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
-#if ForSaurik
+#if LogBrowser
NSLog(@"nwa:%@", name);
#endif
[delegate_ openURL:url];
else if ([name isEqualToString:@"_popup"]) {
RVBook *book([[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
+ [book setHook:indirect_];
RVPage *page([delegate_ pageForURL:url hasTag:NULL]);
if (page == nil) {
if (request_ != nil)
[request_ autorelease];
request_ = [request retain];
-#if ForSaurik
+#if LogBrowser
NSLog(@"dpn:%@", request_);
#endif
}
[self _pushPage];
return;
}
-#if ForSaurik
+#if LogBrowser
else NSLog(@"nav:%@:%@", url, [action description]);
#endif
int store(_not(int));
if (NSURL *itms = [url itmsURL:&store]) {
-#if ForSaurik
+#if LogBrowser
NSLog(@"itms#%@#%u#%@", url, store, itms);
#endif
- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features {
//- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)gesture {
-#if ForSaurik
+#if LogBrowser
NSLog(@"cwv:%@ (%@): %@", request, title_, features == nil ? @"{}" : [features description]);
//NSLog(@"cwv:%@ (%@): %@", request, title_, gesture ? @"Yes" : @"No");
#endif
if (features != nil && popup_) {
[book setDelegate:delegate_];
+ [book setHook:indirect_];
[browser setDelegate:delegate_];
[browser loadRequest:request];
function_ = nil;
}
+ if (closer_ != nil) {
+ [closer_ release];
+ closer_ = nil;
+ }
+
[book_ reloadTitleForPage:self];
[scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
}
}
-- (bool) _loading {
+- (bool) isLoading {
return loading_;
}
- (void) reloadButtons {
- if ([self _loading])
+ if ([self isLoading])
[indicator_ startAnimation];
else
[indicator_ stopAnimation];
}
- (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
-#if ForSaurik
+#if LogBrowser || ForSaurik
lprintf("Console:%s\n", [[dictionary description] UTF8String]);
#endif
}
[webview_ redrawScaledDocument];
}
-- (void) _rightButtonClicked {
- if (function_ == nil) {
- reloading_ = true;
- [self reloadURL];
- } else {
- WebView *webview([webview_ webView]);
- WebFrame *frame([webview mainFrame]);
-
- 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());
-
- bool no;
- if (settings == NULL)
- no = 0;
- else {
- no = settings->JavaScriptCanOpenWindowsAutomatically();
- settings->setJavaScriptCanOpenWindowsAutomatically(true);
- }
+- (void) callFunction:(WebScriptObject *)function {
+ WebView *webview([webview_ webView]);
+ WebFrame *frame([webview mainFrame]);
- [delegate_ clearFirstResponder];
- JSObjectRef function([function_ JSObject]);
- JSGlobalContextRef context([frame globalContext]);
- JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
+ 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());
- if (settings != NULL)
- settings->setJavaScriptCanOpenWindowsAutomatically(no);
+ bool no;
+ if (settings == NULL)
+ no = 0;
+ else {
+ no = settings->JavaScriptCanOpenWindowsAutomatically();
+ settings->setJavaScriptCanOpenWindowsAutomatically(true);
}
+
+ [delegate_ clearFirstResponder];
+ JSObjectRef object([function JSObject]);
+ JSGlobalContextRef context([frame globalContext]);
+ JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
+
+ if (settings != NULL)
+ settings->setJavaScriptCanOpenWindowsAutomatically(no);
+}
+
+- (void) didCloseBook:(RVBook *)book {
+ if (closer_ != nil)
+ [self callFunction:closer_];
+}
+
+- (void) __rightButtonClicked {
+ reloading_ = true;
+ [self reloadURL];
+}
+
+- (void) _rightButtonClicked {
+ if (function_ == nil)
+ [self __rightButtonClicked];
+ else
+ [self callFunction:function_];
}
- (id) _rightButtonTitle {
- return button_ != nil ? button_ : @"Reload";
+ return @"Reload";
}
- (id) rightButtonTitle {
- return [self _loading] ? @"" : [self _rightButtonTitle];
+ return [self isLoading] ? @"" : button_ != nil ? button_ : [self _rightButtonTitle];
}
- (UINavigationButtonStyle) rightButtonStyle {