msxml3: Add proper skips when msxml3 DOM interfaces are unavailable.
[wine/hacks.git] / dlls / mshtml / mutation.c
bloba7942043557450914e5e311d09b40217ac4da1a7
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 "config.h"
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "ole2.h"
30 #include "shlguid.h"
32 #include "mshtml_private.h"
33 #include "htmlevent.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 enum {
40 MUTATION_BINDTOTREE,
41 MUTATION_COMMENT,
42 MUTATION_ENDLOAD,
43 MUTATION_SCRIPT
46 #define IE_MAJOR_VERSION 7
47 #define IE_MINOR_VERSION 0
49 static BOOL handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment)
51 DWORD len;
52 int majorv = 0, minorv = 0;
53 const PRUnichar *ptr, *end;
54 nsAString nsstr;
55 PRUnichar *buf;
56 nsresult nsres;
58 enum {
59 CMP_EQ,
60 CMP_LT,
61 CMP_LTE,
62 CMP_GT,
63 CMP_GTE
64 } cmpt = CMP_EQ;
66 static const PRUnichar endifW[] = {'<','!','[','e','n','d','i','f',']'};
68 if(comment[0] != '[' || comment[1] != 'i' || comment[2] != 'f')
69 return FALSE;
71 ptr = comment+3;
72 while(isspaceW(*ptr))
73 ptr++;
75 if(ptr[0] == 'l' && ptr[1] == 't') {
76 ptr += 2;
77 if(*ptr == 'e') {
78 cmpt = CMP_LTE;
79 ptr++;
80 }else {
81 cmpt = CMP_LT;
83 }else if(ptr[0] == 'g' && ptr[1] == 't') {
84 ptr += 2;
85 if(*ptr == 'e') {
86 cmpt = CMP_GTE;
87 ptr++;
88 }else {
89 cmpt = CMP_GT;
93 if(!isspaceW(*ptr++))
94 return FALSE;
95 while(isspaceW(*ptr))
96 ptr++;
98 if(ptr[0] != 'I' || ptr[1] != 'E')
99 return FALSE;
101 ptr +=2;
102 if(!isspaceW(*ptr++))
103 return FALSE;
104 while(isspaceW(*ptr))
105 ptr++;
107 if(!isdigitW(*ptr))
108 return FALSE;
109 while(isdigitW(*ptr))
110 majorv = majorv*10 + (*ptr++ - '0');
112 if(*ptr == '.') {
113 ptr++;
114 if(!isdigitW(*ptr))
115 return FALSE;
116 while(isdigitW(*ptr))
117 minorv = minorv*10 + (*ptr++ - '0');
120 while(isspaceW(*ptr))
121 ptr++;
122 if(ptr[0] != ']' || ptr[1] != '>')
123 return FALSE;
124 ptr += 2;
126 len = strlenW(ptr);
127 if(len < sizeof(endifW)/sizeof(WCHAR))
128 return FALSE;
130 end = ptr + len-sizeof(endifW)/sizeof(WCHAR);
131 if(memcmp(end, endifW, sizeof(endifW)))
132 return FALSE;
134 switch(cmpt) {
135 case CMP_EQ:
136 if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION)
137 break;
138 return FALSE;
139 case CMP_LT:
140 if(majorv > IE_MAJOR_VERSION)
141 break;
142 if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION)
143 break;
144 return FALSE;
145 case CMP_LTE:
146 if(majorv > IE_MAJOR_VERSION)
147 break;
148 if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION)
149 break;
150 return FALSE;
151 case CMP_GT:
152 if(majorv < IE_MAJOR_VERSION)
153 break;
154 if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION)
155 break;
156 return FALSE;
157 case CMP_GTE:
158 if(majorv < IE_MAJOR_VERSION)
159 break;
160 if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION)
161 break;
162 return FALSE;
165 buf = heap_alloc((end-ptr+1)*sizeof(WCHAR));
166 if(!buf)
167 return FALSE;
169 memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR));
170 buf[end-ptr] = 0;
171 nsAString_InitDepend(&nsstr, buf);
173 /* FIXME: Find better way to insert HTML to document. */
174 nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr);
175 nsAString_Finish(&nsstr);
176 heap_free(buf);
177 if(NS_FAILED(nsres)) {
178 ERR("Write failed: %08x\n", nsres);
179 return FALSE;
182 return TRUE;
185 static void add_script_runner(HTMLDocumentNode *This)
187 nsIDOMNSDocument *nsdoc;
188 nsresult nsres;
190 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
191 if(NS_FAILED(nsres)) {
192 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
193 return;
196 nsIDOMNSDocument_WineAddScriptRunner(nsdoc, NSRUNNABLE(This));
197 nsIDOMNSDocument_Release(nsdoc);
200 #define NSRUNNABLE_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IRunnable, iface)
202 static nsresult NSAPI nsRunnable_QueryInterface(nsIRunnable *iface,
203 nsIIDRef riid, nsQIResult result)
205 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
207 if(IsEqualGUID(riid, &IID_nsISupports)) {
208 TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
209 *result = NSRUNNABLE(This);
210 }else if(IsEqualGUID(riid, &IID_nsIRunnable)) {
211 TRACE("(%p)->(IID_nsIRunnable %p)\n", This, result);
212 *result = NSRUNNABLE(This);
213 }else {
214 *result = NULL;
215 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
216 return NS_NOINTERFACE;
219 nsISupports_AddRef((nsISupports*)*result);
220 return NS_OK;
223 static nsrefcnt NSAPI nsRunnable_AddRef(nsIRunnable *iface)
225 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
226 return htmldoc_addref(&This->basedoc);
229 static nsrefcnt NSAPI nsRunnable_Release(nsIRunnable *iface)
231 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
232 return htmldoc_release(&This->basedoc);
235 static void push_mutation_queue(HTMLDocumentNode *doc, DWORD type, nsISupports *nsiface)
237 mutation_queue_t *elem;
239 elem = heap_alloc(sizeof(mutation_queue_t));
240 if(!elem)
241 return;
243 elem->next = NULL;
244 elem->type = type;
245 elem->nsiface = nsiface;
246 if(nsiface)
247 nsISupports_AddRef(nsiface);
249 if(doc->mutation_queue_tail) {
250 doc->mutation_queue_tail = doc->mutation_queue_tail->next = elem;
251 }else {
252 doc->mutation_queue = doc->mutation_queue_tail = elem;
253 add_script_runner(doc);
257 static void pop_mutation_queue(HTMLDocumentNode *doc)
259 mutation_queue_t *tmp = doc->mutation_queue;
261 if(!tmp)
262 return;
264 doc->mutation_queue = tmp->next;
265 if(!tmp->next)
266 doc->mutation_queue_tail = NULL;
268 if(tmp->nsiface)
269 nsISupports_Release(tmp->nsiface);
270 heap_free(tmp);
273 static void bind_to_tree(HTMLDocumentNode *doc, nsISupports *nsiface)
275 nsIDOMNode *nsnode;
276 HTMLDOMNode *node;
277 nsresult nsres;
279 nsres = nsISupports_QueryInterface(nsiface, &IID_nsIDOMNode, (void**)&nsnode);
280 if(NS_FAILED(nsres))
281 return;
283 node = get_node(doc, nsnode, TRUE);
284 nsIDOMNode_Release(nsnode);
285 if(!node) {
286 ERR("Could not get node\n");
287 return;
290 if(node->vtbl->bind_to_tree)
291 node->vtbl->bind_to_tree(node);
294 /* Calls undocumented 69 cmd of CGID_Explorer */
295 static void call_explorer_69(HTMLDocumentObj *doc)
297 IOleCommandTarget *olecmd;
298 VARIANT var;
299 HRESULT hres;
301 if(!doc->client)
302 return;
304 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
305 if(FAILED(hres))
306 return;
308 VariantInit(&var);
309 hres = IOleCommandTarget_Exec(olecmd, &CGID_Explorer, 69, 0, NULL, &var);
310 IOleCommandTarget_Release(olecmd);
311 if(SUCCEEDED(hres) && V_VT(&var) != VT_NULL)
312 FIXME("handle result\n");
315 static void parse_complete_proc(task_t *task)
317 HTMLDocumentObj *doc = ((docobj_task_t*)task)->doc;
319 TRACE("(%p)\n", doc);
321 if(doc->usermode == EDITMODE)
322 init_editor(&doc->basedoc);
324 call_explorer_69(doc);
325 if(doc->view_sink)
326 IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1);
327 call_property_onchanged(&doc->basedoc.cp_propnotif, 1005);
328 call_explorer_69(doc);
330 /* FIXME: IE7 calls EnableModelless(TRUE), EnableModelless(FALSE) and sets interactive state here */
332 set_ready_state(doc->basedoc.window, READYSTATE_INTERACTIVE);
335 static void handle_end_load(HTMLDocumentNode *This)
337 docobj_task_t *task;
339 TRACE("\n");
341 if(!This->basedoc.doc_obj)
342 return;
344 if(This != This->basedoc.doc_obj->basedoc.doc_node) {
345 set_ready_state(This->basedoc.window, READYSTATE_INTERACTIVE);
346 return;
349 task = heap_alloc(sizeof(docobj_task_t));
350 if(!task)
351 return;
353 task->doc = This->basedoc.doc_obj;
356 * This should be done in the worker thread that parses HTML,
357 * but we don't have such thread (Gecko parses HTML for us).
359 push_task(&task->header, &parse_complete_proc, This->basedoc.doc_obj->basedoc.task_magic);
362 static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
364 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
365 nsresult nsres;
367 TRACE("(%p)\n", This);
369 while(This->mutation_queue) {
370 switch(This->mutation_queue->type) {
371 case MUTATION_BINDTOTREE:
372 bind_to_tree(This, This->mutation_queue->nsiface);
373 break;
375 case MUTATION_COMMENT: {
376 nsIDOMComment *nscomment;
377 nsAString comment_str;
378 BOOL remove_comment = FALSE;
380 nsres = nsISupports_QueryInterface(This->mutation_queue->nsiface, &IID_nsIDOMComment, (void**)&nscomment);
381 if(NS_FAILED(nsres)) {
382 ERR("Could not get nsIDOMComment iface:%08x\n", nsres);
383 return NS_OK;
386 nsAString_Init(&comment_str, NULL);
387 nsres = nsIDOMComment_GetData(nscomment, &comment_str);
388 if(NS_SUCCEEDED(nsres)) {
389 const PRUnichar *comment;
391 nsAString_GetData(&comment_str, &comment);
392 remove_comment = handle_insert_comment(This, comment);
395 nsAString_Finish(&comment_str);
397 if(remove_comment) {
398 nsIDOMNode *nsparent, *tmp;
399 nsAString magic_str;
401 static const PRUnichar remove_comment_magicW[] =
402 {'#','!','w','i','n','e', 'r','e','m','o','v','e','!','#',0};
404 nsAString_InitDepend(&magic_str, remove_comment_magicW);
405 nsres = nsIDOMComment_SetData(nscomment, &magic_str);
406 nsAString_Finish(&magic_str);
407 if(NS_FAILED(nsres))
408 ERR("SetData failed: %08x\n", nsres);
410 nsIDOMComment_GetParentNode(nscomment, &nsparent);
411 if(nsparent) {
412 nsIDOMNode_RemoveChild(nsparent, (nsIDOMNode*)nscomment, &tmp);
413 nsIDOMNode_Release(nsparent);
414 nsIDOMNode_Release(tmp);
418 nsIDOMComment_Release(nscomment);
419 break;
422 case MUTATION_ENDLOAD:
423 handle_end_load(This);
424 break;
426 case MUTATION_SCRIPT: {
427 nsIDOMHTMLScriptElement *nsscript;
429 nsres = nsISupports_QueryInterface(This->mutation_queue->nsiface, &IID_nsIDOMHTMLScriptElement,
430 (void**)&nsscript);
431 if(NS_FAILED(nsres)) {
432 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
433 break;
436 doc_insert_script(This->basedoc.window, nsscript);
437 nsIDOMHTMLScriptElement_Release(nsscript);
438 break;
441 default:
442 ERR("invalid type %d\n", This->mutation_queue->type);
445 pop_mutation_queue(This);
448 return S_OK;
451 #undef NSRUNNABLE_THIS
453 static const nsIRunnableVtbl nsRunnableVtbl = {
454 nsRunnable_QueryInterface,
455 nsRunnable_AddRef,
456 nsRunnable_Release,
457 nsRunnable_Run
460 #define NSDOCOBS_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IDocumentObserver, iface)
462 static nsresult NSAPI nsDocumentObserver_QueryInterface(nsIDocumentObserver *iface,
463 nsIIDRef riid, nsQIResult result)
465 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
467 if(IsEqualGUID(&IID_nsISupports, riid)) {
468 TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
469 *result = NSDOCOBS(This);
470 }else if(IsEqualGUID(&IID_nsIMutationObserver, riid)) {
471 TRACE("(%p)->(IID_nsIMutationObserver %p)\n", This, result);
472 *result = NSDOCOBS(This);
473 }else if(IsEqualGUID(&IID_nsIDocumentObserver, riid)) {
474 TRACE("(%p)->(IID_nsIDocumentObserver %p)\n", This, result);
475 *result = NSDOCOBS(This);
476 }else {
477 *result = NULL;
478 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
479 return NS_NOINTERFACE;
482 htmldoc_addref(&This->basedoc);
483 return NS_OK;
486 static nsrefcnt NSAPI nsDocumentObserver_AddRef(nsIDocumentObserver *iface)
488 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
489 return htmldoc_addref(&This->basedoc);
492 static nsrefcnt NSAPI nsDocumentObserver_Release(nsIDocumentObserver *iface)
494 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
495 return htmldoc_release(&This->basedoc);
498 static void NSAPI nsDocumentObserver_CharacterDataWillChange(nsIDocumentObserver *iface,
499 nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo)
503 static void NSAPI nsDocumentObserver_CharacterDataChanged(nsIDocumentObserver *iface,
504 nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo)
508 static void NSAPI nsDocumentObserver_AttributeWillChange(nsIDocumentObserver *iface, nsIDocument *aDocument,
509 nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType)
513 static void NSAPI nsDocumentObserver_AttributeChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
514 nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType, PRUint32 aStateMask)
518 static void NSAPI nsDocumentObserver_ContentAppended(nsIDocumentObserver *iface, nsIDocument *aDocument,
519 nsIContent *aContainer, PRInt32 aNewIndexInContainer)
523 static void NSAPI nsDocumentObserver_ContentInserted(nsIDocumentObserver *iface, nsIDocument *aDocument,
524 nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)
528 static void NSAPI nsDocumentObserver_ContentRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument,
529 nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer)
533 static void NSAPI nsDocumentObserver_NodeWillBeDestroyed(nsIDocumentObserver *iface, const nsINode *aNode)
537 static void NSAPI nsDocumentObserver_ParentChainChanged(nsIDocumentObserver *iface, nsIContent *aContent)
541 static void NSAPI nsDocumentObserver_BeginUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument,
542 nsUpdateType aUpdateType)
546 static void NSAPI nsDocumentObserver_EndUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument,
547 nsUpdateType aUpdateType)
551 static void NSAPI nsDocumentObserver_BeginLoad(nsIDocumentObserver *iface, nsIDocument *aDocument)
555 static void NSAPI nsDocumentObserver_EndLoad(nsIDocumentObserver *iface, nsIDocument *aDocument)
557 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
559 TRACE("\n");
561 This->content_ready = TRUE;
562 push_mutation_queue(This, MUTATION_ENDLOAD, NULL);
565 static void NSAPI nsDocumentObserver_ContentStatesChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
566 nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask)
570 static void NSAPI nsDocumentObserver_StyleSheetAdded(nsIDocumentObserver *iface, nsIDocument *aDocument,
571 nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)
575 static void NSAPI nsDocumentObserver_StyleSheetRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument,
576 nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet)
580 static void NSAPI nsDocumentObserver_StyleSheetApplicableStateChanged(nsIDocumentObserver *iface,
581 nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable)
585 static void NSAPI nsDocumentObserver_StyleRuleChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
586 nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleSheet *aNewStyleRule)
590 static void NSAPI nsDocumentObserver_StyleRuleAdded(nsIDocumentObserver *iface, nsIDocument *aDocument,
591 nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)
595 static void NSAPI nsDocumentObserver_StyleRuleRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument,
596 nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule)
600 static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, nsIDocument *aDocument,
601 nsIContent *aContent)
603 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
604 nsIDOMHTMLIFrameElement *nsiframe;
605 nsIDOMHTMLFrameElement *nsframe;
606 nsIDOMComment *nscomment;
607 nsIDOMElement *nselem;
608 nsresult nsres;
610 TRACE("(%p)\n", This);
612 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMElement, (void**)&nselem);
613 if(NS_SUCCEEDED(nsres)) {
614 check_event_attr(This, nselem);
615 nsIDOMElement_Release(nselem);
618 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMComment, (void**)&nscomment);
619 if(NS_SUCCEEDED(nsres)) {
620 TRACE("comment node\n");
622 push_mutation_queue(This, MUTATION_COMMENT, (nsISupports*)nscomment);
623 nsIDOMComment_Release(nscomment);
626 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLIFrameElement, (void**)&nsiframe);
627 if(NS_SUCCEEDED(nsres)) {
628 TRACE("iframe node\n");
630 push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsiframe);
631 nsIDOMHTMLIFrameElement_Release(nsiframe);
634 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
635 if(NS_SUCCEEDED(nsres)) {
636 TRACE("frame node\n");
638 push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsframe);
639 nsIDOMHTMLFrameElement_Release(nsframe);
643 static void NSAPI nsDocumentObserver_DoneAddingChildren(nsIDocumentObserver *iface, nsIContent *aContent,
644 PRBool aHaveNotified)
646 HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
647 nsIDOMHTMLScriptElement *nsscript;
648 nsresult nsres;
650 TRACE("(%p)->(%p %x)\n", This, aContent, aHaveNotified);
652 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
653 if(NS_SUCCEEDED(nsres)) {
654 TRACE("script node\n");
656 push_mutation_queue(This, MUTATION_SCRIPT, (nsISupports*)nsscript);
657 nsIDOMHTMLScriptElement_Release(nsscript);
661 #undef NSMUTATIONOBS_THIS
663 static const nsIDocumentObserverVtbl nsDocumentObserverVtbl = {
664 nsDocumentObserver_QueryInterface,
665 nsDocumentObserver_AddRef,
666 nsDocumentObserver_Release,
667 nsDocumentObserver_CharacterDataWillChange,
668 nsDocumentObserver_CharacterDataChanged,
669 nsDocumentObserver_AttributeWillChange,
670 nsDocumentObserver_AttributeChanged,
671 nsDocumentObserver_ContentAppended,
672 nsDocumentObserver_ContentInserted,
673 nsDocumentObserver_ContentRemoved,
674 nsDocumentObserver_NodeWillBeDestroyed,
675 nsDocumentObserver_ParentChainChanged,
676 nsDocumentObserver_BeginUpdate,
677 nsDocumentObserver_EndUpdate,
678 nsDocumentObserver_BeginLoad,
679 nsDocumentObserver_EndLoad,
680 nsDocumentObserver_ContentStatesChanged,
681 nsDocumentObserver_StyleSheetAdded,
682 nsDocumentObserver_StyleSheetRemoved,
683 nsDocumentObserver_StyleSheetApplicableStateChanged,
684 nsDocumentObserver_StyleRuleChanged,
685 nsDocumentObserver_StyleRuleAdded,
686 nsDocumentObserver_StyleRuleRemoved,
687 nsDocumentObserver_BindToDocument,
688 nsDocumentObserver_DoneAddingChildren
691 void init_mutation(HTMLDocumentNode *doc)
693 nsIDOMNSDocument *nsdoc;
694 nsresult nsres;
696 doc->lpIDocumentObserverVtbl = &nsDocumentObserverVtbl;
697 doc->lpIRunnableVtbl = &nsRunnableVtbl;
699 nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
700 if(NS_FAILED(nsres)) {
701 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
702 return;
705 nsIDOMNSDocument_WineAddObserver(nsdoc, NSDOCOBS(doc));
706 nsIDOMNSDocument_Release(nsdoc);
709 void release_mutation(HTMLDocumentNode *doc)
711 nsIDOMNSDocument *nsdoc;
712 nsresult nsres;
714 nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
715 if(NS_FAILED(nsres)) {
716 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
717 return;
720 nsIDOMNSDocument_WineRemoveObserver(nsdoc, NSDOCOBS(doc));
721 nsIDOMNSDocument_Release(nsdoc);