diff options
Diffstat (limited to 'WebKitTools/DrawTest')
35 files changed, 2247 insertions, 0 deletions
diff --git a/WebKitTools/DrawTest/AppDelegate.h b/WebKitTools/DrawTest/AppDelegate.h new file mode 100644 index 0000000..7103bb8 --- /dev/null +++ b/WebKitTools/DrawTest/AppDelegate.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + + +@interface AppDelegate : NSObject { + IBOutlet NSWindow *svgImageRepTestWindow; +} + +- (IBAction)showTestsPanel:(id)sender; +- (IBAction)showImageRepTestWindow:(id)sender; +- (IBAction)showInspectorPanel:(id)sender; + +@end diff --git a/WebKitTools/DrawTest/AppDelegate.m b/WebKitTools/DrawTest/AppDelegate.m new file mode 100644 index 0000000..0f20b35 --- /dev/null +++ b/WebKitTools/DrawTest/AppDelegate.m @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ +#import "AppDelegate.h" + +#import "TestController.h" +#import "DrawTestInspectorController.h" + +@implementation AppDelegate + +- (IBAction)showTestsPanel:(id)sender +{ + [[TestController sharedController] showTestsPanel:sender]; +} + +- (IBAction)showImageRepTestWindow:(id)sender +{ + [svgImageRepTestWindow makeKeyAndOrderFront:sender]; +} + +- (IBAction)showInspectorPanel:(id)sender +{ + [[DrawTestInspectorController sharedInstance] showInspectorPanel:sender]; +} + +- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender +{ + return NO; +} + +@end diff --git a/WebKitTools/DrawTest/DrawTest.xcodeproj/project.pbxproj b/WebKitTools/DrawTest/DrawTest.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3ac995b --- /dev/null +++ b/WebKitTools/DrawTest/DrawTest.xcodeproj/project.pbxproj @@ -0,0 +1,387 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 78662E6D096B4E1600907EA7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78662E6C096B4E1600907EA7 /* WebKit.framework */; }; + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + A8C006CF0898634600BA5114 /* SVGTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006B00898634600BA5114 /* SVGTest.m */; }; + A8C006D00898634600BA5114 /* ScalingImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006B20898634600BA5114 /* ScalingImageView.m */; }; + A8C006D20898634600BA5114 /* DrawTestView.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006B50898634600BA5114 /* DrawTestView.m */; }; + A8C006D30898634600BA5114 /* DrawTestToolbarController.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006B70898634600BA5114 /* DrawTestToolbarController.m */; }; + A8C006D40898634600BA5114 /* DrawTestInspectorController.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006BB0898634600BA5114 /* DrawTestInspectorController.m */; }; + A8C006D50898634600BA5114 /* DrawTestDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006BD0898634600BA5114 /* DrawTestDocument.m */; }; + A8C006E10898634600BA5114 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006CA0898634600BA5114 /* AppDelegate.m */; }; + A8C006E20898634600BA5114 /* TestViewerSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006CC0898634600BA5114 /* TestViewerSplitView.m */; }; + A8C006E30898634600BA5114 /* TestController.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C006CE0898634600BA5114 /* TestController.m */; }; + A8C006F3089865E900BA5114 /* DrawTestDocument.nib in Resources */ = {isa = PBXBuildFile; fileRef = A8C006ED089865E900BA5114 /* DrawTestDocument.nib */; }; + A8C006F4089865E900BA5114 /* Inspector.nib in Resources */ = {isa = PBXBuildFile; fileRef = A8C006EF089865E900BA5114 /* Inspector.nib */; }; + A8C006F5089865E900BA5114 /* TestViewer.nib in Resources */ = {isa = PBXBuildFile; fileRef = A8C006F1089865E900BA5114 /* TestViewer.nib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; + 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; + 32CA4F630368D1EE00C91783 /* DrawTest_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTest_Prefix.pch; sourceTree = "<group>"; }; + 78662E6C096B4E1600907EA7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 8D1107320486CEB800E47090 /* DrawTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DrawTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A8C006AF0898634600BA5114 /* TestController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestController.h; sourceTree = "<group>"; }; + A8C006B00898634600BA5114 /* SVGTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGTest.m; sourceTree = "<group>"; }; + A8C006B10898634600BA5114 /* SVGTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTest.h; sourceTree = "<group>"; }; + A8C006B20898634600BA5114 /* ScalingImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScalingImageView.m; sourceTree = "<group>"; }; + A8C006B30898634600BA5114 /* ScalingImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScalingImageView.h; sourceTree = "<group>"; }; + A8C006B50898634600BA5114 /* DrawTestView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTestView.m; sourceTree = "<group>"; }; + A8C006B60898634600BA5114 /* DrawTestView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTestView.h; sourceTree = "<group>"; }; + A8C006B70898634600BA5114 /* DrawTestToolbarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTestToolbarController.m; sourceTree = "<group>"; }; + A8C006B80898634600BA5114 /* DrawTestDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTestDocument.h; sourceTree = "<group>"; }; + A8C006BA0898634600BA5114 /* DrawTestToolbarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTestToolbarController.h; sourceTree = "<group>"; }; + A8C006BB0898634600BA5114 /* DrawTestInspectorController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTestInspectorController.m; sourceTree = "<group>"; }; + A8C006BC0898634600BA5114 /* DrawTestInspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawTestInspectorController.h; sourceTree = "<group>"; }; + A8C006BD0898634600BA5114 /* DrawTestDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawTestDocument.m; sourceTree = "<group>"; }; + A8C006CA0898634600BA5114 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; + A8C006CB0898634600BA5114 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; + A8C006CC0898634600BA5114 /* TestViewerSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestViewerSplitView.m; sourceTree = "<group>"; }; + A8C006CD0898634600BA5114 /* TestViewerSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestViewerSplitView.h; sourceTree = "<group>"; }; + A8C006CE0898634600BA5114 /* TestController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestController.m; sourceTree = "<group>"; }; + A8C006EE089865E900BA5114 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/DrawTestDocument.nib; sourceTree = "<group>"; }; + A8C006F0089865E900BA5114 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Inspector.nib; sourceTree = "<group>"; }; + A8C006F2089865E900BA5114 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/TestViewer.nib; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + 78662E6D096B4E1600907EA7 /* WebKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + A8C006E5089863A100BA5114 /* Viewer */, + A8C006E6089863B100BA5114 /* Test Browser */, + A8C006CA0898634600BA5114 /* AppDelegate.m */, + A8C006CB0898634600BA5114 /* AppDelegate.h */, + A8C006B20898634600BA5114 /* ScalingImageView.m */, + A8C006B30898634600BA5114 /* ScalingImageView.h */, + ); + name = Classes; + sourceTree = "<group>"; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 78662E6C096B4E1600907EA7 /* WebKit.framework */, + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = "<group>"; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = "<group>"; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* DrawTest.app */, + ); + name = Products; + sourceTree = "<group>"; + }; + 29B97314FDCFA39411CA2CEA /* DrawTest */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* Classes */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = DrawTest; + sourceTree = "<group>"; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 32CA4F630368D1EE00C91783 /* DrawTest_Prefix.pch */, + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = "Other Sources"; + sourceTree = "<group>"; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + 8D1107310486CEB800E47090 /* Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + A8C006ED089865E900BA5114 /* DrawTestDocument.nib */, + A8C006EF089865E900BA5114 /* Inspector.nib */, + A8C006F1089865E900BA5114 /* TestViewer.nib */, + ); + name = Resources; + sourceTree = "<group>"; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = "<group>"; + }; + A8C006E5089863A100BA5114 /* Viewer */ = { + isa = PBXGroup; + children = ( + A8C006BA0898634600BA5114 /* DrawTestToolbarController.h */, + A8C006B70898634600BA5114 /* DrawTestToolbarController.m */, + A8C006B60898634600BA5114 /* DrawTestView.h */, + A8C006B50898634600BA5114 /* DrawTestView.m */, + A8C006B80898634600BA5114 /* DrawTestDocument.h */, + A8C006BD0898634600BA5114 /* DrawTestDocument.m */, + ); + name = Viewer; + sourceTree = "<group>"; + }; + A8C006E6089863B100BA5114 /* Test Browser */ = { + isa = PBXGroup; + children = ( + A8C006B00898634600BA5114 /* SVGTest.m */, + A8C006B10898634600BA5114 /* SVGTest.h */, + A8C006BB0898634600BA5114 /* DrawTestInspectorController.m */, + A8C006BC0898634600BA5114 /* DrawTestInspectorController.h */, + A8C006AF0898634600BA5114 /* TestController.h */, + A8C006CE0898634600BA5114 /* TestController.m */, + A8C006CC0898634600BA5114 /* TestViewerSplitView.m */, + A8C006CD0898634600BA5114 /* TestViewerSplitView.h */, + ); + name = "Test Browser"; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* DrawTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = A8C006740898624E00BA5114 /* Build configuration list for PBXNativeTarget "DrawTest" */; + buildPhases = ( + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DrawTest; + productInstallPath = "$(HOME)/Applications"; + productName = DrawTest; + productReference = 8D1107320486CEB800E47090 /* DrawTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = A8C006780898624E00BA5114 /* Build configuration list for PBXProject "DrawTest" */; + compatibilityVersion = "Xcode 2.4"; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* DrawTest */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D1107260486CEB800E47090 /* DrawTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A8C006F3089865E900BA5114 /* DrawTestDocument.nib in Resources */, + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + A8C006F4089865E900BA5114 /* Inspector.nib in Resources */, + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, + A8C006F5089865E900BA5114 /* TestViewer.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A8C006E10898634600BA5114 /* AppDelegate.m in Sources */, + A8C006D50898634600BA5114 /* DrawTestDocument.m in Sources */, + A8C006D40898634600BA5114 /* DrawTestInspectorController.m in Sources */, + A8C006D30898634600BA5114 /* DrawTestToolbarController.m in Sources */, + A8C006D20898634600BA5114 /* DrawTestView.m in Sources */, + A8C006CF0898634600BA5114 /* SVGTest.m in Sources */, + A8C006D00898634600BA5114 /* ScalingImageView.m in Sources */, + A8C006E30898634600BA5114 /* TestController.m in Sources */, + A8C006E20898634600BA5114 /* TestViewerSplitView.m in Sources */, + 8D11072D0486CEB800E47090 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = "<group>"; + }; + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { + isa = PBXVariantGroup; + children = ( + 29B97319FDCFA39411CA2CEA /* English */, + ); + name = MainMenu.nib; + sourceTree = "<group>"; + }; + A8C006ED089865E900BA5114 /* DrawTestDocument.nib */ = { + isa = PBXVariantGroup; + children = ( + A8C006EE089865E900BA5114 /* English */, + ); + name = DrawTestDocument.nib; + sourceTree = "<group>"; + }; + A8C006EF089865E900BA5114 /* Inspector.nib */ = { + isa = PBXVariantGroup; + children = ( + A8C006F0089865E900BA5114 /* English */, + ); + name = Inspector.nib; + sourceTree = "<group>"; + }; + A8C006F1089865E900BA5114 /* TestViewer.nib */ = { + isa = PBXVariantGroup; + children = ( + A8C006F2089865E900BA5114 /* English */, + ); + name = TestViewer.nib; + sourceTree = "<group>"; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A8C006750898624E00BA5114 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = DrawTest_Prefix.pch; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PREBINDING = NO; + PRODUCT_NAME = DrawTest; + WRAPPER_EXTENSION = app; + ZERO_LINK = YES; + }; + name = Debug; + }; + A8C006760898624E00BA5114 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = DrawTest_Prefix.pch; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PREBINDING = NO; + PRODUCT_NAME = DrawTest; + WRAPPER_EXTENSION = app; + ZERO_LINK = NO; + }; + name = Release; + }; + A8C006790898624E00BA5114 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_C_LANGUAGE_STANDARD = gnu99; + }; + name = Debug; + }; + A8C0067A0898624E00BA5114 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_C_LANGUAGE_STANDARD = gnu99; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A8C006740898624E00BA5114 /* Build configuration list for PBXNativeTarget "DrawTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A8C006750898624E00BA5114 /* Debug */, + A8C006760898624E00BA5114 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A8C006780898624E00BA5114 /* Build configuration list for PBXProject "DrawTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A8C006790898624E00BA5114 /* Debug */, + A8C0067A0898624E00BA5114 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/WebKitTools/DrawTest/DrawTestDocument.h b/WebKitTools/DrawTest/DrawTestDocument.h new file mode 100644 index 0000000..b0b16d9 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestDocument.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + +@class DrawTestView; +@class DrawTestToolbarController; + +@interface DrawTestDocument : NSDocument +{ + IBOutlet DrawTestView *drawView; + IBOutlet NSDrawer *debugDrawer; + + DrawTestToolbarController *toolbarController; +} + +// Debug menu +- (IBAction)dumpSVGToConsole:(id)sender; +- (IBAction)toggleDebugDrawer:(id)sender; +- (IBAction)runWindowResizeTest:(id)sender; + +@end diff --git a/WebKitTools/DrawTest/DrawTestDocument.m b/WebKitTools/DrawTest/DrawTestDocument.m new file mode 100644 index 0000000..c71e7ad --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestDocument.m @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "DrawTestDocument.h" +#import "DrawTestView.h" +#import "DrawTestToolbarController.h" +#import <WebKit/WebView.h> +#import <WebKit/WebFrame.h> +#import <WebKit/WebDataSource.h> + +@implementation DrawTestDocument + +- (id)initWithType:(NSString *)typeName error:(NSError **)outError +{ + if (outError) { + NSDictionary *errorInfo = [NSDictionary dictionaryWithObjectsAndKeys: + @"No document could be created.", NSLocalizedDescriptionKey, + @"New document creation not yet supported.", NSLocalizedFailureReasonErrorKey, + nil]; + *outError = [NSError errorWithDomain:NSCocoaErrorDomain code:0 userInfo:errorInfo]; + } + [self release]; + return nil; +} + +- (void)dealloc +{ + [toolbarController release]; + [super dealloc]; +} + +- (NSString *)windowNibName +{ + return @"DrawTestDocument"; +} + +- (BOOL)readFromFile:(NSString *)filename ofType:(NSString *)docType +{ + // TODO: Check the validity of the document before returning YES. + return YES; +} + +- (void)windowControllerDidLoadNib:(NSWindowController *)aController +{ + [super windowControllerDidLoadNib:aController]; + toolbarController = [[DrawTestToolbarController alloc] initWithDrawView:drawView]; + [drawView setDocument:[self fileURL]]; +} + +- (IBAction)dumpSVGToConsole:(id)sender +{ + WebDataSource* dataSource = [[drawView mainFrame] dataSource]; + NSLog(@"SVG Markup for file %@:\n%@", [self fileURL], [[dataSource representation] documentSource]); +} + +- (IBAction)openSourceForSelection:(id)sender +{ + // TODO: The "path" message (below) will not produce a valid pathname if we are dealing with a remote file. + NSString *filename = [[self fileURL] path]; + [[NSWorkspace sharedWorkspace] openFile:filename withApplication:@"TextEdit"]; +} + +- (NSData *)dataRepresentationOfType:(NSString *)aType +{ + WebDataSource* dataSource = [[drawView mainFrame] dataSource]; + return [dataSource data]; +} + +#pragma mark - +#pragma mark Debug Methods + +- (IBAction)toggleDebugDrawer:(id)sender +{ + [debugDrawer toggle:sender]; +} + +- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item +{ + return nil; +} + +- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item +{ + return NO; +} + +- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item +{ + return 0; +} + +- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item +{ + return nil; +} + +- (IBAction)runWindowResizeTest:(id)sender +{ + NSWindow *window = [drawView window]; + NSScreen *screen = [window screen]; + float screenHeight = [screen visibleFrame].size.height; + NSRect originalFrame = [window frame]; + // initial setup + BOOL toolbarVisible = [[window toolbar] isVisible]; + if (toolbarVisible) [window toggleToolbarShown:self]; + [window setFrame:NSMakeRect(0,screenHeight-100,100,100) display:YES]; + + // grab time. + CFAbsoluteTime start = CFAbsoluteTimeGetCurrent(); + + // run test + for (int x = 0; x < 3; x++) { + for (float size = 100; size < 500.f; size += 20.f) { + [window setFrame:NSMakeRect(0, screenHeight-size, size, size) display:YES]; + } + } + + double elapsed = CFAbsoluteTimeGetCurrent() - start; + + // log + NSLog(@"Window resize test: %fs", elapsed); + + // restore + if (toolbarVisible) [window toggleToolbarShown:self]; + [window setFrame:originalFrame display:YES]; +} + +@end diff --git a/WebKitTools/DrawTest/DrawTestInspectorController.h b/WebKitTools/DrawTest/DrawTestInspectorController.h new file mode 100644 index 0000000..43c06f0 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestInspectorController.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + + +@interface DrawTestInspectorController : NSObject { + IBOutlet NSPanel *_inspectorPanel; +} + ++ (id)sharedInstance; + +- (IBAction)showInspectorPanel:(id)sender; + +@end diff --git a/WebKitTools/DrawTest/DrawTestInspectorController.m b/WebKitTools/DrawTest/DrawTestInspectorController.m new file mode 100644 index 0000000..604bf03 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestInspectorController.m @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "DrawTestInspectorController.h" + +@implementation DrawTestInspectorController + ++ (id)sharedInstance +{ + static DrawTestInspectorController *__sharedController = nil; + if (!__sharedController) { + __sharedController = [[self alloc] init]; + } + return __sharedController; +} + +- (IBAction)showInspectorPanel:(id)sender +{ + if (!_inspectorPanel) { + [NSBundle loadNibNamed:@"Inspector" owner:self]; + } + [_inspectorPanel makeKeyAndOrderFront:self]; +} + + +@end diff --git a/WebKitTools/DrawTest/DrawTestToolbarController.h b/WebKitTools/DrawTest/DrawTestToolbarController.h new file mode 100644 index 0000000..a69fb57 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestToolbarController.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + +@class WebView; + +@interface DrawTestToolbarController : NSObject { + WebView *_drawView; + NSMutableDictionary *_toolbarItems; +} + +- (id)initWithDrawView:(WebView *)drawView; + +@end diff --git a/WebKitTools/DrawTest/DrawTestToolbarController.m b/WebKitTools/DrawTest/DrawTestToolbarController.m new file mode 100644 index 0000000..9190252 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestToolbarController.m @@ -0,0 +1,354 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "DrawTestToolbarController.h" + +enum +{ + ToolbarBrowseToolTag = 0, + ToolbarPanToolTag, + ToolbarZoomToolTag, + + ToolbarPointerToolTag, + ToolbarLineToolTag, + ToolbarRectangleToolTag, + ToolbarElipseToolTag, + ToolbarTriangleToolTag, + ToolbarPolyLineToolTag, + ToolbarArcToolTag, + + ToolbarDeleteSelectionTag, + + ToolbarMoveForwardTag, + ToolbarMoveBackwardTag, + ToolbarMoveToFrontTag, + ToolbarMoveToBackTag, + ToolbarMiscItem +}; + +// Constants +NSString *ToolbarIdentifier = @"Main Document Toolbar"; + +NSString *ToolbarBrowseToolIdentifier = @"Browse"; +NSString *ToolbarPanToolIdentifier = @"Pan"; +NSString *ToolbarZoomToolIdentifier = @"Zoom"; + +NSString *ToolbarPointerToolIdentifier = @"Pointer"; +NSString *ToolbarRectangleToolIdentifier = @"Rectangle"; +NSString *ToolbarElipseToolIdentifier = @"Oval"; +NSString *ToolbarTriangleToolIdentifier = @"Triangle"; +NSString *ToolbarPolyLineToolIdentifier = @"PolyLine"; +NSString *ToolbarArcToolIdentifier = @"Arc"; + +NSString *ToolbarDeleteShapeIdentifier = @"Delete"; +NSString *ToolbarMoveForwardIdentifier = @"Forward"; +NSString *ToolbarMoveBackwardIdentifier = @"Backward"; +NSString *ToolbarMoveToFrontIdentifier = @"Front"; +NSString *ToolbarMoveToBackIdentifier = @"Back"; + +NSString *ToolbarPointerToolImage = @"Toolbar_Pointer"; +NSString *ToolbarRectangleToolImage = @"Toolbar_Rectangle"; +NSString *ToolbarElipseToolImage = @"Toolbar_Oval"; +NSString *ToolbarTriangleToolImage = @"Toolbar_Triangle"; + +NSString *ToolbarDeleteShapeImage = @"Toolbar_Delete"; +NSString *ToolbarMoveForwardImage = @"Toolbar_Forward"; +NSString *ToolbarMoveBackwardImage = @"Toolbar_Backward"; +NSString *ToolbarMoveToFrontImage = @"Toolbar_Front"; +NSString *ToolbarMoveToBackImage = @"Toolbar_Back"; + +@interface DrawTestToolbarController (InternalMethods) +- (void)setupToolbar; +- (void)addToolbarItemWithIdentifier:(NSString *)identifier withImage:(NSString *)image withTag:(int)tag; +- (void)addToolbarItemWithIdentifier:(NSString *)identifier withImage:(NSString *)image; +- (void)addToolbarItem:(NSString *)identifier + withLabel:(NSString *)label + withPaletteLabel:(NSString *)paletteLabel + withImage:(NSString *)imageName + withToolTip:(NSString *)toolTip + withTag:(int)tag; +@end + + +@implementation DrawTestToolbarController + +- (id)initWithDrawView:(WebView *)drawView +{ + if (self = [super init]){ + _drawView = [drawView retain]; + [self setupToolbar]; // could be done lazily. + } + return self; +} + +- (void)dealloc +{ + [_toolbarItems release]; + [super dealloc]; +} + + +- (void)addToolbarItemWithIdentifier:(NSString *)identifier withImage:(NSString *)image withTag:(int)tag +{ + + [self addToolbarItem:identifier + withLabel:identifier + withPaletteLabel:identifier + withImage:image + withToolTip:identifier + withTag:tag]; +} + +- (void)addToolbarItemWithIdentifier:(NSString *)identifier withImage:(NSString *)image +{ + [self addToolbarItemWithIdentifier:identifier withImage:image withTag:ToolbarMiscItem]; +} + +- (void)addToolbarItem:(NSString *)identifier + withLabel:(NSString *)label + withPaletteLabel:(NSString *)paletteLabel + withImage:(NSString *)imageName + withToolTip:(NSString *)toolTip + withTag:(int)tag +{ + NSToolbarItem *item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease]; + + [item setLabel:label]; + [item setPaletteLabel:paletteLabel]; + [item setToolTip:toolTip]; + [item setImage:[NSImage imageNamed:imageName]]; + [item setTarget:self]; + [item setAction:@selector(clickedToolbarItem:)]; + [item setTag:tag]; + + [_toolbarItems setObject:item forKey:identifier]; +} + +- (void)setupToolbar +{ + _toolbarItems = [[NSMutableDictionary alloc] init]; + + [self addToolbarItemWithIdentifier:ToolbarBrowseToolIdentifier + withImage:ToolbarPointerToolImage + withTag:ToolbarBrowseToolTag]; + [[_toolbarItems objectForKey:ToolbarBrowseToolIdentifier] setImage:[[NSCursor pointingHandCursor] image]]; + + [self addToolbarItemWithIdentifier:ToolbarPanToolIdentifier + withImage:ToolbarPointerToolImage + withTag:ToolbarPanToolTag]; + [[_toolbarItems objectForKey:ToolbarPanToolIdentifier] setImage:[[NSCursor openHandCursor] image]]; + + [self addToolbarItemWithIdentifier:ToolbarZoomToolIdentifier + withImage:ToolbarPointerToolImage + withTag:ToolbarZoomToolTag]; + + + [self addToolbarItemWithIdentifier:ToolbarPointerToolIdentifier + withImage:ToolbarPointerToolImage + withTag:ToolbarPointerToolTag]; + + [self addToolbarItemWithIdentifier:ToolbarRectangleToolIdentifier + withImage:ToolbarRectangleToolImage + withTag:ToolbarRectangleToolTag]; + + [self addToolbarItemWithIdentifier:ToolbarElipseToolIdentifier + withImage:ToolbarElipseToolImage + withTag:ToolbarElipseToolTag]; + + [self addToolbarItemWithIdentifier:ToolbarTriangleToolIdentifier + withImage:ToolbarTriangleToolImage + withTag:ToolbarTriangleToolTag]; + + [self addToolbarItemWithIdentifier:ToolbarDeleteShapeIdentifier + withImage:ToolbarDeleteShapeImage + withTag:ToolbarDeleteSelectionTag]; + + [self addToolbarItemWithIdentifier:ToolbarMoveForwardIdentifier + withImage:ToolbarMoveForwardImage + withTag:ToolbarMoveForwardTag]; + + [self addToolbarItemWithIdentifier:ToolbarMoveBackwardIdentifier + withImage:ToolbarMoveBackwardImage + withTag:ToolbarMoveBackwardTag]; + + [self addToolbarItemWithIdentifier:ToolbarMoveToFrontIdentifier + withImage:ToolbarMoveToFrontImage + withTag:ToolbarMoveToFrontTag]; + + [self addToolbarItemWithIdentifier:ToolbarMoveToBackIdentifier + withImage:ToolbarMoveToBackImage + withTag:ToolbarMoveToBackTag]; + + + NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:ToolbarIdentifier] autorelease]; + + [toolbar setAllowsUserCustomization:YES]; + [toolbar setAutosavesConfiguration:YES]; + [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + [toolbar setSizeMode:NSToolbarSizeModeSmall]; + [toolbar setDisplayMode:NSToolbarDisplayModeLabelOnly]; + [toolbar setDelegate:self]; + [toolbar setSelectedItemIdentifier:ToolbarBrowseToolIdentifier]; + [toolbar setVisible:NO]; + + [[_drawView window] setToolbar:toolbar]; +} + + +- (void)clickedToolbarItem:(id)sender +{ + int tag = [sender tag]; + + switch(tag) { +#if 0 + case ToolbarBrowseToolTag: + [_drawView setToolMode:DrawViewToolBrowse]; + break; + case ToolbarPanToolTag: + [_drawView setToolMode:DrawViewToolPan]; + break; + case ToolbarZoomToolTag: + [_drawView setToolMode:DrawViewToolZoom]; + break; + case ToolbarPointerToolTag: + [_drawView setToolMode:DrawViewToolArrow]; + break; + case ToolbarRectangleToolTag: + [_drawView setToolMode:DrawViewToolRectangle]; + break; + case ToolbarElipseToolTag: + [_drawView setToolMode:DrawViewToolElipse]; + break; + case ToolbarTriangleToolTag: + [_drawView setToolMode:DrawViewToolTriangle]; + break; + case ToolbarMoveForwardTag: + [_drawView moveSelectionForward:sender]; + break; + case ToolbarMoveBackwardTag: + [_drawView moveSelectionBackward:sender]; + break; + case ToolbarDeleteSelectionTag: + [_drawView deleteSelection:sender]; + break; +#endif + default: + NSLog(@"Toolbar item: %i not implemented!", tag); + } + + [_drawView setNeedsDisplay:YES]; +} + +// NSToolbar delegate methods +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdent + willBeInsertedIntoToolbar:(BOOL)willBeInserted +{ + NSToolbarItem * toolbarItem = [_toolbarItems objectForKey:itemIdent]; + + if( toolbarItem == nil ) + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdent] autorelease]; + + return toolbarItem; +} + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + ToolbarBrowseToolIdentifier, + ToolbarPanToolIdentifier, + ToolbarZoomToolIdentifier, + ToolbarPointerToolIdentifier, + ToolbarRectangleToolIdentifier, + ToolbarElipseToolIdentifier, + ToolbarTriangleToolIdentifier, + ToolbarDeleteShapeIdentifier, + NSToolbarShowColorsItemIdentifier, + ToolbarMoveForwardIdentifier, + ToolbarMoveBackwardIdentifier, + ToolbarMoveToFrontIdentifier, + ToolbarMoveToBackIdentifier, + NSToolbarCustomizeToolbarItemIdentifier, + NSToolbarFlexibleSpaceItemIdentifier, + NSToolbarSpaceItemIdentifier, + NSToolbarSeparatorItemIdentifier, nil]; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + ToolbarBrowseToolIdentifier, + ToolbarPanToolIdentifier, + //ToolbarZoomToolIdentifier, + NSToolbarFlexibleSpaceItemIdentifier, + ToolbarPointerToolIdentifier, + ToolbarRectangleToolIdentifier, + ToolbarElipseToolIdentifier, + //ToolbarTriangleToolIdentifier, + //NSToolbarSeparatorItemIdentifier, + ToolbarDeleteShapeIdentifier, + //ToolbarMoveForwardIdentifier, + //ToolbarMoveBackwardIdentifier, + //ToolbarMoveToFrontIdentifier, + //ToolbarMoveToBackIdentifier, + NSToolbarSeparatorItemIdentifier, + //NSToolbarShowColorsItemIdentifier, + //NSToolbarFlexibleSpaceItemIdentifier, + NSToolbarCustomizeToolbarItemIdentifier, + nil]; +} + +- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar +{ + return [NSArray arrayWithObjects: + ToolbarBrowseToolIdentifier, + ToolbarPanToolIdentifier, + ToolbarZoomToolIdentifier, + ToolbarPointerToolIdentifier, + ToolbarRectangleToolIdentifier, + ToolbarElipseToolIdentifier, + ToolbarTriangleToolIdentifier, + nil]; +} + +- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem +{ + BOOL enabled = YES; + +#if 0 + switch([theItem tag]) { + case ToolbarMoveForwardTag: + case ToolbarMoveBackwardTag: + case ToolbarMoveToFrontTag: + case ToolbarMoveToBackTag: + case ToolbarDeleteSelectionTag: + enabled = ([[_drawView selectedCanvasItems] count] != 0); + } +#endif + + return enabled; +} + +@end diff --git a/WebKitTools/DrawTest/DrawTestView.h b/WebKitTools/DrawTest/DrawTestView.h new file mode 100644 index 0000000..95d5956 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestView.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + +#import <WebKit/WebView.h> + +@interface DrawTestView : WebView +{ + +} + +- (void)setDocument:(NSURL *)documentURL; + +@end diff --git a/WebKitTools/DrawTest/DrawTestView.m b/WebKitTools/DrawTest/DrawTestView.m new file mode 100644 index 0000000..c865f99 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTestView.m @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <WebKit/WebFrame.h> + +#import "DrawTestView.h" + +@implementation DrawTestView + +- (void)setDocument:(NSURL *)documentURL +{ + [[self mainFrame] loadRequest:[NSURLRequest requestWithURL:documentURL]]; +} + +- (BOOL)acceptsFirstResponder +{ + return YES; +} + +@end diff --git a/WebKitTools/DrawTest/DrawTest_Prefix.pch b/WebKitTools/DrawTest/DrawTest_Prefix.pch new file mode 100644 index 0000000..8393f01 --- /dev/null +++ b/WebKitTools/DrawTest/DrawTest_Prefix.pch @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +// +// Prefix header for all source files of the 'DrawTest' target in the 'DrawTest' project +// + +#ifdef __OBJC__ +#import <Cocoa/Cocoa.h> + +#define foreacharray(__variable, __container) \ + for (int __variable##__i=0, __variable##__n=[__container count]; \ + __variable##__i < __variable##__n && (__variable = [__container objectAtIndex:__variable##__i]); \ + ++__variable##__i) +#endif diff --git a/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/classes.nib b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/classes.nib new file mode 100644 index 0000000..296ffc3 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/classes.nib @@ -0,0 +1,34 @@ +{ + IBClasses = ( + { + ACTIONS = {toggleShowDebugAxes = id; toggleShowDebugString = id; }; + CLASS = DrawTestView; + LANGUAGE = ObjC; + SUPERCLASS = DrawView; + }, + { + ACTIONS = { + deleteSelection = id; + moveSelectionBackward = id; + moveSelectionForward = id; + zoomIn = id; + zoomOriginal = id; + zoomOut = id; + zoomToFit = id; + }; + CLASS = DrawView; + LANGUAGE = ObjC; + SUPERCLASS = NSView; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {dumpSVGToConsole = id; }; + CLASS = MyDocument; + LANGUAGE = ObjC; + OUTLETS = {drawView = KCanvasTestView; }; + SUPERCLASS = NSDocument; + }, + {CLASS = NSSegmentedControl; LANGUAGE = ObjC; SUPERCLASS = NSControl; } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/info.nib b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/info.nib new file mode 100644 index 0000000..3c96fd5 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/info.nib @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>86 30 356 240 0 0 1024 746 </string> + <key>IBEditorPositions</key> + <dict> + <key>50</key> + <string>377 327 270 342 0 0 1024 746 </string> + </dict> + <key>IBFramework Version</key> + <string>437.0</string> + <key>IBOpenObjects</key> + <array> + <integer>50</integer> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8C42</string> +</dict> +</plist> diff --git a/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/keyedobjects.nib b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/keyedobjects.nib Binary files differnew file mode 100644 index 0000000..b78ff2c --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/DrawTestDocument.nib/keyedobjects.nib diff --git a/WebKitTools/DrawTest/English.lproj/InfoPlist.strings b/WebKitTools/DrawTest/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 0000000..f88820f --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/InfoPlist.strings diff --git a/WebKitTools/DrawTest/English.lproj/Inspector.nib/classes.nib b/WebKitTools/DrawTest/English.lproj/Inspector.nib/classes.nib new file mode 100644 index 0000000..725f5a4 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/Inspector.nib/classes.nib @@ -0,0 +1,12 @@ +{ + IBClasses = ( + { + CLASS = DrawTestInspectorController; + LANGUAGE = ObjC; + OUTLETS = {"_inspectorPanel" = NSPanel; }; + SUPERCLASS = NSObject; + }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/WebKitTools/DrawTest/English.lproj/Inspector.nib/info.nib b/WebKitTools/DrawTest/English.lproj/Inspector.nib/info.nib new file mode 100644 index 0000000..d930763 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/Inspector.nib/info.nib @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>261 184 356 240 0 0 1024 746 </string> + <key>IBFramework Version</key> + <string>437.0</string> + <key>IBOpenObjects</key> + <array> + <integer>7</integer> + </array> + <key>IBSystem Version</key> + <string>8B9</string> +</dict> +</plist> diff --git a/WebKitTools/DrawTest/English.lproj/Inspector.nib/keyedobjects.nib b/WebKitTools/DrawTest/English.lproj/Inspector.nib/keyedobjects.nib Binary files differnew file mode 100644 index 0000000..02869ca --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/Inspector.nib/keyedobjects.nib diff --git a/WebKitTools/DrawTest/English.lproj/MainMenu.nib/classes.nib b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 0000000..c0ca441 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,44 @@ +{ + IBClasses = ( + { + ACTIONS = {showImageRepTestWindow = id; showInspectorPanel = id; showTestsPanel = id; }; + CLASS = AppDelegate; + LANGUAGE = ObjC; + OUTLETS = {svgImageRepTestWindow = NSWindow; }; + SUPERCLASS = NSObject; + }, + { + ACTIONS = { + dumpSVGToConsole = id; + openSelectionInViewer = id; + openSourceForSelection = id; + runWindowResizeTest = id; + showCompositeWindow = id; + showImageRepTestWindow = id; + showInspectorPanel = id; + showTestsPanel = id; + toggleDebugDrawer = id; + toggleFilterSupport = id; + toggleShowDebugAxes = id; + toggleShowDebugString = id; + toggleViewersScaleRule = id; + zoomIn = id; + zoomOriginal = id; + zoomOut = id; + zoomToContent = id; + }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + }, + {CLASS = KCanvasTestView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, + { + ACTIONS = {dumpSVGToConsole = id; }; + CLASS = MyDocument; + LANGUAGE = ObjC; + OUTLETS = {canvasView = KCanvasTestView; }; + SUPERCLASS = NSDocument; + } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/WebKitTools/DrawTest/English.lproj/MainMenu.nib/info.nib b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 0000000..9b783e0 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>274 58 356 240 0 0 1024 746 </string> + <key>IBEditorPositions</key> + <dict> + <key>29</key> + <string>128 678 355 44 0 0 1024 746 </string> + </dict> + <key>IBFramework Version</key> + <string>439.0</string> + <key>IBOpenObjects</key> + <array> + <integer>29</integer> + </array> + <key>IBSystem Version</key> + <string>8C32</string> +</dict> +</plist> diff --git a/WebKitTools/DrawTest/English.lproj/MainMenu.nib/keyedobjects.nib b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/keyedobjects.nib Binary files differnew file mode 100644 index 0000000..642b5ae --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/MainMenu.nib/keyedobjects.nib diff --git a/WebKitTools/DrawTest/English.lproj/TestViewer.nib/classes.nib b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/classes.nib new file mode 100644 index 0000000..eb82ec7 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/classes.nib @@ -0,0 +1,36 @@ +{ + IBClasses = ( + {CLASS = DrawView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + {CLASS = KCanvasTestView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, + {CLASS = MyImageView; LANGUAGE = ObjC; SUPERCLASS = NSImageView; }, + { + ACTIONS = { + browse = id; + jumpToParentDirectory = id; + openSelectionInViewer = id; + openSourceForSelection = id; + openTestViewerForSelection = id; + showCompositeWindow = id; + showTestWindow = id; + showTestsPanel = id; + toggleViewersScaleRule = id; + }; + CLASS = TestController; + LANGUAGE = ObjC; + OUTLETS = { + "_compositeImageView" = NSImageView; + "_compositeWindow" = NSWindow; + "_parentDirectoryPopup" = NSPopUpButton; + "_splitView" = TestViewerSplitView; + "_testPanel" = NSPanel; + "_testWindow" = NSWindow; + "_testsArrayController" = NSArrayController; + "_testsTableView" = NSTableView; + }; + SUPERCLASS = NSObject; + }, + {CLASS = TestViewerSplitView; LANGUAGE = ObjC; SUPERCLASS = NSView; } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/WebKitTools/DrawTest/English.lproj/TestViewer.nib/info.nib b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/info.nib new file mode 100644 index 0000000..ca801e8 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/info.nib @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>263 119 356 240 0 0 1024 746 </string> + <key>IBFramework Version</key> + <string>437.0</string> + <key>IBOpenObjects</key> + <array> + <integer>24</integer> + <integer>60</integer> + </array> + <key>IBSystem Version</key> + <string>8C26</string> +</dict> +</plist> diff --git a/WebKitTools/DrawTest/English.lproj/TestViewer.nib/keyedobjects.nib b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/keyedobjects.nib Binary files differnew file mode 100644 index 0000000..46b8964 --- /dev/null +++ b/WebKitTools/DrawTest/English.lproj/TestViewer.nib/keyedobjects.nib diff --git a/WebKitTools/DrawTest/Info.plist b/WebKitTools/DrawTest/Info.plist new file mode 100644 index 0000000..0fd092b --- /dev/null +++ b/WebKitTools/DrawTest/Info.plist @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>svg</string> + </array> + <key>CFBundleTypeName</key> + <string>SVG Document</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>????</string> + </array> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>LSTypeIsPackage</key> + <false/> + <key>NSDocumentClass</key> + <string>DrawTestDocument</string> + <key>NSPersistentStoreTypeKey</key> + <string>Binary</string> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>DrawTest</string> + <key>CFBundleGetInfoString</key> + <string>420+, Copyright 2005, 2006 Apple Computer, Inc.</string> + <key>CFBundleIdentifier</key> + <string>com.apple.DrawTest</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> diff --git a/WebKitTools/DrawTest/SVGTest.h b/WebKitTools/DrawTest/SVGTest.h new file mode 100644 index 0000000..70eed41 --- /dev/null +++ b/WebKitTools/DrawTest/SVGTest.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + +@interface SVGTest : NSObject { + NSString *_svgPath; + NSString *_imagePath; + + NSImage *_image; + NSImage *_compositeImage; + BOOL _hasPassed; +} + ++ (id)testWithSVGPath:(NSString *)svgPath imagePath:(NSString *)imagePath; +- (id)initWithSVGPath:(NSString *)svgPath imagePath:(NSString *)imagePath; + +- (NSString *)imagePath; +- (NSString *)svgPath; + +- (NSImage *)image; +- (NSImage *)compositeImage; +- (NSString *)name; + +@end diff --git a/WebKitTools/DrawTest/SVGTest.m b/WebKitTools/DrawTest/SVGTest.m new file mode 100644 index 0000000..4ea562d --- /dev/null +++ b/WebKitTools/DrawTest/SVGTest.m @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "SVGTest.h" + +#import <WebKit/WebView.h> + +@implementation SVGTest + ++ (id)testWithSVGPath:(NSString *)svgPath imagePath:(NSString *)imagePath +{ + SVGTest *test = [[self alloc] initWithSVGPath:svgPath imagePath:imagePath]; + return [test autorelease]; +} + +static WebView *__sharedDrawView = nil; ++ (WebView *)sharedDrawView +{ + if (!__sharedDrawView) { + __sharedDrawView = [[WebView alloc] initWithFrame:NSMakeRect(0,0,0,0)]; + } + return __sharedDrawView; +} + +- (id)initWithSVGPath:(NSString *)svgPath imagePath:(NSString *)imagePath +{ + if (self = [super init]) { + _svgPath = [svgPath copy]; + _imagePath = [imagePath copy]; + } + return self; +} + +- (NSString *)imagePath +{ + return _imagePath; +} + +- (NSString *)svgPath +{ + return _svgPath; +} + +- (NSImage *)image +{ + if (!_image && _imagePath) { + _image = [[NSImage alloc] initByReferencingFile:_imagePath]; + } + return _image; +} + +- (NSString *)name +{ + NSMutableString *name = [[[[_svgPath lastPathComponent] stringByDeletingPathExtension] mutableCopy] autorelease]; + [name replaceOccurrencesOfString:@"_" withString:@" " options:0 range:NSMakeRange(0, [name length])]; + return [name capitalizedString]; +} + +- (void)generateCompositeIfNecessary +{ + if (!_compositeImage) { + WebView *view = [SVGTest sharedDrawView]; + NSSize svgSize = [view bounds].size; + + NSImage *image = [self image]; + NSSize imageSize = [image size]; + + NSBitmapImageRep *svgImage = [view bitmapImageRepForCachingDisplayInRect:[view bounds]]; + [view cacheDisplayInRect:[view bounds] toBitmapImageRep:svgImage]; + + NSSize unionSize = NSMakeSize(MAX(svgSize.width, imageSize.width), MAX(svgSize.height, imageSize.height)); + _compositeImage = [[NSImage alloc] initWithSize:unionSize]; + + [_compositeImage lockFocus]; + [svgImage drawInRect:NSMakeRect(0,0,svgSize.width,svgSize.height)]; + [image drawInRect:NSMakeRect(0,0,imageSize.width,imageSize.height) + fromRect:NSMakeRect(0,0,imageSize.width,imageSize.height) + operation:NSCompositeXOR fraction:1.0]; + [_compositeImage unlockFocus]; + } +} + +- (NSImage *)compositeImage +{ + [self generateCompositeIfNecessary]; + return _compositeImage; +} + + +@end diff --git a/WebKitTools/DrawTest/ScalingImageView.h b/WebKitTools/DrawTest/ScalingImageView.h new file mode 100644 index 0000000..4370ff5 --- /dev/null +++ b/WebKitTools/DrawTest/ScalingImageView.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + + +@interface ScalingImageView : NSImageView { + +} + +@end diff --git a/WebKitTools/DrawTest/ScalingImageView.m b/WebKitTools/DrawTest/ScalingImageView.m new file mode 100644 index 0000000..605397a --- /dev/null +++ b/WebKitTools/DrawTest/ScalingImageView.m @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + + +#import "ScalingImageView.h" + +@implementation ScalingImageView + +/* + This class offers two behaviors different from the standard NSImageView + (and which were not available w/o subclassing) + 1. Scale an image proportionally up to fit a larger view (NSImageView refuses) + 2. Draw a background color w/o needing to show a bezel. +*/ + +- (void)drawRect:(NSRect)dirtyRect +{ + [[NSColor whiteColor] set]; + NSRectFill(dirtyRect); + + NSSize imageSize = [[self image] size]; + float scale = 1.0f; + if ([self imageScaling] == NSScaleProportionally && imageSize.width && imageSize.height) { + float widthScale = [self bounds].size.width / imageSize.width; + float heightScale = [self bounds].size.height / imageSize.height; + scale = MIN(widthScale, heightScale); + } + + float scaledHeight = imageSize.height * scale; + NSRect destRect = NSMakeRect(0,[self bounds].size.height - scaledHeight,imageSize.width * scale, scaledHeight); + [[self image] drawInRect:destRect + fromRect:NSMakeRect(0,0,imageSize.width, imageSize.height) operation:NSCompositeSourceOver fraction:1.0]; +} + +@end diff --git a/WebKitTools/DrawTest/TestController.h b/WebKitTools/DrawTest/TestController.h new file mode 100644 index 0000000..1e781fe --- /dev/null +++ b/WebKitTools/DrawTest/TestController.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import <Cocoa/Cocoa.h> + +@class DrawTestView; +@class SVGTest; +@class TestViewerSplitView; + +@interface TestController : NSObject { + IBOutlet NSPanel *_testPanel; + IBOutlet NSWindow *_testWindow; + IBOutlet TestViewerSplitView *_splitView; + + IBOutlet NSArrayController *_testsArrayController; + IBOutlet NSPopUpButton *_parentDirectoryPopup; + IBOutlet NSTableView *_testsTableView; + + IBOutlet NSWindow *_compositeWindow; + IBOutlet NSImageView *_compositeImageView; + +@private + NSString *_currentPath; + NSArray *_tests; + SVGTest *_selectedTest; + + DrawTestView *_drawView; + NSImageView *_imageView; +} + ++ (id)sharedController; + +- (IBAction)showTestsPanel:(id)sender; +- (IBAction)showTestWindow:(id)sender; +- (IBAction)showCompositeWindow:(id)sender; + +- (IBAction)browse:(id)sender; +- (IBAction)jumpToParentDirectory:(id)sender; +- (IBAction)openTestViewerForSelection:(id)sender; +- (IBAction)openSourceForSelection:(id)sender; +- (IBAction)openSelectionInViewer:(id)sender; +- (IBAction)toggleViewersScaleRule:(id)sender; + +- (NSArray *)tests; +- (NSString *)currentPath; +- (void)setCurrentPath:(NSString *)newPath; +- (NSArray *)directoryHierarchy; + +@end diff --git a/WebKitTools/DrawTest/TestController.m b/WebKitTools/DrawTest/TestController.m new file mode 100644 index 0000000..506920b --- /dev/null +++ b/WebKitTools/DrawTest/TestController.m @@ -0,0 +1,270 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Nefaur Khandker <nefaurk@gmail.com> 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "TestController.h" +#import "SVGTest.h" +#import "TestViewerSplitView.h" +#import "ScalingImageView.h" +#import "DrawTestView.h" + +#import <WebKit/WebView.h> + +@interface NSArray (TestControllerAdditions) +- (id)firstObject; +@end + +@implementation NSArray (TestControllerAdditions) +- (id)firstObject +{ + if ([self count]) + return [self objectAtIndex:0]; + return nil; +} +@end + +static TestController *__sharedInstance = nil; + +@implementation TestController + +- (id)init +{ + if (self = [super init]) { + NSString *path = [[NSUserDefaults standardUserDefaults] objectForKey:@"TestDirectory"]; + BOOL isDirectory = NO; + if (![[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory] || !isDirectory) { + path = [@"~" stringByStandardizingPath]; + } + [self setCurrentPath:path]; + } + return self; +} + ++ (void)initialize +{ + [self setKeys:[NSArray arrayWithObject:@"currentPath"] triggerChangeNotificationsForDependentKey:@"directoryHierarchy"]; + [self setKeys:[NSArray arrayWithObject:@"currentPath"] triggerChangeNotificationsForDependentKey:@"tests"]; +} + ++ (id)sharedController +{ + if (!__sharedInstance) { + __sharedInstance = [[self alloc] init]; + } + return __sharedInstance; +} + +- (void)loadNibIfNecessary +{ + if (!_testPanel) { + [NSBundle loadNibNamed:@"TestViewer" owner:self]; + } +} + +- (void)awakeFromNib +{ + [_testsTableView setTarget:self]; + [_testsTableView setDoubleAction:@selector(openTestViewerForSelection:)]; + _drawView = [[DrawTestView alloc] initWithFrame:NSZeroRect]; + _imageView = [[ScalingImageView alloc] initWithFrame:NSZeroRect]; + [_splitView addSubview:_drawView]; + [_splitView addSubview:_imageView]; +} + +- (IBAction)showTestsPanel:(id)sender +{ + [self loadNibIfNecessary]; + [_testPanel makeKeyAndOrderFront:sender]; +} + +- (IBAction)showTestWindow:(id)sender +{ + [self loadNibIfNecessary]; + [_testWindow makeKeyAndOrderFront:sender]; +} + +- (IBAction)showCompositeWindow:(id)sender +{ + [self loadNibIfNecessary]; + NSLog(@"showCompositeWindow: %@", _compositeWindow); + [_compositeWindow makeKeyAndOrderFront:sender]; +} + +- (IBAction)browse:(id)sender +{ + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + [openPanel setCanChooseDirectories:YES]; + [openPanel setCanChooseFiles:NO]; + [openPanel beginSheetForDirectory:nil file:nil modalForWindow:_testPanel modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; +} + +- (void)openPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void *)contextInfo +{ + if (returnCode == NSOKButton) { + NSArray *folders = [openPanel filenames]; + NSString *selectedFolder = [folders firstObject]; + [self setCurrentPath:selectedFolder]; + } +} + +- (IBAction)jumpToParentDirectory:(id)sender +{ + int index = [_parentDirectoryPopup indexOfSelectedItem]; + NSArray *components = [_currentPath pathComponents]; + NSArray *newComponents = [components subarrayWithRange:NSMakeRange(0, [components count] - index)]; + NSString *newPath = [NSString pathWithComponents:newComponents]; + [self setCurrentPath:newPath]; +} + +- (void)setSelectedTest:(SVGTest *)selectedTest +{ + id oldTest = _selectedTest; + _selectedTest = [selectedTest retain]; + [oldTest release]; + + if ([_testWindow isVisible]) { + [_testWindow setTitle:[NSString stringWithFormat:@"Test Viewer - %@", [_selectedTest name]]]; + [_drawView setDocument:[NSURL fileURLWithPath:[_selectedTest svgPath]]]; + [_imageView setImage:[_selectedTest image]]; + if ([_compositeWindow isVisible]) + [_compositeImageView setImage:[_selectedTest compositeImage]]; + } +} + +- (void)tableViewSelectionDidChange:(NSNotification *)aNotification +{ + [self setSelectedTest:[[_testsArrayController selectedObjects] firstObject]]; +} + +- (IBAction)openTestViewerForSelection:(id)sender +{ + [self showTestWindow:sender]; + [_drawView setDocument:[NSURL fileURLWithPath:[_selectedTest svgPath]]]; + [_imageView setImage:[_selectedTest image]]; +} + +- (IBAction)openSourceForSelection:(id)sender +{ + [[NSWorkspace sharedWorkspace] openFile:[_selectedTest svgPath] withApplication:@"TextEdit"]; +} + +- (IBAction)openSelectionInViewer:(id)sender +{ + [[NSWorkspace sharedWorkspace] openFile:[_selectedTest svgPath]]; +} + +- (NSString *)imagePathForSVGPath:(NSString *)svgPath +{ + // eventually this code will build an array instead... + + NSString *currentDirectory = [self currentPath]; + NSString *parentDirectory = [currentDirectory stringByDeletingLastPathComponent]; + + NSString *testName = [[svgPath lastPathComponent] stringByDeletingPathExtension]; + NSString *imageName, *imageDirectory, *imagePath; + + // first look in ../png/test.png -- SVG 1.1 baselines + // The SVG 1.1 spec has various different pngs, we should allow the + // tester to choose... + imageName = [[@"full-" stringByAppendingString:testName] stringByAppendingPathExtension:@"png"]; + imageDirectory = [parentDirectory stringByAppendingPathComponent:@"png"]; + imagePath = [imageDirectory stringByAppendingPathComponent:imageName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) return imagePath; + + // then look for ../name.png -- openclipart.org + imageName = [testName stringByAppendingPathExtension:@"png"]; + imageDirectory = parentDirectory; + imagePath = [imageDirectory stringByAppendingPathComponent:imageName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) return imagePath; + + // then look for ./name-w3c.png -- WebCore tests + imageName = [[testName stringByAppendingString:@"-w3c"] stringByAppendingPathExtension:@"png"]; + imageDirectory = currentDirectory; + imagePath = [imageDirectory stringByAppendingPathComponent:imageName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) return imagePath; + + // finally try name-baseline.png -- ksvg regression baselines + imageName = [[testName stringByAppendingString:@"-baseline"] stringByAppendingPathExtension:@"png"]; + imageDirectory = currentDirectory; + imagePath = [imageDirectory stringByAppendingPathComponent:imageName]; + if ([[NSFileManager defaultManager] fileExistsAtPath:imagePath]) return imagePath; + + return nil; +} + +- (NSArray *)tests +{ + if (!_tests) { + NSMutableArray *newTests = [[NSMutableArray alloc] init]; + NSArray *files = [[NSFileManager defaultManager] directoryContentsAtPath:[self currentPath]]; + NSString *file = nil; + foreacharray(file, files) { + if ([[file pathExtension] isEqualToString:@"svg"]) { + NSString *svgPath = [[self currentPath] stringByAppendingPathComponent:file]; + NSString *imagePath = [self imagePathForSVGPath:svgPath]; + [newTests addObject:[SVGTest testWithSVGPath:svgPath imagePath:imagePath]]; + } + } + [self setValue:newTests forKey:@"tests"]; + } + return _tests; +} + +- (NSArray *)directoryHierarchy +{ + // A hackish way to reverse an array. + return [[[_currentPath pathComponents] reverseObjectEnumerator] allObjects]; +} + +- (NSString *)currentPath +{ + return _currentPath; +} + +- (void)setCurrentPath:(NSString *)newPath +{ + if (![newPath isEqualToString:_currentPath]) { + [_currentPath release]; + _currentPath = [newPath copy]; + [self setValue:nil forKey:@"tests"]; + } + + [[NSUserDefaults standardUserDefaults] setObject:_currentPath forKey:@"TestDirectory"]; +} + +- (IBAction)toggleViewersScaleRule:(id)sender +{ +#if 0 + if ([_drawView imageScaling] == NSScaleProportionally) { + [_drawView setImageScaling:NSScaleNone]; + [_imageView setImageScaling:NSScaleNone]; + } else { + [_drawView setImageScaling:NSScaleProportionally]; + [_imageView setImageScaling:NSScaleProportionally]; + } +#endif +} + +@end diff --git a/WebKitTools/DrawTest/TestViewerSplitView.h b/WebKitTools/DrawTest/TestViewerSplitView.h new file mode 100644 index 0000000..e663f23 --- /dev/null +++ b/WebKitTools/DrawTest/TestViewerSplitView.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ +#import <Cocoa/Cocoa.h> + +@interface TestViewerSplitView : NSView { + NSMutableArray *subviewLabels; +} + +@end diff --git a/WebKitTools/DrawTest/TestViewerSplitView.m b/WebKitTools/DrawTest/TestViewerSplitView.m new file mode 100644 index 0000000..96f2055 --- /dev/null +++ b/WebKitTools/DrawTest/TestViewerSplitView.m @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +#import "TestViewerSplitView.h" + +@implementation TestViewerSplitView + +- (void)drawRect:(NSRect)rect +{ + NSArray *subviews = [self subviews]; + int subviewCount = [subviews count]; + for (int x=0; x < subviewCount; x++) { + NSView *subview = [subviews objectAtIndex:x]; + [subview drawRect:rect]; +#if 0 + NSString *label = [subviewLabels objectAtIndex:0]; + [label drawAtPoint:[subview frame].origin withAttributes:NULL]; +#endif + } +} + +- (void)retileSubviews +{ + NSRect bounds = [self bounds]; + NSArray *subviews = [self subviews]; + int subviewCount = [subviews count]; + if (!subviewCount) return; + float subviewWidth = bounds.size.width / subviewCount; + + for (int x=0; x < subviewCount; x++) { + [[subviews objectAtIndex:x] setFrame:NSMakeRect(x * subviewWidth, 0, subviewWidth, bounds.size.height)]; + } +} + +- (void)didAddSubview:(NSView *)subview +{ + [super didAddSubview:subview]; + [self retileSubviews]; +} + +- (void)willRemoveSubview:(NSView *)subview +{ + [super willRemoveSubview:subview]; + [self retileSubviews]; +} + +- (void)setFrame:(NSRect)newFrame +{ + // ideally we also want to catch when the bounds changes without the + // frame changing, but we're not bothering with that now - ECS 7/29/05 + [super setFrame:newFrame]; + [self retileSubviews]; +} + +@end diff --git a/WebKitTools/DrawTest/main.m b/WebKitTools/DrawTest/main.m new file mode 100644 index 0000000..90337b6 --- /dev/null +++ b/WebKitTools/DrawTest/main.m @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005 Apple Computer, 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR + * 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. + */ + +int main (int argc, const char *argv[]) +{ + return NSApplicationMain(argc, argv); +} |