diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2012-09-12 21:12:58 -0700 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2012-09-12 21:12:58 -0700 |
commit | aa1e190657c229f1fd1c59f0867621dd739379ee (patch) | |
tree | 2313ac25dd17d35981283ba5a7887cf61672e103 /CyteKit | |
parent | 07d0e88e46b7e041b64dc2aaeae3f415a9437e5e (diff) |
Add cydia.registerFrame() to force auto-iframe size.
Diffstat (limited to 'CyteKit')
-rw-r--r-- | CyteKit/WebViewController.h | 5 | ||||
-rw-r--r-- | CyteKit/WebViewController.mm | 28 |
2 files changed, 33 insertions, 0 deletions
diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index d3ded44..b827020 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -78,6 +78,9 @@ _H<NSString> title_; _H<NSMutableSet> loading_; + _H<NSMutableSet> registered_; + _H<NSTimer> timer_; + // XXX: NSString * or UIImage * _H<NSObject> custom_; _H<NSString> style_; @@ -152,6 +155,8 @@ - (void) setScrollAlwaysBounceVertical:(bool)value; - (void) setScrollIndicatorStyle:(UIScrollViewIndicatorStyle)style; +- (void) registerFrame:(WebFrame *)frame; + @end #endif//CyteKit_WebViewController_H diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 5d15213..ccb1823 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -48,12 +48,24 @@ float CYScrollViewDecelerationRateNormal; - (void) _setAllowsMessaging:(BOOL)allows; @end +@interface WebFrame (Cydia) +- (void) cydia$updateHeight; +@end + @implementation WebFrame (Cydia) - (NSString *) description { return [NSString stringWithFormat:@"<%s: %p, %@>", class_getName([self class]), self, [[[([self provisionalDataSource] ?: [self dataSource]) request] URL] absoluteString]]; } +- (void) cydia$updateHeight { + [[[self frameElement] style] + setProperty:@"height" + value:[NSString stringWithFormat:@"%dpx", + [[[self DOMDocument] body] scrollHeight]] + priority:nil]; +} + @end /* Indirect Delegate {{{ */ @@ -595,6 +607,9 @@ float CYScrollViewDecelerationRateNormal; style_ = nil; function_ = nil; + [registered_ removeAllObjects]; + timer_ = nil; + allowsNavigationAction_ = true; [self setHidesNavigationBar:NO]; @@ -811,6 +826,7 @@ float CYScrollViewDecelerationRateNormal; allowsNavigationAction_ = true; loading_ = [NSMutableSet setWithCapacity:5]; + registered_ = [NSMutableSet setWithCapacity:5]; indirect_ = [[[IndirectDelegate alloc] initWithDelegate:self] autorelease]; reloaditem_ = [[[UIBarButtonItem alloc] @@ -1122,4 +1138,16 @@ float CYScrollViewDecelerationRateNormal; [self dispatchEvent:@"CydiaViewDidDisappear"]; } +- (void) updateHeights:(NSTimer *)timer { + for (WebFrame *frame in (id) registered_) + [frame cydia$updateHeight]; +} + +- (void) registerFrame:(WebFrame *)frame { + [registered_ addObject:frame]; + + if (timer_ == nil) + timer_ = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(updateHeights:) userInfo:nil repeats:YES]; +} + @end |