mshtml: Moved Wine[Add|Remove]Observer calls to HTMLDocumentNode constructor/destructor.

oldstable
Jacek Caban 2009-10-21 21:28:39 +02:00 committed by Alexandre Julliard
parent 5894e3be75
commit 250ec843a5
4 changed files with 32 additions and 38 deletions

View File

@ -1769,8 +1769,10 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
detach_ranges(This);
release_nodes(This);
if(This->nsdoc)
if(This->nsdoc) {
release_mutation(This);
nsIDOMHTMLDocument_Release(This->nsdoc);
}
destroy_htmldoc(&This->basedoc);
}
@ -1811,7 +1813,6 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
doc->basedoc.doc_node = doc;
doc->basedoc.doc_obj = doc_obj;
init_mutation(doc);
init_dispex(&doc->node.dispex, (IUnknown*)HTMLDOMNODE(&doc->node), &HTMLDocumentNode_dispex);
init_doc(&doc->basedoc, (IUnknown*)HTMLDOMNODE(&doc->node), DISPATCHEX(&doc->node.dispex));
HTMLDocumentNode_SecMgr_Init(doc);
@ -1819,6 +1820,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
nsIDOMHTMLDocument_AddRef(nsdoc);
doc->nsdoc = nsdoc;
init_mutation(doc);
doc->basedoc.window = window;
@ -1887,8 +1889,6 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
set_document_bscallback(&This->basedoc, NULL);
set_current_mon(&This->basedoc, NULL);
if(This->basedoc.doc_node) {
if(This->basedoc.doc_node->nsdoc)
remove_mutation_observer(This->basedoc.doc_node);
This->basedoc.doc_node->basedoc.doc_obj = NULL;
IHTMLDocument2_Release(HTMLDOC(&This->basedoc.doc_node->basedoc));
}

View File

@ -601,8 +601,7 @@ NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
void NSContainer_Release(NSContainer*);
void init_mutation(HTMLDocumentNode*);
void set_mutation_observer(HTMLDocumentNode*);
void remove_mutation_observer(HTMLDocumentNode*);
void release_mutation(HTMLDocumentNode*);
void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);

View File

@ -40,36 +40,6 @@ enum {
MUTATION_SCRIPT
};
void set_mutation_observer(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
return;
}
nsIDOMNSDocument_WineAddObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}
void remove_mutation_observer(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
return;
}
nsIDOMNSDocument_WineRemoveObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}
#define IE_MAJOR_VERSION 7
#define IE_MINOR_VERSION 0
@ -612,6 +582,33 @@ static const nsIDocumentObserverVtbl nsDocumentObserverVtbl = {
void init_mutation(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
doc->lpIDocumentObserverVtbl = &nsDocumentObserverVtbl;
doc->lpIRunnableVtbl = &nsRunnableVtbl;
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
return;
}
nsIDOMNSDocument_WineAddObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}
void release_mutation(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
return;
}
nsIDOMNSDocument_WineRemoveObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}

View File

@ -838,7 +838,6 @@ void update_nsdocument(HTMLDocumentObj *doc)
if(doc->basedoc.doc_node && doc->basedoc.doc_node->nsdoc) {
doc_node = doc->basedoc.doc_node;
remove_mutation_observer(doc_node);
doc_node->basedoc.doc_obj = NULL;
IHTMLDocument2_Release(HTMLDOC(&doc_node->basedoc));
doc->basedoc.doc_node = NULL;
@ -856,7 +855,6 @@ void update_nsdocument(HTMLDocumentObj *doc)
return;
}
set_mutation_observer(doc_node);
doc->basedoc.doc_node = doc_node;
window_set_docnode(doc->basedoc.window, doc_node);
}