diff options
Diffstat (limited to 'CyteKit/CyteWebViewController.mm')
-rw-r--r-- | CyteKit/CyteWebViewController.mm | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/CyteKit/CyteWebViewController.mm b/CyteKit/CyteWebViewController.mm index 9db2c8a..5c7ceaf 100644 --- a/CyteKit/CyteWebViewController.mm +++ b/CyteKit/CyteWebViewController.mm @@ -6,6 +6,7 @@ #include "CyteKit/CyteLocalize.h" #include "CyteKit/CyteWebViewController.h" #include "CyteKit/PerlCompatibleRegEx.hpp" +#include "CyteKit/WebThreadLocked.hpp" //#include <QuartzCore/CALayer.h> // XXX: fix the minimum requirement @@ -30,18 +31,6 @@ extern NSString * const kCAFilterNearest; #define lprintf(args...) fprintf(stderr, args) -// WebThreadLocked {{{ -struct WebThreadLocked { - _finline WebThreadLocked() { - WebThreadLock(); - } - - _finline ~WebThreadLocked() { - WebThreadUnlock(); - } -}; -// }}} - template <typename Type_> static inline void CYRelease(Type_ &value) { if (value != nil) { @@ -890,26 +879,7 @@ float CYScrollViewDecelerationRateNormal; } - (void) dispatchEvent:(NSString *)event { - WebThreadLocked lock; - - NSString *script([NSString stringWithFormat:@ - "(function() {" - "var event = this.document.createEvent('Events');" - "event.initEvent('%@', false, false);" - "this.document.dispatchEvent(event);" - "})();" - , event]); - - NSMutableArray *frames([NSMutableArray arrayWithObjects: - [[[webview_ _documentView] webView] mainFrame] - , nil]); - - while (WebFrame *frame = [frames lastObject]) { - WebScriptObject *object([frame windowObject]); - [object evaluateWebScript:script]; - [frames removeLastObject]; - [frames addObjectsFromArray:[frame childFrames]]; - } + [webview_ dispatchEvent:event]; } - (bool) hidesNavigationBar { |