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

mshtml: Added parsing external scripts support.

parent 620a9500
...@@ -718,6 +718,117 @@ HRESULT start_binding(HTMLDocument *doc, BSCallback *bscallback, IBindCtx *bctx) ...@@ -718,6 +718,117 @@ HRESULT start_binding(HTMLDocument *doc, BSCallback *bscallback, IBindCtx *bctx)
return S_OK; return S_OK;
} }
typedef struct {
BSCallback bsc;
DWORD size;
BYTE *buf;
HRESULT hres;
} BufferBSC;
#define BUFFERBSC_THIS(bsc) ((BufferBSC*) bsc)
static void BufferBSC_destroy(BSCallback *bsc)
{
BufferBSC *This = BUFFERBSC_THIS(bsc);
heap_free(This->buf);
heap_free(This);
}
static HRESULT BufferBSC_start_binding(BSCallback *bsc)
{
return S_OK;
}
static HRESULT BufferBSC_stop_binding(BSCallback *bsc, HRESULT result)
{
BufferBSC *This = BUFFERBSC_THIS(bsc);
This->hres = result;
if(FAILED(result)) {
heap_free(This->buf);
This->buf = NULL;
This->size = 0;
}
return S_OK;
}
static HRESULT BufferBSC_read_data(BSCallback *bsc, IStream *stream)
{
BufferBSC *This = BUFFERBSC_THIS(bsc);
DWORD readed;
HRESULT hres;
if(!This->buf) {
This->size = 128;
This->buf = heap_alloc(This->size);
}
do {
if(This->bsc.readed == This->size) {
This->size <<= 1;
This->buf = heap_realloc(This->buf, This->size);
}
readed = 0;
hres = IStream_Read(stream, This->buf+This->bsc.readed, This->size-This->bsc.readed, &readed);
This->bsc.readed += readed;
}while(hres == S_OK);
return S_OK;
}
static HRESULT BufferBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
{
return S_OK;
}
#undef BUFFERBSC_THIS
static const BSCallbackVtbl BufferBSCVtbl = {
BufferBSC_destroy,
BufferBSC_start_binding,
BufferBSC_stop_binding,
BufferBSC_read_data,
BufferBSC_on_progress,
};
static BufferBSC *create_bufferbsc(IMoniker *mon)
{
BufferBSC *ret = heap_alloc_zero(sizeof(*ret));
init_bscallback(&ret->bsc, &BufferBSCVtbl, mon, 0);
ret->hres = E_FAIL;
return ret;
}
HRESULT bind_mon_to_buffer(HTMLDocument *doc, IMoniker *mon, void **buf)
{
BufferBSC *bsc = create_bufferbsc(mon);
HRESULT hres;
*buf = NULL;
hres = start_binding(doc, &bsc->bsc, NULL);
if(SUCCEEDED(hres)) {
hres = bsc->hres;
if(SUCCEEDED(hres)) {
*buf = bsc->buf;
bsc->buf = NULL;
bsc->size = 0;
}
}
IBindStatusCallback_Release(STATUSCLB(&bsc->bsc));
return hres;
}
struct nsChannelBSC { struct nsChannelBSC {
BSCallback bsc; BSCallback bsc;
......
...@@ -474,7 +474,31 @@ static void parse_text(ScriptHost *script_host, LPCWSTR text) ...@@ -474,7 +474,31 @@ static void parse_text(ScriptHost *script_host, LPCWSTR text)
static void parse_extern_script(ScriptHost *script_host, LPCWSTR src) static void parse_extern_script(ScriptHost *script_host, LPCWSTR src)
{ {
FIXME("%p %s\n", script_host, debugstr_w(src)); IMoniker *mon;
char *buf;
WCHAR *text;
HRESULT hres;
static const WCHAR wine_schemaW[] = {'w','i','n','e',':'};
if(strlenW(src) > sizeof(wine_schemaW)/sizeof(WCHAR) && !memcmp(src, wine_schemaW, sizeof(wine_schemaW)))
src += sizeof(wine_schemaW)/sizeof(WCHAR);
hres = CreateURLMoniker(NULL, src, &mon);
if(FAILED(hres))
return;
hres = bind_mon_to_buffer(script_host->doc, mon, (void**)&buf);
IMoniker_Release(mon);
if(FAILED(hres))
return;
text = heap_strdupAtoW(buf);
heap_free(buf);
parse_text(script_host, text);
heap_free(text);
} }
static void parse_inline_script(ScriptHost *script_host, nsIDOMHTMLScriptElement *nsscript) static void parse_inline_script(ScriptHost *script_host, nsIDOMHTMLScriptElement *nsscript)
......
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