diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index cf663d5a9c3..f6cb876659a 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1811,6 +1811,7 @@ 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);
@@ -1887,7 +1888,7 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
set_current_mon(&This->basedoc, NULL);
if(This->basedoc.doc_node) {
if(This->basedoc.doc_node->nsdoc)
- remove_mutation_observer(This->nscontainer, 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));
}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index aa46dac1ff2..92688e1a567 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -360,13 +360,6 @@ typedef struct {
NSContainer *This;
} nsEventListener;
-typedef struct _mutation_queue_t {
- DWORD type;
- nsISupports *nsiface;
-
- struct _mutation_queue_t *next;
-} mutation_queue_t;
-
struct NSContainer {
const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
@@ -377,10 +370,6 @@ struct NSContainer {
const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
- const nsIDocumentObserverVtbl *lpDocumentObserverVtbl;
-
- const nsIRunnableVtbl *lpRunnableVtbl;
-
nsEventListener blur_listener;
nsEventListener focus_listener;
nsEventListener keypress_listener;
@@ -404,9 +393,6 @@ struct NSContainer {
HWND hwnd;
- mutation_queue_t *mutation_queue;
- mutation_queue_t *mutation_queue_tail;
-
nsChannelBSC *bscallback; /* hack */
HWND reset_focus; /* hack */
};
@@ -476,12 +462,22 @@ typedef struct {
ConnectionPoint cp;
} HTMLTextContainer;
+typedef struct _mutation_queue_t {
+ DWORD type;
+ nsISupports *nsiface;
+
+ struct _mutation_queue_t *next;
+} mutation_queue_t;
+
struct HTMLDocumentNode {
HTMLDOMNode node;
HTMLDocument basedoc;
const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
+ const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
+ const nsIRunnableVtbl *lpIRunnableVtbl;
+
LONG ref;
nsIDOMHTMLDocument *nsdoc;
@@ -490,6 +486,9 @@ struct HTMLDocumentNode {
IInternetSecurityManager *secmgr;
+ mutation_queue_t *mutation_queue;
+ mutation_queue_t *mutation_queue_tail;
+
struct list selection_list;
struct list range_list;
};
@@ -534,9 +533,9 @@ struct HTMLDocumentNode {
#define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
#define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
-#define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpDocumentObserverVtbl)
+#define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
-#define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpRunnableVtbl)
+#define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
#define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
#define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
@@ -601,9 +600,9 @@ void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
void NSContainer_Release(NSContainer*);
-void init_mutation(NSContainer*);
-void set_mutation_observer(NSContainer*,nsIDOMHTMLDocument*);
-void remove_mutation_observer(NSContainer*,nsIDOMHTMLDocument*);
+void init_mutation(HTMLDocumentNode*);
+void set_mutation_observer(HTMLDocumentNode*);
+void remove_mutation_observer(HTMLDocumentNode*);
void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c
index 0ea1bf24d17..f2c510ac9ed 100644
--- a/dlls/mshtml/mutation.c
+++ b/dlls/mshtml/mutation.c
@@ -40,33 +40,33 @@ enum {
MUTATION_SCRIPT
};
-void set_mutation_observer(NSContainer *nscontainer, nsIDOMHTMLDocument *nshtmldoc)
+void set_mutation_observer(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
- nsres = nsIDOMHTMLDocument_QueryInterface(nshtmldoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
+ 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(nscontainer));
+ nsIDOMNSDocument_WineAddObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}
-void remove_mutation_observer(NSContainer *nscontainer, nsIDOMHTMLDocument *nshtmldoc)
+void remove_mutation_observer(HTMLDocumentNode *doc)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
- nsres = nsIDOMHTMLDocument_QueryInterface(nshtmldoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
+ 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(nscontainer));
+ nsIDOMNSDocument_WineRemoveObserver(nsdoc, NSDOCOBS(doc));
nsIDOMNSDocument_Release(nsdoc);
}
@@ -209,12 +209,12 @@ static BOOL handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *commen
return TRUE;
}
-static void add_script_runner(NSContainer *This)
+static void add_script_runner(HTMLDocumentNode *This)
{
nsIDOMNSDocument *nsdoc;
nsresult nsres;
- nsres = nsIDOMHTMLDocument_QueryInterface(This->doc->basedoc.doc_node->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
+ nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSDocument: %08x\n", nsres);
return;
@@ -224,12 +224,12 @@ static void add_script_runner(NSContainer *This)
nsIDOMNSDocument_Release(nsdoc);
}
-#define NSRUNNABLE_THIS(iface) DEFINE_THIS(NSContainer, Runnable, iface)
+#define NSRUNNABLE_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IRunnable, iface)
static nsresult NSAPI nsRunnable_QueryInterface(nsIRunnable *iface,
nsIIDRef riid, nsQIResult result)
{
- NSContainer *This = NSRUNNABLE_THIS(iface);
+ HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
if(IsEqualGUID(riid, &IID_nsISupports)) {
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
@@ -249,26 +249,26 @@ static nsresult NSAPI nsRunnable_QueryInterface(nsIRunnable *iface,
static nsrefcnt NSAPI nsRunnable_AddRef(nsIRunnable *iface)
{
- NSContainer *This = NSRUNNABLE_THIS(iface);
- return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
+ HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
+ return htmldoc_addref(&This->basedoc);
}
static nsrefcnt NSAPI nsRunnable_Release(nsIRunnable *iface)
{
- NSContainer *This = NSRUNNABLE_THIS(iface);
- return nsIWebBrowserChrome_Release(NSWBCHROME(This));
+ HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
+ return htmldoc_release(&This->basedoc);
}
-static void pop_mutation_queue(NSContainer *nscontainer)
+static void pop_mutation_queue(HTMLDocumentNode *doc)
{
- mutation_queue_t *tmp = nscontainer->mutation_queue;
+ mutation_queue_t *tmp = doc->mutation_queue;
if(!tmp)
return;
- nscontainer->mutation_queue = tmp->next;
+ doc->mutation_queue = tmp->next;
if(!tmp->next)
- nscontainer->mutation_queue_tail = NULL;
+ doc->mutation_queue_tail = NULL;
nsISupports_Release(tmp->nsiface);
heap_free(tmp);
@@ -276,7 +276,7 @@ static void pop_mutation_queue(NSContainer *nscontainer)
static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
{
- NSContainer *This = NSRUNNABLE_THIS(iface);
+ HTMLDocumentNode *This = NSRUNNABLE_THIS(iface);
nsresult nsres;
TRACE("(%p)\n", This);
@@ -300,7 +300,7 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
const PRUnichar *comment;
nsAString_GetData(&comment_str, &comment);
- remove_comment = handle_insert_comment(This->doc->basedoc.doc_node, comment);
+ remove_comment = handle_insert_comment(This, comment);
}
nsAString_Finish(&comment_str);
@@ -340,7 +340,7 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
break;
}
- doc_insert_script(This->doc->basedoc.window, nsscript);
+ doc_insert_script(This->basedoc.window, nsscript);
nsIDOMHTMLScriptElement_Release(nsscript);
break;
}
@@ -364,12 +364,12 @@ static const nsIRunnableVtbl nsRunnableVtbl = {
nsRunnable_Run
};
-#define NSDOCOBS_THIS(iface) DEFINE_THIS(NSContainer, DocumentObserver, iface)
+#define NSDOCOBS_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IDocumentObserver, iface)
static nsresult NSAPI nsDocumentObserver_QueryInterface(nsIDocumentObserver *iface,
nsIIDRef riid, nsQIResult result)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
if(IsEqualGUID(&IID_nsISupports, riid)) {
TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
@@ -386,20 +386,20 @@ static nsresult NSAPI nsDocumentObserver_QueryInterface(nsIDocumentObserver *ifa
return NS_NOINTERFACE;
}
- nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
+ htmldoc_addref(&This->basedoc);
return NS_OK;
}
static nsrefcnt NSAPI nsDocumentObserver_AddRef(nsIDocumentObserver *iface)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
- return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
+ return htmldoc_addref(&This->basedoc);
}
static nsrefcnt NSAPI nsDocumentObserver_Release(nsIDocumentObserver *iface)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
- return nsIWebBrowserChrome_Release(NSWBCHROME(This));
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
+ return htmldoc_release(&This->basedoc);
}
static void NSAPI nsDocumentObserver_CharacterDataWillChange(nsIDocumentObserver *iface,
@@ -461,24 +461,26 @@ static void NSAPI nsDocumentObserver_BeginLoad(nsIDocumentObserver *iface, nsIDo
static void NSAPI nsDocumentObserver_EndLoad(nsIDocumentObserver *iface, nsIDocument *aDocument)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
- task_t *task;
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
TRACE("\n");
- This->doc->basedoc.doc_node->content_ready = TRUE;
+ This->content_ready = TRUE;
- task = heap_alloc(sizeof(task_t));
+ if(This == This->basedoc.doc_obj->basedoc.doc_node) {
+ task_t *task;
+ task = heap_alloc(sizeof(task_t));
- task->doc = &This->doc->basedoc;
- task->task_id = TASK_PARSECOMPLETE;
- task->next = NULL;
+ task->doc = &This->basedoc.doc_obj->basedoc;
+ task->task_id = TASK_PARSECOMPLETE;
+ task->next = NULL;
- /*
- * This should be done in the worker thread that parses HTML,
- * but we don't have such thread (Gecko parses HTML for us).
- */
- push_task(task);
+ /*
+ * This should be done in the worker thread that parses HTML,
+ * but we don't have such thread (Gecko parses HTML for us).
+ */
+ push_task(task);
+ }
}
static void NSAPI nsDocumentObserver_ContentStatesChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
@@ -516,7 +518,7 @@ static void NSAPI nsDocumentObserver_StyleRuleRemoved(nsIDocumentObserver *iface
{
}
-static void push_mutation_queue(NSContainer *nscontainer, DWORD type, nsISupports *nsiface)
+static void push_mutation_queue(HTMLDocumentNode *doc, DWORD type, nsISupports *nsiface)
{
mutation_queue_t *elem;
@@ -529,16 +531,16 @@ static void push_mutation_queue(NSContainer *nscontainer, DWORD type, nsISupport
elem->nsiface = nsiface;
nsISupports_AddRef(nsiface);
- if(nscontainer->mutation_queue_tail)
- nscontainer->mutation_queue_tail = nscontainer->mutation_queue_tail->next = elem;
+ if(doc->mutation_queue_tail)
+ doc->mutation_queue_tail = doc->mutation_queue_tail->next = elem;
else
- nscontainer->mutation_queue = nscontainer->mutation_queue_tail = elem;
+ doc->mutation_queue = doc->mutation_queue_tail = elem;
}
static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, nsIDocument *aDocument,
nsIContent *aContent)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
nsIDOMComment *nscomment;
nsIDOMElement *nselem;
nsresult nsres;
@@ -547,7 +549,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
nsres = nsISupports_QueryInterface(aContent, &IID_nsIDOMElement, (void**)&nselem);
if(NS_SUCCEEDED(nsres)) {
- check_event_attr(This->doc->basedoc.doc_node, nselem);
+ check_event_attr(This, nselem);
nsIDOMElement_Release(nselem);
}
@@ -564,7 +566,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
static void NSAPI nsDocumentObserver_DoneAddingChildren(nsIDocumentObserver *iface, nsIContent *aContent,
PRBool aHaveNotified)
{
- NSContainer *This = NSDOCOBS_THIS(iface);
+ HTMLDocumentNode *This = NSDOCOBS_THIS(iface);
nsIDOMHTMLScriptElement *nsscript;
nsresult nsres;
@@ -608,8 +610,8 @@ static const nsIDocumentObserverVtbl nsDocumentObserverVtbl = {
nsDocumentObserver_DoneAddingChildren
};
-void init_mutation(NSContainer *nscontainer)
+void init_mutation(HTMLDocumentNode *doc)
{
- nscontainer->lpDocumentObserverVtbl = &nsDocumentObserverVtbl;
- nscontainer->lpRunnableVtbl = &nsRunnableVtbl;
+ doc->lpIDocumentObserverVtbl = &nsDocumentObserverVtbl;
+ doc->lpIRunnableVtbl = &nsRunnableVtbl;
}
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 5cdf433de0d..565b688f89a 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -837,9 +837,8 @@ void update_nsdocument(HTMLDocumentObj *doc)
}
if(doc->basedoc.doc_node && doc->basedoc.doc_node->nsdoc) {
- remove_mutation_observer(doc->nscontainer, 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;
@@ -851,14 +850,13 @@ void update_nsdocument(HTMLDocumentObj *doc)
return;
}
- set_mutation_observer(doc->nscontainer, nsdoc);
-
hres = create_doc_from_nsdoc(nsdoc, doc, doc->basedoc.window, &doc_node);
if(FAILED(hres)) {
ERR("Could not create document: %08x\n", hres);
return;
}
+ set_mutation_observer(doc_node);
doc->basedoc.doc_node = doc_node;
window_set_docnode(doc->basedoc.window, doc_node);
}
@@ -1693,7 +1691,6 @@ NSContainer *NSContainer_Create(HTMLDocumentObj *doc, NSContainer *parent)
ret->doc = doc;
ret->ref = 1;
- init_mutation(ret);
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_WEBBROWSER_CONTRACTID,
NULL, &IID_nsIWebBrowser, (void**)&ret->webbrowser);