]> git.saurik.com Git - cydia.git/commitdiff
Add cydia.registerFrame() to force auto-iframe size.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 13 Sep 2012 04:12:58 +0000 (21:12 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 13 Sep 2012 04:12:58 +0000 (21:12 -0700)
CyteKit/WebViewController.h
CyteKit/WebViewController.mm
MobileCydia.app/iframe.html [new file with mode: 0644]
MobileCydia.mm
iPhonePrivate.h

index d3ded440c3b7183246b9308261cf9a7a88c4cad0..b82702019bbf7b9d96579ec70b012f4caa944d4f 100644 (file)
@@ -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_;
 - (void) setScrollAlwaysBounceVertical:(bool)value;
 - (void) setScrollIndicatorStyle:(UIScrollViewIndicatorStyle)style;
 
+- (void) registerFrame:(WebFrame *)frame;
+
 @end
 
 #endif//CyteKit_WebViewController_H
index 5d15213964fa0512b5e4ceabe68d28159948c3f2..ccb1823c4c99e1a2fbd197a08658ea2a9c65e289 100644 (file)
@@ -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
diff --git a/MobileCydia.app/iframe.html b/MobileCydia.app/iframe.html
new file mode 100644 (file)
index 0000000..f35ef99
--- /dev/null
@@ -0,0 +1,6 @@
+<html><head>
+</head><body>
+    <script type="text/javascript">
+        document.write();
+    </script>
+</body></html>
index 3b3347f1722c00fac52bc0bff6029b54a5c295cd..e2f1d85d29c3e7f99b56a8402ee65931e8ff097c 100644 (file)
@@ -69,6 +69,7 @@
 #include <QuartzCore/CALayer.h>
 
 #include <WebCore/WebCoreThread.h>
+#include <WebKit/DOMHTMLIFrameElement.h>
 
 #include <algorithm>
 #include <iomanip>
@@ -4169,6 +4170,8 @@ static _H<NSMutableSet> Diversions_;
         return @"popViewController";
     else if (selector == @selector(refreshSources))
         return @"refreshSources";
+    else if (selector == @selector(registerFrame:))
+        return @"registerFrame";
     else if (selector == @selector(removeButton))
         return @"removeButton";
     else if (selector == @selector(saveConfig))
@@ -4294,6 +4297,11 @@ static _H<NSMutableSet> Diversions_;
     return [Values_ allKeys];
 } }
 
+- (void) registerFrame:(DOMHTMLIFrameElement *)iframe {
+    WebFrame *frame([iframe contentFrame]);
+    [indirect_ registerFrame:frame];
+}
+
 - (void) _setShowPromoted:(NSNumber *)value {
     [Metadata_ setObject:value forKey:@"ShowPromoted"];
     Changed_ = true;
index 98f86b4e0160b78a68455b083aead077122274bf..80aed02f2e26774ba12336dbd872e711e317c15f 100644 (file)
@@ -6,6 +6,7 @@
 #include <UIKit/UIKit.h>
 // }}}
 // #import <*> {{{
+#import <WebKit/DOMHTMLIFrameElement.h>
 #import <WebKit/WebFrame.h>
 #import <WebKit/WebPreferences.h>
 // }}}
@@ -413,6 +414,10 @@ extern float const UIScrollViewDecelerationRateNormal;
 @property(nonatomic,readonly) CGFloat scale;
 @end
 
+@interface DOMHTMLIFrameElement (IDL)
+- (WebFrame *) contentFrame;
+@end
+
 // extern *; {{{
 extern CFStringRef const kGSDisplayIdentifiersCapability;
 extern float const UIWebViewGrowsAndShrinksToFitHeight;