]> git.saurik.com Git - cydia.git/commitdiff
Make cydia.setViewportWidth() work again with CYWebView.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 21 Nov 2010 06:17:28 +0000 (22:17 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 21 Nov 2010 06:17:28 +0000 (22:17 -0800)
UICaboodle/BrowserView.h
UICaboodle/BrowserView.mm
iPhonePrivate.h

index e2da3c0909abf0005ec05ff93e1d91ef8c96363f..22a4f107bf62f4f5dfee0e143a41e6c4c71a0382 100644 (file)
@@ -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
index e446d6058a966f5e682ef0a53bc8564e11ef0773..705c7e176d7f11c85866e069e6f8450f1992b196 100644 (file)
@@ -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 {
index 29c8e0e06c0b06c1d941c20fd3a169f84d197d02..ce4fa1304706bcd4f4b5bb1358bdc3539bc8b2d4 100644 (file)
@@ -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;