From 9297d5d59d19fb6d410ea53e23a70187d3a31631 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 20 Nov 2010 22:17:28 -0800 Subject: [PATCH] Make cydia.setViewportWidth() work again with CYWebView. --- UICaboodle/BrowserView.h | 1 + UICaboodle/BrowserView.mm | 18 +++++++++++++++++- iPhonePrivate.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index e2da3c09..22a4f107 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 e446d605..705c7e17 100644 --- a/UICaboodle/BrowserView.mm +++ b/UICaboodle/BrowserView.mm @@ -376,6 +376,14 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se } // }}} +- (void) _updateViewSettings { + [super _updateViewSettings]; + + id 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 29c8e0e0..ce4fa130 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)listener; - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id)listener; -- 2.47.2