X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/09ea4166f344fa4ee00893a48ae7bd07022ea9f5..fd1c824a084fdf3fa140f907a0257d9478717552:/WBMarkup.mm diff --git a/WBMarkup.mm b/WBMarkup.mm index 73066d4..9918a28 100644 --- a/WBMarkup.mm +++ b/WBMarkup.mm @@ -1,14 +1,15 @@ #include "WBMarkup.h" +#include + @class WKView; -extern "C" { - void WebThreadLock(); - CGContextRef WKGetCurrentGraphicsContext(); - void WKViewLockFocus(WKView *); - void WKViewUnlockFocus(WKView *); - void WKViewDisplayRect(WKView *, CGRect); -} +extern "C" void WebThreadLock(); +extern "C" CGContextRef WKGetCurrentGraphicsContext(); + +static void (*WKViewLockFocus$)(WKView *); +static void (*WKViewUnlockFocus$)(WKView *); +static void (*WKViewDisplayRect$)(WKView *, CGRect); @interface DOMElement : NSObject - (void) setInnerHTML:(NSString *)value; @@ -64,6 +65,20 @@ 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); + + MSImageRef JavaScriptCore(MSGetImageByName("/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore")); + + void (*_ZN3JSC19initializeThreadingEv)(); + MSHookSymbol(_ZN3JSC19initializeThreadingEv, "__ZN3JSC19initializeThreadingEv", JavaScriptCore); + if (_ZN3JSC19initializeThreadingEv != NULL) + (*_ZN3JSC19initializeThreadingEv)(); +} + + (BOOL) isSharedMarkupCreated { return SharedMarkup_ != nil; } @@ -117,9 +132,9 @@ static WBMarkup *SharedMarkup_; [view_ _drawRect:draw context:context_ lockFocus:YES]; else { WKView *view([view_ _viewRef]); - WKViewLockFocus(view); { - WKViewDisplayRect(view, draw); - } WKViewUnlockFocus(view); + WKViewLockFocus$(view); { + WKViewDisplayRect$(view, draw); + } WKViewUnlockFocus$(view); } } CGContextRestoreGState(context_); } @@ -136,7 +151,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]) @@ -153,7 +168,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]) @@ -175,7 +190,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)