Rubber stamped by Darin.
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 20:51:53 +0000 (20:51 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 20:51:53 +0000 (20:51 +0000)
        Make DumpRenderTree more cross platform ready.
        - Convert GCController to use the JSCore API instead of the WebScriptObject.
        - Use CF types instead of NS objects.
        - General cleanup.

        * DumpRenderTree/DumpRenderTree.h:
        * DumpRenderTree/DumpRenderTree.mm:
        (dumpRenderTree):
        (dump):
        (runTest):
        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
        * DumpRenderTree/EditingDelegate.m:
        * DumpRenderTree/FrameLoadDelegate.h:
        * DumpRenderTree/FrameLoadDelegate.mm:
        (-[FrameLoadDelegate init]):
        (-[FrameLoadDelegate dealloc]):
        (-[FrameLoadDelegate webView:didClearWindowObject:forFrame:]):
        * DumpRenderTree/GCController.cpp: Added.
        (GCController::GCController):
        (GCController::~GCController):
        (collectCallback):
        (collectOnAlternateThreadCallback):
        (getJSObjectCountCallback):
        (GCController::makeWindowObject):
        (GCController::getJSClass):
        (GCController::staticFunctions):
        * DumpRenderTree/GCController.h:
        * DumpRenderTree/GCController.mm:
        (GCController::collect):
        (GCController::collectOnAlternateThread):
        (GCController::getJSObjectCount):
        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::makeWindowObject):
        (LayoutTestController::getJSClass):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/LayoutTestControllerMac.mm:
        (LayoutTestController::addDisallowedURL):
        (waitUntilDoneWatchdogFired):
        (LayoutTestController::waitUntilDone):
        * DumpRenderTree/ResourceLoadDelegate.m:
        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):

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

14 files changed:
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.h
WebKitTools/DumpRenderTree/DumpRenderTree.mm
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/DumpRenderTree/EditingDelegate.m
WebKitTools/DumpRenderTree/FrameLoadDelegate.h
WebKitTools/DumpRenderTree/FrameLoadDelegate.mm
WebKitTools/DumpRenderTree/GCController.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/GCController.h
WebKitTools/DumpRenderTree/GCController.mm
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/ResourceLoadDelegate.m

index 1c477c5c2a7ad339ac62084984107fb3aadb7137..b5523f705a83dde4a58281d8685d328cb6198b79 100644 (file)
@@ -1,3 +1,49 @@
+2007-09-13  Sam Weinig  <sam@webkit.org>
+
+        Rubber stamped by Darin.
+
+        Make DumpRenderTree more cross platform ready.
+        - Convert GCController to use the JSCore API instead of the WebScriptObject.
+        - Use CF types instead of NS objects.
+        - General cleanup.
+
+        * DumpRenderTree/DumpRenderTree.h:
+        * DumpRenderTree/DumpRenderTree.mm:
+        (dumpRenderTree):
+        (dump):
+        (runTest):
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/EditingDelegate.m:
+        * DumpRenderTree/FrameLoadDelegate.h:
+        * DumpRenderTree/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate init]):
+        (-[FrameLoadDelegate dealloc]):
+        (-[FrameLoadDelegate webView:didClearWindowObject:forFrame:]):
+        * DumpRenderTree/GCController.cpp: Added.
+        (GCController::GCController):
+        (GCController::~GCController):
+        (collectCallback):
+        (collectOnAlternateThreadCallback):
+        (getJSObjectCountCallback):
+        (GCController::makeWindowObject):
+        (GCController::getJSClass):
+        (GCController::staticFunctions):
+        * DumpRenderTree/GCController.h:
+        * DumpRenderTree/GCController.mm:
+        (GCController::collect):
+        (GCController::collectOnAlternateThread):
+        (GCController::getJSObjectCount):
+        * DumpRenderTree/LayoutTestController.cpp:
+        (LayoutTestController::makeWindowObject):
+        (LayoutTestController::getJSClass):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/LayoutTestControllerMac.mm:
+        (LayoutTestController::addDisallowedURL):
+        (waitUntilDoneWatchdogFired):
+        (LayoutTestController::waitUntilDone):
+        * DumpRenderTree/ResourceLoadDelegate.m:
+        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
+
 2007-09-12  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Stephanie.
index dd11ae553af09b99aa254e8fc9f1abb983551df6..325954351c38d463a8249c041306ae97a0f97e6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef DumpRenderTree_h
+#define DumpRenderTree_h
 
 @class DumpRenderTreeDraggingInfo;
 @class EditingDelegate;
 @class ResourceLoadDelegate;
 @class UIDelegate;
 @class WebFrame;
-@class WebScriptObject;
 @class WebView;
 
+extern volatile bool done;
 
-extern BOOL dumpAsText;
-extern BOOL dumpDOMAsWebArchive;
-extern BOOL dumpSourceAsWebArchive;
-extern BOOL dumpSelectionRect;
-extern BOOL dumpTitleChanges;
-extern BOOL dumpBackForwardList;
-extern BOOL dumpChildFrameScrollPositions;
-extern BOOL dumpChildFramesAsText;
-extern BOOL testRepaint;
-extern BOOL repaintSweepHorizontally;
-extern BOOL windowIsKey;
-extern BOOL shouldDumpEditingCallbacks;
-extern BOOL shouldDumpResourceLoadCallbacks;
-extern BOOL shouldDumpFrameLoadCallbacks;
-extern BOOL shouldDumpResourceLoadCallbacks;
-extern BOOL shouldDumpFrameLoadCallbacks;
-extern BOOL waitToDump;
-extern BOOL canOpenWindows;
-extern BOOL closeWebViews;
-extern BOOL closeRemainingWindowsWhenComplete;
-extern BOOL addFileToPasteboardOnDrag;
+extern bool dumpAsText;
+extern bool dumpSelectionRect;
+extern bool dumpTitleChanges;
+extern bool dumpBackForwardList;
+extern bool dumpChildFrameScrollPositions;
+extern bool dumpChildFramesAsText;
+extern bool dumpDOMAsWebArchive;
+extern bool dumpSourceAsWebArchive;
+extern bool shouldDumpEditingCallbacks;
+extern bool shouldDumpResourceLoadCallbacks;
+extern bool shouldDumpFrameLoadCallbacks;
+extern bool shouldDumpResourceLoadCallbacks;
+extern bool shouldDumpFrameLoadCallbacks;
+extern bool addFileToPasteboardOnDrag;
+extern bool canOpenWindows;
+extern bool closeRemainingWindowsWhenComplete;
+extern bool closeWebViews;
+extern bool repaintSweepHorizontally;
+extern bool testRepaint;
+extern bool waitToDump;
+extern bool windowIsKey;
 
-extern volatile BOOL done;
+extern CFMutableArrayRef allWindowsRef;
+extern CFMutableSetRef disallowedURLs;
+extern CFRunLoopTimerRef waitToDumpWatchdog;
+extern CFTimeInterval waitToDumpWatchdogInterval;
+
+extern WebFrame* mainFrame;
+extern WebFrame* topLoadingFrame;
 
-extern WebFrame *mainFrame;
 extern DumpRenderTreeDraggingInfo *draggingInfo;
-extern WebFrame *topLoadingFrame;
-extern NavigationController *navigationController;
-extern NSTimer *waitToDumpWatchdog;
-extern NSTimeInterval waitToDumpWatchdogInterval;
-extern CFMutableArrayRef allWindowsRef;
-extern NSMutableSet *disallowedURLs;
+
+// Global Controllers
+extern NavigationController* navigationController;
 
 // Delegates
-extern FrameLoadDelegate *frameLoadDelegate;
-extern UIDelegate *uiDelegate;
-extern EditingDelegate *editingDelegate;
-extern ResourceLoadDelegate *resourceLoadDelegate;
-extern PolicyDelegate *policyDelegate;
+extern FrameLoadDelegateframeLoadDelegate;
+extern UIDelegateuiDelegate;
+extern EditingDelegateeditingDelegate;
+extern ResourceLoadDelegateresourceLoadDelegate;
+extern PolicyDelegatepolicyDelegate;
 
-WebView *createWebView();
+WebViewcreateWebView();
 void displayWebView();
 void dump(void);
+
+#endif DumpRenderTree_h
index 2f884aad7c9e844f8dd42bbaa372388996bf2c04..a22dd281f87cf27524e4efd320b8df201edb55fb 100644 (file)
 }
 @end
 
-LayoutTestController* layoutTestController = 0;
-
-BOOL windowIsKey = YES;
-WebFrame *mainFrame = 0;
-BOOL shouldDumpEditingCallbacks;
-BOOL shouldDumpResourceLoadCallbacks;
-BOOL shouldDumpFrameLoadCallbacks;
-NSMutableSet *disallowedURLs = 0;
-BOOL waitToDump;     // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
-BOOL canOpenWindows;
-BOOL closeWebViews;
-BOOL closeRemainingWindowsWhenComplete = YES;
-BOOL addFileToPasteboardOnDrag = NO;
-
 static void runTest(const char *pathOrURL);
 static NSString *md5HashStringForBitmap(CGImageRef bitmap);
 
-volatile BOOL done;
-NavigationController *navigationController = nil;
-
-NSTimer *waitToDumpWatchdog;
-NSTimeInterval waitToDumpWatchdogInterval = 10; // seconds
-
-// Delegates
-FrameLoadDelegate *frameLoadDelegate;
-UIDelegate *uiDelegate;
-EditingDelegate *editingDelegate;
-ResourceLoadDelegate *resourceLoadDelegate;
-PolicyDelegate *policyDelegate;
-
 // Deciding when it's OK to dump out the state is a bit tricky.  All these must be true:
 // - There is no load in progress
 // - There is no work queued up (see workQueue var, below)
@@ -126,22 +99,49 @@ PolicyDelegate *policyDelegate;
 //       and notifyDone was called subsequently.
 // Note that the call to notifyDone and the end of the load can happen in either order.
 
+volatile bool done;
+
+LayoutTestController* layoutTestController = 0;
+NavigationController* navigationController = 0;
+
+WebFrame *mainFrame = 0;
 // This is the topmost frame that is loading, during a given load, or nil when no load is 
 // in progress.  Usually this is the same as the main frame, but not always.  In the case
 // where a frameset is loaded, and then new content is loaded into one of the child frames,
 // that child frame is the "topmost frame that is loading".
 WebFrame *topLoadingFrame = nil;     // !nil iff a load is in progress
 
-BOOL dumpAsText;
-BOOL dumpDOMAsWebArchive;
-BOOL dumpSourceAsWebArchive;
-BOOL dumpSelectionRect;
-BOOL dumpTitleChanges = NO;
-BOOL dumpBackForwardList;
-BOOL dumpChildFrameScrollPositions;
-BOOL dumpChildFramesAsText;
-BOOL testRepaint;
-BOOL repaintSweepHorizontally;
+bool addFileToPasteboardOnDrag = NO;
+bool canOpenWindows;
+bool closeRemainingWindowsWhenComplete = YES;
+bool closeWebViews;
+bool dumpAsText;
+bool dumpBackForwardList;
+bool dumpChildFramesAsText;
+bool dumpChildFrameScrollPositions;
+bool dumpDOMAsWebArchive;
+bool dumpSelectionRect;
+bool dumpSourceAsWebArchive;
+bool dumpTitleChanges = NO;
+bool repaintSweepHorizontally;
+bool shouldDumpEditingCallbacks;
+bool shouldDumpFrameLoadCallbacks;
+bool shouldDumpResourceLoadCallbacks;
+bool testRepaint;
+bool waitToDump;     // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
+bool windowIsKey = YES;
+
+CFMutableArrayRef allWindowsRef = 0;
+CFMutableSetRef disallowedURLs = 0;
+CFRunLoopTimerRef waitToDumpWatchdog = 0;
+CFTimeInterval waitToDumpWatchdogInterval = 10.0; // seconds
+
+// Delegates
+FrameLoadDelegate *frameLoadDelegate;
+UIDelegate *uiDelegate;
+EditingDelegate *editingDelegate;
+ResourceLoadDelegate *resourceLoadDelegate;
+PolicyDelegate *policyDelegate;
 
 static int dumpPixels;
 static int paint;
@@ -162,8 +162,6 @@ static CGColorSpaceRef sharedColorSpace;
 const unsigned maxViewHeight = 600;
 const unsigned maxViewWidth = 800;
 
-CFMutableArrayRef allWindowsRef;
-
 static pthread_mutex_t javaScriptThreadsMutex = PTHREAD_MUTEX_INITIALIZER;
 static BOOL javaScriptThreadsShouldTerminate;
 
@@ -597,10 +595,12 @@ void dumpRenderTree(int argc, const char *argv[])
     
     [navigationController release];
     navigationController = nil;
-    
-    [disallowedURLs release];
-    disallowedURLs = nil;
-    
+
+    if (disallowedURLs) {
+        CFRelease(disallowedURLs);
+        disallowedURLs = 0;
+    }
+
     if (dumpPixels)
         restoreColorSpace(0);
 }
@@ -849,10 +849,12 @@ static void dumpBackForwardListForWebView(WebView *view)
 
 void dump(void)
 {
-    [waitToDumpWatchdog invalidate];
-    [waitToDumpWatchdog release];
-    waitToDumpWatchdog = nil;
-    
+    if (waitToDumpWatchdog) {
+        CFRunLoopTimerInvalidate(waitToDumpWatchdog);
+        CFRelease(waitToDumpWatchdog);
+        waitToDumpWatchdog = 0;
+    }
+
     if (dumpTree) {
         NSString *result = nil;
 
@@ -893,9 +895,9 @@ void dump(void)
         }
 
         if (dumpBackForwardList) {
-            unsigned count = [(NSArray *)allWindowsRef count];
+            unsigned count = CFArrayGetCount(allWindowsRef);
             for (unsigned i = 0; i < count; i++) {
-                NSWindow *window = [(NSArray *)allWindowsRef objectAtIndex:i];
+                NSWindow *window = (NSWindow *)CFArrayGetValueAtIndex(allWindowsRef, i);
                 WebView *webView = [[[window contentView] subviews] objectAtIndex:0];
                 dumpBackForwardListForWebView(webView);
             }
@@ -1056,8 +1058,9 @@ static void runTest(const char *pathOrURL)
     if ([WebHistory optionalSharedHistory])
         [WebHistory setOptionalSharedHistory:nil];
     lastMousePosition = NSMakePoint(0, 0);
-    [disallowedURLs removeAllObjects];
-    
+    if (disallowedURLs)
+        CFSetRemoveAllValues(disallowedURLs);
+
     if (currentTest != nil)
         CFRelease(currentTest);
     currentTest = (NSString *)pathOrURLString;
index 16727c5eb89bd5cce84c81bd0d684968eb475577..bc0e9ac71c384010952b73c0af4a8a5ea240100c 100644 (file)
@@ -76,6 +76,7 @@
                BCA51F970C960CFC0076A81A /* LayoutTestControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */; };
                BCA876B70C921FA100946E9C /* ObjCController.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA876B50C921FA100946E9C /* ObjCController.h */; };
                BCA876B80C921FA100946E9C /* ObjCController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA876B60C921FA100946E9C /* ObjCController.m */; };
+               BCF6C6500C98E9C000AC063E /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF6C64F0C98E9C000AC063E /* GCController.cpp */; };
                D23AE9660C56BB2100C47236 /* PolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D23AE8EA0C56B2FF00C47236 /* PolicyDelegate.m */; };
                D23AE9690C56BB2900C47236 /* PolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D23AE8E00C56B29E00C47236 /* PolicyDelegate.h */; };
                E1330800099624DA00AC0A91 /* AppleScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E13307FE099624DA00AC0A91 /* AppleScriptController.h */; };
                9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
                93442CF408F8BA4900BFE8CA /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
                93442CF508F8BA4900BFE8CA /* TextInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextInputController.m; sourceTree = "<group>"; };
-               9345229C0BD12B710086EDA0 /* AHEM____.TTF */ = {isa = PBXFileReference; explicitFileType = file; name = "AHEM____.TTF"; path = "DumpRenderTree.qtproj/fonts/AHEM____.TTF"; sourceTree = "<group>"; };
+               9345229C0BD12B710086EDA0 /* AHEM____.TTF */ = {isa = PBXFileReference; explicitFileType = file; name = AHEM____.TTF; path = DumpRenderTree.qtproj/fonts/AHEM____.TTF; sourceTree = "<group>"; };
                A803FCB709CAAAB0009B2A37 /* EventSendingController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EventSendingController.h; sourceTree = "<group>"; };
                A803FCB809CAAAB1009B2A37 /* EventSendingController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = EventSendingController.m; sourceTree = "<group>"; };
                A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTree.h; sourceTree = "<group>"; };
                BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayoutTestControllerMac.mm; sourceTree = "<group>"; };
                BCA876B50C921FA100946E9C /* ObjCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCController.h; sourceTree = "<group>"; };
                BCA876B60C921FA100946E9C /* ObjCController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCController.m; sourceTree = "<group>"; };
+               BCF6C64F0C98E9C000AC063E /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; };
                D23AE8E00C56B29E00C47236 /* PolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyDelegate.h; sourceTree = "<group>"; };
                D23AE8EA0C56B2FF00C47236 /* PolicyDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PolicyDelegate.m; sourceTree = "<group>"; };
                E13307FE099624DA00AC0A91 /* AppleScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleScriptController.h; sourceTree = "<group>"; };
                                E13307FF099624DA00AC0A91 /* AppleScriptController.m */,
                                A803FCB709CAAAB0009B2A37 /* EventSendingController.h */,
                                A803FCB809CAAAB1009B2A37 /* EventSendingController.m */,
+                               BCF6C64F0C98E9C000AC063E /* GCController.cpp */,
                                14770FE00A22ADF7009342EE /* GCController.h */,
                                14770FE10A22ADF7009342EE /* GCController.mm */,
+                               BC0131D80C9772010087317D /* LayoutTestController.cpp */,
+                               BC0131D90C9772010087317D /* LayoutTestController.h */,
+                               BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */,
                                14A6FB880971CAE5008B014F /* NavigationController.h */,
                                14A6FB890971CAE5008B014F /* NavigationController.m */,
-                               93442CF408F8BA4900BFE8CA /* TextInputController.h */,
-                               93442CF508F8BA4900BFE8CA /* TextInputController.m */,
                                BCA876B50C921FA100946E9C /* ObjCController.h */,
                                BCA876B60C921FA100946E9C /* ObjCController.m */,
-                               BC0131D80C9772010087317D /* LayoutTestController.cpp */,
-                               BC0131D90C9772010087317D /* LayoutTestController.h */,
-                               BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */,
+                               93442CF408F8BA4900BFE8CA /* TextInputController.h */,
+                               93442CF508F8BA4900BFE8CA /* TextInputController.m */,
                        );
                        name = Controllers;
                        sourceTree = "<group>";
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C29C308902C6D008A9EFC /* Build configuration list for PBXProject "DumpRenderTree" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* DumpRenderTree */;
                        productRefGroup = 9340995508540CAF007F3BC8 /* Products */;
                                BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */,
                                BC0131DA0C9772010087317D /* LayoutTestController.cpp in Sources */,
                                BC0131EF0C9774700087317D /* WorkQueueItemMac.mm in Sources */,
+                               BCF6C6500C98E9C000AC063E /* GCController.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                        "-sectcreate",
                                        __DATA,
                                        Ahem,
-                                       "DumpRenderTree.qtproj/fonts/AHEM____.TTF",
+                                       DumpRenderTree.qtproj/fonts/AHEM____.TTF,
                                );
                                PRODUCT_NAME = DumpRenderTree;
                                VALID_ARCHS = "ppc7400 ppc970 i386 ppc";
                                        "-sectcreate",
                                        __DATA,
                                        Ahem,
-                                       "DumpRenderTree.qtproj/fonts/AHEM____.TTF",
+                                       DumpRenderTree.qtproj/fonts/AHEM____.TTF,
                                );
                                PRODUCT_NAME = DumpRenderTree;
                                VALID_ARCHS = "ppc7400 ppc970 i386 ppc";
index db352d77a46972c950bb9b4ad59046ac0ea0e4b1..6e38938558a8172ba27583606bc9f24c553bacf1 100644 (file)
@@ -31,7 +31,7 @@
 
 #import <WebKit/WebKit.h>
 
-extern BOOL shouldDumpEditingCallbacks;
+extern bool shouldDumpEditingCallbacks;
 
 @interface DOMNode (dumpPath)
 - (NSString *)dumpPath;
index 18766bd3c75b688efd76a4029c165e2c02467a9a..e5e8ed90599660b21eac027610ecb07ff8b6a55e 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
 
-class LayoutTestController; 
+class LayoutTestController;
+class GCController;
 
 @interface FrameLoadDelegate : NSObject
 {
     LayoutTestController* layoutTestContoller;
+    GCController* gcController;
 }
 @end
index edeee1e2cba1f749d88ddf53feb81c5f4014c3be..a6cb58494e78b4b692182e8f15d92c0b68506e33 100644 (file)
 
 - (id)init
 {
-    if ((self = [super init]))
+    if ((self = [super init])) {
         layoutTestContoller = new LayoutTestController;
+        gcController = new GCController;
+    }
     return self;
 }
 
 - (void)dealloc
 {
     delete layoutTestContoller;
+    delete gcController;
     [super dealloc];
 }
 
     JSContextRef context = [frame globalContext];
     JSObjectRef globalObject = JSContextGetGlobalObject(context);
     JSValueRef exception = 0;
+
     layoutTestContoller->makeWindowObject(context, globalObject, &exception);
     ASSERT(!exception);
 
+    gcController->makeWindowObject(context, globalObject, &exception);
+    ASSERT(!exception);
+
     // Make Old-Style controllers
     EventSendingController *esc = [[EventSendingController alloc] init];
     [obj setValue:esc forKey:@"eventSender"];
     AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
     [obj setValue:asc forKey:@"appleScriptController"];
     [asc release];
-    
-    GCController *gcc = [[GCController alloc] init];
-    [obj setValue:gcc forKey:@"GCController"];
-    [gcc release];
 
     ObjCController *occ = [[ObjCController alloc] init];
     [obj setValue:occ forKey:@"objCController"];
diff --git a/WebKitTools/DumpRenderTree/GCController.cpp b/WebKitTools/DumpRenderTree/GCController.cpp
new file mode 100644 (file)
index 0000000..01137f6
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "GCController.h"
+
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
+
+GCController::GCController()
+{
+}
+
+GCController::~GCController()
+{
+}
+
+#pragma mark -
+#pragma mark Static Functions
+
+static JSValueRef collectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    GCController* controller = reinterpret_cast<GCController*>(JSObjectGetPrivate(thisObject));
+    controller->collect();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef collectOnAlternateThreadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    bool waitUntilDone = false;
+    if (argumentCount > 0)
+        waitUntilDone = JSValueToBoolean(context, arguments[0]);
+
+    GCController* controller = reinterpret_cast<GCController*>(JSObjectGetPrivate(thisObject));
+    controller->collectOnAlternateThread(waitUntilDone);
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef getJSObjectCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    GCController* controller = reinterpret_cast<GCController*>(JSObjectGetPrivate(thisObject));
+    size_t jsObjectCount = controller->getJSObjectCount();
+
+    return JSValueMakeNumber(context, jsObjectCount);
+}
+
+#pragma mark -
+#pragma mark Object Creation
+
+void GCController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
+{
+    JSRetainPtr<JSStringRef> gcControllerStr(Adopt, JSStringCreateWithUTF8CString("GCController"));
+    JSValueRef gcControllerObject = JSObjectMake(context, getJSClass(), this);
+    JSObjectSetProperty(context, windowObject, gcControllerStr.get(), gcControllerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
+}
+
+JSClassRef GCController::getJSClass()
+{
+    static JSClassRef gcControllerClass = 0;
+
+    if (!gcControllerClass) {
+        JSStaticFunction* staticFunctions = GCController::staticFunctions();
+        JSClassDefinition classDefinition = {
+            0, kJSClassAttributeNone, "GCController", 0, 0, staticFunctions,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+        };
+
+        gcControllerClass = JSClassCreate(&classDefinition);
+    }
+
+    return gcControllerClass;
+}
+
+JSStaticFunction* GCController::staticFunctions()
+{
+    static JSStaticFunction staticFunctions[] = {
+        { "collect", collectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "collectOnAlternateThread", collectOnAlternateThreadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "getJSObjectCount", getJSObjectCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { 0, 0, 0 }
+    };
+
+    return staticFunctions;
+}
index 308701ceebe5a72ff0482063505b86d1df3e4500..4284275d394d7877516b6a7f8ffbae0690013036 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import <WebKit/WebView.h>
+#ifndef GCController_h
+#define GCController_h
 
-@interface GCController : NSObject {
-}
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector;
-+ (NSString *)webScriptNameForSelector:(SEL)aSelector;
-- (void)collect;
-- (void)collectOnAlternateThread:(BOOL)waitUntilDone;
-- (size_t)getJSObjectCount;
-@end
+#include <JavaScriptCore/JSObjectRef.h>
+
+class GCController {
+public:
+    GCController();
+    ~GCController();
+
+    void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
+
+    // Controller Methods - platfrom independant implementations
+    void collect() const;
+    void collectOnAlternateThread(bool waitUntilDone) const;
+    size_t getJSObjectCount() const;
+
+private:
+    static JSClassRef getJSClass();
+    static JSStaticFunction* staticFunctions();
+};
+
+#endif // GCController_h
index 32165406e5ade81ec5f85cf7158ce53922f127b9..4b8a85dfebd8aabf536cae47637a98ba0af5c728 100644 (file)
 #import "GCController.h"
 #import <WebKit/WebCoreStatistics.h>
 
-@implementation GCController
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
-{
-    if (aSelector == @selector(collect))
-        return NO;
-    if (aSelector == @selector(collectOnAlternateThread:))
-        return NO;
-    if (aSelector == @selector(getJSObjectCount))
-        return NO;
-    
-    return YES;
-}
-
-+ (NSString *)webScriptNameForSelector:(SEL)aSelector
-{
-    if (aSelector == @selector(collectOnAlternateThread:))
-        return @"collectOnAlternateThread";
-    
-    return nil;
-}
 
-- (void)collect
+void GCController::collect() const
 {
     [WebCoreStatistics garbageCollectJavaScriptObjects];
 }
 
-- (void)collectOnAlternateThread:(BOOL)waitUntilDone
+void GCController::collectOnAlternateThread(bool waitUntilDone) const
 {
     [WebCoreStatistics garbageCollectJavaScriptObjectsOnAlternateThread:waitUntilDone];
 }
 
-- (size_t)getJSObjectCount
+size_t GCController::getJSObjectCount() const
 {
     return [WebCoreStatistics javaScriptObjectsCount];
 }
-@end
index 4ff4aa0eef2a6f63539078ab98005d0f6bc711b5..83c456e7e8fbf41dd59e0eda9e42a0a7c197bc75 100644 (file)
@@ -447,11 +447,11 @@ static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function
 void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
 {
     JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
-    JSValueRef layoutTestContollerObject = JSObjectMake(context, getLayoutTestControllerJSClass(), this);
-    JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeNone, exception);
+    JSValueRef layoutTestContollerObject = JSObjectMake(context, getJSClass(), this);
+    JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception);
 }
 
-JSClassRef LayoutTestController::getLayoutTestControllerJSClass()
+JSClassRef LayoutTestController::getJSClass()
 {
     static JSClassRef layoutTestControllerClass = 0;
 
index d2651afd99e049ca5cd96532e47ca77103f28fbc..c7380f82bc6b8c5ec2eebed836b312d3788f8c4a 100644 (file)
@@ -81,7 +81,7 @@ public:
 
 
 private:
-    static JSClassRef getLayoutTestControllerJSClass();
+    static JSClassRef getJSClass();
     static JSStaticFunction* staticFunctions();
 };
 
index c4cd27227d7a85b3440b15fd44a869f7c3a2dad3..a2ae56151cf8ca5dcb523e8c1349004f19256cfe 100644 (file)
@@ -137,13 +137,13 @@ void LayoutTestController::addDisallowedURL(JSStringRef url)
     RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, url));
 
     if (!disallowedURLs)
-        disallowedURLs = [[NSMutableSet alloc] init];
+        disallowedURLs = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL);
 
     // Canonicalize the URL
     NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]];
     request = [NSURLProtocol canonicalRequestForRequest:request];
 
-    [disallowedURLs addObject:[request URL]];
+    CFSetAddValue(disallowedURLs, [request URL]);
 }
 
 void LayoutTestController::clearBackForwardList()
@@ -282,25 +282,19 @@ void LayoutTestController::setWindowIsKey(bool flag)
         [(WebHTMLView *)documentView _updateActiveState];
 }
 
-@interface WaitToDumpWatchdog : NSObject
-+ (void)waitUntilDoneWatchdogFired;
-@end
-
-@implementation WaitToDumpWatchdog
-+ (void)waitUntilDoneWatchdogFired
+static void waitUntilDoneWatchdogFired(CFRunLoopTimerRef timer, void* info)
 {
     const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
     fprintf(stderr, message);
     fprintf(stdout, message);
     dump();
 }
-@end
 
 void LayoutTestController::waitUntilDone()
 {
     waitToDump = true;
     if (!waitToDumpWatchdog)
-        waitToDumpWatchdog = [[NSTimer scheduledTimerWithTimeInterval:waitToDumpWatchdogInterval target:[WaitToDumpWatchdog class] selector:@selector(waitUntilDoneWatchdogFired) userInfo:nil repeats:NO] retain];
+        waitToDumpWatchdog = CFRunLoopTimerCreate(kCFAllocatorDefault, 0, waitToDumpWatchdogInterval, 0, 0, waitUntilDoneWatchdogFired, NULL);
 }
 
 int LayoutTestController::windowCount()
index c5839e32a97ba2a5600c8cdcdd15d056221f7375..b894e847b9e08025730c158e1a411a738af549f6 100644 (file)
         printf ("%s\n", [string UTF8String]);
     }    
     
-    if ([disallowedURLs containsObject:[newRequest URL]])
+    if (disallowedURLs && CFSetContainsValue(disallowedURLs, [newRequest URL]))
         return nil;
     
     return newRequest;