]> git.saurik.com Git - cydia.git/blobdiff - UICaboodle/BrowserView.mm
Updated German translation
[cydia.git] / UICaboodle / BrowserView.mm
index 6f6081eeec3ae429b2c518370eaae234d43be2af..e08c291fa7726b37ffb3dd43cad4d17b8466a686 100644 (file)
@@ -1,11 +1,12 @@
-#include <BrowserView.h>
-#include <UCLocalize.h>
+#include <UICaboodle/BrowserView.h>
+#include <UICaboodle/UCLocalize.h>
 
 #import <QuartzCore/CALayer.h>
 // XXX: fix the minimum requirement
 extern NSString * const kCAFilterNearest;
 
 #include <WebCore/WebCoreThread.h>
+#include <WebKit/WebPreferences-WebPrivate.h>
 
 #include "substrate.h"
 
@@ -209,12 +210,28 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 /* }}} */
 #endif
 
+#define ShowInternals 0
+#define LogBrowser 0
+
+#define lprintf(args...) fprintf(stderr, args)
+
 @implementation BrowserView
 
 #if ShowInternals
-#include "Internals.h"
+#include "UICaboodle/UCInternal.h"
 #endif
 
++ (void) _initialize {
+    NSLog(@"INITIALIZING");
+    [WebView enableWebThread];
+
+    WebPreferences *preferences([WebPreferences standardPreferences]);
+    [preferences setCacheModel:WebCacheModelDocumentBrowser];
+    [preferences setOfflineWebApplicationCacheEnabled:YES];
+
+    [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
+}
+
 - (void) dealloc {
 #if LogBrowser
     NSLog(@"[BrowserView dealloc]");
@@ -232,9 +249,8 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     [webview setScriptDebugDelegate:nil];
     [webview setPolicyDelegate:nil];
 
-    [webview setDownloadDelegate:nil];
-
     /* XXX: these are set by UIWebDocumentView
+    [webview setDownloadDelegate:nil];
     [webview _setFormDelegate:nil];
     [webview _setUIKitDelegate:nil];
     [webview setEditingDelegate:nil];*/
@@ -425,6 +441,13 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         return false;
 }
 
+- (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
+}
+
+- (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
+    [self fixScroller];
+}
+
 - (void) webViewShow:(WebView *)sender {
     /* XXX: this is where I cry myself to sleep */
 }
@@ -643,7 +666,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
                     [self setBackButtonTitle:title_];
 
-                    BrowserView *browser([[[BrowserView alloc] initWithBook:book] autorelease]);
+                    BrowserView *browser([[[class_ alloc] initWithBook:book] autorelease]);
                     [browser loadURL:url];
                     page = browser;
                 }
@@ -896,7 +919,7 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     RVBook *book(!popup_ ? book_ : [[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
 
     /* XXX: deal with cydia:// pages */
-    BrowserView *browser([[[BrowserView alloc] initWithBook:book forWidth:width] autorelease]);
+    BrowserView *browser([[[class_ alloc] initWithBook:book forWidth:width] autorelease]);
 
     if (features != nil && popup_) {
         [book setDelegate:delegate_];
@@ -1158,8 +1181,9 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     [self _setTileDrawingEnabled:YES];
 }
 
-- (id) initWithBook:(RVBook *)book forWidth:(float)width {
+- (id) initWithBook:(RVBook *)book forWidth:(float)width ofClass:(Class)_class {
     if ((self = [super initWithBook:book]) != nil) {
+        class_ = _class;
         loading_ = [[NSMutableSet alloc] initWithCapacity:3];
         popup_ = false;
 
@@ -1213,17 +1237,25 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
 
             [webview_ setTileSize:CGSizeMake(webrect.size.width, 500)];
 
+            if ([webview_ respondsToSelector:@selector(enableReachability)])
+                [webview_ enableReachability];
+
             [webview_ setAllowsMessaging:YES];
 
+            if ([webview_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
+                [webview_ useSelectionAssistantWithMode:0];
+
             [webview_ setTilingEnabled:YES];
             [webview_ setDrawsGrid:NO];
             [webview_ setLogsTilingChanges:NO];
             [webview_ setTileMinificationFilter:kCAFilterNearest];
+
             if ([webview_ respondsToSelector:@selector(setDataDetectorTypes:)])
                 /* XXX: abstractify */
                 [webview_ setDataDetectorTypes:0x80000000];
             else
                 [webview_ setDetectsPhoneNumbers:NO];
+
             [webview_ setAutoresizes:YES];
 
             [webview_ setMinimumScale:0.25f forDocumentTypes:0x10];
@@ -1251,8 +1283,13 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
             [webview _setUsesLoaderCache:YES];
 
             [webview setGroupName:@"CydiaGroup"];
+
+            WebPreferences *preferences([webview preferences]);
+
             if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
                 [webview _setLayoutInterval:0];
+            else
+                [preferences _setLayoutInterval:0];
         }
 
         [self setViewportWidth:width];
@@ -1269,10 +1306,12 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
         indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
 
         [webview setFrameLoadDelegate:indirect_];
+        [webview setPolicyDelegate:indirect_];
         [webview setResourceLoadDelegate:indirect_];
         [webview setUIDelegate:indirect_];
-        [webview setScriptDebugDelegate:indirect_];
-        [webview setPolicyDelegate:indirect_];
+
+        /* XXX: do not turn this on under penalty of extreme pain */
+        [webview setScriptDebugDelegate:nil];
 
         WebThreadUnlock();
 
@@ -1289,6 +1328,10 @@ UIActionSheet *mailAlertSheet = [[UIActionSheet alloc] initWithTitle:UCLocalize(
     } return self;
 }
 
+- (id) initWithBook:(RVBook *)book forWidth:(float)width {
+    return [self initWithBook:book forWidth:width ofClass:[self class]];
+}
+
 - (id) initWithBook:(RVBook *)book {
     return [self initWithBook:book forWidth:0];
 }