Move FormValuesPropertyBag into its own files
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2008 19:07:53 +0000 (19:07 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2008 19:07:53 +0000 (19:07 +0000)
         Reviewed by Sam.

         * WebCoreSupport/FormValuesPropertyBag.cpp: Added.
         (FormValuesPropertyBag::QueryInterface):
         (FormValuesPropertyBag::AddRef):
         (FormValuesPropertyBag::Release):
         (FormValuesPropertyBag::Read):
         (FormValuesPropertyBag::Write):
         (FormValuesPropertyBag::CountProperties):
         (FormValuesPropertyBag::GetPropertyInfo):
         (FormValuesPropertyBag::LoadObject):
         * WebCoreSupport/FormValuesPropertyBag.h: Added.
         (FormValuesPropertyBag::FormValuesPropertyBag):
         * WebFrame.cpp: Deleted FormValuesPropertyBag code.
         * WebKit.vcproj/WebKit.vcproj: Added new files to the project.

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

WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/FormValuesPropertyBag.cpp [new file with mode: 0644]
WebKit/win/WebCoreSupport/FormValuesPropertyBag.h [new file with mode: 0644]
WebKit/win/WebFrame.cpp
WebKit/win/WebKit.vcproj/WebKit.vcproj

index 280428d3a0974a99d7e9c58558b38de1801d4f85..6e29b43796fc6d6eb418c275235107102138b15a 100644 (file)
@@ -1,3 +1,23 @@
+2008-02-22  Adam Roben  <aroben@apple.com>
+
+        Move FormValuesPropertyBag into its own files
+
+        Reviewed by Sam.
+
+        * WebCoreSupport/FormValuesPropertyBag.cpp: Added.
+        (FormValuesPropertyBag::QueryInterface):
+        (FormValuesPropertyBag::AddRef):
+        (FormValuesPropertyBag::Release):
+        (FormValuesPropertyBag::Read):
+        (FormValuesPropertyBag::Write):
+        (FormValuesPropertyBag::CountProperties):
+        (FormValuesPropertyBag::GetPropertyInfo):
+        (FormValuesPropertyBag::LoadObject):
+        * WebCoreSupport/FormValuesPropertyBag.h: Added.
+        (FormValuesPropertyBag::FormValuesPropertyBag):
+        * WebFrame.cpp: Deleted FormValuesPropertyBag code.
+        * WebKit.vcproj/WebKit.vcproj: Added new files to the project.
+
 2008-02-22  Adam Roben  <aroben@apple.com>
 
         Remove some unused WebFrame methods
diff --git a/WebKit/win/WebCoreSupport/FormValuesPropertyBag.cpp b/WebKit/win/WebCoreSupport/FormValuesPropertyBag.cpp
new file mode 100644 (file)
index 0000000..56bdd74
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 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 "config.h"
+#include "FormValuesPropertyBag.h"
+
+using namespace WebCore;
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::QueryInterface(REFIID riid, void** ppvObject)
+{
+    *ppvObject = 0;
+    if (IsEqualGUID(riid, IID_IUnknown))
+        *ppvObject = this;
+    else if (IsEqualGUID(riid, IID_IPropertyBag))
+        *ppvObject = static_cast<IPropertyBag*>(this);
+    else if (IsEqualGUID(riid, IID_IPropertyBag2))
+        *ppvObject = static_cast<IPropertyBag2*>(this);
+    else
+        return E_NOINTERFACE;
+
+    AddRef();
+    return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE FormValuesPropertyBag::AddRef(void)
+{
+    return 1;
+}
+
+ULONG STDMETHODCALLTYPE FormValuesPropertyBag::Release(void)
+{
+    return 0;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* /*pErrorLog*/)
+{
+    HRESULT hr = S_OK;
+
+    if (!pszPropName || !pVar)
+        return E_POINTER;
+
+    String key(pszPropName);
+    if (!m_formValues->contains(key))
+        return E_INVALIDARG;
+
+    String value = m_formValues->get(key);
+
+    VARTYPE requestedType = V_VT(pVar);
+    VariantClear(pVar);
+    V_VT(pVar) = VT_BSTR;
+    V_BSTR(pVar) = SysAllocStringLen(value.characters(), value.length());
+    if (value.length() && !V_BSTR(pVar))
+        return E_OUTOFMEMORY;
+
+    if (requestedType != VT_BSTR && requestedType != VT_EMPTY)
+        hr = VariantChangeType(pVar, pVar, VARIANT_NOUSEROVERRIDE | VARIANT_ALPHABOOL, requestedType);
+
+    return hr;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write(LPCOLESTR pszPropName, VARIANT* pVar)
+{
+    if (!pszPropName || !pVar)
+        return E_POINTER;
+    VariantClear(pVar);
+    return E_FAIL;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read(
+    /* [in] */ ULONG cProperties,
+    /* [in] */ PROPBAG2* pPropBag,
+    /* [in] */ IErrorLog* pErrLog,
+    /* [out] */ VARIANT* pvarValue,
+    /* [out] */ HRESULT* phrError)
+{
+    if (cProperties > (size_t)m_formValues->size())
+        return E_INVALIDARG;
+    if (!pPropBag || !pvarValue || !phrError)
+        return E_POINTER;
+
+    for (ULONG i=0; i<cProperties; i++) {
+        VariantInit(&pvarValue[i]);
+        phrError[i] = Read(pPropBag->pstrName, &pvarValue[i], pErrLog);
+    }
+
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write(
+    /* [in] */ ULONG /*cProperties*/,
+    /* [in] */ PROPBAG2* pPropBag,
+    /* [in] */ VARIANT* pvarValue)
+{
+    if (!pPropBag || !pvarValue)
+        return E_POINTER;
+    return E_FAIL;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::CountProperties(
+    /* [out] */ ULONG* pcProperties)
+{
+    *pcProperties = m_formValues->size();
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::GetPropertyInfo(
+    /* [in] */ ULONG iProperty,
+    /* [in] */ ULONG cProperties,
+    /* [out] */ PROPBAG2* pPropBag,
+    /* [out] */ ULONG* pcProperties)
+{
+    if (iProperty > (size_t)m_formValues->size() || iProperty+cProperties > (size_t)m_formValues->size())
+        return E_INVALIDARG;
+    if (!pPropBag || !pcProperties)
+        return E_POINTER;
+
+    *pcProperties = 0;
+    ULONG i = 0;
+    ULONG endProperty = iProperty + cProperties;
+    for (HashMap<String, String>::iterator it = m_formValues->begin(); i<endProperty; i++) {
+        if (i >= iProperty) {
+            int storeIndex = (*pcProperties)++;
+            pPropBag[storeIndex].dwType = PROPBAG2_TYPE_DATA;
+            pPropBag[storeIndex].vt = VT_BSTR;
+            pPropBag[storeIndex].cfType = CF_TEXT;
+            pPropBag[storeIndex].dwHint = 0;
+            pPropBag[storeIndex].pstrName = const_cast<LPOLESTR>(it->first.charactersWithNullTermination());
+        }
+        ++it;
+    }
+
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::LoadObject(
+    /* [in] */ LPCOLESTR pstrName,
+    /* [in] */ DWORD /*dwHint*/,
+    /* [in] */ IUnknown* pUnkObject,
+    /* [in] */ IErrorLog* /*pErrLog*/)
+{
+    if (!pstrName || !pUnkObject)
+        return E_POINTER;
+    return E_FAIL;
+}
diff --git a/WebKit/win/WebCoreSupport/FormValuesPropertyBag.h b/WebKit/win/WebCoreSupport/FormValuesPropertyBag.h
new file mode 100644 (file)
index 0000000..89dc728
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2006, 2007, 2008 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.
+ */
+
+#ifndef FormValuesPropertyBag_h
+#define FormValuesPropertyBag_h
+
+#pragma warning(push, 0)
+#include <WebCore/StringHash.h>
+#pragma warning(pop)
+#include <wtf/HashMap.h>
+
+class FormValuesPropertyBag : public IPropertyBag, public IPropertyBag2 {
+public:
+    FormValuesPropertyBag(HashMap<WebCore::String, WebCore::String>* formValues)
+        : m_formValues(formValues)
+    {
+    }
+
+    // IUnknown
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef();
+    virtual ULONG STDMETHODCALLTYPE Release();
+
+    // IPropertyBag
+    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(
+        /* [in] */ LPCOLESTR pszPropName,
+        /* [out][in] */ VARIANT*,
+        /* [in] */ IErrorLog*);
+
+    virtual HRESULT STDMETHODCALLTYPE Write(
+        /* [in] */ LPCOLESTR pszPropName,
+        /* [in] */ VARIANT*);
+
+    // IPropertyBag2
+    virtual HRESULT STDMETHODCALLTYPE Read(
+        /* [in] */ ULONG cProperties,
+        /* [in] */ PROPBAG2*,
+        /* [in] */ IErrorLog*,
+        /* [out] */ VARIANT* pvarValue,
+        /* [out] */ HRESULT* phrError);
+
+    virtual HRESULT STDMETHODCALLTYPE Write(
+        /* [in] */ ULONG cProperties,
+        /* [in] */ PROPBAG2*,
+        /* [in] */ VARIANT*);
+
+    virtual HRESULT STDMETHODCALLTYPE CountProperties(
+        /* [out] */ ULONG* pcProperties);
+
+    virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(
+        /* [in] */ ULONG iProperty,
+        /* [in] */ ULONG cProperties,
+        /* [out] */ PROPBAG2* pPropBag,
+        /* [out] */ ULONG* pcProperties);
+
+    virtual HRESULT STDMETHODCALLTYPE LoadObject(
+        /* [in] */ LPCOLESTR pstrName,
+        /* [in] */ DWORD dwHint,
+        /* [in] */ IUnknown*,
+        /* [in] */ IErrorLog*);
+
+protected:
+    HashMap<WebCore::String, WebCore::String>* m_formValues;
+};
+
+#endif // FormValuesPropertyBag_h
index 8a7c8b7505bd01d10ec3921283fb9b9aa153d16c..5ab9e30bad22f52141e5f88a194efd8a812faa26 100644 (file)
@@ -31,6 +31,7 @@
 #include "COMPtr.h"
 #include "DefaultPolicyDelegate.h"
 #include "DOMCoreClasses.h"
+#include "FormValuesPropertyBag.h"
 #include "MarshallingHelpers.h"
 #include "WebActionPropertyBag.h"
 #include "WebCachedPagePlatformData.h"
@@ -165,197 +166,6 @@ WebView* kit(Page* page)
 
 //-----------------------------------------------------------------------------
 
-class FormValuesPropertyBag : public IPropertyBag, public IPropertyBag2
-{
-public:
-    FormValuesPropertyBag(HashMap<String, String>* formValues) : m_formValues(formValues) {}
-
-    // IUnknown
-    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
-    virtual ULONG STDMETHODCALLTYPE AddRef(void);
-    virtual ULONG STDMETHODCALLTYPE Release(void);
-
-    // IPropertyBag
-    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( 
-        /* [in] */ LPCOLESTR pszPropName,
-        /* [out][in] */ VARIANT* pVar,
-        /* [in] */ IErrorLog* pErrorLog);
-
-    virtual HRESULT STDMETHODCALLTYPE Write( 
-        /* [in] */ LPCOLESTR pszPropName,
-        /* [in] */ VARIANT* pVar);
-
-    // IPropertyBag2
-    virtual HRESULT STDMETHODCALLTYPE Read( 
-        /* [in] */ ULONG cProperties,
-        /* [in] */ PROPBAG2 *pPropBag,
-        /* [in] */ IErrorLog *pErrLog,
-        /* [out] */ VARIANT *pvarValue,
-        /* [out] */ HRESULT *phrError);
-    
-    virtual HRESULT STDMETHODCALLTYPE Write( 
-        /* [in] */ ULONG cProperties,
-        /* [in] */ PROPBAG2 *pPropBag,
-        /* [in] */ VARIANT *pvarValue);
-    
-    virtual HRESULT STDMETHODCALLTYPE CountProperties( 
-        /* [out] */ ULONG *pcProperties);
-    
-    virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo( 
-        /* [in] */ ULONG iProperty,
-        /* [in] */ ULONG cProperties,
-        /* [out] */ PROPBAG2 *pPropBag,
-        /* [out] */ ULONG *pcProperties);
-    
-    virtual HRESULT STDMETHODCALLTYPE LoadObject( 
-        /* [in] */ LPCOLESTR pstrName,
-        /* [in] */ DWORD dwHint,
-        /* [in] */ IUnknown *pUnkObject,
-        /* [in] */ IErrorLog *pErrLog);
-    
-protected:
-    HashMap<String, String>* m_formValues;
-};
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::QueryInterface(REFIID riid, void** ppvObject)
-{
-    *ppvObject = 0;
-    if (IsEqualGUID(riid, IID_IUnknown))
-        *ppvObject = this;
-    else if (IsEqualGUID(riid, IID_IPropertyBag))
-        *ppvObject = static_cast<IPropertyBag*>(this);
-    else if (IsEqualGUID(riid, IID_IPropertyBag2))
-        *ppvObject = static_cast<IPropertyBag2*>(this);
-    else
-        return E_NOINTERFACE;
-
-    AddRef();
-    return S_OK;
-}
-
-ULONG STDMETHODCALLTYPE FormValuesPropertyBag::AddRef(void)
-{
-    return 1;
-}
-
-ULONG STDMETHODCALLTYPE FormValuesPropertyBag::Release(void)
-{
-    return 0;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* /*pErrorLog*/)
-{
-    HRESULT hr = S_OK;
-
-    if (!pszPropName || !pVar)
-        return E_POINTER;
-
-    String key(pszPropName);
-    if (!m_formValues->contains(key))
-        return E_INVALIDARG;
-    
-    String value = m_formValues->get(key);
-
-    VARTYPE requestedType = V_VT(pVar);
-    VariantClear(pVar);
-    V_VT(pVar) = VT_BSTR;
-    V_BSTR(pVar) = SysAllocStringLen(value.characters(), value.length());
-    if (value.length() && !V_BSTR(pVar))
-        return E_OUTOFMEMORY;
-
-    if (requestedType != VT_BSTR && requestedType != VT_EMPTY)
-        hr = VariantChangeType(pVar, pVar, VARIANT_NOUSEROVERRIDE | VARIANT_ALPHABOOL, requestedType);
-    
-    return hr;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write(LPCOLESTR pszPropName, VARIANT* pVar)
-{
-    if (!pszPropName || !pVar)
-        return E_POINTER;
-    VariantClear(pVar);
-    return E_FAIL;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read( 
-    /* [in] */ ULONG cProperties,
-    /* [in] */ PROPBAG2* pPropBag,
-    /* [in] */ IErrorLog* pErrLog,
-    /* [out] */ VARIANT* pvarValue,
-    /* [out] */ HRESULT* phrError)
-{
-    if (cProperties > (size_t)m_formValues->size())
-        return E_INVALIDARG;
-    if (!pPropBag || !pvarValue || !phrError)
-        return E_POINTER;
-
-    for (ULONG i=0; i<cProperties; i++) {
-        VariantInit(&pvarValue[i]);
-        phrError[i] = Read(pPropBag->pstrName, &pvarValue[i], pErrLog);
-    }
-
-    return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write( 
-    /* [in] */ ULONG /*cProperties*/,
-    /* [in] */ PROPBAG2* pPropBag,
-    /* [in] */ VARIANT* pvarValue)
-{
-    if (!pPropBag || !pvarValue)
-        return E_POINTER;
-    return E_FAIL;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::CountProperties( 
-    /* [out] */ ULONG* pcProperties)
-{
-    *pcProperties = m_formValues->size();
-    return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::GetPropertyInfo( 
-    /* [in] */ ULONG iProperty,
-    /* [in] */ ULONG cProperties,
-    /* [out] */ PROPBAG2* pPropBag,
-    /* [out] */ ULONG* pcProperties)
-{
-    if (iProperty > (size_t)m_formValues->size() || iProperty+cProperties > (size_t)m_formValues->size())
-        return E_INVALIDARG;
-    if (!pPropBag || !pcProperties)
-        return E_POINTER;
-
-    *pcProperties = 0;
-    ULONG i = 0;
-    ULONG endProperty = iProperty + cProperties;
-    for (HashMap<String, String>::iterator it = m_formValues->begin(); i<endProperty; i++) {
-        if (i >= iProperty) {
-            int storeIndex = (*pcProperties)++;
-            pPropBag[storeIndex].dwType = PROPBAG2_TYPE_DATA;
-            pPropBag[storeIndex].vt = VT_BSTR;
-            pPropBag[storeIndex].cfType = CF_TEXT;
-            pPropBag[storeIndex].dwHint = 0;
-            pPropBag[storeIndex].pstrName = const_cast<LPOLESTR>(it->first.charactersWithNullTermination());
-        }
-        ++it;
-    }
-
-    return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::LoadObject( 
-    /* [in] */ LPCOLESTR pstrName,
-    /* [in] */ DWORD /*dwHint*/,
-    /* [in] */ IUnknown* pUnkObject,
-    /* [in] */ IErrorLog* /*pErrLog*/)
-{
-    if (!pstrName || !pUnkObject)
-        return E_POINTER;
-    return E_FAIL;
-}
-
-//-----------------------------------------------------------------------------
-
 static Element *elementFromDOMElement(IDOMElement *element)
 {
     if (!element)
index 66db7c00d6e73c97cd86590f2f12586b2fe18cf4..0a5d227f1db4801833e7f401ee45cdbcea6e28a8 100644 (file)
                <Filter\r
                        Name="WebCoreSupport"\r
                        >\r
+                       <File\r
+                               RelativePath="..\WebCoreSupport\FormValuesPropertyBag.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\WebCoreSupport\FormValuesPropertyBag.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\WebCoreSupport\WebChromeClient.cpp"\r
                                >\r