Commit 77458d83 authored by sfalken@apple.com's avatar sfalken@apple.com

WebKit/win:

2009-04-21  Steve Falkenburg  <sfalken@apple.com>

        Add registry-free CoCreateInstance API for WebKit clients: WebKitCreateInstance.

        Manifest-based registry-free COM continues to work for clients that have embedded
        manifests with isolated COM information.
        
        Reviewed by Adam Roben.

        * WebKit.vcproj/WebKit.def: Added WebKitCreateInstance.
        * WebKit.vcproj/WebKit.vcproj: Link against rpcrt4.dll for UUID hashing.
        * WebKit.vcproj/WebKit_debug.def: Added WebKitCreateInstance.
        * WebKitCOMAPI.cpp: Added.
        (CLSIDHash::hash):
        (CLSIDHash::equal):
        (CLSIDHashTraits::constructDeletedValue):
        (CLSIDHashTraits::isDeletedValue):
        (classFactory):
        (WebKitCreateInstance): New API.
        * WebKitCOMAPI.h: Added.

WebKitTools:

2009-04-21  Steve Falkenburg  <sfalken@apple.com>

        Use new WebKitCreateInstance API instead of CoCreateInstance
        or COMPtr's createInstance to instantiate WebKit COM objects.

        Reviewed by Adam Roben.

        * DumpRenderTree/win/DumpRenderTree.cpp:
        (initialize):
        (runTest):
        (createWebViewAndOffscreenWindow):
        (main):
        * DumpRenderTree/win/DumpRenderTree.vcproj:
        * DumpRenderTree/win/GCControllerWin.cpp:
        (GCController::collect):
        (GCController::collectOnAlternateThread):
        (GCController::getJSObjectCount):
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::keepWebHistory):
        (LayoutTestController::webHistoryItemCount):
        (LayoutTestController::setIconDatabaseEnabled):
        * DumpRenderTree/win/WorkQueueItemWin.cpp:
        (LoadItem::invoke):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c9fbbab7
2009-04-21 Steve Falkenburg <sfalken@apple.com>
Add registry-free CoCreateInstance API for WebKit clients: WebKitCreateInstance.
Manifest-based registry-free COM continues to work for clients that have embedded
manifests with isolated COM information.
Reviewed by Adam Roben.
* WebKit.vcproj/WebKit.def: Added WebKitCreateInstance.
* WebKit.vcproj/WebKit.vcproj: Link against rpcrt4.dll for UUID hashing.
* WebKit.vcproj/WebKit_debug.def: Added WebKitCreateInstance.
* WebKitCOMAPI.cpp: Added.
(CLSIDHash::hash):
(CLSIDHash::equal):
(CLSIDHashTraits::constructDeletedValue):
(CLSIDHashTraits::isDeletedValue):
(classFactory):
(WebKitCreateInstance): New API.
* WebKitCOMAPI.h: Added.
2009-04-21 Adam Roben <aroben@apple.com>
Rename JavaScriptCore_debug.dll to JavaScriptCore.dll in the Debug
......
......@@ -19,7 +19,8 @@ EXPORTS
RightTruncateStringToWidth
WebKitSetShouldUseFontSmoothing
WebKitShouldUseFontSmoothing
WebKitCreateInstance
; These functions are deprecated
WebLocalizedString
WebLocalizedLPCTSTR
......
This diff is collapsed.
......@@ -19,7 +19,8 @@ EXPORTS
RightTruncateStringToWidth
WebKitSetShouldUseFontSmoothing
WebKitShouldUseFontSmoothing
WebKitCreateInstance
; These functions are deprecated
WebLocalizedString
WebLocalizedLPCTSTR
......
/*
* Copyright (C) 2009 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.
*
* 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.
*/
#include "config.h"
#include "WebKitCOMAPI.h"
#include "WebKit.h"
#include "WebKitDLL.h"
#include <WebCore/COMPtr.h>
struct CLSIDHash {
static unsigned hash(const CLSID& clsid)
{
RPC_STATUS status;
return ::UuidHash(const_cast<CLSID*>(&clsid), &status);
}
static bool equal(const CLSID& a, const CLSID& b) { return ::IsEqualCLSID(a, b); }
static const bool safeToCompareToEmptyOrDeleted = true;
};
struct CLSIDHashTraits : WTF::GenericHashTraits<CLSID> {
static void constructDeletedValue(CLSID& slot) { slot = CLSID_NULL; }
static bool isDeletedValue(const CLSID& value) { return value == CLSID_NULL; }
};
static COMPtr<IClassFactory> classFactory(const CLSID& clsid)
{
typedef HashMap<CLSID, COMPtr<IClassFactory>, CLSIDHash, CLSIDHashTraits> FactoryMap;
static FactoryMap& factories = *new FactoryMap;
COMPtr<IClassFactory>& factory = factories.add(clsid, 0).first->second;
if (!factory && FAILED(DllGetClassObject(clsid, __uuidof(factory), reinterpret_cast<void**>(&factory))))
factory = 0;
return factory;
}
HRESULT WebKitCreateInstance(REFCLSID rclsid, IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
{
COMPtr<IClassFactory> factory = classFactory(rclsid);
if (!factory)
return REGDB_E_CLASSNOTREG;
return factory->CreateInstance(pUnkOuter, riid, ppvObject);
}
/*
* Copyright (C) 2009 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.
*
* 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.
*/
#ifndef WebKitCOMAPI_h
#define WebKitCOMAPI_h
extern "C" {
// Callers should use this API instead of CoCreateInstance to instantiate WebKit COM classes.
// This bypasses CoCreateInstance entirely, so registry keys and isolated COM manifests aren't needed.
HRESULT WebKitCreateInstance(REFCLSID, IUnknown* pUnkOuter, REFIID, void** ppvObject);
}
#endif // !defined(WebKitCOMAPI_h)
2009-04-21 Steve Falkenburg <sfalken@apple.com>
Use new WebKitCreateInstance API instead of CoCreateInstance
or COMPtr's createInstance to instantiate WebKit COM objects.
Reviewed by Adam Roben.
* DumpRenderTree/win/DumpRenderTree.cpp:
(initialize):
(runTest):
(createWebViewAndOffscreenWindow):
(main):
* DumpRenderTree/win/DumpRenderTree.vcproj:
* DumpRenderTree/win/GCControllerWin.cpp:
(GCController::collect):
(GCController::collectOnAlternateThread):
(GCController::getJSObjectCount):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::keepWebHistory):
(LayoutTestController::webHistoryItemCount):
(LayoutTestController::setIconDatabaseEnabled):
* DumpRenderTree/win/WorkQueueItemWin.cpp:
(LoadItem::invoke):
2009-04-20 Timothy Hatcher <timothy@apple.com>
Stop using the fullDocumentTeardownEnabled WebPreference methods.
......
......@@ -53,8 +53,8 @@
#include <CFNetwork/CFURLCachePriv.h>
#include <CoreFoundation/CoreFoundation.h>
#include <JavaScriptCore/JavaScriptCore.h>
#include <WebKit/ForEachCoClass.h>
#include <WebKit/WebKit.h>
#include <WebKit/WebKitCOMAPI.h>
using namespace std;
......@@ -231,7 +231,7 @@ static void initialize()
wstring resourcesPath = fontsPath();
COMPtr<IWebTextRenderer> textRenderer;
if (SUCCEEDED(CoCreateInstance(CLSID_WebTextRenderer, 0, CLSCTX_ALL, IID_IWebTextRenderer, (void**)&textRenderer)))
if (SUCCEEDED(WebKitCreateInstance(CLSID_WebTextRenderer, 0, IID_IWebTextRenderer, (void**)&textRenderer)))
for (int i = 0; i < ARRAYSIZE(fontsToInstall); ++i)
textRenderer->registerPrivateFont(wstring(resourcesPath + fontsToInstall[i]).c_str());
......@@ -740,8 +740,8 @@ static void runTest(const string& testPathOrURL)
if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))
gLayoutTestController->setDumpFrameLoadCallbacks(true);
COMPtr<IWebHistory> history(Create, CLSID_WebHistory);
if (history)
COMPtr<IWebHistory> history;
if (SUCCEEDED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(history), reinterpret_cast<void**>(&history))))
history->setOptionalSharedHistory(0);
resetWebViewToConsistentStateBeforeTesting();
......@@ -761,7 +761,7 @@ static void runTest(const string& testPathOrURL)
webView->hostWindow(reinterpret_cast<OLE_HANDLE*>(&hostWindow));
COMPtr<IWebMutableURLRequest> request;
HRESULT hr = CoCreateInstance(CLSID_WebMutableURLRequest, 0, CLSCTX_ALL, IID_IWebMutableURLRequest, (void**)&request);
HRESULT hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&request);
if (FAILED(hr))
goto exit;
......@@ -969,7 +969,7 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow)
IWebView* webView;
HRESULT hr = CoCreateInstance(CLSID_WebView, 0, CLSCTX_ALL, IID_IWebView, (void**)&webView);
HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, (void**)&webView);
if (FAILED(hr)) {
fprintf(stderr, "Failed to create CLSID_WebView instance, error 0x%x\n", hr);
return 0;
......@@ -1096,7 +1096,7 @@ int main(int argc, char* argv[])
COMPtr<IWebIconDatabase> iconDatabase;
COMPtr<IWebIconDatabase> tmpIconDatabase;
if (FAILED(CoCreateInstance(CLSID_WebIconDatabase, 0, CLSCTX_ALL, IID_IWebIconDatabase, (void**)&tmpIconDatabase)))
if (FAILED(WebKitCreateInstance(CLSID_WebIconDatabase, 0, IID_IWebIconDatabase, (void**)&tmpIconDatabase)))
return -1;
if (FAILED(tmpIconDatabase->sharedIconDatabase(&iconDatabase)))
return -1;
......
......@@ -66,8 +66,6 @@
/>
<Tool
Name="VCManifestTool"
TypeLibraryFile="$(WebKitOutputDir)\lib\WebKit.tlb"
ComponentFileName="WebKit$(WebKitDLLConfigSuffix)"
/>
<Tool
Name="VCXDCMakeTool"
......@@ -141,8 +139,6 @@
/>
<Tool
Name="VCManifestTool"
TypeLibraryFile="$(WebKitOutputDir)\lib\WebKit.tlb"
ComponentFileName="WebKit$(WebKitDLLConfigSuffix)"
/>
<Tool
Name="VCXDCMakeTool"
......@@ -214,8 +210,6 @@
/>
<Tool
Name="VCManifestTool"
TypeLibraryFile="$(WebKitOutputDir)\lib\WebKit.tlb"
ComponentFileName="WebKit$(WebKitDLLConfigSuffix)"
/>
<Tool
Name="VCXDCMakeTool"
......
......@@ -32,11 +32,12 @@
#include "DumpRenderTree.h"
#include <WebCore/COMPtr.h>
#include <WebKit/WebKit.h>
#include <WebKit/WebKitCOMAPI.h>
void GCController::collect() const
{
COMPtr<IWebJavaScriptCollector> collector;
if (FAILED(::CoCreateInstance(CLSID_WebJavaScriptCollector, 0, CLSCTX_ALL, IID_IWebJavaScriptCollector, (void**)&collector)))
if (FAILED(WebKitCreateInstance(CLSID_WebJavaScriptCollector, 0, IID_IWebJavaScriptCollector, (void**)&collector)))
return;
collector->collect();
}
......@@ -44,7 +45,7 @@ void GCController::collect() const
void GCController::collectOnAlternateThread(bool waitUntilDone) const
{
COMPtr<IWebJavaScriptCollector> collector;
if (FAILED(::CoCreateInstance(CLSID_WebJavaScriptCollector, 0, CLSCTX_ALL, IID_IWebJavaScriptCollector, (void**)&collector)))
if (FAILED(WebKitCreateInstance(CLSID_WebJavaScriptCollector, 0, IID_IWebJavaScriptCollector, (void**)&collector)))
return;
collector->collectOnAlternateThread(waitUntilDone ? TRUE : FALSE);
}
......@@ -52,7 +53,7 @@ void GCController::collectOnAlternateThread(bool waitUntilDone) const
size_t GCController::getJSObjectCount() const
{
COMPtr<IWebJavaScriptCollector> collector;
if (FAILED(::CoCreateInstance(CLSID_WebJavaScriptCollector, 0, CLSCTX_ALL, IID_IWebJavaScriptCollector, (void**)&collector)))
if (FAILED(WebKitCreateInstance(CLSID_WebJavaScriptCollector, 0, IID_IWebJavaScriptCollector, (void**)&collector)))
return 0;
UINT objects = 0;
collector->objectCount(&objects);
......
......@@ -43,6 +43,7 @@
#include <JavaScriptCore/JSRetainPtr.h>
#include <JavaScriptCore/JSStringRefBSTR.h>
#include <WebKit/WebKit.h>
#include <WebKit/WebKitCOMAPI.h>
#include <string>
#include <CoreFoundation/CoreFoundation.h>
#include <shlwapi.h>
......@@ -127,12 +128,12 @@ void LayoutTestController::display()
void LayoutTestController::keepWebHistory()
{
COMPtr<IWebHistory> history(Create, CLSID_WebHistory);
if (!history)
COMPtr<IWebHistory> history;
if (FAILED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(history), reinterpret_cast<void**>(&history))))
return;
COMPtr<IWebHistory> sharedHistory(Create, CLSID_WebHistory);
if (!sharedHistory)
COMPtr<IWebHistory> sharedHistory;
if (FAILED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(sharedHistory), reinterpret_cast<void**>(&sharedHistory))))
return;
history->setOptionalSharedHistory(sharedHistory.get());
......@@ -145,8 +146,8 @@ void LayoutTestController::waitForPolicyDelegate()
size_t LayoutTestController::webHistoryItemCount()
{
COMPtr<IWebHistory> history(Create, CLSID_WebHistory);
if (!history)
COMPtr<IWebHistory> history;
if (FAILED(WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(history), reinterpret_cast<void**>(&history))))
return 0;
COMPtr<IWebHistory> sharedHistory;
......@@ -276,7 +277,7 @@ void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled)
// See also <rdar://problem/6480108>
COMPtr<IWebIconDatabase> iconDatabase;
COMPtr<IWebIconDatabase> tmpIconDatabase;
if (FAILED(CoCreateInstance(CLSID_WebIconDatabase, 0, CLSCTX_ALL, IID_IWebIconDatabase, (void**)&tmpIconDatabase)))
if (FAILED(WebKitCreateInstance(CLSID_WebIconDatabase, 0, IID_IWebIconDatabase, (void**)&tmpIconDatabase)))
return;
if (FAILED(tmpIconDatabase->sharedIconDatabase(&iconDatabase)))
return;
......
......@@ -32,6 +32,7 @@
#include "DumpRenderTree.h"
#include <WebCore/COMPtr.h>
#include <WebKit/WebKit.h>
#include <WebKit/WebKitCOMAPI.h>
#include <JavaScriptCore/JSStringRef.h>
#include <JavaScriptCore/JSStringRefCF.h>
#include <JavaScriptCore/RetainPtr.h>
......@@ -66,7 +67,7 @@ bool LoadItem::invoke() const
}
COMPtr<IWebURLRequest> request;
if (FAILED(CoCreateInstance(CLSID_WebURLRequest, 0, CLSCTX_ALL, IID_IWebURLRequest, (void**)&request)))
if (FAILED(WebKitCreateInstance(CLSID_WebURLRequest, 0, IID_IWebURLRequest, (void**)&request)))
return false;
wstring urlString = jsStringRefToWString(m_url.get());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment