Jacek Caban : mshtml: Added parsing external scripts support.
Alexandre Julliard
julliard at winehq.org
Mon Mar 31 09:15:22 CDT 2008
Module: wine
Branch: master
Commit: cb7b58c528c874f40c4d47319de19cc20bab5b6e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb7b58c528c874f40c4d47319de19cc20bab5b6e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sat Mar 29 20:57:48 2008 +0000
mshtml: Added parsing external scripts support.
---
dlls/mshtml/navigate.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++
dlls/mshtml/script.c | 26 +++++++++++-
2 files changed, 136 insertions(+), 1 deletions(-)
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index 8ae064c..9ed1dea 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -718,6 +718,117 @@ HRESULT start_binding(HTMLDocument *doc, BSCallback *bscallback, IBindCtx *bctx)
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 {
BSCallback bsc;
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index 40911de..15a939c 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -474,7 +474,31 @@ static void parse_text(ScriptHost *script_host, LPCWSTR text)
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)
More information about the wine-cvs
mailing list