Commit f309cdf7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Store HTMLDocument pointer in BSCallback object.

parent 951ca73f
...@@ -1185,6 +1185,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject) ...@@ -1185,6 +1185,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->window = NULL; ret->window = NULL;
ret->option_factory = NULL; ret->option_factory = NULL;
list_init(&ret->bindings);
list_init(&ret->selection_list); list_init(&ret->selection_list);
list_init(&ret->range_list); list_init(&ret->range_list);
......
...@@ -140,6 +140,7 @@ struct HTMLDocument { ...@@ -140,6 +140,7 @@ struct HTMLDocument {
BSCallback *bscallback; BSCallback *bscallback;
IMoniker *mon; IMoniker *mon;
LPOLESTR url; LPOLESTR url;
struct list bindings;
HWND hwnd; HWND hwnd;
HWND tooltips_hwnd; HWND tooltips_hwnd;
...@@ -260,6 +261,8 @@ struct BSCallback { ...@@ -260,6 +261,8 @@ struct BSCallback {
HTMLDocument *doc; HTMLDocument *doc;
nsProtocolStream *nsstream; nsProtocolStream *nsstream;
struct list entry;
}; };
typedef struct { typedef struct {
...@@ -417,7 +420,7 @@ void init_nsevents(NSContainer*); ...@@ -417,7 +420,7 @@ void init_nsevents(NSContainer*);
nsresult get_nsinterface(nsISupports*,REFIID,void**); nsresult get_nsinterface(nsISupports*,REFIID,void**);
BSCallback *create_bscallback(IMoniker*); BSCallback *create_bscallback(IMoniker*);
HRESULT start_binding(BSCallback*); HRESULT start_binding(HTMLDocument*,BSCallback*);
HRESULT load_stream(BSCallback*,IStream*); HRESULT load_stream(BSCallback*,IStream*);
void set_document_bscallback(HTMLDocument*,BSCallback*); void set_document_bscallback(HTMLDocument*,BSCallback*);
void set_current_mon(HTMLDocument*,IMoniker*); void set_current_mon(HTMLDocument*,IMoniker*);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "winuser.h" #include "winuser.h"
#include "ole2.h" #include "ole2.h"
#include "hlguids.h" #include "hlguids.h"
#include "shlguid.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
...@@ -222,7 +223,7 @@ static HRESULT read_stream_data(BSCallback *This, IStream *stream) ...@@ -222,7 +223,7 @@ static HRESULT read_stream_data(BSCallback *This, IStream *stream)
FIXME("OnStartRequest failed: %08x\n", nsres); FIXME("OnStartRequest failed: %08x\n", nsres);
/* events are reset when a new document URI is loaded, so re-initialise them here */ /* events are reset when a new document URI is loaded, so re-initialise them here */
if(This->doc && This->doc->nscontainer) if(This->doc && This->doc->bscallback == This && This->doc->nscontainer)
init_nsevents(This->doc->nscontainer); init_nsevents(This->doc->nscontainer);
} }
...@@ -328,6 +329,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) ...@@ -328,6 +329,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
IMoniker_Release(This->mon); IMoniker_Release(This->mon);
if(This->binding) if(This->binding)
IBinding_Release(This->binding); IBinding_Release(This->binding);
list_remove(&This->entry);
mshtml_free(This->headers); mshtml_free(This->headers);
mshtml_free(This); mshtml_free(This);
} }
...@@ -345,6 +347,9 @@ static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *ifa ...@@ -345,6 +347,9 @@ static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *ifa
IBinding_AddRef(pbind); IBinding_AddRef(pbind);
This->binding = pbind; This->binding = pbind;
if(This->doc)
list_add_head(&This->doc->bindings, &This->entry);
add_nsrequest(This); add_nsrequest(This);
return S_OK; return S_OK;
...@@ -414,7 +419,12 @@ static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *ifac ...@@ -414,7 +419,12 @@ static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *ifac
} }
} }
if(This->doc && !This->doc->nscontainer) { list_remove(&This->entry);
if(FAILED(hresult))
return S_OK;
if(This->doc && This->doc->bscallback == This && !This->doc->nscontainer) {
task_t *task = mshtml_alloc(sizeof(task_t)); task_t *task = mshtml_alloc(sizeof(task_t));
task->doc = This->doc; task->doc = This->doc;
...@@ -670,6 +680,8 @@ BSCallback *create_bscallback(IMoniker *mon) ...@@ -670,6 +680,8 @@ BSCallback *create_bscallback(IMoniker *mon)
ret->binding = NULL; ret->binding = NULL;
ret->doc = NULL; ret->doc = NULL;
list_init(&ret->entry);
if(mon) if(mon)
IMoniker_AddRef(mon); IMoniker_AddRef(mon);
ret->mon = mon; ret->mon = mon;
...@@ -796,12 +808,14 @@ void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame, ...@@ -796,12 +808,14 @@ void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame,
IBindStatusCallback_Release(STATUSCLB(callback)); IBindStatusCallback_Release(STATUSCLB(callback));
} }
HRESULT start_binding(BSCallback *bscallback) HRESULT start_binding(HTMLDocument *doc, BSCallback *bscallback)
{ {
IStream *str = NULL; IStream *str = NULL;
IBindCtx *bctx; IBindCtx *bctx;
HRESULT hres; HRESULT hres;
bscallback->doc = doc;
hres = CreateAsyncBindCtx(0, STATUSCLB(bscallback), NULL, &bctx); hres = CreateAsyncBindCtx(0, STATUSCLB(bscallback), NULL, &bctx);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("CreateAsyncBindCtx failed: %08x\n", hres); WARN("CreateAsyncBindCtx failed: %08x\n", hres);
...@@ -828,6 +842,8 @@ HRESULT start_binding(BSCallback *bscallback) ...@@ -828,6 +842,8 @@ HRESULT start_binding(BSCallback *bscallback)
void set_document_bscallback(HTMLDocument *doc, BSCallback *callback) void set_document_bscallback(HTMLDocument *doc, BSCallback *callback)
{ {
BSCallback *iter;
if(doc->bscallback) { if(doc->bscallback) {
if(doc->bscallback->binding) if(doc->bscallback->binding)
IBinding_Abort(doc->bscallback->binding); IBinding_Abort(doc->bscallback->binding);
...@@ -835,6 +851,11 @@ void set_document_bscallback(HTMLDocument *doc, BSCallback *callback) ...@@ -835,6 +851,11 @@ void set_document_bscallback(HTMLDocument *doc, BSCallback *callback)
IBindStatusCallback_Release(STATUSCLB(doc->bscallback)); IBindStatusCallback_Release(STATUSCLB(doc->bscallback));
} }
LIST_FOR_EACH_ENTRY(iter, &doc->bindings, BSCallback, entry) {
iter->doc = NULL;
list_remove(&iter->entry);
}
doc->bscallback = callback; doc->bscallback = callback;
if(callback) { if(callback) {
......
...@@ -429,7 +429,7 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva ...@@ -429,7 +429,7 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva
return hres; return hres;
if(!bind_complete) if(!bind_complete)
return start_binding(This->bscallback); return start_binding(This, This->bscallback);
return S_OK; return S_OK;
} }
......
...@@ -211,9 +211,10 @@ static void set_progress(HTMLDocument *doc) ...@@ -211,9 +211,10 @@ static void set_progress(HTMLDocument *doc)
} }
} }
static void task_start_binding(BSCallback *bscallback) static void task_start_binding(HTMLDocument *doc, BSCallback *bscallback)
{ {
start_binding(bscallback); if(doc)
start_binding(doc, bscallback);
IBindStatusCallback_Release(STATUSCLB(bscallback)); IBindStatusCallback_Release(STATUSCLB(bscallback));
} }
...@@ -230,7 +231,7 @@ static void process_task(task_t *task) ...@@ -230,7 +231,7 @@ static void process_task(task_t *task)
set_progress(task->doc); set_progress(task->doc);
break; break;
case TASK_START_BINDING: case TASK_START_BINDING:
task_start_binding(task->bscallback); task_start_binding(task->doc, task->bscallback);
break; break;
default: default:
ERR("Wrong task_id %d\n", task->task_id); ERR("Wrong task_id %d\n", task->task_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment