Reviewed by Tim Hatcher.
authortomernic <tomernic@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2006 00:58:29 +0000 (00:58 +0000)
committertomernic <tomernic@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2006 00:58:29 +0000 (00:58 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=8945 (REGRESSION: Scrolling is very slow when dragging
        the thumb)

        Rolled out one of my tweaks to the window display throttle hack (remember the last flush time instead
        of the last display time).  While that was technically a better approach, we discovered a problem
        with how it interacts with NSView scroll tracking.  Rather than further complicate this already
        crazy hack, I'm reverting back to the simple version.  This should yield similar numbers on iBench,
        but not exhibit the nasty scrolling problem.

        * Misc/WebNSWindowExtras.m:
        (+[NSWindow _webkit_enableWindowDisplayThrottle]):
        (+[NSWindow _webkit_disableWindowDisplayThrottle]):
        (getWindowDisplayInfo):
        (requestWindowDisplay):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/Misc/WebNSWindowExtras.m

index a6906737def21cdc6a0badd4235e2871377544f5..0ebab9ab494f14b58cd5617f5fa7656a5127336e 100644 (file)
@@ -1,3 +1,22 @@
+2006-05-16  Tim Omernick  <timo@apple.com>
+
+        Reviewed by Tim Hatcher.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8945 (REGRESSION: Scrolling is very slow when dragging
+        the thumb)
+
+        Rolled out one of my tweaks to the window display throttle hack (remember the last flush time instead
+        of the last display time).  While that was technically a better approach, we discovered a problem
+        with how it interacts with NSView scroll tracking.  Rather than further complicate this already
+        crazy hack, I'm reverting back to the simple version.  This should yield similar numbers on iBench,
+        but not exhibit the nasty scrolling problem.
+        
+        * Misc/WebNSWindowExtras.m:
+        (+[NSWindow _webkit_enableWindowDisplayThrottle]):
+        (+[NSWindow _webkit_disableWindowDisplayThrottle]):
+        (getWindowDisplayInfo):
+        (requestWindowDisplay):
+
 2006-05-16  bradeeoh  <beidson@apple.com>
 
         Reviewed by Maciej Stachowiak
index ad7970c962aae32690aa6c0674998c7b7dbe7521..8df8cdb11b4a7b252bf2345ed38266c5a9aa666a 100644 (file)
@@ -40,11 +40,10 @@ static BOOL throttlingWindowDisplay;
 static CFMutableDictionaryRef windowDisplayInfoDictionary;
 static IMP oldNSWindowPostWindowNeedsDisplayIMP;
 static IMP oldNSWindowCloseIMP;
-static IMP oldNSWindowFlushWindowIMP;
 
 typedef struct {
     NSWindow *window;
-    CFTimeInterval lastFlushTime;
+    CFTimeInterval lastDisplayTime;
     NSTimer *displayTimer;
 } WindowDisplayInfo;
 
@@ -52,7 +51,6 @@ typedef struct {
 static IMP swizzleInstanceMethod(Class class, SEL selector, IMP newImplementation);
 static void replacementPostWindowNeedsDisplay(id self, SEL cmd);
 static void replacementClose(id self, SEL cmd);
-static void replacementFlushWindow(id self, SEL cmd);
 static WindowDisplayInfo *getWindowDisplayInfo(NSWindow *window);
 static BOOL requestWindowDisplay(NSWindow *window);
 static void cancelPendingWindowDisplay(WindowDisplayInfo *displayInfo);
@@ -83,11 +81,6 @@ static void cancelPendingWindowDisplay(WindowDisplayInfo *displayInfo);
     oldNSWindowCloseIMP = swizzleInstanceMethod(self, @selector(close), (IMP)replacementClose);
     ASSERT(oldNSWindowCloseIMP);
 
-    // Override -[NSWindow flushWindow]    
-    ASSERT(!oldNSWindowFlushWindowIMP);
-    oldNSWindowFlushWindowIMP = swizzleInstanceMethod(self, @selector(flushWindow), (IMP)replacementFlushWindow);
-    ASSERT(oldNSWindowFlushWindowIMP);
-    
 //    NSLog(@"Throttling window display to %.3f times per second", 1.0 / DISPLAY_REFRESH_INTERVAL);
     
     throttlingWindowDisplay = YES;
@@ -135,11 +128,6 @@ static void disableWindowDisplayThrottleApplierFunction(const void *key, const v
     swizzleInstanceMethod(self, @selector(close), oldNSWindowCloseIMP);
     oldNSWindowCloseIMP = NULL;
 
-    // Restore -[NSWindow flushWindow]    
-    ASSERT(oldNSWindowFlushWindowIMP);
-    swizzleInstanceMethod(self, @selector(flushWindow), oldNSWindowFlushWindowIMP);
-    oldNSWindowFlushWindowIMP = NULL;
-
     CFDictionaryApplyFunction(windowDisplayInfoDictionary, disableWindowDisplayThrottleApplierFunction, NULL);
     CFRelease(windowDisplayInfoDictionary);
     windowDisplayInfoDictionary = NULL;
@@ -210,14 +198,6 @@ static void replacementClose(id self, SEL cmd)
     oldNSWindowCloseIMP(self, cmd);
 }
 
-static void replacementFlushWindow(id self, SEL cmd)
-{
-    ASSERT(throttlingWindowDisplay);
-
-    oldNSWindowFlushWindowIMP(self, cmd);
-    getWindowDisplayInfo(self)->lastFlushTime = CFAbsoluteTimeGetCurrent();
-}
-
 static WindowDisplayInfo *getWindowDisplayInfo(NSWindow *window)
 {
     ASSERT(throttlingWindowDisplay);
@@ -228,7 +208,7 @@ static WindowDisplayInfo *getWindowDisplayInfo(NSWindow *window)
     if (!displayInfo) {
         displayInfo = (WindowDisplayInfo *)malloc(sizeof(WindowDisplayInfo));
         displayInfo->window = window;
-        displayInfo->lastFlushTime = 0;
+        displayInfo->lastDisplayTime = 0;
         displayInfo->displayTimer = nil;
         CFDictionarySetValue(windowDisplayInfoDictionary, window, displayInfo);
     }
@@ -247,7 +227,7 @@ static BOOL requestWindowDisplay(NSWindow *window)
         
     // Defer display if it hasn't been at least DISPLAY_REFRESH_INTERVAL seconds since the last display
     CFTimeInterval now = CFAbsoluteTimeGetCurrent();
-    CFTimeInterval timeSinceLastDisplay = now - displayInfo->lastFlushTime;
+    CFTimeInterval timeSinceLastDisplay = now - displayInfo->lastDisplayTime;
     if (timeSinceLastDisplay < DISPLAY_REFRESH_INTERVAL) {
         // Redisplay soon -- if we redisplay too quickly, we'll block due to pending CG coalesced updates
         displayInfo->displayTimer = [[NSTimer timerWithTimeInterval:(DISPLAY_REFRESH_INTERVAL - timeSinceLastDisplay)
@@ -269,6 +249,8 @@ static BOOL requestWindowDisplay(NSWindow *window)
         return NO;
     }
 
+    // Allow the display: there is no pending display, and it's been long enough to display again.
+    displayInfo->lastDisplayTime = now;
     return YES;
 }