[Win] Implement DOMNode::attributes.
authorpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Sep 2015 18:18:51 +0000 (18:18 +0000)
committerpeavo@outlook.com <peavo@outlook.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Sep 2015 18:18:51 +0000 (18:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148747

Reviewed by Brent Fulgham.

* DOMCoreClasses.cpp:
(DOMNode::attributes):
(DOMNode::ownerDocument):
(DOMRange::detach):
(DOMNamedNodeMap::DOMNamedNodeMap):
(DOMNamedNodeMap::~DOMNamedNodeMap):
(DOMNamedNodeMap::createInstance):
(DOMNamedNodeMap::QueryInterface):
(DOMNamedNodeMap::getNamedItem):
(DOMNamedNodeMap::setNamedItem):
(DOMNamedNodeMap::removeNamedItem):
(DOMNamedNodeMap::item):
(DOMNamedNodeMap::length):
(DOMNamedNodeMap::getNamedItemNS):
(DOMNamedNodeMap::setNamedItemNS):
(DOMNamedNodeMap::removeNamedItemNS):
* DOMCoreClasses.h:
(DOMNamedNodeMap::AddRef):
(DOMNamedNodeMap::Release):
(DOMNamedNodeMap::throwException):
(DOMNamedNodeMap::callWebScriptMethod):
(DOMNamedNodeMap::evaluateWebScript):
(DOMNamedNodeMap::removeWebScriptKey):
(DOMNamedNodeMap::stringRepresentation):
(DOMNamedNodeMap::webScriptValueAtIndex):
(DOMNamedNodeMap::setWebScriptValueAtIndex):
(DOMNamedNodeMap::setException):

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

Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp
Source/WebKit/win/DOMCoreClasses.h

index b8ad98a..225dfee 100644 (file)
@@ -1,3 +1,38 @@
+2015-09-08  Per Arne Vollan  <peavo@outlook.com>
+
+        [Win] Implement DOMNode::attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=148747
+
+        Reviewed by Brent Fulgham.
+
+        * DOMCoreClasses.cpp:
+        (DOMNode::attributes):
+        (DOMNode::ownerDocument):
+        (DOMRange::detach):
+        (DOMNamedNodeMap::DOMNamedNodeMap):
+        (DOMNamedNodeMap::~DOMNamedNodeMap):
+        (DOMNamedNodeMap::createInstance):
+        (DOMNamedNodeMap::QueryInterface):
+        (DOMNamedNodeMap::getNamedItem):
+        (DOMNamedNodeMap::setNamedItem):
+        (DOMNamedNodeMap::removeNamedItem):
+        (DOMNamedNodeMap::item):
+        (DOMNamedNodeMap::length):
+        (DOMNamedNodeMap::getNamedItemNS):
+        (DOMNamedNodeMap::setNamedItemNS):
+        (DOMNamedNodeMap::removeNamedItemNS):
+        * DOMCoreClasses.h:
+        (DOMNamedNodeMap::AddRef):
+        (DOMNamedNodeMap::Release):
+        (DOMNamedNodeMap::throwException):
+        (DOMNamedNodeMap::callWebScriptMethod):
+        (DOMNamedNodeMap::evaluateWebScript):
+        (DOMNamedNodeMap::removeWebScriptKey):
+        (DOMNamedNodeMap::stringRepresentation):
+        (DOMNamedNodeMap::webScriptValueAtIndex):
+        (DOMNamedNodeMap::setWebScriptValueAtIndex):
+        (DOMNamedNodeMap::setException):
+
 2015-09-04  Brian Burg  <bburg@apple.com>
 
         Web Inspector: agents should send messages through FrontendRouter instead of FrontendChannel
index 7ce88ed..73b67b5 100644 (file)
@@ -47,6 +47,7 @@
 #include <WebCore/HTMLOptionElement.h>
 #include <WebCore/HTMLSelectElement.h>
 #include <WebCore/HTMLTextAreaElement.h>
+#include <WebCore/NamedNodeMap.h>
 #include <WebCore/NodeList.h>
 #include <WebCore/Range.h>
 #include <WebCore/RenderElement.h>
@@ -212,11 +213,13 @@ HRESULT DOMNode::nextSibling(_COM_Outptr_opt_ IDOMNode** result)
 
 HRESULT DOMNode::attributes(_COM_Outptr_opt_ IDOMNamedNodeMap** result)
 {
-    ASSERT_NOT_REACHED();
     if (!result)
         return E_POINTER;
     *result = nullptr;
-    return E_NOTIMPL;
+    if (!m_node)
+        return E_FAIL;
+    *result = DOMNamedNodeMap::createInstance(m_node->attributes());
+    return *result ? S_OK : E_FAIL;
 }
 
 HRESULT DOMNode::ownerDocument(_COM_Outptr_opt_ IDOMDocument** result)
@@ -1795,3 +1798,89 @@ HRESULT DOMRange::detach()
     ASSERT_NOT_REACHED();
     return E_NOTIMPL;
 }
+
+DOMNamedNodeMap::DOMNamedNodeMap(WebCore::NamedNodeMap* nodeMap)
+    : m_nodeMap(nodeMap)
+{
+}
+
+DOMNamedNodeMap::~DOMNamedNodeMap()
+{
+}
+
+IDOMNamedNodeMap* DOMNamedNodeMap::createInstance(WebCore::NamedNodeMap* nodeMap)
+{
+    if (!nodeMap)
+        return nullptr;
+
+    DOMNamedNodeMap* namedNodeMap = new DOMNamedNodeMap(nodeMap);
+
+    IDOMNamedNodeMap* domNamedNodeMap = nullptr;
+    if (FAILED(namedNodeMap->QueryInterface(IID_IDOMNamedNodeMap, reinterpret_cast<void**>(&domNamedNodeMap))))
+        return nullptr;
+
+    return namedNodeMap;
+}
+
+HRESULT DOMNamedNodeMap::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject)
+{
+    *ppvObject = nullptr;
+    if (IsEqualGUID(riid, IID_IDOMNamedNodeMap))
+        *ppvObject = static_cast<IDOMNamedNodeMap*>(this);
+    else
+        return DOMObject::QueryInterface(riid, ppvObject);
+
+    AddRef();
+    return S_OK;
+}
+
+HRESULT DOMNamedNodeMap::getNamedItem(_In_ BSTR name, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DOMNamedNodeMap::setNamedItem(_In_opt_ IDOMNode* arg, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DOMNamedNodeMap::removeNamedItem(_In_ BSTR name, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DOMNamedNodeMap::item(_In_ UINT index, _COM_Outptr_opt_ IDOMNode** result)
+{
+    if (!result)
+        return E_POINTER;
+    
+    if (!m_nodeMap)
+        return E_FAIL;
+
+    *result = DOMNode::createInstance(m_nodeMap->item(index).get());
+    return *result ? S_OK : E_FAIL;
+}
+
+HRESULT DOMNamedNodeMap::length(_Out_opt_ UINT* result)
+{
+    if (!result)
+        return E_POINTER;
+
+    *result = m_nodeMap->length();
+    return S_OK;
+}
+
+HRESULT DOMNamedNodeMap::getNamedItemNS(_In_ BSTR namespaceURI, _In_ BSTR localName, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DOMNamedNodeMap::setNamedItemNS(_In_opt_ IDOMNode* arg, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT DOMNamedNodeMap::removeNamedItemNS(_In_ BSTR namespaceURI, _In_ BSTR localName, _COM_Outptr_opt_ IDOMNode** result)
+{
+    return E_NOTIMPL;
+}
index cfb4449..ac643b6 100644 (file)
@@ -36,6 +36,7 @@ class DOMWindow;
 class Node;
 class NodeList;
 class Range;
+class NamedNodeMap;
 }
 
 
@@ -898,4 +899,72 @@ public:
 protected:
     WebCore::Range* m_range;
 };
+
+class DOMNamedNodeMap : public DOMObject, public IDOMNamedNodeMap {
+protected:
+    DOMNamedNodeMap(WebCore::NamedNodeMap*);
+    ~DOMNamedNodeMap();
+
+public:
+    static IDOMNamedNodeMap* createInstance(WebCore::NamedNodeMap*);
+
+    // IUnknown
+    virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject);
+    virtual ULONG STDMETHODCALLTYPE AddRef(void) { return DOMObject::AddRef(); }
+    virtual ULONG STDMETHODCALLTYPE Release(void) { return DOMObject::Release(); }
+
+    virtual HRESULT STDMETHODCALLTYPE getNamedItem(_In_ BSTR name, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE setNamedItem(_In_opt_ IDOMNode* arg, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE removeNamedItem(_In_ BSTR name, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE item(_In_ UINT index, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE length(_Out_ UINT* result);
+    virtual HRESULT STDMETHODCALLTYPE getNamedItemNS(_In_ BSTR namespaceURI, _In_ BSTR localName, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE setNamedItemNS(_In_opt_ IDOMNode* arg, _COM_Outptr_opt_ IDOMNode** result);
+    virtual HRESULT STDMETHODCALLTYPE removeNamedItemNS(_In_ BSTR namespaceURI, _In_ BSTR localName, _COM_Outptr_opt_ IDOMNode** result);
+
+    // IWebScriptObject
+    virtual HRESULT STDMETHODCALLTYPE throwException(_In_ BSTR exceptionMessage, _Out_ BOOL* result)
+    {
+        return DOMObject::throwException(exceptionMessage, result);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE callWebScriptMethod(_In_ BSTR name, _In_ const VARIANT args[], _In_ int cArgs, _Out_ VARIANT* result)
+    {
+        return DOMObject::callWebScriptMethod(name, args, cArgs, result);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE evaluateWebScript(_In_ BSTR script, _Out_ VARIANT* result)
+    {
+        return DOMObject::evaluateWebScript(script, result);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE removeWebScriptKey(_In_ BSTR name)
+    {
+        return DOMObject::removeWebScriptKey(name);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE stringRepresentation(_Out_ BSTR* stringRepresentation)
+    {
+        return DOMObject::stringRepresentation(stringRepresentation);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE webScriptValueAtIndex(_In_ unsigned index, _Out_ VARIANT* result)
+    {
+        return DOMObject::webScriptValueAtIndex(index, result);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE setWebScriptValueAtIndex(_In_ unsigned index, _In_ VARIANT val)
+    {
+        return DOMObject::setWebScriptValueAtIndex(index, val);
+    }
+
+    virtual HRESULT STDMETHODCALLTYPE setException(_In_ BSTR description)
+    {
+        return DOMObject::setException(description);
+    }
+
+protected:
+    WebCore::NamedNodeMap* m_nodeMap;
+};
+
 #endif