Peter Hosey committed 6ae6091

Workaround for the 1-pt-tall-notification-window problem (#108).

The problem seems to be that WebKit hasn't finished laying out the content, even by the time of webView:didFinishLoadForFrame:. It may be that WebKit is getting distracted and laying out other notifications before it finishes the first.

An apparent fix is to only attempt to get and use the size after a delay, at least when the size isn't already in yet. I'm not yet certain that this is a real fix, but it at least makes the problem much less frequent, to the point that I'm no longer able to reproduce it.

Comments (0)

Files changed (1)


 - (NSData *)PNGRepresentation;
+@interface GrowlWebKitWindowController ()
+- (void) viewIsReady:(GrowlWebKitWindowView *)view;
 @implementation GrowlWebKitWindowController
 #define GrowlWebKitDurationPrefDefault				5.0
 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
 	if (frame != [sender mainFrame]) return;
+	if ([[[frame frameView] documentView] frame].size.height < 2.0f) {
+		//Finished loading it may be, but it's not finished rendering, in which case the document view's height will be 1 px. Not good for sizing to fit. So, try again one cycle of the run loop from now.
+		[self performSelector:@selector(viewIsReady:) withObject:sender afterDelay:0.0];
+	} else {
+		//It really is done, so just call through directly.
+		[self viewIsReady:(GrowlWebKitWindowView *)sender];
+	}
+- (void) viewIsReady:(GrowlWebKitWindowView *)view {
 	NSWindow *myWindow = [self window];
 	if ([myWindow isFlushWindowDisabled])
 		[myWindow enableFlushWindow];
-	GrowlWebKitWindowView *view = (GrowlWebKitWindowView *)sender;
 	[view sizeToFit];
 	//Update our new frame