mshtml: Store HTMLDocument pointer in BSCallback object.

This commit is contained in:
Jacek Caban 2007-11-05 21:45:07 +01:00 committed by Alexandre Julliard
parent 951ca73ff7
commit f309cdf733
5 changed files with 34 additions and 8 deletions

View File

@ -1185,6 +1185,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->window = NULL;
ret->option_factory = NULL;
list_init(&ret->bindings);
list_init(&ret->selection_list);
list_init(&ret->range_list);

View File

@ -140,6 +140,7 @@ struct HTMLDocument {
BSCallback *bscallback;
IMoniker *mon;
LPOLESTR url;
struct list bindings;
HWND hwnd;
HWND tooltips_hwnd;
@ -260,6 +261,8 @@ struct BSCallback {
HTMLDocument *doc;
nsProtocolStream *nsstream;
struct list entry;
};
typedef struct {
@ -417,7 +420,7 @@ void init_nsevents(NSContainer*);
nsresult get_nsinterface(nsISupports*,REFIID,void**);
BSCallback *create_bscallback(IMoniker*);
HRESULT start_binding(BSCallback*);
HRESULT start_binding(HTMLDocument*,BSCallback*);
HRESULT load_stream(BSCallback*,IStream*);
void set_document_bscallback(HTMLDocument*,BSCallback*);
void set_current_mon(HTMLDocument*,IMoniker*);

View File

@ -29,6 +29,7 @@
#include "winuser.h"
#include "ole2.h"
#include "hlguids.h"
#include "shlguid.h"
#include "wine/debug.h"
#include "wine/unicode.h"
@ -222,7 +223,7 @@ static HRESULT read_stream_data(BSCallback *This, IStream *stream)
FIXME("OnStartRequest failed: %08x\n", nsres);
/* 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);
}
@ -328,6 +329,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
IMoniker_Release(This->mon);
if(This->binding)
IBinding_Release(This->binding);
list_remove(&This->entry);
mshtml_free(This->headers);
mshtml_free(This);
}
@ -345,6 +347,9 @@ static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *ifa
IBinding_AddRef(pbind);
This->binding = pbind;
if(This->doc)
list_add_head(&This->doc->bindings, &This->entry);
add_nsrequest(This);
return S_OK;
@ -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->doc = This->doc;
@ -670,6 +680,8 @@ BSCallback *create_bscallback(IMoniker *mon)
ret->binding = NULL;
ret->doc = NULL;
list_init(&ret->entry);
if(mon)
IMoniker_AddRef(mon);
ret->mon = mon;
@ -796,12 +808,14 @@ void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame,
IBindStatusCallback_Release(STATUSCLB(callback));
}
HRESULT start_binding(BSCallback *bscallback)
HRESULT start_binding(HTMLDocument *doc, BSCallback *bscallback)
{
IStream *str = NULL;
IBindCtx *bctx;
HRESULT hres;
bscallback->doc = doc;
hres = CreateAsyncBindCtx(0, STATUSCLB(bscallback), NULL, &bctx);
if(FAILED(hres)) {
WARN("CreateAsyncBindCtx failed: %08x\n", hres);
@ -828,6 +842,8 @@ HRESULT start_binding(BSCallback *bscallback)
void set_document_bscallback(HTMLDocument *doc, BSCallback *callback)
{
BSCallback *iter;
if(doc->bscallback) {
if(doc->bscallback->binding)
IBinding_Abort(doc->bscallback->binding);
@ -835,6 +851,11 @@ void set_document_bscallback(HTMLDocument *doc, BSCallback *callback)
IBindStatusCallback_Release(STATUSCLB(doc->bscallback));
}
LIST_FOR_EACH_ENTRY(iter, &doc->bindings, BSCallback, entry) {
iter->doc = NULL;
list_remove(&iter->entry);
}
doc->bscallback = callback;
if(callback) {

View File

@ -429,7 +429,7 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva
return hres;
if(!bind_complete)
return start_binding(This->bscallback);
return start_binding(This, This->bscallback);
return S_OK;
}

View File

@ -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));
}
@ -230,7 +231,7 @@ static void process_task(task_t *task)
set_progress(task->doc);
break;
case TASK_START_BINDING:
task_start_binding(task->bscallback);
task_start_binding(task->doc, task->bscallback);
break;
default:
ERR("Wrong task_id %d\n", task->task_id);