Add WebKitInitializer and use it in DumpRenderTree and testkjs
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Sep 2007 00:54:22 +0000 (00:54 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Sep 2007 00:54:22 +0000 (00:54 +0000)
JavaScriptCore:

        Make testkjs use WebKitInitializer

        Reviewed by Sam.

        * JavaScriptCore.vcproj/JavaScriptCore.sln: Add WebKitInitializer and
        make testkjs depend on it.
        * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Link against
        WebKitInitializer.lib.
        * kjs/testkjs.cpp:
        (main): Call initializeWebKit.

WebKitTools:

        Add WebKitInitializer and use it in DumpRenderTree

        WebKitInitializer is a static library that has one function,
        initializeWebKit(). This registers WebKit and sets up the DLL search
        path so that WebKit's dependencies that are installed with Safari can
        be found.

        Reviewed by Sam.

        * DumpRenderTree/DumpRenderTree.sln: Added WebKitInitializer and made
        DumpRenderTree depend on it.
        * DumpRenderTree/win/DumpRenderTree.cpp:
        (initialize): Call initializeWebKit.
        * DumpRenderTree/win/DumpRenderTree.vcproj: Link against
        WebKitInitializer.lib.
        * WebKitInitializer/WebKitInitializer.cpp: Added.
        (getStringValue):
        (getWebViewCLSID):
        (getInstalledWebKitDirectory):
        (initializeWebKit):
        * WebKitInitializer/WebKitInitializer.h: Added.
        * WebKitInitializer/WebKitInitializer.vcproj: Added.
        * WebKitInitializer/debug.vsprops: Added.
        * WebKitInitializer/release.vsprops: Added.

WebKit/win:

        Add WebKitInitializer to WebKit.sln

        Reviewed by Sam.

        * WebKit.vcproj/WebKit.sln: DumpRenderTree and testkjs now depend on
        WebKitInitializer.

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

15 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore.sln
JavaScriptCore/JavaScriptCore.vcproj/testkjs/testkjs.vcproj
JavaScriptCore/kjs/testkjs.cpp
WebKit/win/ChangeLog
WebKit/win/WebKit.vcproj/WebKit.sln
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.sln
WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj
WebKitTools/WebKitInitializer/WebKitInitializer.cpp [new file with mode: 0644]
WebKitTools/WebKitInitializer/WebKitInitializer.h [new file with mode: 0644]
WebKitTools/WebKitInitializer/WebKitInitializer.vcproj [new file with mode: 0644]
WebKitTools/WebKitInitializer/debug.vsprops [new file with mode: 0644]
WebKitTools/WebKitInitializer/release.vsprops [new file with mode: 0644]

index 75e0489..bcffbbb 100644 (file)
@@ -1,3 +1,16 @@
+2007-09-25  Adam Roben  <aroben@apple.com>
+
+        Make testkjs use WebKitInitializer
+
+        Reviewed by Sam.
+
+        * JavaScriptCore.vcproj/JavaScriptCore.sln: Add WebKitInitializer and
+        make testkjs depend on it.
+        * JavaScriptCore.vcproj/testkjs/testkjs.vcproj: Link against
+        WebKitInitializer.lib.
+        * kjs/testkjs.cpp:
+        (main): Call initializeWebKit.
+
 2007-09-24  Kevin McCullough  <kmccullough@apple.com>
 
         Reviewed by Sam.
index 896662c..619d368 100644 (file)
@@ -11,11 +11,14 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testkjs", "testkjs\testkjs.vcproj", "{C59E5129-B453-49B7-A52B-1E104715F76E}"\r
        ProjectSection(ProjectDependencies) = postProject\r
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6}\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02} = {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}\r
                {011D10F1-B656-4A1B-A0C3-3842F02122C5} = {011D10F1-B656-4A1B-A0C3-3842F02122C5}\r
        EndProjectSection\r
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTF", "WTF\WTF.vcproj", "{AA8A5A85-592B-4357-BC60-E0E91E026AF6}"\r
 EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitInitializer", "..\..\WebKitTools\WebKitInitializer\WebKitInitializer.vcproj", "{9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug_Internal|Win32 = Debug_Internal|Win32\r
@@ -47,6 +50,12 @@ Global
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Debug|Win32.Build.0 = Debug|Win32\r
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Release|Win32.ActiveCfg = Release|Win32\r
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Release|Win32.Build.0 = Release|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug_Internal|Win32.ActiveCfg = Debug|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug_Internal|Win32.Build.0 = Debug|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.Build.0 = Debug|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.ActiveCfg = Release|Win32\r
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.Build.0 = Release|Win32\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
index fd03234..fbfdcc8 100644 (file)
@@ -42,7 +42,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
+                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE; WIN32"
                                MinimalRebuild="true"
                                ExceptionHandling="0"
@@ -67,7 +67,7 @@
                        <Tool
                                Name="VCLinkerTool"
                                LinkLibraryDependencies="false"
-                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
+                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;..\..\..\icu\lib"
                        />
                        <Tool
                                Name="VCCLCompilerTool"
-                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
+                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE; WIN32"
                                ExceptionHandling="0"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCLinkerTool"
                                LinkLibraryDependencies="false"
-                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
+                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="1"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;..\..\..\icu\lib"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
+                               AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\include&quot;;&quot;$(WebKitOutputDir)\obj\JavaScriptCore\$(ConfigurationName)\DerivedSources\&quot;;../../;&quot;../../os-win32/&quot;;../../pcre/;../../kjs/;../../wtf/;&quot;$(WebKitLibrariesDir)\include\icu&quot;;../../../icu/include"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE; WIN32"
                                MinimalRebuild="true"
                                ExceptionHandling="0"
                        <Tool
                                Name="VCLinkerTool"
                                LinkLibraryDependencies="false"
-                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
+                               AdditionalDependencies="JavaScriptCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib winmm.lib pthreadVC2$(LibraryConfigSuffix).lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;..\..\..\icu\lib"
index 68ba146..74c32df 100644 (file)
@@ -41,6 +41,7 @@
 #include "protect.h"
 
 #if PLATFORM(WIN_OS)
+#include <WebKitInitializer/WebKitInitializer.h>
 #include <windows.h>
 #include <crtdbg.h>
 #endif
@@ -204,6 +205,12 @@ int kjsmain(int argc, char** argv);
 
 int main(int argc, char** argv)
 {
+#if PLATFORM(WIN_OS)
+    if (!initializeWebKit()) {
+        fprintf(stderr, "Failed to initialize WebKit\n");
+        abort();
+    }
+#endif
 #if defined(_DEBUG) && PLATFORM(WIN_OS)
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
index e8cb58a..d5082d6 100644 (file)
@@ -1,3 +1,12 @@
+2007-09-25  Adam Roben  <aroben@apple.com>
+
+        Add WebKitInitializer to WebKit.sln
+
+        Reviewed by Sam.
+
+        * WebKit.vcproj/WebKit.sln: DumpRenderTree and testkjs now depend on
+        WebKitInitializer.
+
 2007-09-25  Darin Adler  <darin@apple.com>
 
         Reviewed by Steve.
index b20c8ec..ce42421 100644 (file)
@@ -24,6 +24,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\..\..\WebCore
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DumpRenderTree", "..\..\..\WebKitTools\DumpRenderTree\win\DumpRenderTree.vcproj", "{6567DFD4-D6DE-4CD5-825D-17E353D160E1}"
        ProjectSection(ProjectDependencies) = postProject
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02} = {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}
                {0662A8A9-82A3-4638-97D8-EC425D8D87C9} = {0662A8A9-82A3-4638-97D8-EC425D8D87C9}
        EndProjectSection
 EndProject
@@ -39,14 +40,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaScriptCore", "..\..\..\
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testkjs", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\testkjs\testkjs.vcproj", "{C59E5129-B453-49B7-A52B-1E104715F76E}"
        ProjectSection(ProjectDependencies) = postProject
-               {011D10F1-B656-4A1B-A0C3-3842F02122C5} = {011D10F1-B656-4A1B-A0C3-3842F02122C5}
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6}
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02} = {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}
+               {011D10F1-B656-4A1B-A0C3-3842F02122C5} = {011D10F1-B656-4A1B-A0C3-3842F02122C5}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dftables", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\dftables\dftables.vcproj", "{BC2981C0-67A5-4A3C-879B-784BCBDE2541}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTF", "..\..\..\JavaScriptCore\JavaScriptCore.vcproj\WTF\WTF.vcproj", "{AA8A5A85-592B-4357-BC60-E0E91E026AF6}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitInitializer", "..\..\..\WebKitTools\WebKitInitializer\WebKitInitializer.vcproj", "{9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Win32 = Debug|Win32
@@ -93,6 +97,10 @@ Global
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Debug|Win32.Build.0 = Debug|Win32
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Release|Win32.ActiveCfg = Release|Win32
                {AA8A5A85-592B-4357-BC60-E0E91E026AF6}.Release|Win32.Build.0 = Release|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.ActiveCfg = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.Build.0 = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.ActiveCfg = Release|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index fbcd5f8..d609a3d 100644 (file)
@@ -1,5 +1,32 @@
 2007-09-25  Adam Roben  <aroben@apple.com>
 
+        Add WebKitInitializer and use it in DumpRenderTree
+
+        WebKitInitializer is a static library that has one function,
+        initializeWebKit(). This registers WebKit and sets up the DLL search
+        path so that WebKit's dependencies that are installed with Safari can
+        be found.
+
+        Reviewed by Sam.
+
+        * DumpRenderTree/DumpRenderTree.sln: Added WebKitInitializer and made
+        DumpRenderTree depend on it.
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (initialize): Call initializeWebKit.
+        * DumpRenderTree/win/DumpRenderTree.vcproj: Link against
+        WebKitInitializer.lib.
+        * WebKitInitializer/WebKitInitializer.cpp: Added.
+        (getStringValue):
+        (getWebViewCLSID):
+        (getInstalledWebKitDirectory):
+        (initializeWebKit):
+        * WebKitInitializer/WebKitInitializer.h: Added.
+        * WebKitInitializer/WebKitInitializer.vcproj: Added.
+        * WebKitInitializer/debug.vsprops: Added.
+        * WebKitInitializer/release.vsprops: Added.
+
+2007-09-25  Adam Roben  <aroben@apple.com>
+
         Make run-webkit-tests respect set-webkit-configuration
 
         Reviewed by Sam.
index a12e09a..654dd53 100644 (file)
@@ -2,16 +2,13 @@
 Microsoft Visual Studio Solution File, Format Version 9.00
 # Visual Studio 2005
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DumpRenderTree", "win\DumpRenderTree.vcproj", "{6567DFD4-D6DE-4CD5-825D-17E353D160E1}"
-       ProjectSection(WebsiteProperties) = preProject
-               Debug.AspNetCompiler.Debug = "True"
-               Release.AspNetCompiler.Debug = "False"
+       ProjectSection(ProjectDependencies) = postProject
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02} = {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}
        EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestNetscapePlugin", "win\TestNetscapePlugin\TestNetscapePlugin.vcproj", "{C0737398-3565-439E-A2B8-AB2BE4D5430C}"
-       ProjectSection(WebsiteProperties) = preProject
-               Debug.AspNetCompiler.Debug = "True"
-               Release.AspNetCompiler.Debug = "False"
-       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitInitializer", "..\WebKitInitializer\WebKitInitializer.vcproj", "{9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}"
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -32,6 +29,12 @@ Global
                {C0737398-3565-439E-A2B8-AB2BE4D5430C}.Debug|Win32.Build.0 = Debug|Win32
                {C0737398-3565-439E-A2B8-AB2BE4D5430C}.Release|Win32.ActiveCfg = Release|Win32
                {C0737398-3565-439E-A2B8-AB2BE4D5430C}.Release|Win32.Build.0 = Release|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug_Internal|Win32.ActiveCfg = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug_Internal|Win32.Build.0 = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.ActiveCfg = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Debug|Win32.Build.0 = Debug|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.ActiveCfg = Release|Win32
+               {9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}.Release|Win32.Build.0 = Release|Win32
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 4ea3778..26bb7f8 100644 (file)
@@ -42,6 +42,7 @@
 #include <pthread.h>
 #include <string>
 #include <tchar.h>
+#include <WebKitInitializer/WebKitInitializer.h>
 #include <WebKit/DOMPrivate.h>
 #include <WebKit/IWebFramePrivate.h>
 #include <WebKit/IWebHistoryItem.h>
@@ -111,13 +112,10 @@ extern "C" BOOL InitializeCoreGraphics();
 
 static wstring initialize(HMODULE hModule)
 {
-#ifdef NDEBUG
-    HMODULE webKitModule = LoadLibraryW(L"WebKit.dll");
-#else
-    HMODULE webKitModule = LoadLibraryW(L"WebKit_debug.dll");
-#endif
-    FARPROC dllRegisterServer = ::GetProcAddress(webKitModule, "DllRegisterServer");
-    dllRegisterServer();
+    if (!initializeWebKit()) {
+        fprintf(stderr, "WebKit failed to initialize\n");
+        abort();
+    }
 
     static LPCTSTR fontsToInstall[] = {
         TEXT("AHEM____.ttf"),
index a088c2e..66b42eb 100644 (file)
@@ -62,7 +62,7 @@
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
+                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;&quot;$(WebKitOutputDir)\bin&quot;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
+                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="1"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;&quot;$(WebKitOutputDir)\bin&quot;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
+                               AdditionalDependencies="WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitInitializer$(WebKitConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib"
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).exe"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;;&quot;$(WebKitOutputDir)\bin&quot;"
diff --git a/WebKitTools/WebKitInitializer/WebKitInitializer.cpp b/WebKitTools/WebKitInitializer/WebKitInitializer.cpp
new file mode 100644 (file)
index 0000000..e6d0bff
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "WebKitInitializer.h"
+
+// Needed to get SetDllDirectory
+#define _WIN32_WINNT 0x0502
+
+#include <shlwapi.h>
+#include <tchar.h>
+#include <windows.h>
+
+static TCHAR* getStringValue(HKEY key, LPCTSTR valueName)
+{
+    DWORD type = 0;
+    DWORD bufferSize = 0;
+    if (RegQueryValueEx(key, valueName, 0, &type, 0, &bufferSize) != ERROR_SUCCESS || type != REG_SZ)
+        return 0;
+
+    TCHAR* buffer = new TCHAR[bufferSize / sizeof(TCHAR)];
+    if (RegQueryValueEx(key, 0, 0, &type, reinterpret_cast<LPBYTE>(buffer), &bufferSize) != ERROR_SUCCESS) {
+        delete [] buffer;
+        return 0;
+    }
+
+    return buffer;
+}
+
+static LPOLESTR getWebViewCLSID()
+{
+    // FIXME <rdar://5505062>: Once WebKit switches to truly version-independent
+    // ProgIDs, this should just become "WebKit.WebView".
+    LPCTSTR webViewProgID = TEXT("WebKit.WebView.3");
+
+    CLSID clsid = CLSID_NULL;
+    HRESULT hr = CLSIDFromProgID(webViewProgID, &clsid);
+    if (FAILED(hr)) {
+        _ftprintf(stderr, TEXT("Failed to get CLSID for %s\n"), webViewProgID);
+        return 0;
+    }
+
+    LPOLESTR clsidString = 0;
+    if (FAILED(StringFromCLSID(clsid, &clsidString))) {
+        _ftprintf(stderr, TEXT("Failed to get string representation of CLSID for WebView\n"));
+        return 0;
+    }
+
+    return clsidString;
+}
+
+static TCHAR* getInstalledWebKitDirectory()
+{
+    LPCTSTR keyPrefix = TEXT("SOFTWARE\\Classes\\CLSID\\");
+    LPCTSTR keySuffix = TEXT("\\InprocServer32");
+
+    LPOLESTR clsid = getWebViewCLSID();
+    if (!clsid)
+        return 0;
+
+    size_t keyBufferLength = _tcslen(keyPrefix) + _tcslen(clsid) + _tcslen(keySuffix) + 1;
+    TCHAR* keyString = new TCHAR[keyBufferLength];
+
+    int ret = _sntprintf_s(keyString, keyBufferLength, keyBufferLength - 1, TEXT("%s%s%s"), keyPrefix, clsid, keySuffix);
+    CoTaskMemFree(clsid);
+    if (ret == -1) {
+        _ftprintf(stderr, TEXT("Failed to construct InprocServer32 key\n"));
+        return 0;
+    }
+
+    HKEY serverKey = 0;
+    LONG error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyString, 0, KEY_READ, &serverKey);
+    delete [] keyString;
+    if (error != ERROR_SUCCESS) {
+        _ftprintf(stderr, TEXT("Failed to open registry key %s\n"), keyString);
+        return 0;
+    }
+
+    TCHAR* webKitPath = getStringValue(serverKey, 0);
+    RegCloseKey(serverKey);
+    if (!webKitPath) {
+        _ftprintf(stderr, TEXT("Couldn't retrieve value for registry key %s\n"), keyString);
+        return 0;
+    }
+
+    TCHAR* startOfFileName = PathFindFileName(webKitPath);
+    if (startOfFileName == webKitPath) {
+        _ftprintf(stderr, TEXT("Couldn't find filename from path %s\n"), webKitPath);
+        delete [] webKitPath;
+        return 0;
+    }
+
+    *startOfFileName = '\0';
+    return webKitPath;
+}
+
+bool initializeWebKit()
+{
+    static bool haveInitialized;
+    static bool success;
+    if (haveInitialized)
+        return success;
+    haveInitialized = true;
+
+#ifdef NDEBUG
+    LPCTSTR webKitDLL = TEXT("WebKit.dll");
+#else
+    LPCTSTR webKitDLL = TEXT("WebKit_debug.dll");
+#endif
+
+    HMODULE webKitModule = LoadLibrary(webKitDLL);
+    if (!webKitModule) {
+        _ftprintf(stderr, TEXT("LoadLibrary(%s) failed\n"), webKitDLL);
+        return false;
+    }
+
+    FARPROC dllRegisterServer = GetProcAddress(webKitModule, "DllRegisterServer");
+    if (!dllRegisterServer) {
+        _ftprintf(stderr, TEXT("GetProcAddress(\"DllRegisterServer\") failed\n"));
+        return false;
+    }
+
+    dllRegisterServer();
+
+    TCHAR* directory = getInstalledWebKitDirectory();
+    if (!directory) {
+        _ftprintf(stderr, TEXT("Couldn't determine installed WebKit directory\n"));
+        return false;
+    }
+
+    SetDllDirectory(directory);
+    delete [] directory;
+
+    success = true;
+    return success;
+}
diff --git a/WebKitTools/WebKitInitializer/WebKitInitializer.h b/WebKitTools/WebKitInitializer/WebKitInitializer.h
new file mode 100644 (file)
index 0000000..b2cb325
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+bool initializeWebKit();
diff --git a/WebKitTools/WebKitInitializer/WebKitInitializer.vcproj b/WebKitTools/WebKitInitializer/WebKitInitializer.vcproj
new file mode 100644 (file)
index 0000000..d643271
--- /dev/null
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="WebKitInitializer"
+       ProjectGUID="{9E96B9B5-0CCB-47F8-A95E-C25ABE049E02}"
+       RootNamespace="WebKitInitializer"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(WebKitOutputDir)\lib"
+                       IntermediateDirectory="$(WebKitOutputDir)\obj\$(ProjectName)\$(ConfigurationName)"
+                       ConfigurationType="4"
+                       InheritedPropertySheets=".\debug.vsprops"
+                       CharacterSet="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               WarningLevel="4"
+                               WarnAsError="true"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                               AdditionalDependencies="shlwapi.lib"
+                               OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).lib"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                               CommandLine="mkdir 2&gt;NUL &quot;$(WebKitOutputDir)\include\WebKitInitializer&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(InputDir)*.h&quot; &quot;$(WebKitOutputDir)\include\WebKitInitializer&quot;"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(WebKitOutputDir)\lib"
+                       IntermediateDirectory="$(WebKitOutputDir)\obj\$(ProjectName)\$(ConfigurationName)"
+                       ConfigurationType="4"
+                       InheritedPropertySheets=".\release.vsprops"
+                       CharacterSet="1"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               RuntimeLibrary="2"
+                               WarningLevel="4"
+                               WarnAsError="true"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                               AdditionalDependencies="shlwapi.lib"
+                               OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix).lib"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                               CommandLine="mkdir 2&gt;NUL &quot;$(WebKitOutputDir)\include\WebKitInitializer&quot;&#x0D;&#x0A;xcopy /y /d &quot;$(InputDir)*.h&quot; &quot;$(WebKitOutputDir)\include\WebKitInitializer&quot;"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\WebKitInitializer.cpp"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath=".\WebKitInitializer.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/WebKitTools/WebKitInitializer/debug.vsprops b/WebKitTools/WebKitInitializer/debug.vsprops
new file mode 100644 (file)
index 0000000..2c75b59
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="debug"
+       >
+       <UserMacro
+               Name="WebKitConfigSuffix"
+               Value="_debug"
+       />
+</VisualStudioPropertySheet>
diff --git a/WebKitTools/WebKitInitializer/release.vsprops b/WebKitTools/WebKitInitializer/release.vsprops
new file mode 100644 (file)
index 0000000..2113c7d
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="release"
+       >
+       <UserMacro
+               Name="WebKitConfigSuffix"
+               Value=""
+       />
+</VisualStudioPropertySheet>