Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmutation.c
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 #include "config.h" 00020 00021 #include <stdarg.h> 00022 00023 #define COBJMACROS 00024 00025 #include "windef.h" 00026 #include "winbase.h" 00027 #include "winuser.h" 00028 #include "winreg.h" 00029 #include "ole2.h" 00030 #include "shlguid.h" 00031 00032 #include "mshtml_private.h" 00033 #include "htmlevent.h" 00034 00035 #include "wine/debug.h" 00036 00037 WINE_DEFAULT_DEBUG_CHANNEL(mshtml); 00038 00039 enum { 00040 MUTATION_BINDTOTREE, 00041 MUTATION_COMMENT, 00042 MUTATION_ENDLOAD, 00043 MUTATION_SCRIPT 00044 }; 00045 00046 #define IE_MAJOR_VERSION 7 00047 #define IE_MINOR_VERSION 0 00048 00049 static BOOL handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment) 00050 { 00051 DWORD len; 00052 int majorv = 0, minorv = 0; 00053 const PRUnichar *ptr, *end; 00054 nsAString nsstr; 00055 PRUnichar *buf; 00056 nsresult nsres; 00057 00058 enum { 00059 CMP_EQ, 00060 CMP_LT, 00061 CMP_LTE, 00062 CMP_GT, 00063 CMP_GTE 00064 } cmpt = CMP_EQ; 00065 00066 static const PRUnichar endifW[] = {'<','!','[','e','n','d','i','f',']'}; 00067 00068 if(comment[0] != '[' || comment[1] != 'i' || comment[2] != 'f') 00069 return FALSE; 00070 00071 ptr = comment+3; 00072 while(isspaceW(*ptr)) 00073 ptr++; 00074 00075 if(ptr[0] == 'l' && ptr[1] == 't') { 00076 ptr += 2; 00077 if(*ptr == 'e') { 00078 cmpt = CMP_LTE; 00079 ptr++; 00080 }else { 00081 cmpt = CMP_LT; 00082 } 00083 }else if(ptr[0] == 'g' && ptr[1] == 't') { 00084 ptr += 2; 00085 if(*ptr == 'e') { 00086 cmpt = CMP_GTE; 00087 ptr++; 00088 }else { 00089 cmpt = CMP_GT; 00090 } 00091 } 00092 00093 if(!isspaceW(*ptr++)) 00094 return FALSE; 00095 while(isspaceW(*ptr)) 00096 ptr++; 00097 00098 if(ptr[0] != 'I' || ptr[1] != 'E') 00099 return FALSE; 00100 00101 ptr +=2; 00102 if(!isspaceW(*ptr++)) 00103 return FALSE; 00104 while(isspaceW(*ptr)) 00105 ptr++; 00106 00107 if(!isdigitW(*ptr)) 00108 return FALSE; 00109 while(isdigitW(*ptr)) 00110 majorv = majorv*10 + (*ptr++ - '0'); 00111 00112 if(*ptr == '.') { 00113 ptr++; 00114 if(!isdigitW(*ptr)) 00115 return FALSE; 00116 while(isdigitW(*ptr)) 00117 minorv = minorv*10 + (*ptr++ - '0'); 00118 } 00119 00120 while(isspaceW(*ptr)) 00121 ptr++; 00122 if(ptr[0] != ']' || ptr[1] != '>') 00123 return FALSE; 00124 ptr += 2; 00125 00126 len = strlenW(ptr); 00127 if(len < sizeof(endifW)/sizeof(WCHAR)) 00128 return FALSE; 00129 00130 end = ptr + len-sizeof(endifW)/sizeof(WCHAR); 00131 if(memcmp(end, endifW, sizeof(endifW))) 00132 return FALSE; 00133 00134 switch(cmpt) { 00135 case CMP_EQ: 00136 if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION) 00137 break; 00138 return FALSE; 00139 case CMP_LT: 00140 if(majorv > IE_MAJOR_VERSION) 00141 break; 00142 if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION) 00143 break; 00144 return FALSE; 00145 case CMP_LTE: 00146 if(majorv > IE_MAJOR_VERSION) 00147 break; 00148 if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION) 00149 break; 00150 return FALSE; 00151 case CMP_GT: 00152 if(majorv < IE_MAJOR_VERSION) 00153 break; 00154 if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION) 00155 break; 00156 return FALSE; 00157 case CMP_GTE: 00158 if(majorv < IE_MAJOR_VERSION) 00159 break; 00160 if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION) 00161 break; 00162 return FALSE; 00163 } 00164 00165 buf = heap_alloc((end-ptr+1)*sizeof(WCHAR)); 00166 if(!buf) 00167 return FALSE; 00168 00169 memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR)); 00170 buf[end-ptr] = 0; 00171 nsAString_InitDepend(&nsstr, buf); 00172 00173 /* FIXME: Find better way to insert HTML to document. */ 00174 nsres = nsIDOMHTMLDocument_Write(doc->nsdoc, &nsstr); 00175 nsAString_Finish(&nsstr); 00176 heap_free(buf); 00177 if(NS_FAILED(nsres)) { 00178 ERR("Write failed: %08x\n", nsres); 00179 return FALSE; 00180 } 00181 00182 return TRUE; 00183 } 00184 00185 static void add_script_runner(HTMLDocumentNode *This) 00186 { 00187 nsIDOMNSDocument *nsdoc; 00188 nsresult nsres; 00189 00190 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc); 00191 if(NS_FAILED(nsres)) { 00192 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres); 00193 return; 00194 } 00195 00196 nsIDOMNSDocument_WineAddScriptRunner(nsdoc, NSRUNNABLE(This)); 00197 nsIDOMNSDocument_Release(nsdoc); 00198 } 00199 00200 #define NSRUNNABLE_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IRunnable, iface) 00201 00202 static nsresult NSAPI nsRunnable_QueryInterface(nsIRunnable *iface, 00203 nsIIDRef riid, nsQIResult result) 00204 { 00205 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface); 00206 00207 if(IsEqualGUID(riid, &IID_nsISupports)) { 00208 TRACE("(%p)->(IID_nsISupports %p)\n", This, result); 00209 *result = NSRUNNABLE(This); 00210 }else if(IsEqualGUID(riid, &IID_nsIRunnable)) { 00211 TRACE("(%p)->(IID_nsIRunnable %p)\n", This, result); 00212 *result = NSRUNNABLE(This); 00213 }else { 00214 *result = NULL; 00215 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result); 00216 return NS_NOINTERFACE; 00217 } 00218 00219 nsISupports_AddRef((nsISupports*)*result); 00220 return NS_OK; 00221 } 00222 00223 static nsrefcnt NSAPI nsRunnable_AddRef(nsIRunnable *iface) 00224 { 00225 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface); 00226 return htmldoc_addref(&This->basedoc); 00227 } 00228 00229 static nsrefcnt NSAPI nsRunnable_Release(nsIRunnable *iface) 00230 { 00231 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface); 00232 return htmldoc_release(&This->basedoc); 00233 } 00234 00235 static void push_mutation_queue(HTMLDocumentNode *doc, DWORD type, nsISupports *nsiface) 00236 { 00237 mutation_queue_t *elem; 00238 00239 elem = heap_alloc(sizeof(mutation_queue_t)); 00240 if(!elem) 00241 return; 00242 00243 elem->next = NULL; 00244 elem->type = type; 00245 elem->nsiface = nsiface; 00246 if(nsiface) 00247 nsISupports_AddRef(nsiface); 00248 00249 if(doc->mutation_queue_tail) { 00250 doc->mutation_queue_tail = doc->mutation_queue_tail->next = elem; 00251 }else { 00252 doc->mutation_queue = doc->mutation_queue_tail = elem; 00253 add_script_runner(doc); 00254 } 00255 } 00256 00257 static void pop_mutation_queue(HTMLDocumentNode *doc) 00258 { 00259 mutation_queue_t *tmp = doc->mutation_queue; 00260 00261 if(!tmp) 00262 return; 00263 00264 doc->mutation_queue = tmp->next; 00265 if(!tmp->next) 00266 doc->mutation_queue_tail = NULL; 00267 00268 if(tmp->nsiface) 00269 nsISupports_Release(tmp->nsiface); 00270 heap_free(tmp); 00271 } 00272 00273 static void bind_to_tree(HTMLDocumentNode *doc, nsISupports *nsiface) 00274 { 00275 nsIDOMNode *nsnode; 00276 HTMLDOMNode *node; 00277 nsresult nsres; 00278 00279 nsres = nsISupports_QueryInterface(nsiface, &IID_nsIDOMNode, (void**)&nsnode); 00280 if(NS_FAILED(nsres)) 00281 return; 00282 00283 node = get_node(doc, nsnode, TRUE); 00284 nsIDOMNode_Release(nsnode); 00285 if(!node) { 00286 ERR("Could not get node\n"); 00287 return; 00288 } 00289 00290 if(node->vtbl->bind_to_tree) 00291 node->vtbl->bind_to_tree(node); 00292 } 00293 00294 /* Calls undocumented 69 cmd of CGID_Explorer */ 00295 static void call_explorer_69(HTMLDocumentObj *doc) 00296 { 00297 IOleCommandTarget *olecmd; 00298 VARIANT var; 00299 HRESULT hres; 00300 00301 if(!doc->client) 00302 return; 00303 00304 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd); 00305 if(FAILED(hres)) 00306 return; 00307 00308 VariantInit(&var); 00309 hres = IOleCommandTarget_Exec(olecmd, &CGID_Explorer, 69, 0, NULL, &var); 00310 IOleCommandTarget_Release(olecmd); 00311 if(SUCCEEDED(hres) && V_VT(&var) != VT_NULL) 00312 FIXME("handle result\n"); 00313 } 00314 00315 static void parse_complete_proc(task_t *task) 00316 { 00317 HTMLDocumentObj *doc = ((docobj_task_t*)task)->doc; 00318 00319 TRACE("(%p)\n", doc); 00320 00321 if(doc->usermode == EDITMODE) 00322 init_editor(&doc->basedoc); 00323 00324 call_explorer_69(doc); 00325 if(doc->view_sink) 00326 IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1); 00327 call_property_onchanged(&doc->basedoc.cp_propnotif, 1005); 00328 call_explorer_69(doc); 00329 00330 /* FIXME: IE7 calls EnableModelless(TRUE), EnableModelless(FALSE) and sets interactive state here */ 00331 00332 set_ready_state(doc->basedoc.window, READYSTATE_INTERACTIVE); 00333 } 00334 00335 static void handle_end_load(HTMLDocumentNode *This) 00336 { 00337 docobj_task_t *task; 00338 00339 TRACE("\n"); 00340 00341 if(!This->basedoc.doc_obj) 00342 return; 00343 00344 if(This != This->basedoc.doc_obj->basedoc.doc_node) { 00345 set_ready_state(This->basedoc.window, READYSTATE_INTERACTIVE); 00346 return; 00347 } 00348 00349 task = heap_alloc(sizeof(docobj_task_t)); 00350 if(!task) 00351 return; 00352 00353 task->doc = This->basedoc.doc_obj; 00354 00355 /* 00356 * This should be done in the worker thread that parses HTML, 00357 * but we don't have such thread (Gecko parses HTML for us). 00358 */ 00359 push_task(&task->header, &parse_complete_proc, This->basedoc.doc_obj->basedoc.task_magic); 00360 } 00361 00362 static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface) 00363 { 00364 HTMLDocumentNode *This = NSRUNNABLE_THIS(iface); 00365 nsresult nsres; 00366 00367 TRACE("(%p)\n", This); 00368 00369 while(This->mutation_queue) { 00370 switch(This->mutation_queue->type) { 00371 case MUTATION_BINDTOTREE: 00372 bind_to_tree(This, This->mutation_queue->nsiface); 00373 break; 00374 00375 case MUTATION_COMMENT: { 00376 nsIDOMComment *nscomment; 00377 nsAString comment_str; 00378 BOOL remove_comment = FALSE; 00379 00380 nsres = nsISupports_QueryInterface(This->mutation_queue->nsiface, &IID_nsIDOMComment, (void**)&nscomment); 00381 if(NS_FAILED(nsres)) { 00382 ERR("Could not get nsIDOMComment iface:%08x\n", nsres); 00383 return NS_OK; 00384 } 00385 00386 nsAString_Init(&comment_str, NULL); 00387 nsres = nsIDOMComment_GetData(nscomment, &comment_str); 00388 if(NS_SUCCEEDED(nsres)) { 00389 const PRUnichar *comment; 00390 00391 nsAString_GetData(&comment_str, &comment); 00392 remove_comment = handle_insert_comment(This, comment); 00393 } 00394 00395 nsAString_Finish(&comment_str); 00396 00397 if(remove_comment) { 00398 nsIDOMNode *nsparent, *tmp; 00399 nsAString magic_str; 00400 00401 static const PRUnichar remove_comment_magicW[] = 00402 {'#','!','w','i','n','e', 'r','e','m','o','v','e','!','#',0}; 00403 00404 nsAString_InitDepend(&magic_str, remove_comment_magicW); 00405 nsres = nsIDOMComment_SetData(nscomment, &magic_str); 00406 nsAString_Finish(&magic_str); 00407 if(NS_FAILED(nsres)) 00408 ERR("SetData failed: %08x\n", nsres); 00409 00410 nsIDOMComment_GetParentNode(nscomment, &nsparent); 00411 if(nsparent) { 00412 nsIDOMNode_RemoveChild(nsparent, (nsIDOMNode*)nscomment, &tmp); 00413 nsIDOMNode_Release(nsparent); 00414 nsIDOMNode_Release(tmp); 00415 } 00416 } 00417 00418 nsIDOMComment_Release(nscomment); 00419 break; 00420 } 00421 00422 case MUTATION_ENDLOAD: 00423 handle_end_load(This); 00424 break; 00425 00426 case MUTATION_SCRIPT: { 00427 nsIDOMHTMLScriptElement *nsscript; 00428 00429 nsres = nsISupports_QueryInterface(This->mutation_queue->nsiface, &IID_nsIDOMHTMLScriptElement, 00430 (void**)&nsscript); 00431 if(NS_FAILED(nsres)) { 00432 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres); 00433 break; 00434 } 00435 00436 doc_insert_script(This->basedoc.window, nsscript); 00437 nsIDOMHTMLScriptElement_Release(nsscript); 00438 break; 00439 } 00440 00441 default: 00442 ERR("invalid type %d\n", This->mutation_queue->type); 00443 } 00444 00445 pop_mutation_queue(This); 00446 } 00447 00448 return S_OK; 00449 } 00450 00451 #undef NSRUNNABLE_THIS 00452 00453 static const nsIRunnableVtbl nsRunnableVtbl = { 00454 nsRunnable_QueryInterface, 00455 nsRunnable_AddRef, 00456 nsRunnable_Release, 00457 nsRunnable_Run 00458 }; 00459 00460 #define NSDOCOBS_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IDocumentObserver, iface) 00461 00462 static nsresult NSAPI nsDocumentObserver_QueryInterface(nsIDocumentObserver *iface, 00463 nsIIDRef riid, nsQIResult result) 00464 { 00465 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00466 00467 if(IsEqualGUID(&IID_nsISupports, riid)) { 00468 TRACE("(%p)->(IID_nsISupports, %p)\n", This, result); 00469 *result = NSDOCOBS(This); 00470 }else if(IsEqualGUID(&IID_nsIMutationObserver, riid)) { 00471 TRACE("(%p)->(IID_nsIMutationObserver %p)\n", This, result); 00472 *result = NSDOCOBS(This); 00473 }else if(IsEqualGUID(&IID_nsIDocumentObserver, riid)) { 00474 TRACE("(%p)->(IID_nsIDocumentObserver %p)\n", This, result); 00475 *result = NSDOCOBS(This); 00476 }else { 00477 *result = NULL; 00478 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result); 00479 return NS_NOINTERFACE; 00480 } 00481 00482 htmldoc_addref(&This->basedoc); 00483 return NS_OK; 00484 } 00485 00486 static nsrefcnt NSAPI nsDocumentObserver_AddRef(nsIDocumentObserver *iface) 00487 { 00488 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00489 return htmldoc_addref(&This->basedoc); 00490 } 00491 00492 static nsrefcnt NSAPI nsDocumentObserver_Release(nsIDocumentObserver *iface) 00493 { 00494 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00495 return htmldoc_release(&This->basedoc); 00496 } 00497 00498 static void NSAPI nsDocumentObserver_CharacterDataWillChange(nsIDocumentObserver *iface, 00499 nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo) 00500 { 00501 } 00502 00503 static void NSAPI nsDocumentObserver_CharacterDataChanged(nsIDocumentObserver *iface, 00504 nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo) 00505 { 00506 } 00507 00508 static void NSAPI nsDocumentObserver_AttributeWillChange(nsIDocumentObserver *iface, nsIDocument *aDocument, 00509 nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType) 00510 { 00511 } 00512 00513 static void NSAPI nsDocumentObserver_AttributeChanged(nsIDocumentObserver *iface, nsIDocument *aDocument, 00514 nsIContent *aContent, PRInt32 aNameSpaceID, nsIAtom *aAttribute, PRInt32 aModType, PRUint32 aStateMask) 00515 { 00516 } 00517 00518 static void NSAPI nsDocumentObserver_ContentAppended(nsIDocumentObserver *iface, nsIDocument *aDocument, 00519 nsIContent *aContainer, PRInt32 aNewIndexInContainer) 00520 { 00521 } 00522 00523 static void NSAPI nsDocumentObserver_ContentInserted(nsIDocumentObserver *iface, nsIDocument *aDocument, 00524 nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer) 00525 { 00526 } 00527 00528 static void NSAPI nsDocumentObserver_ContentRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument, 00529 nsIContent *aContainer, nsIContent *aChild, PRInt32 aIndexInContainer) 00530 { 00531 } 00532 00533 static void NSAPI nsDocumentObserver_NodeWillBeDestroyed(nsIDocumentObserver *iface, const nsINode *aNode) 00534 { 00535 } 00536 00537 static void NSAPI nsDocumentObserver_ParentChainChanged(nsIDocumentObserver *iface, nsIContent *aContent) 00538 { 00539 } 00540 00541 static void NSAPI nsDocumentObserver_BeginUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument, 00542 nsUpdateType aUpdateType) 00543 { 00544 } 00545 00546 static void NSAPI nsDocumentObserver_EndUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument, 00547 nsUpdateType aUpdateType) 00548 { 00549 } 00550 00551 static void NSAPI nsDocumentObserver_BeginLoad(nsIDocumentObserver *iface, nsIDocument *aDocument) 00552 { 00553 } 00554 00555 static void NSAPI nsDocumentObserver_EndLoad(nsIDocumentObserver *iface, nsIDocument *aDocument) 00556 { 00557 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00558 00559 TRACE("\n"); 00560 00561 This->content_ready = TRUE; 00562 push_mutation_queue(This, MUTATION_ENDLOAD, NULL); 00563 } 00564 00565 static void NSAPI nsDocumentObserver_ContentStatesChanged(nsIDocumentObserver *iface, nsIDocument *aDocument, 00566 nsIContent *aContent1, nsIContent *aContent2, PRInt32 aStateMask) 00567 { 00568 } 00569 00570 static void NSAPI nsDocumentObserver_StyleSheetAdded(nsIDocumentObserver *iface, nsIDocument *aDocument, 00571 nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet) 00572 { 00573 } 00574 00575 static void NSAPI nsDocumentObserver_StyleSheetRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument, 00576 nsIStyleSheet *aStyleSheet, PRBool aDocumentSheet) 00577 { 00578 } 00579 00580 static void NSAPI nsDocumentObserver_StyleSheetApplicableStateChanged(nsIDocumentObserver *iface, 00581 nsIDocument *aDocument, nsIStyleSheet *aStyleSheet, PRBool aApplicable) 00582 { 00583 } 00584 00585 static void NSAPI nsDocumentObserver_StyleRuleChanged(nsIDocumentObserver *iface, nsIDocument *aDocument, 00586 nsIStyleSheet *aStyleSheet, nsIStyleRule *aOldStyleRule, nsIStyleSheet *aNewStyleRule) 00587 { 00588 } 00589 00590 static void NSAPI nsDocumentObserver_StyleRuleAdded(nsIDocumentObserver *iface, nsIDocument *aDocument, 00591 nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule) 00592 { 00593 } 00594 00595 static void NSAPI nsDocumentObserver_StyleRuleRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument, 00596 nsIStyleSheet *aStyleSheet, nsIStyleRule *aStyleRule) 00597 { 00598 } 00599 00600 static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, nsIDocument *aDocument, 00601 nsIContent *aContent) 00602 { 00603 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00604 nsIDOMHTMLIFrameElement *nsiframe; 00605 nsIDOMHTMLFrameElement *nsframe; 00606 nsIDOMComment *nscomment; 00607 nsIDOMElement *nselem; 00608 nsresult nsres; 00609 00610 TRACE("(%p)\n", This); 00611 00612 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMElement, (void**)&nselem); 00613 if(NS_SUCCEEDED(nsres)) { 00614 check_event_attr(This, nselem); 00615 nsIDOMElement_Release(nselem); 00616 } 00617 00618 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMComment, (void**)&nscomment); 00619 if(NS_SUCCEEDED(nsres)) { 00620 TRACE("comment node\n"); 00621 00622 push_mutation_queue(This, MUTATION_COMMENT, (nsISupports*)nscomment); 00623 nsIDOMComment_Release(nscomment); 00624 } 00625 00626 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLIFrameElement, (void**)&nsiframe); 00627 if(NS_SUCCEEDED(nsres)) { 00628 TRACE("iframe node\n"); 00629 00630 push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsiframe); 00631 nsIDOMHTMLIFrameElement_Release(nsiframe); 00632 } 00633 00634 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe); 00635 if(NS_SUCCEEDED(nsres)) { 00636 TRACE("frame node\n"); 00637 00638 push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsframe); 00639 nsIDOMHTMLFrameElement_Release(nsframe); 00640 } 00641 } 00642 00643 static void NSAPI nsDocumentObserver_DoneAddingChildren(nsIDocumentObserver *iface, nsIContent *aContent, 00644 PRBool aHaveNotified) 00645 { 00646 HTMLDocumentNode *This = NSDOCOBS_THIS(iface); 00647 nsIDOMHTMLScriptElement *nsscript; 00648 nsresult nsres; 00649 00650 TRACE("(%p)->(%p %x)\n", This, aContent, aHaveNotified); 00651 00652 nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript); 00653 if(NS_SUCCEEDED(nsres)) { 00654 TRACE("script node\n"); 00655 00656 push_mutation_queue(This, MUTATION_SCRIPT, (nsISupports*)nsscript); 00657 nsIDOMHTMLScriptElement_Release(nsscript); 00658 } 00659 } 00660 00661 #undef NSMUTATIONOBS_THIS 00662 00663 static const nsIDocumentObserverVtbl nsDocumentObserverVtbl = { 00664 nsDocumentObserver_QueryInterface, 00665 nsDocumentObserver_AddRef, 00666 nsDocumentObserver_Release, 00667 nsDocumentObserver_CharacterDataWillChange, 00668 nsDocumentObserver_CharacterDataChanged, 00669 nsDocumentObserver_AttributeWillChange, 00670 nsDocumentObserver_AttributeChanged, 00671 nsDocumentObserver_ContentAppended, 00672 nsDocumentObserver_ContentInserted, 00673 nsDocumentObserver_ContentRemoved, 00674 nsDocumentObserver_NodeWillBeDestroyed, 00675 nsDocumentObserver_ParentChainChanged, 00676 nsDocumentObserver_BeginUpdate, 00677 nsDocumentObserver_EndUpdate, 00678 nsDocumentObserver_BeginLoad, 00679 nsDocumentObserver_EndLoad, 00680 nsDocumentObserver_ContentStatesChanged, 00681 nsDocumentObserver_StyleSheetAdded, 00682 nsDocumentObserver_StyleSheetRemoved, 00683 nsDocumentObserver_StyleSheetApplicableStateChanged, 00684 nsDocumentObserver_StyleRuleChanged, 00685 nsDocumentObserver_StyleRuleAdded, 00686 nsDocumentObserver_StyleRuleRemoved, 00687 nsDocumentObserver_BindToDocument, 00688 nsDocumentObserver_DoneAddingChildren 00689 }; 00690 00691 void init_mutation(HTMLDocumentNode *doc) 00692 { 00693 nsIDOMNSDocument *nsdoc; 00694 nsresult nsres; 00695 00696 doc->lpIDocumentObserverVtbl = &nsDocumentObserverVtbl; 00697 doc->lpIRunnableVtbl = &nsRunnableVtbl; 00698 00699 nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc); 00700 if(NS_FAILED(nsres)) { 00701 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres); 00702 return; 00703 } 00704 00705 nsIDOMNSDocument_WineAddObserver(nsdoc, NSDOCOBS(doc)); 00706 nsIDOMNSDocument_Release(nsdoc); 00707 } 00708 00709 void release_mutation(HTMLDocumentNode *doc) 00710 { 00711 nsIDOMNSDocument *nsdoc; 00712 nsresult nsres; 00713 00714 nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc); 00715 if(NS_FAILED(nsres)) { 00716 ERR("Could not get nsIDOMNSDocument: %08x\n", nsres); 00717 return; 00718 } 00719 00720 nsIDOMNSDocument_WineRemoveObserver(nsdoc, NSDOCOBS(doc)); 00721 nsIDOMNSDocument_Release(nsdoc); 00722 } Generated on Sun May 27 2012 04:25:02 for ReactOS by
1.7.6.1
|