wbemprox: Implement IEnumWbemClassObject::Clone.
[wine] / dlls / mshtml / htmlframebase.c
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20 #include <assert.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28
29 #include "mshtml_private.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 static const WCHAR autoW[] = {'a','u','t','o',0};
36 static const WCHAR yesW[] = {'y','e','s',0};
37 static const WCHAR noW[] = {'n','o',0};
38
39 HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
40 {
41     nsIDOMWindow *nswindow;
42     HTMLOuterWindow *window;
43     nsresult nsres;
44     HRESULT hres = S_OK;
45
46     if(frame->content_window)
47         return S_OK;
48
49     nsres = nsIDOMDocument_GetDefaultView(nsdoc, &nswindow);
50     if(NS_FAILED(nsres) || !nswindow)
51         return E_FAIL;
52
53     window = nswindow_to_window(nswindow);
54     if(!window)
55         hres = HTMLOuterWindow_Create(frame->element.node.doc->basedoc.doc_obj, nswindow,
56                 frame->element.node.doc->basedoc.window, &window);
57     nsIDOMWindow_Release(nswindow);
58     if(FAILED(hres))
59         return hres;
60
61     frame->content_window = window;
62     window->frame_element = frame;
63     return S_OK;
64 }
65
66 static inline HTMLFrameBase *impl_from_IHTMLFrameBase(IHTMLFrameBase *iface)
67 {
68     return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase_iface);
69 }
70
71 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
72 {
73     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
74
75     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
76 }
77
78 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
79 {
80     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
81
82     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
83 }
84
85 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
86 {
87     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
88
89     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
90 }
91
92 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
93 {
94     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
95
96     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
97 }
98
99 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
100         LCID lcid, ITypeInfo **ppTInfo)
101 {
102     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
103
104     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
105             ppTInfo);
106 }
107
108 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
109         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
110 {
111     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
112
113     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
114             cNames, lcid, rgDispId);
115 }
116
117 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
118         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
119         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
120 {
121     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
122
123     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
124             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
125 }
126
127 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
128 {
129     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
130
131     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
132
133     if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
134         FIXME("detached element\n");
135         return E_FAIL;
136     }
137
138     return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
139 }
140
141 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
142 {
143     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
144     FIXME("(%p)->(%p)\n", This, p);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
149 {
150     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
151     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
156 {
157     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
158     nsAString nsstr;
159     nsresult nsres;
160
161     TRACE("(%p)->(%p)\n", This, p);
162
163     if(!This->nsframe && !This->nsiframe) {
164         ERR("No attached ns frame object\n");
165         return E_UNEXPECTED;
166     }
167
168     nsAString_Init(&nsstr, NULL);
169     if(This->nsframe)
170         nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
171     else
172         nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
173     return return_nsstr(nsres, &nsstr, p);
174 }
175
176 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
177 {
178     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
179     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
184 {
185     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
186     FIXME("(%p)->(%p)\n", This, p);
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
191 {
192     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
193     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
198 {
199     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
200     FIXME("(%p)->(%p)\n", This, p);
201     return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
205 {
206     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
207     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
212 {
213     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
214     FIXME("(%p)->(%p)\n", This, p);
215     return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
219 {
220     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
221     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
222     return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
226 {
227     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
228     FIXME("(%p)->(%p)\n", This, p);
229     return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
233 {
234     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
235     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
236     return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
240 {
241     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
242     FIXME("(%p)->(%p)\n", This, p);
243     return E_NOTIMPL;
244 }
245
246 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
247 {
248     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
249     FIXME("(%p)->(%x)\n", This, v);
250     return E_NOTIMPL;
251 }
252
253 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
254 {
255     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
256     FIXME("(%p)->(%p)\n", This, p);
257     return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
261 {
262     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
263     nsAString nsstr;
264     nsresult nsres;
265
266     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
267
268     if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
269         return E_INVALIDARG;
270
271     if(This->nsframe) {
272         nsAString_InitDepend(&nsstr, v);
273         nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
274     }else if(This->nsiframe) {
275         nsAString_InitDepend(&nsstr, v);
276         nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
277     }else {
278         ERR("No attached ns frame object\n");
279         return E_UNEXPECTED;
280     }
281     nsAString_Finish(&nsstr);
282
283     if(NS_FAILED(nsres)) {
284         ERR("SetScrolling failed: 0x%08x\n", nsres);
285         return E_FAIL;
286     }
287
288     return S_OK;
289 }
290
291 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
292 {
293     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
294     nsAString nsstr;
295     const PRUnichar *strdata;
296     nsresult nsres;
297
298     TRACE("(%p)->(%p)\n", This, p);
299
300     if(This->nsframe) {
301         nsAString_Init(&nsstr, NULL);
302         nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
303     }else if(This->nsiframe) {
304         nsAString_Init(&nsstr, NULL);
305         nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
306     }else {
307         ERR("No attached ns frame object\n");
308         return E_UNEXPECTED;
309     }
310
311     if(NS_FAILED(nsres)) {
312         ERR("GetScrolling failed: 0x%08x\n", nsres);
313         nsAString_Finish(&nsstr);
314         return E_FAIL;
315     }
316
317     nsAString_GetData(&nsstr, &strdata);
318
319     if(*strdata)
320         *p = SysAllocString(strdata);
321     else
322         *p = SysAllocString(autoW);
323
324     nsAString_Finish(&nsstr);
325
326     return *p ? S_OK : E_OUTOFMEMORY;
327 }
328
329 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
330     HTMLFrameBase_QueryInterface,
331     HTMLFrameBase_AddRef,
332     HTMLFrameBase_Release,
333     HTMLFrameBase_GetTypeInfoCount,
334     HTMLFrameBase_GetTypeInfo,
335     HTMLFrameBase_GetIDsOfNames,
336     HTMLFrameBase_Invoke,
337     HTMLFrameBase_put_src,
338     HTMLFrameBase_get_src,
339     HTMLFrameBase_put_name,
340     HTMLFrameBase_get_name,
341     HTMLFrameBase_put_border,
342     HTMLFrameBase_get_border,
343     HTMLFrameBase_put_frameBorder,
344     HTMLFrameBase_get_frameBorder,
345     HTMLFrameBase_put_frameSpacing,
346     HTMLFrameBase_get_frameSpacing,
347     HTMLFrameBase_put_marginWidth,
348     HTMLFrameBase_get_marginWidth,
349     HTMLFrameBase_put_marginHeight,
350     HTMLFrameBase_get_marginHeight,
351     HTMLFrameBase_put_noResize,
352     HTMLFrameBase_get_noResize,
353     HTMLFrameBase_put_scrolling,
354     HTMLFrameBase_get_scrolling
355 };
356
357 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
358 {
359     return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
360 }
361
362 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
363 {
364     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
365
366     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
367 }
368
369 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
370 {
371     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
372
373     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
374 }
375
376 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
377 {
378     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
379
380     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
381 }
382
383 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
384 {
385     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
386     FIXME("(%p)\n", This);
387     return E_NOTIMPL;
388 }
389
390 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
391         LCID lcid, ITypeInfo **ppTInfo)
392 {
393     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
394     FIXME("(%p)\n", This);
395     return E_NOTIMPL;
396 }
397
398 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
399         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
400 {
401     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
402     FIXME("(%p)\n", This);
403     return E_NOTIMPL;
404 }
405
406 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
407         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
408         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
409 {
410     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
411     FIXME("(%p)\n", This);
412     return E_NOTIMPL;
413 }
414
415 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
416 {
417     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
418
419     TRACE("(%p)->(%p)\n", This, p);
420
421     if(This->content_window) {
422         IHTMLWindow2_AddRef(&This->content_window->base.IHTMLWindow2_iface);
423         *p = &This->content_window->base.IHTMLWindow2_iface;
424     }else {
425         WARN("NULL content window\n");
426         *p = NULL;
427     }
428     return S_OK;
429 }
430
431 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
432 {
433     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
434     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
435     return E_NOTIMPL;
436 }
437
438 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
439 {
440     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
441     FIXME("(%p)->(%p)\n", This, p);
442     return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
446 {
447     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
448     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
449     return E_NOTIMPL;
450 }
451
452 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
453 {
454     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
455     FIXME("(%p)->(%p)\n", This, p);
456     return E_NOTIMPL;
457 }
458
459 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
460 {
461     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
462
463     TRACE("(%p)->(%p)\n", This, p);
464
465     if(!This->content_window || !This->content_window->base.inner_window->doc) {
466         FIXME("no document associated\n");
467         return E_FAIL;
468     }
469
470     return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface, p);
471 }
472
473 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
474 {
475     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
476     FIXME("(%p)->(%x)\n", This, v);
477     return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
481 {
482     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
483     FIXME("(%p)->(%p)\n", This, p);
484     return E_NOTIMPL;
485 }
486
487 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
488     HTMLFrameBase2_QueryInterface,
489     HTMLFrameBase2_AddRef,
490     HTMLFrameBase2_Release,
491     HTMLFrameBase2_GetTypeInfoCount,
492     HTMLFrameBase2_GetTypeInfo,
493     HTMLFrameBase2_GetIDsOfNames,
494     HTMLFrameBase2_Invoke,
495     HTMLFrameBase2_get_contentWindow,
496     HTMLFrameBase2_put_onload,
497     HTMLFrameBase2_get_onload,
498     HTMLFrameBase2_put_onreadystatechange,
499     HTMLFrameBase2_get_onreadystatechange,
500     HTMLFrameBase2_get_readyState,
501     HTMLFrameBase2_put_allowTransparency,
502     HTMLFrameBase2_get_allowTransparency
503 };
504
505 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
506 {
507     if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
508         TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
509         *ppv = &This->IHTMLFrameBase_iface;
510     }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
511         TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
512         *ppv = &This->IHTMLFrameBase2_iface;
513     }else {
514         return HTMLElement_QI(&This->element.node, riid, ppv);
515     }
516
517     IUnknown_AddRef((IUnknown*)*ppv);
518     return S_OK;
519 }
520
521 void HTMLFrameBase_destructor(HTMLFrameBase *This)
522 {
523     if(This->content_window)
524         This->content_window->frame_element = NULL;
525
526     HTMLElement_destructor(&This->element.node);
527 }
528
529 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
530         dispex_static_data_t *dispex_data)
531 {
532     nsresult nsres;
533
534     This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
535     This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
536
537     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
538
539     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
540     if(NS_FAILED(nsres)) {
541         This->nsframe = NULL;
542         nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
543         assert(nsres == NS_OK && (nsIDOMNode*)This->nsiframe == This->element.node.nsnode);
544     }else {
545         assert((nsIDOMNode*)This->nsframe == This->element.node.nsnode);
546         This->nsiframe = NULL;
547     }
548
549     /* Share the reference with nsnode */
550     nsIDOMNode_Release(This->element.node.nsnode);
551 }