diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-28 21:34:18 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-03-07 02:41:32 -0800 |
commit | 4bcafc016a94c555e6a91a1c50c35b201d389e66 (patch) | |
tree | 836fdea68e12c9cafb7578d06a3a4bd43be273b0 /CyteKit/CyteWebViewController.mm | |
parent | 5276ff21e3ed70bb2c65099fff053e7eac49a936 (diff) |
Move -[BrowserController dispatchEvent:] to CYWebView.
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 { |