push 149f0a5527ac85057a8ef03858d34d91c36f97e8
[wine/hacks.git] / dlls / mshtml / htmliframe.c
blob2132df353081981e0530326df3f00d7c457f0009
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "mshtml_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 HTMLFrameBase framebase;
37 LONG ref;
39 nsIDOMHTMLIFrameElement *nsiframe;
40 } HTMLIFrame;
42 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
44 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
46 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
48 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
51 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
53 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
55 if(This->nsiframe)
56 nsIDOMHTMLIFrameElement_Release(This->nsiframe);
58 HTMLFrameBase_destructor(&This->framebase);
61 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
63 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
65 if(!This->framebase.content_window || !This->framebase.content_window->doc) {
66 *p = NULL;
67 return S_OK;
70 *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc);
71 IDispatch_AddRef(*p);
72 return S_OK;
75 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
77 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
79 return IHTMLFrameBase2_get_readyState(HTMLFRAMEBASE2(&This->framebase), p);
82 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
84 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
85 nsIDOMDocument *nsdoc;
86 nsresult nsres;
87 HRESULT hres;
89 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->nsiframe, &nsdoc);
90 if(NS_FAILED(nsres) || !nsdoc) {
91 ERR("GetContentDocument failed: %08x\n", nsres);
92 return E_FAIL;
95 hres = set_frame_doc(&This->framebase, nsdoc);
96 nsIDOMDocument_Release(nsdoc);
97 return hres;
100 #undef HTMLIFRAME_NODE_THIS
102 static const NodeImplVtbl HTMLIFrameImplVtbl = {
103 HTMLIFrame_QI,
104 HTMLIFrame_destructor,
105 NULL,
106 NULL,
107 NULL,
108 NULL,
109 HTMLIFrame_get_document,
110 HTMLIFrame_get_readystate,
111 NULL,
112 NULL,
113 HTMLIFrame_bind_to_tree
116 static const tid_t HTMLIFrame_iface_tids[] = {
117 IHTMLDOMNode_tid,
118 IHTMLDOMNode2_tid,
119 IHTMLElement_tid,
120 IHTMLElement2_tid,
121 IHTMLElement3_tid,
122 IHTMLFrameBase_tid,
123 IHTMLFrameBase2_tid,
127 static dispex_static_data_t HTMLIFrame_dispex = {
128 NULL,
129 DispHTMLIFrame_tid,
130 NULL,
131 HTMLIFrame_iface_tids
134 HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
136 HTMLIFrame *ret;
137 nsresult nsres;
139 ret = heap_alloc_zero(sizeof(HTMLIFrame));
141 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
143 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe);
144 if(NS_FAILED(nsres))
145 ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres);
147 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
149 return &ret->framebase.element;