summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2010-11-20 22:17:28 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2010-11-20 22:17:28 -0800
commit7e37a67619923da62b21ca0d4527ccd5ec0bf1b7 (patch)
treef35e2cfbc1f7983408b53674f92bbb5df9ce4bb8
parent6a575b5e80ea78e300112949b58ab7315f7c40b4 (diff)
Make cydia.setViewportWidth() work again with CYWebView.
-rw-r--r--UICaboodle/BrowserView.h1
-rw-r--r--UICaboodle/BrowserView.mm18
-rw-r--r--iPhonePrivate.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index e2da3c0..22a4f10 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -38,6 +38,7 @@
- (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;
+- (void) webViewUpdateViewSettings:(UIWebView *)view;
@end
@interface CYWebView : UIWebView
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm
index e446d60..705c7e1 100644
--- a/UICaboodle/BrowserView.mm
+++ b/UICaboodle/BrowserView.mm
@@ -376,6 +376,14 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
}
// }}}
+- (void) _updateViewSettings {
+ [super _updateViewSettings];
+
+ id<CYWebViewDelegate> delegate([self delegate]);
+ if ([delegate respondsToSelector:@selector(webViewUpdateViewSettings:)])
+ [delegate webViewUpdateViewSettings:self];
+}
+
+ (void) initialize {
if (Class $UIWebViewWebViewDelegate = objc_getClass("UIWebViewWebViewDelegate")) {
class_addMethod($UIWebViewWebViewDelegate, @selector(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:), (IMP) &$UIWebViewWebViewDelegate$webView$decidePolicyForNewWindowAction$request$newFrameName$decisionListener$, "v28@0:4@8@12@16@20@24");
@@ -552,9 +560,17 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
closer_ = [function retain];
}
+- (void) _setViewportWidth {
+ [[webview_ _documentView] setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+}
+
- (void) setViewportWidth:(float)width {
width_ = width != 0 ? width : [[self class] defaultWidth];
- [[webview_ _documentView] setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
+ [self _setViewportWidth];
+}
+
+- (void) webViewUpdateViewSettings:(UIWebView *)view {
+ [self _setViewportWidth];
}
- (void) _openMailToURL:(NSURL *)url {
diff --git a/iPhonePrivate.h b/iPhonePrivate.h
index 29c8e0e..ce4fa13 100644
--- a/iPhonePrivate.h
+++ b/iPhonePrivate.h
@@ -282,6 +282,7 @@ typedef enum {
- (UIWebDocumentView *) _documentView;
- (UIScrollView *) _scrollView;
- (UIScroller *) _scroller;
+- (void) _updateViewSettings;
//- (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;