X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/6fa0bb60da6b661c2aafc03f11b842ee7136a9bb..136cc0a23da9281874ee88b7b51174538fcb9269:/CyteKit/WebView.mm diff --git a/CyteKit/WebView.mm b/CyteKit/WebView.mm index 66304630..9e0cbea8 100644 --- a/CyteKit/WebView.mm +++ b/CyteKit/WebView.mm @@ -1,5 +1,5 @@ /* Cydia - iPhone UIKit Front-End for Debian APT - * Copyright (C) 2008-2014 Jay Freeman (saurik) + * Copyright (C) 2008-2015 Jay Freeman (saurik) */ /* GNU General Public License, Version 3 {{{ */ @@ -19,10 +19,12 @@ **/ /* }}} */ +#include "CyteKit/UCPlatform.h" + #include "CyteKit/dispatchEvent.h" #include "CyteKit/WebView.h" -#include +#include "Substrate.hpp" #include "iPhonePrivate.h" @@ -88,7 +90,8 @@ @end // }}} -@implementation CyteWebView : UIWebView +@implementation CyteWebView : UIWebView { +} #if ShowInternals #include "CyteKit/UCInternal.h" @@ -295,6 +298,16 @@ static NSURLRequest *$UIWebViewWebViewDelegate$webView$resource$willSendRequest$ return request; } // }}} +// webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource: {{{ +- (NSURLRequest *) webThreadWebView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source { + id delegate([self delegate]); + if ([UIWebView instancesRespondToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)]) + request = [super webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source]; + if ([delegate respondsToSelector:@selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:)]) + request = [delegate webThreadWebView:view resource:identifier willSendRequest:request redirectResponse:response fromDataSource:source]; + return request; +} +// }}} // webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame: (2.1+) {{{ - (void) webView:(WebView *)view runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { [[self retain] autorelease]; @@ -404,3 +417,29 @@ __attribute__((__constructor__)) static void $() { class_addMethod($UIWebViewWebViewDelegate, @selector(_clearUIWebView), (IMP) &$UIWebViewWebViewDelegate$_clearUIWebView, "v8@0:4"); } } + +@implementation UIWebDocumentView (Cydia) + +- (void) _setScrollerOffset:(CGPoint)offset { + UIScroller *scroller([self _scroller]); + + CGSize size([scroller contentSize]); + CGSize bounds([scroller bounds].size); + + CGPoint max; + max.x = size.width - bounds.width; + max.y = size.height - bounds.height; + + // wtf Apple?! + if (max.x < 0) + max.x = 0; + if (max.y < 0) + max.y = 0; + + offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x; + offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y; + + [scroller setOffset:offset]; +} + +@end