htmlgeneric.c 6.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*
 * Copyright 2008 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */


#include <stdarg.h>

#define COBJMACROS

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"

#include "wine/debug.h"

#include "mshtml_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(mshtml);

typedef struct {
    HTMLElement element;

38
    IHTMLGenericElement IHTMLGenericElement_iface;
39 40
} HTMLGenericElement;

41 42 43 44
static inline HTMLGenericElement *impl_from_IHTMLGenericElement(IHTMLGenericElement *iface)
{
    return CONTAINING_RECORD(iface, HTMLGenericElement, IHTMLGenericElement_iface);
}
45 46 47

static HRESULT WINAPI HTMLGenericElement_QueryInterface(IHTMLGenericElement *iface, REFIID riid, void **ppv)
{
48
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
49

50
    return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
51 52 53 54
}

static ULONG WINAPI HTMLGenericElement_AddRef(IHTMLGenericElement *iface)
{
55
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
56

57
    return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
58 59 60 61
}

static ULONG WINAPI HTMLGenericElement_Release(IHTMLGenericElement *iface)
{
62
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
63

64
    return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
65 66 67 68
}

static HRESULT WINAPI HTMLGenericElement_GetTypeInfoCount(IHTMLGenericElement *iface, UINT *pctinfo)
{
69
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
70
    return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
71 72 73 74 75
}

static HRESULT WINAPI HTMLGenericElement_GetTypeInfo(IHTMLGenericElement *iface, UINT iTInfo,
                                              LCID lcid, ITypeInfo **ppTInfo)
{
76
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
77
    return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
78
            ppTInfo);
79 80 81 82 83
}

static HRESULT WINAPI HTMLGenericElement_GetIDsOfNames(IHTMLGenericElement *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
84
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
85
    return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
86
            cNames, lcid, rgDispId);
87 88 89 90 91 92
}

static HRESULT WINAPI HTMLGenericElement_Invoke(IHTMLGenericElement *iface, DISPID dispIdMember,
        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
93
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
94
    return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
95
            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
96 97 98 99
}

static HRESULT WINAPI HTMLGenericElement_get_recordset(IHTMLGenericElement *iface, IDispatch **p)
{
100
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
101 102 103 104 105 106 107
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLGenericElement_namedRecordset(IHTMLGenericElement *iface,
        BSTR dataMember, VARIANT *hierarchy, IDispatch **ppRecordset)
{
108
    HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
    FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
    return E_NOTIMPL;
}

static const IHTMLGenericElementVtbl HTMLGenericElementVtbl = {
    HTMLGenericElement_QueryInterface,
    HTMLGenericElement_AddRef,
    HTMLGenericElement_Release,
    HTMLGenericElement_GetTypeInfoCount,
    HTMLGenericElement_GetTypeInfo,
    HTMLGenericElement_GetIDsOfNames,
    HTMLGenericElement_Invoke,
    HTMLGenericElement_get_recordset,
    HTMLGenericElement_namedRecordset
};

125 126 127 128
static inline HTMLGenericElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
{
    return CONTAINING_RECORD(iface, HTMLGenericElement, element.node);
}
129 130 131

static HRESULT HTMLGenericElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
132
    HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
133 134 135 136 137

    *ppv = NULL;

    if(IsEqualGUID(&IID_IHTMLGenericElement, riid)) {
        TRACE("(%p)->(IID_IHTMLGenericElement %p)\n", This, ppv);
138
        *ppv = &This->IHTMLGenericElement_iface;
139 140 141 142 143 144 145 146 147 148
    }else {
        return HTMLElement_QI(&This->element.node, riid, ppv);
    }

    IUnknown_AddRef((IUnknown*)*ppv);
    return S_OK;
}

static void HTMLGenericElement_destructor(HTMLDOMNode *iface)
{
149
    HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
150 151 152 153 154 155

    HTMLElement_destructor(&This->element.node);
}

static const NodeImplVtbl HTMLGenericElementImplVtbl = {
    HTMLGenericElement_QI,
156
    HTMLGenericElement_destructor,
157
    HTMLElement_cpc,
158
    HTMLElement_clone,
159
    HTMLElement_handle_event,
160
    HTMLElement_get_attr_col
161 162
};

163
static const tid_t HTMLGenericElement_iface_tids[] = {
164
    HTMLELEMENT_TIDS,
165 166 167 168 169 170 171
    IHTMLGenericElement_tid,
    0
};

static dispex_static_data_t HTMLGenericElement_dispex = {
    NULL,
    DispHTMLGenericElement_tid,
172 173
    HTMLGenericElement_iface_tids,
    HTMLElement_init_dispex_info
174 175
};

176
HRESULT HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
177 178 179 180
{
    HTMLGenericElement *ret;

    ret = heap_alloc_zero(sizeof(HTMLGenericElement));
181 182
    if(!ret)
        return E_OUTOFMEMORY;
183

184
    ret->IHTMLGenericElement_iface.lpVtbl = &HTMLGenericElementVtbl;
185 186
    ret->element.node.vtbl = &HTMLGenericElementImplVtbl;

187
    HTMLElement_Init(&ret->element, doc, nselem, &HTMLGenericElement_dispex);
188

189 190
    *elem = &ret->element;
    return S_OK;
191
}