htmldoc5.c 13.6 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
/*
 * Copyright 2007 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 "config.h"

#include <stdarg.h>
#include <stdio.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);

37 38 39 40
static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
{
    return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
}
41 42 43 44

static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
        REFIID riid, void **ppv)
{
45
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
46
    return htmldoc_query_interface(This, riid, ppv);
47 48 49 50
}

static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
{
51
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
52
    return htmldoc_addref(This);
53 54 55 56
}

static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
{
57
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
58
    return htmldoc_release(This);
59 60 61 62
}

static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
{
63
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
64
    return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
65 66 67 68 69
}

static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
70
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
71
    return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
72 73 74 75 76
}

static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
77
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
78 79
    return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
            rgDispId);
80 81 82 83 84 85
}

static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
86
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
87 88
    return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
            pDispParams, pVarResult, pExcepInfo, puArgErr);
89 90 91 92
}

static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
{
93
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
94
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
95 96 97 98 99
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
{
100
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
101 102 103 104 105 106
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
{
107
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
108 109 110 111 112 113
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
{
114
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
115 116 117 118 119 120 121
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
        IHTMLDOMAttribute **ppattribute)
{
122
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
123 124 125 126 127 128 129
    FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
        IHTMLDOMNode **ppRetNode)
{
130
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
131
    nsIDOMComment *nscomment;
132
    HTMLElement *elem;
133 134
    nsAString str;
    nsresult nsres;
135
    HRESULT hres;
136 137 138

    TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);

139
    if(!This->doc_node->nsdoc) {
140 141 142 143
        WARN("NULL nsdoc\n");
        return E_UNEXPECTED;
    }

144
    nsAString_InitDepend(&str, bstrdata);
145
    nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
146 147 148 149 150 151
    nsAString_Finish(&str);
    if(NS_FAILED(nsres)) {
        ERR("CreateTextNode failed: %08x\n", nsres);
        return E_FAIL;
    }

152
    hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
153
    nsIDOMComment_Release(nscomment);
154 155
    if(FAILED(hres))
        return hres;
156

157
    *ppRetNode = &elem->node.IHTMLDOMNode_iface;
158
    return S_OK;
159 160 161 162
}

static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
{
163
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
164
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
165 166 167 168 169
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
{
170
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
171 172 173 174 175 176
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
{
177
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
178
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
179 180 181 182 183
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
{
184
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
185 186 187 188 189 190
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
{
191
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
192
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
193 194 195 196 197
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
{
198
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
199 200 201 202 203 204
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
{
205
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
206
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
207 208 209 210 211
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
{
212
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
213 214 215 216 217 218
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
{
219
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
220
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
221 222 223 224 225
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
{
226
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
227 228 229 230 231 232
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
{
233
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
234
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
235 236 237 238 239
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
{
240
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
241 242 243 244 245 246
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
{
247
    HTMLDocument *This = impl_from_IHTMLDocument5(iface);
248 249 250 251 252
    nsAString mode_str;
    const PRUnichar *mode;

    TRACE("(%p)->(%p)\n", This, p);

253
    if(!This->doc_node->nsdoc) {
254 255 256
        WARN("NULL nsdoc\n");
        return E_UNEXPECTED;
    }
257 258

    nsAString_Init(&mode_str, NULL);
259
    nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
260

261
    nsAString_GetData(&mode_str, &mode);
262 263 264 265
    *p = SysAllocString(mode);
    nsAString_Finish(&mode_str);

    return S_OK;
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
}

static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
    HTMLDocument5_QueryInterface,
    HTMLDocument5_AddRef,
    HTMLDocument5_Release,
    HTMLDocument5_GetTypeInfoCount,
    HTMLDocument5_GetTypeInfo,
    HTMLDocument5_GetIDsOfNames,
    HTMLDocument5_Invoke,
    HTMLDocument5_put_onmousewheel,
    HTMLDocument5_get_onmousewheel,
    HTMLDocument5_get_doctype,
    HTMLDocument5_get_implementation,
    HTMLDocument5_createAttribute,
    HTMLDocument5_createComment,
    HTMLDocument5_put_onfocusin,
    HTMLDocument5_get_onfocusin,
    HTMLDocument5_put_onfocusout,
    HTMLDocument5_get_onfocusout,
    HTMLDocument5_put_onactivate,
    HTMLDocument5_get_onactivate,
    HTMLDocument5_put_ondeactivate,
    HTMLDocument5_get_ondeactivate,
    HTMLDocument5_put_onbeforeactivate,
    HTMLDocument5_get_onbeforeactivate,
    HTMLDocument5_put_onbeforedeactivate,
    HTMLDocument5_get_onbeforedeactivate,
    HTMLDocument5_get_compatMode
};

297 298 299 300
static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
{
    return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
}
301 302 303 304

static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
        REFIID riid, void **ppv)
{
305
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
306
    return htmldoc_query_interface(This, riid, ppv);
307 308 309 310
}

static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
{
311
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
312
    return htmldoc_addref(This);
313 314 315 316
}

static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
{
317
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
318
    return htmldoc_release(This);
319 320 321 322
}

static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
{
323
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
324
    return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
325 326 327 328 329
}

static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
        LCID lcid, ITypeInfo **ppTInfo)
{
330
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
331
    return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
332 333 334 335 336
}

static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
337
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
338 339
    return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
            rgDispId);
340 341 342 343 344 345
}

static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
346
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
347 348
    return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
            pDispParams, pVarResult, pExcepInfo, puArgErr);
349 350 351 352 353
}

static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
        IHTMLDocumentCompatibleInfoCollection **p)
{
354
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
355 356 357 358 359 360 361
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
        VARIANT *p)
{
362
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
363 364 365 366 367 368 369
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
        VARIANT *p)
{
370
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
371 372 373 374
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

375
static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
376
{
377
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
378
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
379 380 381 382 383 384
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
        VARIANT *p)
{
385
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
386 387 388 389
    FIXME("(%p)->(%p)\n", This, p);
    return E_NOTIMPL;
}

390
static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
391
{
392
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
393
    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
394 395 396 397 398 399
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
        BSTR bstrId, IHTMLElement2 **p)
{
400
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
401 402 403 404 405 406
    FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
    return E_NOTIMPL;
}

static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
{
407
    HTMLDocument *This = impl_from_IHTMLDocument6(iface);
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
    FIXME("(%p)->()\n", This);
    return E_NOTIMPL;
}

static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
    HTMLDocument6_QueryInterface,
    HTMLDocument6_AddRef,
    HTMLDocument6_Release,
    HTMLDocument6_GetTypeInfoCount,
    HTMLDocument6_GetTypeInfo,
    HTMLDocument6_GetIDsOfNames,
    HTMLDocument6_Invoke,
    HTMLDocument6_get_compatible,
    HTMLDocument6_get_documentMode,
    HTMLDocument6_put_onstorage,
    HTMLDocument6_get_onstorage,
    HTMLDocument6_put_onstoragecommit,
    HTMLDocument6_get_onstoragecommit,
    HTMLDocument6_getElementById,
    HTMLDocument6_updateSettings
};

430 431
void HTMLDocument_HTMLDocument5_Init(HTMLDocument *This)
{
432
    This->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
433
    This->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
434
}