Commit 07023e63 authored by paroga@webkit.org's avatar paroga@webkit.org

2011-03-28 Patrick Gansterer <paroga@webkit.org>

        Unreviewed build fix.

        * COMPropertyBag.h: Added missing include.
        * WebKitCOMAPI.h: Ditto.
        * WebCoreSupport/WebFrameLoaderClient.h: Added missing forward declaration.

git-svn-id: svn://svn.chromium.org/blink/trunk@82101 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3c8297bb
/* /*
* Copyright (C) 2008 Apple Inc. All Rights Reserved. * Copyright (C) 2008 Apple Inc. All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef COMPropertyBag_h #ifndef COMPropertyBag_h
#define COMPropertyBag_h #define COMPropertyBag_h
#define NOMINMAX #define NOMINMAX
#include <unknwn.h> #include <ocidl.h>
#include <unknwn.h>
#include <wtf/Noncopyable.h>
#include <wtf/HashMap.h> #include <wtf/Noncopyable.h>
#include <wtf/HashMap.h>
#include "COMVariantSetter.h"
#include "COMVariantSetter.h"
template<typename ValueType, typename KeyType = typename WTF::String, typename HashType = typename WTF::StringHash>
class COMPropertyBag : public IPropertyBag, public IPropertyBag2 { template<typename ValueType, typename KeyType = typename WTF::String, typename HashType = typename WTF::StringHash>
WTF_MAKE_NONCOPYABLE(COMPropertyBag); class COMPropertyBag : public IPropertyBag, public IPropertyBag2 {
public: WTF_MAKE_NONCOPYABLE(COMPropertyBag);
typedef HashMap<KeyType, ValueType, HashType> HashMapType; public:
typedef HashMap<KeyType, ValueType, HashType> HashMapType;
static COMPropertyBag* createInstance(const HashMapType&);
static COMPropertyBag* adopt(HashMapType&); static COMPropertyBag* createInstance(const HashMapType&);
static COMPropertyBag* adopt(HashMapType&);
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); // IUnknown
virtual ULONG STDMETHODCALLTYPE AddRef(); virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
virtual ULONG STDMETHODCALLTYPE Release(); virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
// IPropertyBag
virtual HRESULT STDMETHODCALLTYPE Read(LPCOLESTR pszPropName, VARIANT*, IErrorLog*); // IPropertyBag
virtual HRESULT STDMETHODCALLTYPE Write(LPCOLESTR pszPropName, VARIANT*); virtual HRESULT STDMETHODCALLTYPE Read(LPCOLESTR pszPropName, VARIANT*, IErrorLog*);
virtual HRESULT STDMETHODCALLTYPE Write(LPCOLESTR pszPropName, VARIANT*);
// IPropertyBag2
virtual HRESULT STDMETHODCALLTYPE Read(ULONG cProperties, PROPBAG2*, IErrorLog*, VARIANT* pvarValue, HRESULT* phrError); // IPropertyBag2
virtual HRESULT STDMETHODCALLTYPE Write(ULONG cProperties, PROPBAG2*, VARIANT*); virtual HRESULT STDMETHODCALLTYPE Read(ULONG cProperties, PROPBAG2*, IErrorLog*, VARIANT* pvarValue, HRESULT* phrError);
virtual HRESULT STDMETHODCALLTYPE CountProperties(ULONG* pcProperties); virtual HRESULT STDMETHODCALLTYPE Write(ULONG cProperties, PROPBAG2*, VARIANT*);
virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties); virtual HRESULT STDMETHODCALLTYPE CountProperties(ULONG* pcProperties);
virtual HRESULT STDMETHODCALLTYPE LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown*, IErrorLog*); virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties);
virtual HRESULT STDMETHODCALLTYPE LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown*, IErrorLog*);
private:
COMPropertyBag() private:
: m_refCount(0) COMPropertyBag()
{ : m_refCount(0)
} {
}
COMPropertyBag(const HashMapType& hashMap)
: m_refCount(0) COMPropertyBag(const HashMapType& hashMap)
, m_hashMap(hashMap) : m_refCount(0)
{ , m_hashMap(hashMap)
} {
}
~COMPropertyBag() {}
~COMPropertyBag() {}
ULONG m_refCount;
HashMapType m_hashMap; ULONG m_refCount;
}; HashMapType m_hashMap;
};
// COMPropertyBag ------------------------------------------------------------------
template<typename ValueType, typename KeyType, typename HashType> // COMPropertyBag ------------------------------------------------------------------
COMPropertyBag<ValueType, KeyType, HashType>* COMPropertyBag<typename ValueType, typename KeyType, HashType>::createInstance(const HashMapType& hashMap) template<typename ValueType, typename KeyType, typename HashType>
{ COMPropertyBag<ValueType, KeyType, HashType>* COMPropertyBag<typename ValueType, typename KeyType, HashType>::createInstance(const HashMapType& hashMap)
COMPropertyBag* instance = new COMPropertyBag(hashMap); {
instance->AddRef(); COMPropertyBag* instance = new COMPropertyBag(hashMap);
return instance; instance->AddRef();
} return instance;
}
template<typename ValueType, typename KeyType, typename HashType>
COMPropertyBag<ValueType, KeyType, HashType>* COMPropertyBag<typename ValueType, typename KeyType, HashType>::adopt(HashMapType& hashMap) template<typename ValueType, typename KeyType, typename HashType>
{ COMPropertyBag<ValueType, KeyType, HashType>* COMPropertyBag<typename ValueType, typename KeyType, HashType>::adopt(HashMapType& hashMap)
COMPropertyBag* instance = new COMPropertyBag; {
instance->m_hashMap.swap(hashMap); COMPropertyBag* instance = new COMPropertyBag;
instance->AddRef(); instance->m_hashMap.swap(hashMap);
return instance; instance->AddRef();
} return instance;
}
// IUnknown ------------------------------------------------------------------------
template<typename ValueType, typename KeyType, typename HashType> // IUnknown ------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::QueryInterface(REFIID riid, void** ppvObject) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::QueryInterface(REFIID riid, void** ppvObject)
*ppvObject = 0; {
if (IsEqualGUID(riid, IID_IUnknown)) *ppvObject = 0;
*ppvObject = static_cast<IPropertyBag*>(this); if (IsEqualGUID(riid, IID_IUnknown))
else if (IsEqualGUID(riid, IID_IPropertyBag)) *ppvObject = static_cast<IPropertyBag*>(this);
*ppvObject = static_cast<IPropertyBag*>(this); else if (IsEqualGUID(riid, IID_IPropertyBag))
else if (IsEqualGUID(riid, IID_IPropertyBag2)) *ppvObject = static_cast<IPropertyBag*>(this);
*ppvObject = static_cast<IPropertyBag2*>(this); else if (IsEqualGUID(riid, IID_IPropertyBag2))
else *ppvObject = static_cast<IPropertyBag2*>(this);
return E_NOINTERFACE; else
return E_NOINTERFACE;
AddRef();
return S_OK; AddRef();
} return S_OK;
}
template<typename ValueType, typename KeyType, typename HashType>
ULONG STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::AddRef() template<typename ValueType, typename KeyType, typename HashType>
{ ULONG STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::AddRef()
return ++m_refCount; {
} return ++m_refCount;
}
template<typename ValueType, typename KeyType, typename HashType>
ULONG STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Release() template<typename ValueType, typename KeyType, typename HashType>
{ ULONG STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Release()
ULONG newRef = --m_refCount; {
if (!newRef) ULONG newRef = --m_refCount;
delete this; if (!newRef)
delete this;
return newRef;
} return newRef;
}
// IPropertyBag --------------------------------------------------------------------
// IPropertyBag --------------------------------------------------------------------
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
if (!pszPropName) {
return E_POINTER; if (!pszPropName)
return E_POINTER;
HashMapType::const_iterator it = m_hashMap.find(String(pszPropName));
HashMapType::const_iterator end = m_hashMap.end(); HashMapType::const_iterator it = m_hashMap.find(String(pszPropName));
if (it == end) HashMapType::const_iterator end = m_hashMap.end();
return E_INVALIDARG; if (it == end)
return E_INVALIDARG;
VARTYPE requestedType = V_VT(pVar);
V_VT(pVar) = VT_EMPTY; VARTYPE requestedType = V_VT(pVar);
COMVariantSetter<ValueType>::setVariant(pVar, it->second); V_VT(pVar) = VT_EMPTY;
COMVariantSetter<ValueType>::setVariant(pVar, it->second);
if (requestedType != COMVariantSetter<ValueType>::variantType(it->second) && requestedType != VT_EMPTY)
return ::VariantChangeType(pVar, pVar, VARIANT_NOUSEROVERRIDE | VARIANT_ALPHABOOL, requestedType); if (requestedType != COMVariantSetter<ValueType>::variantType(it->second) && requestedType != VT_EMPTY)
return ::VariantChangeType(pVar, pVar, VARIANT_NOUSEROVERRIDE | VARIANT_ALPHABOOL, requestedType);
return S_OK;
} return S_OK;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Write(LPCOLESTR pszPropName, VARIANT* pVar) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Write(LPCOLESTR pszPropName, VARIANT* pVar)
return E_FAIL; {
} return E_FAIL;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrorLog, VARIANT* pvarValue, HRESULT* phrError) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Read(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrorLog, VARIANT* pvarValue, HRESULT* phrError)
if (!pPropBag || !pvarValue || !phrError) {
return E_POINTER; if (!pPropBag || !pvarValue || !phrError)
return E_POINTER;
HRESULT hr = S_OK;
HRESULT hr = S_OK;
for (ULONG i = 0; i < cProperties; ++i) {
VariantInit(&pvarValue[i]); for (ULONG i = 0; i < cProperties; ++i) {
pvarValue[i].vt = pPropBag[i].vt; VariantInit(&pvarValue[i]);
phrError[i] = Read(pPropBag[i].pstrName, &pvarValue[i], pErrorLog); pvarValue[i].vt = pPropBag[i].vt;
if (FAILED(phrError[i])) phrError[i] = Read(pPropBag[i].pstrName, &pvarValue[i], pErrorLog);
hr = E_FAIL; if (FAILED(phrError[i]))
} hr = E_FAIL;
}
return hr;
} return hr;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Write(ULONG cProperties, PROPBAG2*, VARIANT*) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::Write(ULONG cProperties, PROPBAG2*, VARIANT*)
return E_NOTIMPL; {
} return E_NOTIMPL;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::CountProperties(ULONG* pcProperties) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::CountProperties(ULONG* pcProperties)
if (!pcProperties) {
return E_POINTER; if (!pcProperties)
return E_POINTER;
*pcProperties = m_hashMap.size();
return S_OK; *pcProperties = m_hashMap.size();
} return S_OK;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::GetPropertyInfo(ULONG iProperty, ULONG cProperties, PROPBAG2* pPropBag, ULONG* pcProperties)
if (!pPropBag || !pcProperties) {
return E_POINTER; if (!pPropBag || !pcProperties)
return E_POINTER;
if (m_hashMap.size() <= iProperty)
return E_INVALIDARG; if (m_hashMap.size() <= iProperty)
return E_INVALIDARG;
*pcProperties = 0;
typedef HashMapType::const_iterator Iterator; *pcProperties = 0;
Iterator current = m_hashMap.begin(); typedef HashMapType::const_iterator Iterator;
Iterator end = m_hashMap.end(); Iterator current = m_hashMap.begin();
for (ULONG i = 0; i < iProperty; ++i, ++current) Iterator end = m_hashMap.end();
; for (ULONG i = 0; i < iProperty; ++i, ++current)
for (ULONG j = 0; j < cProperties && current != end; ++j, ++current) { ;
// FIXME: the following fields aren't filled in for (ULONG j = 0; j < cProperties && current != end; ++j, ++current) {
//pPropBag[j].cfType; // (CLIPFORMAT) Clipboard format or MIME type of the property. // FIXME: the following fields aren't filled in
//pPropBag[j].clsid; // (CLSID) CLSID of the object. This member is valid only if dwType is PROPBAG2_TYPE_OBJECT. //pPropBag[j].cfType; // (CLIPFORMAT) Clipboard format or MIME type of the property.
//pPropBag[j].clsid; // (CLSID) CLSID of the object. This member is valid only if dwType is PROPBAG2_TYPE_OBJECT.
pPropBag[j].dwType = PROPBAG2_TYPE_DATA;
pPropBag[j].vt = COMVariantSetter<ValueType>::variantType(current->second); pPropBag[j].dwType = PROPBAG2_TYPE_DATA;
pPropBag[j].dwHint = iProperty + j; pPropBag[j].vt = COMVariantSetter<ValueType>::variantType(current->second);
pPropBag[j].pstrName = (LPOLESTR)CoTaskMemAlloc(sizeof(wchar_t)*(current->first.length()+1)); pPropBag[j].dwHint = iProperty + j;
if (!pPropBag[j].pstrName) pPropBag[j].pstrName = (LPOLESTR)CoTaskMemAlloc(sizeof(wchar_t)*(current->first.length()+1));
return E_OUTOFMEMORY; if (!pPropBag[j].pstrName)
wcscpy_s(pPropBag[j].pstrName, current->first.length()+1, static_cast<String>(current->first).charactersWithNullTermination()); return E_OUTOFMEMORY;
++*pcProperties; wcscpy_s(pPropBag[j].pstrName, current->first.length()+1, static_cast<String>(current->first).charactersWithNullTermination());
} ++*pcProperties;
return S_OK; }
} return S_OK;
}
template<typename ValueType, typename KeyType, typename HashType>
HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown*, IErrorLog*) template<typename ValueType, typename KeyType, typename HashType>
{ HRESULT STDMETHODCALLTYPE COMPropertyBag<ValueType, KeyType, HashType>::LoadObject(LPCOLESTR pstrName, DWORD dwHint, IUnknown*, IErrorLog*)
return E_NOTIMPL; {
} return E_NOTIMPL;
}
#endif // COMPropertyBag_h
#endif // COMPropertyBag_h
2011-03-28 Patrick Gansterer <paroga@webkit.org>
Unreviewed build fix.
* COMPropertyBag.h: Added missing include.
* WebKitCOMAPI.h: Ditto.
* WebCoreSupport/WebFrameLoaderClient.h: Added missing forward declaration.
2011-03-25 Sam Weinig <sam@webkit.org> 2011-03-25 Sam Weinig <sam@webkit.org>
Reviewed by Jon Honeycutt. Reviewed by Jon Honeycutt.
......
...@@ -40,6 +40,7 @@ namespace WebCore { ...@@ -40,6 +40,7 @@ namespace WebCore {
template <typename T> class COMPtr; template <typename T> class COMPtr;
class WebFrame; class WebFrame;
class WebHistory;
class WebFrameLoaderClient : public WebCore::FrameLoaderClient { class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
public: public:
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#ifndef WebKitCOMAPI_h #ifndef WebKitCOMAPI_h
#define WebKitCOMAPI_h #define WebKitCOMAPI_h
#include <unknwn.h>
extern "C" { extern "C" {
// Callers should use this API instead of CoCreateInstance to instantiate WebKit COM classes. // Callers should use this API instead of CoCreateInstance to instantiate WebKit COM classes.
......
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