]> git.saurik.com Git - winterboard.git/blobdiff - WBMarkup.mm
Clear the status bar cache. (Thanks, dallasgroot!)
[winterboard.git] / WBMarkup.mm
index 77d7c376238dcdc843947a747f4bcf649be53a68..ff7c98ab9b3f1aeede4a00988c498c372357da0d 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <substrate.h>
 
+MSClassHook(UIWebDocumentView)
+
 @class WKView;
 
 extern "C" void WebThreadLock();
@@ -61,15 +63,26 @@ static void (*WKViewDisplayRect$)(WKView *, CGRect);
 - (void) setContentView:(WebView *)view;
 @end
 
+@interface UIWebDocumentView : NSObject
+- (WebView *) webView;
+@end
+
 static WBMarkup *SharedMarkup_;
 
 @implementation WBMarkup
 
 + (void) initialize {
     MSImageRef WebCore(MSGetImageByName("/System/Library/PrivateFrameworks/WebCore.framework/WebCore"));
-    MSHookSymbol(WKViewLockFocus$, "WKViewLockFocus", WebCore);
-    MSHookSymbol(WKViewUnlockFocus$, "WKViewUnlockFocus", WebCore);
-    MSHookSymbol(WKViewDisplayRect$, "WKViewDisplayRect", WebCore);
+    MSHookSymbol(WKViewLockFocus$, "_WKViewLockFocus", WebCore);
+    MSHookSymbol(WKViewUnlockFocus$, "_WKViewUnlockFocus", WebCore);
+    MSHookSymbol(WKViewDisplayRect$, "_WKViewDisplayRect", WebCore);
+
+    MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore"));
+
+    void (*_ZN3JSC19initializeThreadingEv)();
+    MSHookSymbol(_ZN3JSC19initializeThreadingEv, "__ZN3JSC19initializeThreadingEv", JavaScriptCore);
+    if (_ZN3JSC19initializeThreadingEv != NULL)
+        (*_ZN3JSC19initializeThreadingEv)();
 }
 
 + (BOOL) isSharedMarkupCreated {
@@ -86,9 +99,11 @@ static WBMarkup *SharedMarkup_;
     if ((self = [super init]) != nil) {
         WebThreadLock();
 
-        SharedMarkup_ = self;
+        if ($UIWebDocumentView == Nil)
+            view_ = [[WebView alloc] initWithFrame:CGRectMake(0, 0, 640, 5000)];
+        else
+            view_ = [[[$UIWebDocumentView alloc] initWithFrame:CGRectMake(0, 0, 640, 5000)] webView];
 
-        view_ = [[WebView alloc] initWithFrame:CGRectMake(0, 0, 640, 5000)];
         [view_ setDrawsBackground:NO];
 
         WebPreferences *preferences([[WebPreferences alloc] initWithIdentifier:@"com.apple.webkit.webmarkup"]);
@@ -144,7 +159,7 @@ static WBMarkup *SharedMarkup_;
     origin_ = CGPointZero;
 }
 
-- (CGSize) sizeOfMarkup:(NSString *)markup forWidth:(float)width {
+- (CGSize) sizeOfMarkup:(NSString *)markup forWidth:(CGFloat)width {
     WebThreadLock();
 
     if (![self _webPrepareContextForTextDrawing:NO])
@@ -161,7 +176,7 @@ static WBMarkup *SharedMarkup_;
     return [[view_ mainFrame] renderedSizeOfNode:text_ constrainedToWidth:width];
 }
 
-- (CGSize) sizeOfString:(NSString *)string withStyle:(NSString *)style forWidth:(float)width {
+- (CGSize) sizeOfString:(NSString *)string withStyle:(NSString *)style forWidth:(CGFloat)width {
     WebThreadLock();
 
     if (![self _webPrepareContextForTextDrawing:NO])
@@ -183,7 +198,7 @@ static WBMarkup *SharedMarkup_;
     return style;
 }
 
-- (void) _setupWithStyle:(NSString *)style width:(float)width height:(float)height {
+- (void) _setupWithStyle:(NSString *)style width:(CGFloat)width height:(CGFloat)height {
     WebThreadLock();
 
     if (style != nil && [style length] != 0)