Reviewed by Darin.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2007 13:50:25 +0000 (13:50 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jan 2007 13:50:25 +0000 (13:50 +0000)
        - remove window display throttling code; no longer used

        * Misc/WebNSWindowExtras.h:
        * Misc/WebNSWindowExtras.m:
        * WebView/WebFrameView.mm:
        (-[WebFrameView initWithFrame:]):
        * WebView/WebPreferenceKeysPrivate.h:

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

WebKit/ChangeLog
WebKit/Misc/WebNSWindowExtras.h
WebKit/Misc/WebNSWindowExtras.m
WebKit/WebView/WebFrameView.mm
WebKit/WebView/WebPreferenceKeysPrivate.h

index 883ab8f7b3a4999e893ff776e99375abbc2d13f4..74a883ea6015e50d49e5cc8cb565141021356962 100644 (file)
@@ -1,3 +1,15 @@
+2007-01-09  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - remove window display throttling code; no longer used
+
+        * Misc/WebNSWindowExtras.h:
+        * Misc/WebNSWindowExtras.m:
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView initWithFrame:]):
+        * WebView/WebPreferenceKeysPrivate.h:
+
 2007-01-08  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Brady.
index 8b950f804a940150cc193e859580e93c39d70f21..0aebd4f921a3850a9f7306980b1692db6bf19aa8 100644 (file)
 #import <Cocoa/Cocoa.h>
 
 @interface NSWindow (WebExtras)
-// Throttles the NSWindow autodisplay mechanism to a maximum of 60 frames per second.
-// This ensures that dynamically updated web content does not cause the window to display
-// too often, which can cause performance problems with CoreGraphics' coalesced updates
-// feature.  See <http://developer.apple.com/technotes/tn2005/tn2133.html>.
-+ (void)_webkit_enableWindowDisplayThrottle;
-
-// Disables NSWindow display throttling.  Any windows with pending displays will be displayed
-// immediately when window throttling is disabled.
-+ (void)_webkit_disableWindowDisplayThrottle;
-
-// Force all throttle timers to fire by running the runloop in WebKitDisplayThrottleRunLoopMode until there are
-// no more runloop timers/sources for that mode.
-+ (void)_webkit_displayThrottledWindows;
-
 // centers "visually", putting 1/3 of the remaining space above, and 2/3 below
 - (void)centerOverMainWindow; 
 @end
index 42056be9e2758ffbd4ad442ef5048a39e3318978..ef27b13a7adf5067941029f329d66191f590e9b7 100644 (file)
 
 #import "WebNSWindowExtras.h"
 
-#import "WebKitLogging.h"
-#import <JavaScriptCore/Assertions.h>
-#import <objc/objc-runtime.h>
-
-#define DISPLAY_REFRESH_INTERVAL (1.0 / 60.0)
-
-static NSString *WebKitDisplayThrottleRunLoopMode = @"WebKitDisplayThrottleRunLoopMode";
-
-static BOOL throttlingWindowDisplay;
-static CFMutableDictionaryRef windowDisplayInfoDictionary;
-static IMP oldNSWindowPostWindowNeedsDisplayIMP;
-static IMP oldNSWindowDeallocIMP;
-static IMP oldNSWindowFinalizeIMP;
-
-typedef struct {
-    NSWindow *window;
-    CFTimeInterval lastDisplayTime;
-    NSTimer *displayTimer;
-} WindowDisplayInfo;
-
-@interface NSWindow (WebExtrasInternal)
-static IMP swizzleInstanceMethod(Class class, SEL selector, IMP newImplementation);
-static void replacementPostWindowNeedsDisplay(id self, SEL cmd);
-static void replacementDealloc(id self, SEL cmd);
-static void replacementFinalize(id self, SEL cmd);
-static WindowDisplayInfo *getWindowDisplayInfo(NSWindow *window);
-static BOOL requestWindowDisplay(NSWindow *window);
-static void cancelPendingWindowDisplay(WindowDisplayInfo *displayInfo);
-- (void)_webkit_doPendingPostWindowNeedsDisplay:(NSTimer *)timer;
-@end
-
-@interface NSWindow (AppKitSecretsIKnow)
-- (void)_postWindowNeedsDisplay;
-@end
-
 @implementation NSWindow (WebExtras)
 
-+ (void)_webkit_enableWindowDisplayThrottle
-{
-    if (throttlingWindowDisplay)
-        return;
-    
-    static BOOL installedWindowThrottle = NO;
-    if (!installedWindowThrottle) {        
-        // Override -[NSWindow _postWindowNeedsDisplay]
-        ASSERT(!oldNSWindowPostWindowNeedsDisplayIMP);
-        oldNSWindowPostWindowNeedsDisplayIMP = swizzleInstanceMethod(self, @selector(_postWindowNeedsDisplay), (IMP)replacementPostWindowNeedsDisplay);
-        ASSERT(oldNSWindowPostWindowNeedsDisplayIMP);
-        
-        // Override -[NSWindow dealloc]
-        ASSERT(!oldNSWindowDeallocIMP);
-        oldNSWindowDeallocIMP = swizzleInstanceMethod(self, @selector(dealloc), (IMP)replacementDealloc);
-        ASSERT(oldNSWindowDeallocIMP);
-
-        // Override -[NSWindow finalize]
-        ASSERT(!oldNSWindowFinalizeIMP);
-        oldNSWindowFinalizeIMP = swizzleInstanceMethod(self, @selector(finalize), (IMP)replacementFinalize);
-        ASSERT(oldNSWindowFinalizeIMP);
-
-        installedWindowThrottle = YES;
-    }
-
-    windowDisplayInfoDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL);
-    ASSERT(windowDisplayInfoDictionary);
-
-    throttlingWindowDisplay = YES;
-}
-
-static void disableWindowDisplayThrottleApplierFunction(const void *key, const void *value, void *context)
-{
-    WindowDisplayInfo *displayInfo = (WindowDisplayInfo *)value;
-    
-    // Display immediately
-    [displayInfo->window _postWindowNeedsDisplay];
-    cancelPendingWindowDisplay(displayInfo);
-    free(displayInfo);
-}
-
-+ (void)_webkit_displayThrottledWindows
-{
-    if (!throttlingWindowDisplay)
-        return;
-
-    // Force all throttle timers to fire by running the runloop in WebKitDisplayThrottleRunLoopMode until there are
-    // no more runloop timers/sources for that mode.
-    while (CFRunLoopRunInMode((CFStringRef)WebKitDisplayThrottleRunLoopMode, 1.0 / DISPLAY_REFRESH_INTERVAL, true) == kCFRunLoopRunHandledSource) {}
-}
-
-+ (void)_webkit_disableWindowDisplayThrottle
-{
-    if (!throttlingWindowDisplay)
-        return;
-
-    // Clear throttlingWindowDisplay first so that the displays triggered by disableWindowDisplayThrottleApplierFunction()
-    // go through the normal NSWindow display path
-    throttlingWindowDisplay = NO;
-    
-    // Display any windows that have pending displays
-    CFDictionaryApplyFunction(windowDisplayInfoDictionary, disableWindowDisplayThrottleApplierFunction, NULL);
-    
-    CFRelease(windowDisplayInfoDictionary);
-    windowDisplayInfoDictionary = NULL;
-}
-
 - (void)centerOverMainWindow
 {
     NSRect frameToCenterOver;
@@ -152,152 +50,3 @@ static void disableWindowDisplayThrottleApplierFunction(const void *key, const v
 }
 
 @end
-
-@implementation NSWindow (WebExtrasInternal)
-
-// Returns the old method implementation
-static IMP swizzleInstanceMethod(Class class, SEL selector, IMP newImplementation)
-{
-    Method method = class_getInstanceMethod(class, selector);
-    ASSERT(method);
-    IMP oldIMP;
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0
-    oldIMP = method_setImplementation(method, newImplementation);
-#else
-    oldIMP = method->method_imp;
-    method->method_imp = newImplementation;
-#endif
-    return oldIMP;
-}
-
-static void replacementPostWindowNeedsDisplay(id self, SEL cmd)
-{
-    // Call the original NSWindow method implementation if window throttling is disabled, or the window
-    // is currently being deallocated.
-    if (!throttlingWindowDisplay || ((NSWindow *)self)->_wFlags.windowDying) {
-        oldNSWindowPostWindowNeedsDisplayIMP(self, cmd);
-        return;
-    }
-        
-    // Do not call into -[NSWindow _postWindowNeedsDisplay] if requestWindowDisplay() returns NO.  In that case, requestWindowDisplay()
-    // will schedule a timer to display at the appropriate time.
-    if (requestWindowDisplay(self))
-        oldNSWindowPostWindowNeedsDisplayIMP(self, cmd);
-}
-
-static void clearWindowDisplayInfo(id self)
-{
-    ASSERT(throttlingWindowDisplay);
-    
-    // Remove WindowDisplayInfo for this window
-    WindowDisplayInfo *displayInfo = (WindowDisplayInfo *)CFDictionaryGetValue(windowDisplayInfoDictionary, self);
-    if (displayInfo) {
-        cancelPendingWindowDisplay(displayInfo);
-        free(displayInfo);
-        CFDictionaryRemoveValue(windowDisplayInfoDictionary, self);
-    }
-}
-
-static void replacementDealloc(id self, SEL cmd)
-{
-    if (throttlingWindowDisplay)
-        clearWindowDisplayInfo(self);
-
-    oldNSWindowDeallocIMP(self, cmd);
-}
-
-static void replacementFinalize(id self, SEL cmd)
-{
-    if (throttlingWindowDisplay)
-        clearWindowDisplayInfo(self);
-
-    oldNSWindowFinalizeIMP(self, cmd);
-}
-
-static WindowDisplayInfo *getWindowDisplayInfo(NSWindow *window)
-{
-    ASSERT(throttlingWindowDisplay);
-    ASSERT(windowDisplayInfoDictionary);
-    
-    // Get the WindowDisplayInfo for this window, or create it if it does not exist
-    WindowDisplayInfo *displayInfo = (WindowDisplayInfo *)CFDictionaryGetValue(windowDisplayInfoDictionary, window);
-    if (!displayInfo) {
-        displayInfo = (WindowDisplayInfo *)malloc(sizeof(WindowDisplayInfo));
-        displayInfo->window = window;
-        displayInfo->lastDisplayTime = 0;
-        displayInfo->displayTimer = nil;
-        CFDictionarySetValue(windowDisplayInfoDictionary, window, displayInfo);
-    }
-    
-    return displayInfo;
-}
-
-static BOOL requestWindowDisplay(NSWindow *window)
-{
-    ASSERT(throttlingWindowDisplay);
-
-    // Defer display if there is already a pending display
-    WindowDisplayInfo *displayInfo = getWindowDisplayInfo(window);
-    if (displayInfo->displayTimer)
-        return NO;
-        
-    // Defer display if it hasn't been at least DISPLAY_REFRESH_INTERVAL seconds since the last display
-    CFTimeInterval now = CFAbsoluteTimeGetCurrent();
-    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)
-                                                             target:window
-                                                           selector:@selector(_webkit_doPendingPostWindowNeedsDisplay:)
-                                                           userInfo:nil
-                                                            repeats:NO] retain];
-        
-        // The NSWindow autodisplay mechanism is documented to only work for NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, and NSModalPanelRunLoopMode
-        NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
-        [runLoop addTimer:displayInfo->displayTimer forMode:NSDefaultRunLoopMode];
-        [runLoop addTimer:displayInfo->displayTimer forMode:NSEventTrackingRunLoopMode];
-        [runLoop addTimer:displayInfo->displayTimer forMode:NSModalPanelRunLoopMode];
-        
-        // Schedule the timer in WebKitDisplayThrottleRunLoopMode so that +_webkit_displayThrottledWindows can
-        // force all window throttle timers to fire by running in just that mode
-        [runLoop addTimer:displayInfo->displayTimer forMode:WebKitDisplayThrottleRunLoopMode];
-        
-        return NO;
-    }
-
-    // Allow the display: there is no pending display, and it's been long enough to display again.
-    displayInfo->lastDisplayTime = now;
-    return YES;
-}
-
-static void cancelPendingWindowDisplay(WindowDisplayInfo *displayInfo)
-{
-    if (!displayInfo->displayTimer)
-        return;
-
-    [displayInfo->displayTimer invalidate];
-    [displayInfo->displayTimer release];
-    displayInfo->displayTimer = nil;
-}
-
-- (void)_webkit_doPendingPostWindowNeedsDisplay:(NSTimer *)timer
-{
-    WindowDisplayInfo *displayInfo = getWindowDisplayInfo(self);
-    ASSERT(timer == displayInfo->displayTimer);
-    ASSERT(throttlingWindowDisplay);
-    
-    // Clear displayInfo->displayTimer first because requestWindowDisplay() will not allow a display if the timer is non-nil.
-    // However, we must wait to invalidate timer because it may have the last reference to this window.
-    NSTimer *oldDisplayTimer = displayInfo->displayTimer;
-    displayInfo->displayTimer = nil;
-    
-    // Don't call directly into oldNSWindowPostWindowNeedsDisplayIMP because we don't want to bypass subclass implementations
-    // of -_postWindowNeedsDisplay
-    [self _postWindowNeedsDisplay];
-    
-    // Finally, invalidate the firing display timer.
-    [oldDisplayTimer invalidate];
-    [oldDisplayTimer release];
-}
-
-@end
index 730b679d37ee2e69a1e3364d4749de737329e35f..42ab1d673d27ea0b1db51c6e702ac8887737318e 100644 (file)
@@ -328,12 +328,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
         
-        // Window display is throttled to 60 frames per second if WebKitThrottleWindowDisplayPreferenceKey
-        // is set to YES.  The window display throttle is OFF by default for compatibility with Mac OS X
-        // 10.4.6.
-        if ([defaults boolForKey:WebKitThrottleWindowDisplayPreferenceKey])
-            [NSWindow _webkit_enableWindowDisplayThrottle];
-        
         // CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set
         // to NO, or has no value.  For compatibility with Mac OS X 10.4.6, deferred updates are OFF by
         // default.
index dc4d04fbf25080d485780a849eae8f5245b6b2d3..f2c5ea3f58f4a617665c9fbfd580b9abe75b7288 100644 (file)
 #define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior"
 
 
-// Window display is throttled to 60 frames per second if WebKitThrottleWindowDisplayPreferenceKey
-// is set to YES.  The window display throttle is OFF by default for compatibility with Mac OS X
-// 10.4.6.
-#define WebKitThrottleWindowDisplayPreferenceKey @"WebKitThrottleWindowDisplay"
-
 // CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set
 // to NO, or has no value.  For compatibility with Mac OS X 10.4.6, deferred updates are OFF by
 // default.