[MSHTML]
authorChristoph von Wittich <christoph_vw@reactos.org>
Mon, 18 Jan 2010 16:27:14 +0000 (16:27 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Mon, 18 Jan 2010 16:27:14 +0000 (16:27 +0000)
update mshtml to wine 1.1.36

svn path=/trunk/; revision=45133

50 files changed:
reactos/dll/win32/mshtml/De.rc
reactos/dll/win32/mshtml/Lt.rc
reactos/dll/win32/mshtml/Ru.rc
reactos/dll/win32/mshtml/Sv.rc
reactos/dll/win32/mshtml/conpoint.c
reactos/dll/win32/mshtml/dispex.c
reactos/dll/win32/mshtml/htmlanchor.c
reactos/dll/win32/mshtml/htmlbody.c
reactos/dll/win32/mshtml/htmldoc.c
reactos/dll/win32/mshtml/htmldoc3.c
reactos/dll/win32/mshtml/htmlelem.c
reactos/dll/win32/mshtml/htmlelem2.c
reactos/dll/win32/mshtml/htmlelemcol.c
reactos/dll/win32/mshtml/htmlevent.c
reactos/dll/win32/mshtml/htmlevent.h
reactos/dll/win32/mshtml/htmlform.c [new file with mode: 0644]
reactos/dll/win32/mshtml/htmlframebase.c
reactos/dll/win32/mshtml/htmliframe.c
reactos/dll/win32/mshtml/htmlimg.c
reactos/dll/win32/mshtml/htmllocation.c
reactos/dll/win32/mshtml/htmlscreen.c [new file with mode: 0644]
reactos/dll/win32/mshtml/htmlscript.c
reactos/dll/win32/mshtml/htmlstyle.c
reactos/dll/win32/mshtml/htmlstyle.h
reactos/dll/win32/mshtml/htmlstyle2.c
reactos/dll/win32/mshtml/htmlstyle3.c
reactos/dll/win32/mshtml/htmltable.c
reactos/dll/win32/mshtml/htmltextcont.c
reactos/dll/win32/mshtml/htmltextnode.c
reactos/dll/win32/mshtml/htmlwindow.c
reactos/dll/win32/mshtml/install.c
reactos/dll/win32/mshtml/main.c
reactos/dll/win32/mshtml/mshtml.rbuild
reactos/dll/win32/mshtml/mshtml_private.h
reactos/dll/win32/mshtml/mutation.c
reactos/dll/win32/mshtml/navigate.c
reactos/dll/win32/mshtml/nsembed.c
reactos/dll/win32/mshtml/nsevents.c
reactos/dll/win32/mshtml/nsiface.idl
reactos/dll/win32/mshtml/nsio.c
reactos/dll/win32/mshtml/oleobj.c
reactos/dll/win32/mshtml/persist.c
reactos/dll/win32/mshtml/script.c
reactos/dll/win32/mshtml/secmgr.c
reactos/dll/win32/mshtml/service.c
reactos/dll/win32/mshtml/task.c
reactos/dll/win32/mshtml/txtrange.c
reactos/dll/win32/mshtml/view.c
reactos/include/psdk/mshtmdid.h
reactos/include/psdk/mshtml.idl

index 727d261..219549c 100644 (file)
@@ -37,9 +37,11 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMEN
 CAPTION "Wine-Gecko-Installation"
 FONT 8, "MS Shell Dlg"
 {
-    LTEXT "Wine could not find a Gecko package which is needed for applications embedding HTML " \
-          "to work correctly. Wine can automatically download and install it for you.\n\n" \
-          "Note: it's recommended to use distro packages instead. See http://wiki.winehq.org/Gecko for details.",
+    LTEXT "Wine kann das Gecko-Paket nicht finden. Es wird von Programmen mit eingebettetem HTML benötigt, " \
+          "damit diese richtig funktionieren.\n" \
+          "Wine kann das Paket für Sie herunterladen und installieren.\n\n" \
+          "Hinweis: Es wird empfohlen das Paket ihrer Distribution zu verwenden. " \
+          "Weitere Hinweise finden Sie unter http://wiki.winehq.org/Gecko",
           ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT
     CONTROL "Fortschritt", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 50, 240, 12
     DEFPUSHBUTTON "&Installieren", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP
@@ -71,4 +73,3 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "Abbrechen", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
 }
 
-#pragma code_page(default)
index 9883bb4..8f7e772 100644 (file)
@@ -31,18 +31,18 @@ STRINGTABLE DISCARDABLE
     IDS_INSTALLING      "Įdiegiama..."
 }
 
-ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 260, 95
+ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 260, 105
 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Wine Gecko diegimo programa"
 FONT 8, "MS Shell Dlg"
 {
-    LTEXT "Wine could not find a Gecko package which is needed for applications embedding HTML " \
-          "to work correctly. Wine can automatically download and install it for you.\n\n" \
-          "Note: it's recommended to use distro packages instead. See http://wiki.winehq.org/Gecko for details.",
+    LTEXT "Wine nepavyko rasti Gecko paketo reikalingo programoms įterpiančioms HTML " \
+          "teisingai veikti. Wine gali automatiškai atsiųsti ir įdiegti šį paketą.\n\n" \
+          "Pastaba: rekomenduojama naudoti distribucijos paketus. Daugiau informacijos http://wiki.winehq.org/Gecko.",
           ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT
-    CONTROL "Eiga", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12
-    DEFPUSHBUTTON "&Įdiegti", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP
-    PUSHBUTTON "&Atsisakyti", IDCANCEL, 140, 70, 50, 15, WS_GROUP | WS_TABSTOP
+    CONTROL "Eiga", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 60, 240, 12
+    DEFPUSHBUTTON "&Įdiegti", ID_DWL_INSTALL, 200, 80, 50, 15, WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "&Atsisakyti", IDCANCEL, 140, 80, 50, 15, WS_GROUP | WS_TABSTOP
 }
 
 IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65
index 02bc433..8d3a4c3 100644 (file)
@@ -31,18 +31,18 @@ STRINGTABLE DISCARDABLE
     IDS_INSTALLING      "Установка..."
 }
 
-ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 261, 95
+ID_DWL_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE  0, 0, 261, 110
 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
 CAPTION "Установка Wine Gecko"
 FONT 8, "MS Shell Dlg"
 {
-    LTEXT "Wine could not find a Gecko package which is needed for applications embedding HTML " \
-          "to work correctly. Wine can automatically download and install it for you.\n\n" \
-          "Note: it's recommended to use distro packages instead. See http://wiki.winehq.org/Gecko for details.",
+    LTEXT "Wine не может найти пакет Gecko который нужен для приложений со встроенным HTML " \
+          "для корректной работы. Wine может автоматически загрузить и установить его для Вас.\n\n" \
+          "Примечание: Рекомендовано использовать пакет из Вашего дистрибутива. Посетите http://wiki.winehq.org/Gecko для деталей.",
           ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT
-    CONTROL "Прогресс", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 46, 240, 12
-    DEFPUSHBUTTON "&Установить", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP
-    PUSHBUTTON "&Отмена", IDCANCEL, 140, 63, 70, 15, WS_GROUP | WS_TABSTOP
+    CONTROL "Прогресс", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 65, 240, 12
+    DEFPUSHBUTTON "&Установить", ID_DWL_INSTALL, 180, 85, 70, 15, WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "&Отмена", IDCANCEL, 100, 85, 70, 15, WS_GROUP | WS_TABSTOP
 }
 
 IDD_HYPERLINK DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 250, 65
@@ -58,3 +58,14 @@ FONT 8, "MS Shell Dlg"
     PUSHBUTTON "OK", IDOK, 200, 10, 45, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
     PUSHBUTTON "Отмена", IDCANCEL, 200, 28, 45, 14, WS_GROUP | WS_TABSTOP
 }
+
+ID_PROMPT_DIALOG DIALOG 0, 0, 200, 90
+STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION ""
+FONT 8, "MS Shell Dlg"
+{
+    LTEXT "", ID_PROMPT_PROMPT, 10, 10, 180, 30
+    EDITTEXT ID_PROMPT_EDIT, 10, 45, 180, 14, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "OK", IDOK, 40, 65, 45, 15, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+    PUSHBUTTON "Отмена", IDCANCEL, 115, 65, 45, 15, WS_GROUP | WS_TABSTOP
+}
index e9ba10e..c5a2cc8 100644 (file)
@@ -33,9 +33,9 @@ STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMEN
 CAPTION "Wine Gecko Installationsprogram"
 FONT 8, "MS Shell Dlg"
 {
-    LTEXT "Wine could not find a Gecko package which is needed for applications embedding HTML " \
-          "to work correctly. Wine can automatically download and install it for you.\n\n" \
-          "Note: it's recommended to use distro packages instead. See http://wiki.winehq.org/Gecko for details.",
+    LTEXT "Wine kunde inte hitta paketet Gecko vilket krävs för att program med inbäddad HTML " \
+          "ska fungera korrekt. Wine kan hämta och installera det automatiskt åt dig.\n\n" \
+          "Obs: Du rekommenderas att använda din distributions paket i stället. Se http://wiki.winehq.org/Gecko för mer information.",
           ID_DWL_STATUS, 10, 10, 240, 50, SS_LEFT
     CONTROL "Förlopp", ID_DWL_PROGRESS, PROGRESS_CLASSA, WS_BORDER|PBS_SMOOTH, 10, 40, 240, 12
     DEFPUSHBUTTON "&Installera", ID_DWL_INSTALL, 200, 70, 50, 15, WS_GROUP | WS_TABSTOP
index 10d8e29..da775ad 100644 (file)
@@ -89,13 +89,13 @@ static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
 {
     ConnectionPoint *This = CONPOINT_THIS(iface);
-    return IConnectionPointContainer_AddRef(This->container);
+    return IConnectionPointContainer_AddRef(CONPTCONT(This->container));
 }
 
 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
 {
     ConnectionPoint *This = CONPOINT_THIS(iface);
-    return IConnectionPointContainer_Release(This->container);
+    return IConnectionPointContainer_Release(CONPTCONT(This->container));
 }
 
 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
@@ -121,7 +121,7 @@ static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoi
     if(!ppCPC)
         return E_POINTER;
 
-    *ppCPC = This->container;
+    *ppCPC = CONPTCONT(This->container);
     IConnectionPointContainer_AddRef(*ppCPC);
     return S_OK;
 }
@@ -159,6 +159,9 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *
     This->sinks[i].unk = sink;
     *pdwCookie = i+1;
 
+    if(!i && This->data && This->data->on_advise)
+        This->data->on_advise(This->container->outer, This->data);
+
     return S_OK;
 }
 
@@ -198,14 +201,15 @@ static const IConnectionPointVtbl ConnectionPointVtbl =
     ConnectionPoint_EnumConnections
 };
 
-void ConnectionPoint_Init(ConnectionPoint *cp, ConnectionPointContainer *container, REFIID riid)
+void ConnectionPoint_Init(ConnectionPoint *cp, ConnectionPointContainer *container, REFIID riid, cp_static_data_t *data)
 {
     cp->lpConnectionPointVtbl = &ConnectionPointVtbl;
-    cp->container = CONPTCONT(container);
+    cp->container = container;
     cp->sinks = NULL;
     cp->sinks_size = 0;
     cp->iid = riid;
     cp->next = NULL;
+    cp->data = data;
 
     cp->next = container->cp_list;
     container->cp_list = cp;
@@ -260,6 +264,9 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_cp_guid(riid), ppCP);
 
+    if(This->forward_container)
+        return IConnectionPointContainer_FindConnectionPoint(CONPTCONT(This), riid, ppCP);
+
     *ppCP = NULL;
 
     for(iter = This->cp_list; iter; iter = iter->next) {
index 980b13b..c77ebb9 100644 (file)
@@ -90,6 +90,7 @@ static REFIID tid_ids[] = {
     &DIID_DispHTMLDocument,
     &DIID_DispHTMLDOMTextNode,
     &DIID_DispHTMLElementCollection,
+    &DIID_DispHTMLFormElement,
     &DIID_DispHTMLGenericElement,
     &DIID_DispHTMLIFrame,
     &DIID_DispHTMLImg,
@@ -97,12 +98,14 @@ static REFIID tid_ids[] = {
     &DIID_DispHTMLLocation,
     &DIID_DispHTMLNavigator,
     &DIID_DispHTMLOptionElement,
+    &DIID_DispHTMLScreen,
     &DIID_DispHTMLSelectElement,
     &DIID_DispHTMLStyle,
     &DIID_DispHTMLTable,
     &DIID_DispHTMLTableRow,
     &DIID_DispHTMLUnknownElement,
     &DIID_DispHTMLWindow2,
+    &DIID_HTMLDocumentEvents,
     &IID_IHTMLAnchorElement,
     &IID_IHTMLBodyElement,
     &IID_IHTMLBodyElement2,
@@ -125,6 +128,8 @@ static REFIID tid_ids[] = {
     &IID_IHTMLElement4,
     &IID_IHTMLElementCollection,
     &IID_IHTMLEventObj,
+    &IID_IHTMLFiltersCollection,
+    &IID_IHTMLFormElement,
     &IID_IHTMLFrameBase,
     &IID_IHTMLFrameBase2,
     &IID_IHTMLGenericElement,
@@ -133,6 +138,7 @@ static REFIID tid_ids[] = {
     &IID_IHTMLInputElement,
     &IID_IHTMLLocation,
     &IID_IHTMLOptionElement,
+    &IID_IHTMLScreen,
     &IID_IHTMLSelectElement,
     &IID_IHTMLStyle,
     &IID_IHTMLStyle2,
@@ -144,6 +150,7 @@ static REFIID tid_ids[] = {
     &IID_IHTMLUniqueName,
     &IID_IHTMLWindow2,
     &IID_IHTMLWindow3,
+    &IID_IHTMLWindow4,
     &IID_IOmNavigator
 };
 
@@ -303,6 +310,61 @@ static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
     return data;
 }
 
+static int id_cmp(const void *p1, const void *p2)
+{
+    return *(DISPID*)p1 - *(DISPID*)p2;
+}
+
+HRESULT get_dispids(tid_t tid, DWORD *ret_size, DISPID **ret)
+{
+    unsigned i, func_cnt;
+    FUNCDESC *funcdesc;
+    ITypeInfo *ti;
+    TYPEATTR *attr;
+    DISPID *ids;
+    HRESULT hres;
+
+    hres = get_typeinfo(tid, &ti);
+    if(FAILED(hres))
+        return hres;
+
+    hres = ITypeInfo_GetTypeAttr(ti, &attr);
+    if(FAILED(hres)) {
+        ITypeInfo_Release(ti);
+        return hres;
+    }
+
+    func_cnt = attr->cFuncs;
+    ITypeInfo_ReleaseTypeAttr(ti, attr);
+
+    ids = heap_alloc(func_cnt*sizeof(DISPID));
+    if(!ids) {
+        ITypeInfo_Release(ti);
+        return E_OUTOFMEMORY;
+    }
+
+    for(i=0; i < func_cnt; i++) {
+        hres = ITypeInfo_GetFuncDesc(ti, i, &funcdesc);
+        if(FAILED(hres))
+            break;
+
+        ids[i] = funcdesc->memid;
+        ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
+    }
+
+    ITypeInfo_Release(ti);
+    if(FAILED(hres)) {
+        heap_free(ids);
+        return hres;
+    }
+
+    qsort(ids, func_cnt, sizeof(DISPID), id_cmp);
+
+    *ret_size = func_cnt;
+    *ret = ids;
+    return S_OK;
+}
+
 static CRITICAL_SECTION cs_dispex_static_data;
 static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
 {
index 04960d9..6bbaf26 100644 (file)
@@ -313,43 +313,55 @@ static HRESULT WINAPI HTMLAnchorElement_get_hash(IHTMLAnchorElement *iface, BSTR
 static HRESULT WINAPI HTMLAnchorElement_put_onblur(IHTMLAnchorElement *iface, VARIANT v)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->()\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->()\n", This);
+
+    return IHTMLElement2_put_onblur(HTMLELEM2(&This->element), v);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_onblur(IHTMLAnchorElement *iface, VARIANT *p)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return IHTMLElement2_get_onblur(HTMLELEM2(&This->element), p);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_put_onfocus(IHTMLAnchorElement *iface, VARIANT v)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->()\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->()\n", This);
+
+    return IHTMLElement2_put_onfocus(HTMLELEM2(&This->element), v);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_onfocus(IHTMLAnchorElement *iface, VARIANT *p)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return IHTMLElement2_get_onfocus(HTMLELEM2(&This->element), p);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_put_accessKey(IHTMLAnchorElement *iface, BSTR v)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    return IHTMLElement2_put_accessKey(HTMLELEM2(&This->element), v);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_accessKey(IHTMLAnchorElement *iface, BSTR *p)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return IHTMLElement2_get_accessKey(HTMLELEM2(&This->element), p);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_protocolLong(IHTMLAnchorElement *iface, BSTR *p)
@@ -376,29 +388,37 @@ static HRESULT WINAPI HTMLAnchorElement_get_nameProp(IHTMLAnchorElement *iface,
 static HRESULT WINAPI HTMLAnchorElement_put_tabIndex(IHTMLAnchorElement *iface, short v)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->()\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->()\n", This);
+
+    return IHTMLElement2_put_tabIndex(HTMLELEM2(&This->element), v);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_get_tabIndex(IHTMLAnchorElement *iface, short *p)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return IHTMLElement2_get_tabIndex(HTMLELEM2(&This->element), p);
 }
 
 static HRESULT WINAPI HTMLAnchorElement_focus(IHTMLAnchorElement *iface)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)\n", This);
+
+    return IHTMLElement2_focus(HTMLELEM2(&This->element));
 }
 
 static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
 {
     HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)\n", This);
+
+    return IHTMLElement2_blur(HTMLELEM2(&This->element));
 }
 
 #undef HTMLANCHOR_THIS
index 4da3373..7f22a4e 100644 (file)
@@ -63,40 +63,97 @@ static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
 
 static const struct {
     LPCWSTR keyword;
-    const WCHAR hexstr[8];
+    DWORD rgb;
 } keyword_table[] = {
-    {aquaW,     {'#','0','0','f','f','f','f',0}},
-    {blackW,    {'#','0','0','0','0','0','0',0}},
-    {blueW,     {'#','0','0','0','0','f','f',0}},
-    {fuchsiaW,  {'#','f','f','0','0','f','f',0}},
-    {grayW,     {'#','8','0','8','0','8','0',0}},
-    {greenW,    {'#','0','0','8','0','0','0',0}},
-    {limeW,     {'#','0','0','f','f','0','0',0}},
-    {maroonW,   {'#','8','0','0','0','0','0',0}},
-    {navyW,     {'#','0','0','0','0','8','0',0}},
-    {oliveW,    {'#','8','0','8','0','0','0',0}},
-    {purpleW,   {'#','8','0','0','0','8','0',0}},
-    {redW,      {'#','f','f','0','0','0','0',0}},
-    {silverW,   {'#','c','0','c','0','c','0',0}},
-    {tealW,     {'#','0','0','8','0','8','0',0}},
-    {whiteW,    {'#','f','f','f','f','f','f',0}},
-    {yellowW,   {'#','f','f','f','f','0','0',0}}
+    {aquaW,     0x00ffff},
+    {blackW,    0x000000},
+    {blueW,     0x0000ff},
+    {fuchsiaW,  0xff00ff},
+    {grayW,     0x808080},
+    {greenW,    0x008000},
+    {limeW,     0x00ff00},
+    {maroonW,   0x800000},
+    {navyW,     0x000080},
+    {oliveW,    0x808000},
+    {purpleW,   0x800080},
+    {redW,      0xff0000},
+    {silverW,   0xc0c0c0},
+    {tealW,     0x008080},
+    {whiteW,    0xffffff},
+    {yellowW,   0xffff00}
 };
 
-static BSTR nscolor_to_str(LPCWSTR color)
+static int comp_value(const WCHAR *ptr, int dpc)
+{
+    int ret = 0;
+    WCHAR ch;
+
+    if(dpc > 2)
+        dpc = 2;
+
+    while(dpc--) {
+        if(!*ptr)
+            ret *= 16;
+        else if(isdigitW(ch = *ptr++))
+            ret = ret*16 + (ch-'0');
+        else if('a' <= ch && ch <= 'f')
+            ret = ret*16 + (ch-'a') + 10;
+        else if('A' <= ch && ch <= 'F')
+            ret = ret*16 + (ch-'A') + 10;
+        else
+            ret *= 16;
+    }
+
+    return ret;
+}
+
+/* Based on Gecko NS_LooseHexToRGB */
+static int loose_hex_to_rgb(const WCHAR *hex)
+{
+    int len, dpc;
+
+    len = strlenW(hex);
+    if(*hex == '#') {
+        hex++;
+        len--;
+    }
+    if(len <= 3)
+        return 0;
+
+    dpc = min(len/3 + (len%3 ? 1 : 0), 4);
+    return (comp_value(hex, dpc) << 16)
+        | (comp_value(hex+dpc, dpc) << 8)
+        | comp_value(hex+2*dpc, dpc);
+}
+
+static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
 {
-    int i;
+    int i, rgb = -1;
 
-    if(!color || *color == '#')
-        return SysAllocString(color);
+    static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
 
-    for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
-        if(!strcmpiW(color, keyword_table[i].keyword))
-            return SysAllocString(keyword_table[i].hexstr);
+    if(!color || !*color) {
+        *ret = NULL;
+        return S_OK;
     }
 
-    WARN("unknown color %s\n", debugstr_w(color));
-    return SysAllocString(color);
+    if(*color != '#') {
+        for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
+            if(!strcmpiW(color, keyword_table[i].keyword))
+                rgb = keyword_table[i].rgb;
+        }
+    }
+    if(rgb == -1)
+        rgb = loose_hex_to_rgb(color);
+
+    *ret = SysAllocStringLen(NULL, 7);
+    if(!*ret)
+        return E_OUTOFMEMORY;
+
+    sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
+
+    TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
+    return S_OK;
 }
 
 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
@@ -348,23 +405,25 @@ static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIA
     HTMLBodyElement *This = HTMLBODY_THIS(iface);
     nsAString strColor;
     nsresult nsres;
-    const PRUnichar *color;
+    HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
     nsAString_Init(&strColor, NULL);
     nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
-    if(NS_FAILED(nsres))
-        ERR("SetBgColor failed: %08x\n", nsres);
-
-    nsAString_GetData(&strColor, &color);
+    if(NS_SUCCEEDED(nsres)) {
+        const PRUnichar *color;
 
-    V_VT(p) = VT_BSTR;
-    V_BSTR(p) = nscolor_to_str(color);
+        nsAString_GetData(&strColor, &color);
+        V_VT(p) = VT_BSTR;
+        hres = nscolor_to_str(color, &V_BSTR(p));
+    }else {
+        ERR("SetBgColor failed: %08x\n", nsres);
+        hres = E_FAIL;
+    }
 
     nsAString_Finish(&strColor);
-
-    return S_OK;
+    return hres;
 }
 
 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
@@ -389,22 +448,21 @@ static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT
     HTMLBodyElement *This = HTMLBODY_THIS(iface);
     nsAString text;
     nsresult nsres;
+    HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
     nsAString_Init(&text, NULL);
-
-    V_VT(p) = VT_BSTR;
-    V_BSTR(p) = NULL;
-
     nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
-    if(NS_SUCCEEDED(nsres))
-    {
-        const PRUnichar *sText;
-        nsAString_GetData(&text, &sText);
+    if(NS_SUCCEEDED(nsres)) {
+        const PRUnichar *color;
 
+        nsAString_GetData(&text, &color);
         V_VT(p) = VT_BSTR;
-        V_BSTR(p) = SysAllocString(sText);
+        hres = nscolor_to_str(color, &V_BSTR(p));
+    }else {
+        ERR("GetText failed: %08x\n", nsres);
+        hres = E_FAIL;
     }
 
     nsAString_Finish(&text);
@@ -725,8 +783,8 @@ static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
 {
     HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
 
-    return This->textcont.element.node.doc && This->textcont.element.node.doc->basedoc.window
-        ? &This->textcont.element.node.doc->basedoc.window->event_target
+    return This->textcont.element.node.doc
+        ? &This->textcont.element.node.doc->body_event_target
         : &This->textcont.element.node.event_target;
 }
 
@@ -771,7 +829,7 @@ HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *ns
 
     HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
 
-    ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink);
+    ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink, NULL);
 
     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
                                              (void**)&ret->nsbody);
index 836f1ae..ac67a84 100644 (file)
@@ -26,6 +26,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"
+#include "wininet.h"
 #include "ole2.h"
 #include "perhist.h"
 #include "mshtmdid.h"
@@ -610,15 +611,58 @@ static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    BOOL bret;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
+    if(!bret) {
+        FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
+        return HRESULT_FROM_WIN32(GetLastError());
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    DWORD size;
+    BOOL bret;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    size = 0;
+    bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
+    if(!bret) {
+        switch(GetLastError()) {
+        case ERROR_INSUFFICIENT_BUFFER:
+            break;
+        case ERROR_NO_MORE_ITEMS:
+            *p = NULL;
+            return S_OK;
+        default:
+            FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
+            return HRESULT_FROM_WIN32(GetLastError());
+        }
+    }
+
+    if(!size) {
+        *p = NULL;
+        return S_OK;
+    }
+
+    *p = SysAllocStringLen(NULL, size-1);
+    if(!*p)
+        return E_OUTOFMEMORY;
+
+    bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
+    if(!bret) {
+        ERR("InternetGetCookieExW failed: %u\n", GetLastError());
+        return E_FAIL;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
@@ -1028,29 +1072,37 @@ static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT
 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_doc_event(This, EVENTID_MOUSEUP, &v);
 }
 
 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_doc_event(This, EVENTID_MOUSEUP, p);
 }
 
 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->()\n", This);
+
+    return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
 }
 
 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_doc_event(This, EVENTID_MOUSEDOWN, p);
 }
 
 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
@@ -1070,15 +1122,19 @@ static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIAN
 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_doc_event(This, EVENTID_MOUSEOUT, &v);
 }
 
 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_doc_event(This, EVENTID_MOUSEOUT, p);
 }
 
 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
@@ -1102,15 +1158,19 @@ static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIAN
 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
 }
 
 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
 }
 
 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
@@ -1406,6 +1466,16 @@ static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
     HTMLDocument_createStyleSheet
 };
 
+static void HTMLDocument_on_advise(IUnknown *iface, cp_static_data_t *cp)
+{
+    HTMLDocument *This = HTMLDOC_THIS(iface);
+
+    if(This->window)
+        update_cp_events(This->window, cp);
+}
+
+#undef HTMLDOC_THIS
+
 #define SUPPINFO_THIS(iface) DEFINE_THIS(HTMLDocument, SupportErrorInfo, iface)
 
 static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **ppv)
@@ -1649,6 +1719,9 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
     }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
         TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppv);
         *ppv = VIEWOBJ2(This);
+    }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
+        TRACE("(%p)->(IID_IViewObjectEx, %p)\n", This, ppv);
+        *ppv = VIEWOBJEX(This);
     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
         TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppv);
         *ppv = OLEWIN(This);
@@ -1697,6 +1770,9 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
     }else if(IsEqualGUID(&IID_IMarshal, riid)) {
         TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
         *ppv = NULL;
+    }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
+        TRACE("(%p)->(IID_IObjectWithSite %p)\n", This, ppv);
+        *ppv = OBJSITE(This);
     }else {
         return FALSE;
     }
@@ -1706,6 +1782,8 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
     return TRUE;
 }
 
+static cp_static_data_t HTMLDocumentEvents_data = { HTMLDocumentEvents_tid, HTMLDocument_on_advise };
+
 static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
 {
     doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
@@ -1727,9 +1805,10 @@ static void init_doc(HTMLDocument *doc, IUnknown *unk_impl, IDispatchEx *dispex)
     HTMLDocument_Hlink_Init(doc);
 
     ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
-    ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
-    ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
-    ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
+    ConnectionPoint_Init(&doc->cp_dispatch, &doc->cp_container, &IID_IDispatch, NULL);
+    ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink, NULL);
+    ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents, &HTMLDocumentEvents_data);
+    ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2, NULL);
 }
 
 static void destroy_htmldoc(HTMLDocument *This)
@@ -1763,8 +1842,12 @@ static void HTMLDocumentNode_destructor(HTMLDOMNode *iface)
 {
     HTMLDocumentNode *This = HTMLDOCNODE_NODE_THIS(iface);
 
+    if(This->body_event_target)
+        release_event_target(This->body_event_target);
     if(This->nsevent_listener)
         release_nsevents(This);
+    if(This->catmgr)
+        ICatInformation_Release(This->catmgr);
     if(This->secmgr)
         IInternetSecurityManager_Release(This->secmgr);
 
@@ -1823,6 +1906,8 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
     doc->ref = 1;
 
     doc->basedoc.window = window;
+    if(window == doc_obj->basedoc.window)
+        doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
 
     nsIDOMHTMLDocument_AddRef(nsdoc);
     doc->nsdoc = nsdoc;
@@ -1835,6 +1920,7 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
 
     HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc);
     doc->node.vtbl = &HTMLDocumentNodeImplVtbl;
+    doc->node.cp_container = &doc->basedoc.cp_container;
 
     hres = CoInternetCreateSecurityManager(NULL, &doc->secmgr, 0);
     if(FAILED(hres)) {
@@ -1900,6 +1986,8 @@ static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
             This->basedoc.window->doc_obj = NULL;
             IHTMLWindow2_Release(HTMLWINDOW2(This->basedoc.window));
         }
+        if(This->basedoc.advise_holder)
+            IOleAdviseHolder_Release(This->basedoc.advise_holder);
 
         if(This->client)
             IOleObject_SetClientSite(OLEOBJ(&This->basedoc), NULL);
index a00fa95..de32302 100644 (file)
@@ -431,6 +431,8 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v
     HTMLDocument *This = HTMLDOC3_THIS(iface);
     nsIDOMElement *nselem;
     HTMLDOMNode *node;
+    nsIDOMNode *nsnode, *nsnode_by_id, *nsnode_by_name;
+    nsIDOMNodeList *nsnode_list;
     nsAString id_str;
     nsresult nsres;
 
@@ -442,16 +444,64 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v
     }
 
     nsAString_Init(&id_str, v);
+    /* get element by id attribute */
     nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &id_str, &nselem);
-    nsAString_Finish(&id_str);
     if(FAILED(nsres)) {
         ERR("GetElementById failed: %08x\n", nsres);
+        nsAString_Finish(&id_str);
         return E_FAIL;
     }
+    nsnode_by_id = (nsIDOMNode*)nselem;
 
-    if(nselem) {
-        node = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE);
-        nsIDOMElement_Release(nselem);
+    /* get first element by name attribute */
+    nsres = nsIDOMHTMLDocument_GetElementsByName(This->doc_node->nsdoc, &id_str, &nsnode_list);
+    if(FAILED(nsres)) {
+        ERR("getElementsByName failed: %08x\n", nsres);
+        nsAString_Finish(&id_str);
+        if(nsnode_by_id)
+            nsIDOMNode_Release(nsnode_by_id);
+        return E_FAIL;
+    }
+    nsIDOMNodeList_Item(nsnode_list, 0, &nsnode_by_name);
+    nsIDOMNodeList_Release(nsnode_list);
+
+    nsAString_Finish(&id_str);
+
+    if(nsnode_by_name && nsnode_by_id) {
+        nsIDOM3Node *node3;
+        PRUint16 pos;
+
+        nsres = nsIDOMNode_QueryInterface(nsnode_by_name, &IID_nsIDOM3Node, (void**)&node3);
+        if(NS_FAILED(nsres)) {
+            FIXME("failed to get nsIDOM3Node interface: 0x%08x\n", nsres);
+            nsIDOMNode_Release(nsnode_by_name);
+            nsIDOMNode_Release(nsnode_by_id);
+            return E_FAIL;
+        }
+
+        nsres = nsIDOM3Node_CompareDocumentPosition(node3, nsnode_by_id, &pos);
+        nsIDOM3Node_Release(node3);
+        if(NS_FAILED(nsres)) {
+            FIXME("nsIDOM3Node_CompareDocumentPosition failed: 0x%08x\n", nsres);
+            nsIDOMNode_Release(nsnode_by_name);
+            nsIDOMNode_Release(nsnode_by_id);
+            return E_FAIL;
+        }
+
+        TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
+        if(pos & PRECEDING || pos & CONTAINS) {
+            nsnode = nsnode_by_id;
+            nsIDOMNode_Release(nsnode_by_name);
+        }else {
+            nsnode = nsnode_by_name;
+            nsIDOMNode_Release(nsnode_by_id);
+        }
+    }else
+        nsnode = nsnode_by_name ? nsnode_by_name : nsnode_by_id;
+
+    if(nsnode) {
+        node = get_node(This->doc_node, nsnode, TRUE);
+        nsIDOMNode_Release(nsnode);
 
         IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)pel);
     }else {
@@ -620,7 +670,7 @@ static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
         return E_FAIL;
     }
 
-    nsres = nsIDOMNSHTMLElement_focus(nselem);
+    nsres = nsIDOMNSHTMLElement_Focus(nselem);
     nsIDOMNSHTMLElement_Release(nselem);
     if(NS_FAILED(nsres)) {
         ERR("Focus failed: %08x\n", nsres);
index b794b73..a65ed20 100644 (file)
 #include "mshtml_private.h"
 #include "htmlevent.h"
 
+typedef struct
+{
+    DispatchEx dispex;
+    const IHTMLFiltersCollectionVtbl *lpHTMLFiltersCollectionVtbl;
+
+    LONG ref;
+} HTMLFiltersCollection;
+
+#define HTMLFILTERSCOLLECTION(x)     ((IHTMLFiltersCollection*)  &(x)->lpHTMLFiltersCollectionVtbl)
+
+#define HTMLFILTERSCOLLECTION_THIS(iface) \
+    DEFINE_THIS(HTMLFiltersCollection, HTMLFiltersCollection, iface)
+
+IHTMLFiltersCollection *HTMLFiltersCollection_Create(void);
+
+
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 #define HTMLELEM_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement, iface)
@@ -569,9 +585,11 @@ static HRESULT WINAPI HTMLElement_get_document(IHTMLElement *iface, IDispatch **
     if(!p)
         return E_POINTER;
 
+    if(This->node.vtbl->get_document)
+        return This->node.vtbl->get_document(&This->node, p);
+
     *p = (IDispatch*)HTMLDOC(&This->node.doc->basedoc);
     IDispatch_AddRef(*p);
-
     return S_OK;
 }
 
@@ -908,8 +926,63 @@ static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
 static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
 {
     HTMLElement *This = HTMLELEM_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    nsIDOMDocumentFragment *nsfragment;
+    nsIDOMDocumentRange *nsdocrange;
+    nsIDOMNSRange *nsrange;
+    nsIDOMNode *nsparent;
+    nsIDOMRange *range;
+    nsAString html_str;
+    nsresult nsres;
+    HRESULT hres = S_OK;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    nsres = nsIDOMHTMLDocument_QueryInterface(This->node.doc->nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
+    if(NS_FAILED(nsres))
+        return E_FAIL;
+
+    nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &range);
+    nsIDOMDocumentRange_Release(nsdocrange);
+    if(NS_FAILED(nsres)) {
+        ERR("CreateRange failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void**)&nsrange);
+    nsIDOMRange_Release(range);
+    if(NS_FAILED(nsres)) {
+        ERR("Could not get nsIDOMNSRange: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsAString_Init(&html_str, v);
+    nsIDOMNSRange_CreateContextualFragment(nsrange, &html_str, &nsfragment);
+    nsIDOMNSRange_Release(nsrange);
+    nsAString_Finish(&html_str);
+    if(NS_FAILED(nsres)) {
+        ERR("CreateContextualFragment failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &nsparent);
+    if(NS_SUCCEEDED(nsres) && nsparent) {
+        nsIDOMNode *nstmp;
+
+        nsres = nsIDOMNode_ReplaceChild(nsparent, (nsIDOMNode*)nsfragment, This->node.nsnode, &nstmp);
+        nsIDOMNode_Release(nsparent);
+        if(NS_FAILED(nsres)) {
+            ERR("ReplaceChild failed: %08x\n", nsres);
+            hres = E_FAIL;
+        }else if(nstmp) {
+            nsIDOMNode_Release(nstmp);
+        }
+    }else {
+        ERR("GetParentNode failed: %08x\n", nsres);
+        hres = E_FAIL;
+    }
+
+    nsIDOMDocumentFragment_Release(nsfragment);
+    return hres;
 }
 
 static HRESULT WINAPI HTMLElement_get_outerHTML(IHTMLElement *iface, BSTR *p)
@@ -959,19 +1032,13 @@ static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsI
     static const WCHAR wszAfterEnd[] = {'a','f','t','e','r','E','n','d',0};
     nsresult nsres;
 
-    if(!This->nselem) {
-        FIXME("NULL nselem\n");
-        return E_NOTIMPL;
-    }
-
     if (!strcmpiW(where, wszBeforeBegin))
     {
         nsIDOMNode *unused;
         nsIDOMNode *parent;
-        nsres = nsIDOMNode_GetParentNode(This->nselem, &parent);
+        nsres = nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
         if (!parent) return E_INVALIDARG;
-        nsres = nsIDOMNode_InsertBefore(parent, nsnode,
-                                        (nsIDOMNode *)This->nselem, &unused);
+        nsres = nsIDOMNode_InsertBefore(parent, nsnode, This->node.nsnode, &unused);
         if (unused) nsIDOMNode_Release(unused);
         nsIDOMNode_Release(parent);
     }
@@ -979,15 +1046,15 @@ static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsI
     {
         nsIDOMNode *unused;
         nsIDOMNode *first_child;
-        nsIDOMNode_GetFirstChild(This->nselem, &first_child);
-        nsres = nsIDOMNode_InsertBefore(This->nselem, nsnode, first_child, &unused);
+        nsIDOMNode_GetFirstChild(This->node.nsnode, &first_child);
+        nsres = nsIDOMNode_InsertBefore(This->node.nsnode, nsnode, first_child, &unused);
         if (unused) nsIDOMNode_Release(unused);
         if (first_child) nsIDOMNode_Release(first_child);
     }
     else if (!strcmpiW(where, wszBeforeEnd))
     {
         nsIDOMNode *unused;
-        nsres = nsIDOMNode_AppendChild(This->nselem, nsnode, &unused);
+        nsres = nsIDOMNode_AppendChild(This->node.nsnode, nsnode, &unused);
         if (unused) nsIDOMNode_Release(unused);
     }
     else if (!strcmpiW(where, wszAfterEnd))
@@ -995,10 +1062,10 @@ static HRESULT HTMLElement_InsertAdjacentNode(HTMLElement *This, BSTR where, nsI
         nsIDOMNode *unused;
         nsIDOMNode *next_sibling;
         nsIDOMNode *parent;
-        nsIDOMNode_GetParentNode(This->nselem, &parent);
+        nsIDOMNode_GetParentNode(This->node.nsnode, &parent);
         if (!parent) return E_INVALIDARG;
 
-        nsIDOMNode_GetNextSibling(This->nselem, &next_sibling);
+        nsIDOMNode_GetNextSibling(This->node.nsnode, &next_sibling);
         if (next_sibling)
         {
             nsres = nsIDOMNode_InsertBefore(parent, nsnode, next_sibling, &unused);
@@ -1054,7 +1121,7 @@ static HRESULT WINAPI HTMLElement_insertAdjacentHTML(IHTMLElement *iface, BSTR w
         return E_FAIL;
     }
 
-    nsIDOMRange_SetStartBefore(range, (nsIDOMNode *)This->nselem);
+    nsIDOMRange_SetStartBefore(range, This->node.nsnode);
 
     nsIDOMRange_QueryInterface(range, &IID_nsIDOMNSRange, (void **)&nsrange);
     nsIDOMRange_Release(range);
@@ -1142,8 +1209,14 @@ static HRESULT WINAPI HTMLElement_get_filters(IHTMLElement *iface,
                                               IHTMLFiltersCollection **p)
 {
     HTMLElement *This = HTMLELEM_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(!p)
+        return E_POINTER;
+
+    *p = HTMLFiltersCollection_Create();
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLElement_put_ondragstart(IHTMLElement *iface, VARIANT v)
@@ -1323,6 +1396,31 @@ static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p)
     return S_OK;
 }
 
+static HRESULT HTMLElement_get_dispid(IUnknown *iface, BSTR name,
+        DWORD grfdex, DISPID *pid)
+{
+    HTMLElement *This = HTMLELEM_THIS(iface);
+
+    if(This->node.vtbl->get_dispid)
+        return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid);
+
+    return DISP_E_UNKNOWNNAME;
+}
+
+static HRESULT HTMLElement_invoke(IUnknown *iface, DISPID id, LCID lcid,
+        WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
+        IServiceProvider *caller)
+{
+    HTMLElement *This = HTMLELEM_THIS(iface);
+
+    if(This->node.vtbl->invoke)
+        return This->node.vtbl->invoke(&This->node, id, lcid, flags,
+                params, res, ei, caller);
+
+    ERR("(%p): element has no invoke method\n", This);
+    return E_NOTIMPL;
+}
+
 #undef HTMLELEM_THIS
 
 static const IHTMLElementVtbl HTMLElementVtbl = {
@@ -1482,8 +1580,14 @@ static const tid_t HTMLElement_iface_tids[] = {
     0
 };
 
-static dispex_static_data_t HTMLElement_dispex = {
+static dispex_static_data_vtbl_t HTMLElement_dispex_vtbl = {
     NULL,
+    HTMLElement_get_dispid,
+    HTMLElement_invoke
+};
+
+static dispex_static_data_t HTMLElement_dispex = {
+    &HTMLElement_dispex_vtbl,
     DispHTMLUnknownElement_tid,
     NULL,
     HTMLElement_iface_tids
@@ -1496,6 +1600,8 @@ void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElemen
     HTMLElement2_Init(This);
     HTMLElement3_Init(This);
 
+    if(dispex_data && !dispex_data->vtbl)
+        dispex_data->vtbl = &HTMLElement_dispex_vtbl;
     init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
 
     if(nselem)
@@ -1517,6 +1623,8 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL
 
     static const WCHAR wszA[]        = {'A',0};
     static const WCHAR wszBODY[]     = {'B','O','D','Y',0};
+    static const WCHAR wszFORM[]     = {'F','O','R','M',0};
+    static const WCHAR wszFRAME[]    = {'F','R','A','M','E',0};
     static const WCHAR wszIFRAME[]   = {'I','F','R','A','M','E',0};
     static const WCHAR wszIMG[]      = {'I','M','G',0};
     static const WCHAR wszINPUT[]    = {'I','N','P','U','T',0};
@@ -1540,8 +1648,12 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL
         ret = HTMLAnchorElement_Create(doc, nselem);
     else if(!strcmpW(class_name, wszBODY))
         ret = HTMLBodyElement_Create(doc, nselem);
+    else if(!strcmpW(class_name, wszFORM))
+        ret = HTMLFormElement_Create(doc, nselem);
+    else if(!strcmpW(class_name, wszFRAME))
+        ret = HTMLFrameElement_Create(doc, nselem);
     else if(!strcmpW(class_name, wszIFRAME))
-        ret = HTMLIFrame_Create(doc, nselem, NULL);
+        ret = HTMLIFrame_Create(doc, nselem);
     else if(!strcmpW(class_name, wszIMG))
         ret = HTMLImgElement_Create(doc, nselem);
     else if(!strcmpW(class_name, wszINPUT))
@@ -1574,3 +1686,185 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL
 
     return ret;
 }
+
+/* interaface IHTMLFiltersCollection */
+static HRESULT WINAPI HTMLFiltersCollection_QueryInterface(IHTMLFiltersCollection *iface, REFIID riid, void **ppv)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+
+    TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
+
+    if(IsEqualGUID(&IID_IUnknown, riid)) {
+        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+        *ppv = HTMLFILTERSCOLLECTION(This);
+    }else if(IsEqualGUID(&IID_IHTMLFiltersCollection, riid)) {
+        TRACE("(%p)->(IID_IHTMLFiltersCollection %p)\n", This, ppv);
+        *ppv = HTMLFILTERSCOLLECTION(This);
+    }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
+        return *ppv ? S_OK : E_NOINTERFACE;
+    }
+
+    if(*ppv) {
+        IUnknown_AddRef((IUnknown*)*ppv);
+        return S_OK;
+    }
+
+    FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI HTMLFiltersCollection_AddRef(IHTMLFiltersCollection *iface)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    LONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI HTMLFiltersCollection_Release(IHTMLFiltersCollection *iface)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    LONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    if(!ref)
+    {
+        heap_free(This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfoCount(IHTMLFiltersCollection *iface, UINT *pctinfo)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_GetTypeInfo(IHTMLFiltersCollection *iface,
+                                    UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_GetIDsOfNames(IHTMLFiltersCollection *iface,
+                                    REFIID riid, LPOLESTR *rgszNames, UINT cNames,
+                                    LCID lcid, DISPID *rgDispId)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_Invoke(IHTMLFiltersCollection *iface, DISPID dispIdMember, REFIID riid,
+                                    LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
+                                    EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
+            wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_get_length(IHTMLFiltersCollection *iface, LONG *p)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+
+    FIXME("(%p)->(%p) Always returning 0\n", This, p);
+
+       if(!p)
+               return E_POINTER;
+
+    if(p)
+        *p = 0;
+
+    return S_OK;
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_get__newEnum(IHTMLFiltersCollection *iface, IUnknown **p)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFiltersCollection_item(IHTMLFiltersCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+    FIXME("(%p)->(%p, %p)\n", This, pvarIndex, pvarResult);
+    return E_NOTIMPL;
+}
+
+static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = {
+    HTMLFiltersCollection_QueryInterface,
+    HTMLFiltersCollection_AddRef,
+    HTMLFiltersCollection_Release,
+    HTMLFiltersCollection_GetTypeInfoCount,
+    HTMLFiltersCollection_GetTypeInfo,
+    HTMLFiltersCollection_GetIDsOfNames,
+    HTMLFiltersCollection_Invoke,
+    HTMLFiltersCollection_get_length,
+    HTMLFiltersCollection_get__newEnum,
+    HTMLFiltersCollection_item
+};
+
+static HRESULT HTMLFiltersCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid)
+{
+    WCHAR *ptr;
+    int idx = 0;
+
+    for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
+        idx = idx*10 + (*ptr-'0');
+    if(*ptr)
+        return DISP_E_UNKNOWNNAME;
+
+    *dispid = MSHTML_DISPID_CUSTOM_MIN + idx;
+    TRACE("ret %x\n", *dispid);
+    return S_OK;
+}
+
+static HRESULT HTMLFiltersCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
+        VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
+{
+    HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface);
+
+    TRACE("(%p)->(%x %x %x %p %p %p)\n", This, id, lcid, flags, params, res, ei);
+
+    V_VT(res) = VT_DISPATCH;
+    V_DISPATCH(res) = NULL;
+
+    FIXME("always returning NULL\n");
+
+    return S_OK;
+}
+
+static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
+    NULL,
+    HTMLFiltersCollection_get_dispid,
+    HTMLFiltersCollection_invoke
+};
+
+static const tid_t HTMLFiltersCollection_iface_tids[] = {
+    IHTMLFiltersCollection_tid,
+    0
+};
+static dispex_static_data_t HTMLFiltersCollection_dispex = {
+    &HTMLFiltersCollection_dispex_vtbl,
+    IHTMLFiltersCollection_tid,
+    NULL,
+    HTMLFiltersCollection_iface_tids
+};
+
+IHTMLFiltersCollection *HTMLFiltersCollection_Create()
+{
+    HTMLFiltersCollection *ret = heap_alloc(sizeof(HTMLFiltersCollection));
+
+    ret->lpHTMLFiltersCollectionVtbl = &HTMLFiltersCollectionVtbl;
+    ret->ref = 1;
+
+    init_dispex(&ret->dispex, (IUnknown*)HTMLFILTERSCOLLECTION(ret),  &HTMLFiltersCollection_dispex);
+
+    return HTMLFILTERSCOLLECTION(ret);
+}
index d001eaa..cd9b676 100644 (file)
@@ -451,7 +451,7 @@ static HRESULT WINAPI HTMLElement2_focus(IHTMLElement2 *iface)
 
     nsres = nsIDOMHTMLElement_QueryInterface(This->nselem, &IID_nsIDOMNSHTMLElement, (void**)&nselem);
     if(NS_SUCCEEDED(nsres)) {
-        nsIDOMNSHTMLElement_focus(nselem);
+        nsIDOMNSHTMLElement_Focus(nselem);
         nsIDOMNSHTMLElement_Release(nselem);
     }else {
         ERR("Could not get nsIDOMHTMLNSElement: %08x\n", nsres);
@@ -662,15 +662,34 @@ static HRESULT WINAPI HTMLElement2_detachEvent(IHTMLElement2 *iface, BSTR event,
 static HRESULT WINAPI HTMLElement2_get_readyState(IHTMLElement2 *iface, VARIANT *p)
 {
     HTMLElement *This = HTMLELEM2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    BSTR str;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->node.vtbl->get_readystate) {
+        HRESULT hres;
+
+        hres = This->node.vtbl->get_readystate(&This->node, &str);
+        if(FAILED(hres))
+            return hres;
+    }else {
+        static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
+
+        str = SysAllocString(completeW);
+        if(!str)
+            return E_OUTOFMEMORY;
+    }
+
+    V_VT(p) = VT_BSTR;
+    V_BSTR(p) = str;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLElement2_put_onreadystatechange(IHTMLElement2 *iface, VARIANT v)
 {
     HTMLElement *This = HTMLELEM2_THIS(iface);
 
-    FIXME("(%p)->(%s): semi-stub\n", This, debugstr_variant(&v));
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
     return set_node_event(&This->node, EVENTID_READYSTATECHANGE, &v);
 }
index 70827bc..c973707 100644 (file)
@@ -205,6 +205,26 @@ static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection
     return E_NOTIMPL;
 }
 
+static BOOL is_elem_id(HTMLElement *elem, LPCWSTR name)
+{
+    BSTR elem_id;
+    HRESULT hres;
+
+    hres = IHTMLElement_get_id(HTMLELEM(elem), &elem_id);
+    if(FAILED(hres)){
+        WARN("IHTMLElement_get_id failed: 0x%08x\n", hres);
+        return FALSE;
+    }
+
+    if(elem_id && !strcmpW(elem_id, name)) {
+        SysFreeString(elem_id);
+        return TRUE;
+    }
+
+    SysFreeString(elem_id);
+    return FALSE;
+}
+
 static BOOL is_elem_name(HTMLElement *elem, LPCWSTR name)
 {
     const PRUnichar *str;
@@ -376,7 +396,16 @@ static HRESULT HTMLElementCollection_get_dispid(IUnknown *iface, BSTR name, DWOR
     for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
         idx = idx*10 + (*ptr-'0');
 
-    if(*ptr || idx >= This->len)
+    if(*ptr) {
+        /* the name contains alpha characters, so search by name & id */
+        for(idx = 0; idx < This->len; ++idx) {
+            if(is_elem_id(This->elems[idx], name) ||
+                    is_elem_name(This->elems[idx], name))
+                break;
+        }
+    }
+
+    if(idx >= This->len)
         return DISP_E_UNKNOWNNAME;
 
     *dispid = DISPID_ELEMCOL_0 + idx;
index 345fd83..d04b2e6 100644 (file)
@@ -24,6 +24,7 @@
 #include "winbase.h"
 #include "winuser.h"
 #include "ole2.h"
+#include "mshtmdid.h"
 
 #include "mshtml_private.h"
 #include "htmlevent.h"
@@ -93,6 +94,9 @@ static const WCHAR onpasteW[] = {'o','n','p','a','s','t','e',0};
 static const WCHAR readystatechangeW[] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
 static const WCHAR onreadystatechangeW[] = {'o','n','r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
 
+static const WCHAR resizeW[] = {'r','e','s','i','z','e',0};
+static const WCHAR onresizeW[] = {'o','n','r','e','s','i','z','e',0};
+
 static const WCHAR selectstartW[] = {'s','e','l','e','c','t','s','t','a','r','t',0};
 static const WCHAR onselectstartW[] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0};
 
@@ -118,6 +122,7 @@ typedef struct {
     LPCWSTR name;
     LPCWSTR attr_name;
     DWORD type;
+    DISPID dispid;
     DWORD flags;
 } event_info_t;
 
@@ -126,24 +131,44 @@ typedef struct {
 #define EVENT_FORWARDBODY        0x0004
 
 static const event_info_t event_info[] = {
-    {beforeunloadW,      onbeforeunloadW,      EVENTT_NONE,  EVENT_DEFAULTLISTENER|EVENT_FORWARDBODY},
-    {blurW,              onblurW,              EVENTT_HTML,  EVENT_DEFAULTLISTENER},
-    {changeW,            onchangeW,            EVENTT_HTML,  EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {clickW,             onclickW,             EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {dblclickW,          ondblclickW,          EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {dragW,              ondragW,              EVENTT_MOUSE, 0},
-    {dragstartW,         ondragstartW,         EVENTT_MOUSE, 0},
-    {focusW,             onfocusW,             EVENTT_HTML,  EVENT_DEFAULTLISTENER},
-    {keydownW,           onkeydownW,           EVENTT_KEY,   EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {keyupW,             onkeyupW,             EVENTT_KEY,   EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {loadW,              onloadW,              EVENTT_HTML,  0},
-    {mousedownW,         onmousedownW,         EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {mouseoutW,          onmouseoutW,          EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {mouseoverW,         onmouseoverW,         EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {mouseupW,           onmouseupW,           EVENTT_MOUSE, EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
-    {pasteW,             onpasteW,             EVENTT_NONE,  0},
-    {readystatechangeW,  onreadystatechangeW,  EVENTT_NONE,  0},
-    {selectstartW,       onselectstartW,       EVENTT_MOUSE, 0}
+    {beforeunloadW,      onbeforeunloadW,      EVENTT_NONE,   DISPID_EVMETH_ONBEFOREUNLOAD,
+        EVENT_DEFAULTLISTENER|EVENT_FORWARDBODY},
+    {blurW,              onblurW,              EVENTT_HTML,   DISPID_EVMETH_ONBLUR,
+        EVENT_DEFAULTLISTENER},
+    {changeW,            onchangeW,            EVENTT_HTML,   DISPID_EVMETH_ONCHANGE,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {clickW,             onclickW,             EVENTT_MOUSE,  DISPID_EVMETH_ONCLICK,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {dblclickW,          ondblclickW,          EVENTT_MOUSE,  DISPID_EVMETH_ONDBLCLICK,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {dragW,              ondragW,              EVENTT_MOUSE,  DISPID_EVMETH_ONDRAG,
+        0},
+    {dragstartW,         ondragstartW,         EVENTT_MOUSE,  DISPID_EVMETH_ONDRAGSTART,
+        0},
+    {focusW,             onfocusW,             EVENTT_HTML,   DISPID_EVMETH_ONFOCUS,
+        EVENT_DEFAULTLISTENER},
+    {keydownW,           onkeydownW,           EVENTT_KEY,    DISPID_EVMETH_ONKEYDOWN,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {keyupW,             onkeyupW,             EVENTT_KEY,    DISPID_EVMETH_ONKEYUP,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {loadW,              onloadW,              EVENTT_HTML,   DISPID_EVMETH_ONLOAD,
+        0},
+    {mousedownW,         onmousedownW,         EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEDOWN,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {mouseoutW,          onmouseoutW,          EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEOUT,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {mouseoverW,         onmouseoverW,         EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEOVER,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {mouseupW,           onmouseupW,           EVENTT_MOUSE,  DISPID_EVMETH_ONMOUSEUP,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {pasteW,             onpasteW,             EVENTT_NONE,   DISPID_EVMETH_ONPASTE,
+        0},
+    {readystatechangeW,  onreadystatechangeW,  EVENTT_NONE,   DISPID_EVMETH_ONREADYSTATECHANGE,
+        0},
+    {resizeW,            onresizeW,            EVENTT_NONE,   DISPID_EVMETH_ONRESIZE,
+        EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
+    {selectstartW,       onselectstartW,       EVENTT_MOUSE,  DISPID_EVMETH_ONSELECTSTART,
+        0}
 };
 
 eventid_t str_to_eid(LPCWSTR str)
@@ -738,17 +763,66 @@ static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEve
     return HTMLEVENTOBJ(ret);
 }
 
+static HRESULT call_cp_func(IDispatch *disp, DISPID dispid)
+{
+    DISPPARAMS dp = {NULL,NULL,0,0};
+    ULONG argerr;
+    EXCEPINFO ei;
+    VARIANT vres;
+    HRESULT hres;
+
+    V_VT(&vres) = VT_EMPTY;
+    memset(&ei, 0, sizeof(ei));
+    hres = IDispatch_Invoke(disp, dispid, &IID_NULL, 0, DISPATCH_METHOD, &dp, &vres, &ei, &argerr);
+    if(SUCCEEDED(hres) && V_VT(&vres) != VT_EMPTY) {
+        FIXME("handle result %s\n", debugstr_variant(&vres));
+        VariantClear(&vres);
+    }
+
+    return hres;
+}
+
+static BOOL is_cp_event(cp_static_data_t *data, DISPID dispid)
+{
+    int min, max, i;
+    HRESULT hres;
+
+    if(!data)
+        return FALSE;
+
+    if(!data->ids) {
+        hres = get_dispids(data->tid, &data->id_cnt, &data->ids);
+        if(FAILED(hres))
+            return FALSE;
+    }
+
+    min = 0;
+    max = data->id_cnt-1;
+    while(min <= max) {
+        i = (min+max)/2;
+        if(data->ids[i] == dispid)
+            return TRUE;
+
+        if(data->ids[i] < dispid)
+            min = i+1;
+        else
+            max = i-1;
+    }
+
+    return FALSE;
+}
+
 static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, event_target_t *event_target,
-        eventid_t eid, IDispatch *this_obj)
+        ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj)
 {
-    handler_vector_t *handler_vector;
+    handler_vector_t *handler_vector = NULL;
     DWORD i;
     HRESULT hres;
 
-    if(!event_target || !(handler_vector = event_target->event_table[eid]))
-        return;
+    if(event_target)
+        handler_vector = event_target->event_table[eid];
 
-    if(handler_vector->handler_prop) {
+    if(handler_vector && handler_vector->handler_prop) {
         DISPID named_arg = DISPID_THIS;
         VARIANTARG arg;
         DISPPARAMS dp = {&arg, &named_arg, 1, 1};
@@ -764,7 +838,7 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj,
             WARN("%s <<< %08x\n", debugstr_w(event_info[eid].name), hres);
     }
 
-    if(handler_vector->handler_cnt) {
+    if(handler_vector && handler_vector->handler_cnt) {
         VARIANTARG arg;
         DISPPARAMS dp = {&arg, NULL, 1, 0};
 
@@ -782,6 +856,26 @@ static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj,
             }
         }
     }
+
+    if(cp_container) {
+        ConnectionPoint *cp;
+
+        if(cp_container->forward_container)
+            cp_container = cp_container->forward_container;
+
+        for(cp = cp_container->cp_list; cp; cp = cp->next) {
+            if(cp->sinks_size && is_cp_event(cp->data, event_info[eid].dispid)) {
+                for(i=0; i < cp->sinks_size; i++) {
+                    TRACE("cp %s [%d] >>>\n", debugstr_w(event_info[eid].name), i);
+                    hres = call_cp_func(cp->sinks[i].disp, event_info[eid].dispid);
+                    if(hres == S_OK)
+                        TRACE("cp %s [%d] <<<\n", debugstr_w(event_info[eid].name), i);
+                    else
+                        WARN("cp %s [%d] <<< %08x\n", debugstr_w(event_info[eid].name), i, hres);
+                }
+            }
+        }
+    }
 }
 
 void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOMEvent *nsevent)
@@ -805,7 +899,8 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOM
         do {
             node = get_node(doc, nsnode, FALSE);
             if(node)
-                call_event_handlers(doc, event_obj, *get_node_event_target(node), eid, (IDispatch*)HTMLDOMNODE(node));
+                call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container, eid,
+                        (IDispatch*)HTMLDOMNODE(node));
 
             if(!(event_info[eid].flags & EVENT_BUBBLE))
                 break;
@@ -831,14 +926,15 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOM
             if(NS_SUCCEEDED(nsres) && nsbody) {
                 node = get_node(doc, (nsIDOMNode*)nsbody, FALSE);
                 if(node)
-                    call_event_handlers(doc, event_obj, *get_node_event_target(node), eid, (IDispatch*)HTMLDOMNODE(node));
+                    call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container,
+                            eid, (IDispatch*)HTMLDOMNODE(node));
                 nsIDOMHTMLElement_Release(nsbody);
             }else {
                 ERR("Could not get body: %08x\n", nsres);
             }
         }
 
-        call_event_handlers(doc, event_obj, doc->basedoc.doc_node->node.event_target, eid,
+        call_event_handlers(doc, event_obj, doc->node.event_target, &doc->basedoc.cp_container, eid,
                 (IDispatch*)HTMLDOC(&doc->basedoc));
         break;
 
@@ -921,6 +1017,25 @@ static BOOL alloc_handler_vector(event_target_t *event_target, eventid_t eid, in
     return TRUE;
 }
 
+static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, eventid_t eid)
+{
+    if(!doc->nsdoc || !(event_info[eid].flags & EVENT_DEFAULTLISTENER))
+        return S_OK;
+
+    if(!doc->event_vector) {
+        doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
+        if(!doc->event_vector)
+            return E_OUTOFMEMORY;
+    }
+
+    if(!doc->event_vector[eid]) {
+        doc->event_vector[eid] = TRUE;
+        add_nsevent_listener(doc, event_info[eid].name);
+    }
+
+    return S_OK;
+}
+
 static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDocumentNode *doc,
         eventid_t eid, IDispatch *disp)
 {
@@ -941,20 +1056,7 @@ static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, HTMLDoc
         return S_OK;
     IDispatch_AddRef(disp);
 
-    if(doc->nsdoc && (event_info[eid].flags & EVENT_DEFAULTLISTENER)) {
-        if(!doc->event_vector) {
-            doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
-            if(!doc->event_vector)
-                return E_OUTOFMEMORY;
-        }
-
-        if(!doc->event_vector[eid]) {
-            doc->event_vector[eid] = TRUE;
-            add_nsevent_listener(doc, event_info[eid].name);
-        }
-    }
-
-    return S_OK;
+    return ensure_nsevent_handler(doc, eid);
 }
 
 HRESULT set_event_handler(event_target_t **event_target, HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
@@ -972,6 +1074,7 @@ HRESULT set_event_handler(event_target_t **event_target, HTMLDocumentNode *doc,
 
     default:
         FIXME("not supported vt=%d\n", V_VT(var));
+    case VT_EMPTY:
         return E_NOTIMPL;
     }
 
@@ -1024,6 +1127,16 @@ HRESULT attach_event(event_target_t **event_target_ptr, HTMLDocument *doc, BSTR
     return S_OK;
 }
 
+void update_cp_events(HTMLWindow *window, cp_static_data_t *cp)
+{
+    int i;
+
+    for(i=0; i < EVENTID_LAST; i++) {
+        if((event_info[i].flags & EVENT_DEFAULTLISTENER) && is_cp_event(cp, event_info[i].dispid))
+            ensure_nsevent_handler(window->doc, i);
+    }
+}
+
 void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
 {
     const PRUnichar *attr_value;
index d0332ee..1a8572f 100644 (file)
@@ -34,6 +34,7 @@ typedef enum {
     EVENTID_MOUSEUP,
     EVENTID_PASTE,
     EVENTID_READYSTATECHANGE,
+    EVENTID_RESIZE,
     EVENTID_SELECTSTART,
     EVENTID_LAST
 } eventid_t;
@@ -47,6 +48,7 @@ HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*);
 HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*);
 HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*);
 HRESULT call_event(HTMLDOMNode*,eventid_t);
+void update_cp_events(HTMLWindow*,cp_static_data_t*);
 
 static inline event_target_t **get_node_event_target(HTMLDOMNode *node)
 {
@@ -72,13 +74,3 @@ static inline HRESULT get_doc_event(HTMLDocument *doc, eventid_t eid, VARIANT *v
 {
     return get_node_event(&doc->doc_node->node, eid, var);
 }
-
-static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
-{
-    return set_event_handler(&window->event_target, window->doc, eid, var);
-}
-
-static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
-{
-    return get_event_handler(&window->event_target, eid, var);
-}
diff --git a/reactos/dll/win32/mshtml/htmlform.c b/reactos/dll/win32/mshtml/htmlform.c
new file mode 100644 (file)
index 0000000..1db965a
--- /dev/null
@@ -0,0 +1,517 @@
+/*
+ * Copyright 2009 Andrew Eikum for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ole2.h"
+
+#include "wine/debug.h"
+
+#include "mshtml_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
+
+struct HTMLFormElement {
+    HTMLElement element;
+
+    const IHTMLFormElementVtbl *lpHTMLFormElementVtbl;
+
+    nsIDOMHTMLFormElement *nsform;
+};
+
+#define HTMLFORM(x)  (&(x)->lpHTMLFormElementVtbl)
+
+#define HTMLFORM_THIS(iface) DEFINE_THIS(HTMLFormElement, HTMLFormElement, iface)
+
+static HRESULT WINAPI HTMLFormElement_QueryInterface(IHTMLFormElement *iface,
+        REFIID riid, void **ppv)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+
+    return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
+}
+
+static ULONG WINAPI HTMLFormElement_AddRef(IHTMLFormElement *iface)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+
+    return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
+}
+
+static ULONG WINAPI HTMLFormElement_Release(IHTMLFormElement *iface)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+
+    return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
+}
+
+static HRESULT WINAPI HTMLFormElement_GetTypeInfoCount(IHTMLFormElement *iface, UINT *pctinfo)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
+}
+
+static HRESULT WINAPI HTMLFormElement_GetTypeInfo(IHTMLFormElement *iface, UINT iTInfo,
+                                              LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
+}
+
+static HRESULT WINAPI HTMLFormElement_GetIDsOfNames(IHTMLFormElement *iface, REFIID riid,
+                                                LPOLESTR *rgszNames, UINT cNames,
+                                                LCID lcid, DISPID *rgDispId)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
+}
+
+static HRESULT WINAPI HTMLFormElement_Invoke(IHTMLFormElement *iface, DISPID dispIdMember,
+                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
+            pVarResult, pExcepInfo, puArgErr);
+}
+
+static HRESULT WINAPI HTMLFormElement_put_action(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_action(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_dir(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_dir(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_encoding(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_encoding(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_method(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_method(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDispatch **p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_target(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_target(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_name(IHTMLFormElement *iface, BSTR v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_name(IHTMLFormElement *iface, BSTR *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_onsubmit(IHTMLFormElement *iface, VARIANT v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(v)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_onsubmit(IHTMLFormElement *iface, VARIANT *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_onreset(IHTMLFormElement *iface, VARIANT v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(v)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_onreset(IHTMLFormElement *iface, VARIANT *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_submit(IHTMLFormElement *iface)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->()\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_reset(IHTMLFormElement *iface)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->()\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_put_length(IHTMLFormElement *iface, LONG v)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%d)\n", This, v);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_get_length(IHTMLFormElement *iface, LONG *p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement__newEnum(IHTMLFormElement *iface, IUnknown **p)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_item(IHTMLFormElement *iface, VARIANT name,
+        VARIANT index, IDispatch **pdisp)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(v v %p)\n", This, pdisp);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFormElement_tags(IHTMLFormElement *iface, VARIANT tagName,
+        IDispatch **pdisp)
+{
+    HTMLFormElement *This = HTMLFORM_THIS(iface);
+    FIXME("(%p)->(v %p)\n", This, pdisp);
+    return E_NOTIMPL;
+}
+
+#undef HTMLFORM_THIS
+
+static const IHTMLFormElementVtbl HTMLFormElementVtbl = {
+    HTMLFormElement_QueryInterface,
+    HTMLFormElement_AddRef,
+    HTMLFormElement_Release,
+    HTMLFormElement_GetTypeInfoCount,
+    HTMLFormElement_GetTypeInfo,
+    HTMLFormElement_GetIDsOfNames,
+    HTMLFormElement_Invoke,
+    HTMLFormElement_put_action,
+    HTMLFormElement_get_action,
+    HTMLFormElement_put_dir,
+    HTMLFormElement_get_dir,
+    HTMLFormElement_put_encoding,
+    HTMLFormElement_get_encoding,
+    HTMLFormElement_put_method,
+    HTMLFormElement_get_method,
+    HTMLFormElement_get_elements,
+    HTMLFormElement_put_target,
+    HTMLFormElement_get_target,
+    HTMLFormElement_put_name,
+    HTMLFormElement_get_name,
+    HTMLFormElement_put_onsubmit,
+    HTMLFormElement_get_onsubmit,
+    HTMLFormElement_put_onreset,
+    HTMLFormElement_get_onreset,
+    HTMLFormElement_submit,
+    HTMLFormElement_reset,
+    HTMLFormElement_put_length,
+    HTMLFormElement_get_length,
+    HTMLFormElement__newEnum,
+    HTMLFormElement_item,
+    HTMLFormElement_tags
+};
+
+#define HTMLFORM_NODE_THIS(iface) DEFINE_THIS2(HTMLFormElement, element.node, iface)
+
+static HRESULT HTMLFormElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
+{
+    HTMLFormElement *This = HTMLFORM_NODE_THIS(iface);
+
+    *ppv = NULL;
+
+    if(IsEqualGUID(&IID_IUnknown, riid)) {
+        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+        *ppv = HTMLFORM(This);
+    }else if(IsEqualGUID(&IID_IDispatch, riid)) {
+        TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
+        *ppv = HTMLFORM(This);
+    }else if(IsEqualGUID(&IID_IHTMLFormElement, riid)) {
+        TRACE("(%p)->(IID_IHTMLFormElement %p)\n", This, ppv);
+        *ppv = HTMLFORM(This);
+    }
+
+    if(*ppv) {
+        IUnknown_AddRef((IUnknown*)*ppv);
+        return S_OK;
+    }
+
+    return HTMLElement_QI(&This->element.node, riid, ppv);
+}
+
+static void HTMLFormElement_destructor(HTMLDOMNode *iface)
+{
+    HTMLFormElement *This = HTMLFORM_NODE_THIS(iface);
+
+    if(This->nsform)
+        nsIDOMHTMLFormElement_Release(This->nsform);
+
+    HTMLElement_destructor(&This->element.node);
+}
+
+static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface,
+        BSTR name, DWORD grfdex, DISPID *pid)
+{
+    HTMLFormElement *This = HTMLFORM_NODE_THIS(iface);
+    nsIDOMHTMLCollection *elements;
+    PRUint32 len, i;
+    static const PRUnichar nameW[] = {'n','a','m','e',0};
+    nsAString nsname;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid);
+
+    nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
+    if(NS_FAILED(nsres)) {
+        FIXME("GetElements failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMHTMLCollection_GetLength(elements, &len);
+    if(NS_FAILED(nsres)) {
+        FIXME("GetLength failed: 0x%08x\n", nsres);
+        nsIDOMHTMLCollection_Release(elements);
+        return E_FAIL;
+    }
+
+    nsAString_Init(&nsname, nameW);
+    for(i = 0; i < len; ++i) {
+        nsIDOMNode *nsitem;
+        nsIDOMHTMLElement *nshtml_elem;
+        nsAString nsstr;
+        const PRUnichar *str;
+
+        nsres = nsIDOMHTMLCollection_Item(elements, i, &nsitem);
+        if(NS_FAILED(nsres)) {
+            FIXME("Item failed: 0x%08x\n", nsres);
+            nsAString_Finish(&nsname);
+            nsIDOMHTMLCollection_Release(elements);
+            return E_FAIL;
+        }
+
+        nsres = nsIDOMNode_QueryInterface(nsitem, &IID_nsIDOMHTMLElement, (void**)&nshtml_elem);
+        nsIDOMNode_Release(nsitem);
+        if(NS_FAILED(nsres)) {
+            FIXME("Failed to get nsIDOMHTMLNode interface: 0x%08x\n", nsres);
+            nsAString_Finish(&nsname);
+            nsIDOMHTMLCollection_Release(elements);
+            return E_FAIL;
+        }
+
+        /* compare by id attr */
+        nsAString_Init(&nsstr, NULL);
+        nsres = nsIDOMHTMLElement_GetId(nshtml_elem, &nsstr);
+        if(NS_FAILED(nsres)) {
+            FIXME("GetId failed: 0x%08x\n", nsres);
+            nsAString_Finish(&nsname);
+            nsIDOMHTMLElement_Release(nshtml_elem);
+            nsIDOMHTMLCollection_Release(elements);
+            return E_FAIL;
+        }
+        nsAString_GetData(&nsstr, &str);
+        if(!strcmpiW(str, name)) {
+            /* FIXME: using index for dispid */
+            *pid = MSHTML_DISPID_CUSTOM_MIN + i;
+            nsAString_Finish(&nsname);
+            nsAString_Finish(&nsstr);
+            nsIDOMHTMLElement_Release(nshtml_elem);
+            nsIDOMHTMLCollection_Release(elements);
+            return S_OK;
+        }
+
+        /* compare by name attr */
+        nsres = nsIDOMHTMLElement_GetAttribute(nshtml_elem, &nsname, &nsstr);
+        nsAString_GetData(&nsstr, &str);
+        if(!strcmpiW(str, name)) {
+            /* FIXME: using index for dispid */
+            *pid = MSHTML_DISPID_CUSTOM_MIN + i;
+            nsAString_Finish(&nsname);
+            nsAString_Finish(&nsstr);
+            nsIDOMHTMLElement_Release(nshtml_elem);
+            nsIDOMHTMLCollection_Release(elements);
+            return S_OK;
+        }
+        nsAString_Finish(&nsstr);
+
+        nsIDOMHTMLElement_Release(nshtml_elem);
+    }
+    nsAString_Finish(&nsname);
+
+    nsIDOMHTMLCollection_Release(elements);
+
+    return DISP_E_UNKNOWNNAME;
+}
+
+static HRESULT HTMLFormElement_invoke(HTMLDOMNode *iface,
+        DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res,
+        EXCEPINFO *ei, IServiceProvider *caller)
+{
+    HTMLFormElement *This = HTMLFORM_NODE_THIS(iface);
+    nsIDOMHTMLCollection *elements;
+    nsIDOMNode *item;
+    HTMLDOMNode *node;
+    nsresult nsres;
+
+    TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
+
+    nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
+    if(NS_FAILED(nsres)) {
+        FIXME("GetElements failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMHTMLCollection_Item(elements, id - MSHTML_DISPID_CUSTOM_MIN, &item);
+    nsIDOMHTMLCollection_Release(elements);
+    if(NS_FAILED(nsres)) {
+        FIXME("Item failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    node = get_node(This->element.node.doc, item, TRUE);
+
+    V_VT(res) = VT_DISPATCH;
+    V_DISPATCH(res) = (IDispatch*)node;
+
+    IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
+    nsIDOMNode_Release(item);
+
+    return S_OK;
+}
+
+#undef HTMLFORM_NODE_THIS
+
+static const NodeImplVtbl HTMLFormElementImplVtbl = {
+    HTMLFormElement_QI,
+    HTMLFormElement_destructor,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    HTMLFormElement_get_dispid,
+    HTMLFormElement_invoke
+};
+
+static const tid_t HTMLFormElement_iface_tids[] = {
+    IHTMLDOMNode_tid,
+    IHTMLDOMNode2_tid,
+    IHTMLElement_tid,
+    IHTMLElement2_tid,
+    IHTMLElement3_tid,
+    IHTMLFormElement_tid,
+    0
+};
+
+static dispex_static_data_t HTMLFormElement_dispex = {
+    NULL,
+    DispHTMLFormElement_tid,
+    NULL,
+    HTMLFormElement_iface_tids
+};
+
+HTMLElement *HTMLFormElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
+{
+    HTMLFormElement *ret = heap_alloc_zero(sizeof(HTMLFormElement));
+    nsresult nsres;
+
+    ret->lpHTMLFormElementVtbl = &HTMLFormElementVtbl;
+    ret->element.node.vtbl = &HTMLFormElementImplVtbl;
+
+    HTMLElement_Init(&ret->element, doc, nselem, &HTMLFormElement_dispex);
+
+    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFormElement, (void**)&ret->nsform);
+    if(NS_FAILED(nsres))
+        ERR("Could not get nsIDOMHTMLFormElement interface: %08x\n", nsres);
+
+    return &ret->element;
+}
index 6c0dd40..e94c801 100644 (file)
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
+static const WCHAR autoW[] = {'a','u','t','o',0};
+static const WCHAR yesW[] = {'y','e','s',0};
+static const WCHAR noW[] = {'n','o',0};
+
+HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
+{
+    nsIDOMWindow *nswindow;
+    HTMLWindow *window;
+    HRESULT hres = S_OK;
+
+    if(frame->content_window)
+        return S_OK;
+
+    nswindow = get_nsdoc_window(nsdoc);
+    if(!nswindow)
+        return E_FAIL;
+
+    window = nswindow_to_window(nswindow);
+    if(!window)
+        hres = HTMLWindow_Create(frame->element.node.doc->basedoc.doc_obj, nswindow,
+                frame->element.node.doc->basedoc.window, &window);
+    nsIDOMWindow_Release(nswindow);
+    if(FAILED(hres))
+        return hres;
+
+    frame->content_window = window;
+    window->frame_element = frame;
+    return S_OK;
+}
+
 #define HTMLFRAMEBASE_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase, iface)
 
 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
@@ -91,8 +121,15 @@ static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdM
 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
 {
     HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
+        FIXME("detached element\n");
+        return E_FAIL;
+    }
+
+    return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
 }
 
 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
@@ -112,8 +149,42 @@ static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
 {
     HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsAString nsstr;
+    const PRUnichar *strdata;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->nsframe) {
+        nsAString_Init(&nsstr, NULL);
+        nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
+    }else if(This->nsiframe) {
+        nsAString_Init(&nsstr, NULL);
+        nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
+    }else {
+        ERR("No attached ns frame object\n");
+        return E_UNEXPECTED;
+    }
+
+    if(NS_FAILED(nsres)) {
+        ERR("GetName failed: 0x%08x\n", nsres);
+        nsAString_Finish(&nsstr);
+        return E_FAIL;
+    }
+
+    nsAString_GetData(&nsstr, &strdata);
+    if(*strdata) {
+        *p = SysAllocString(strdata);
+        if(!*p) {
+            nsAString_Finish(&nsstr);
+            return E_OUTOFMEMORY;
+        }
+    }else
+        *p = NULL;
+
+    nsAString_Finish(&nsstr);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
@@ -203,15 +274,70 @@ static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_
 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
 {
     HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    nsAString nsstr;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
+        return E_INVALIDARG;
+
+    if(This->nsframe) {
+        nsAString_Init(&nsstr, v);
+        nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
+    }else if(This->nsiframe) {
+        nsAString_Init(&nsstr, v);
+        nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
+    }else {
+        ERR("No attached ns frame object\n");
+        return E_UNEXPECTED;
+    }
+    nsAString_Finish(&nsstr);
+
+    if(NS_FAILED(nsres)) {
+        ERR("SetScrolling failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
 {
     HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsAString nsstr;
+    const PRUnichar *strdata;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->nsframe) {
+        nsAString_Init(&nsstr, NULL);
+        nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
+    }else if(This->nsiframe) {
+        nsAString_Init(&nsstr, NULL);
+        nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
+    }else {
+        ERR("No attached ns frame object\n");
+        return E_UNEXPECTED;
+    }
+
+    if(NS_FAILED(nsres)) {
+        ERR("GetScrolling failed: 0x%08x\n", nsres);
+        nsAString_Finish(&nsstr);
+        return E_FAIL;
+    }
+
+    nsAString_GetData(&nsstr, &strdata);
+
+    if(*strdata)
+        *p = SysAllocString(strdata);
+    else
+        *p = SysAllocString(autoW);
+
+    nsAString_Finish(&nsstr);
+
+    return *p ? S_OK : E_OUTOFMEMORY;
 }
 
 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
@@ -242,11 +368,161 @@ static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
     HTMLFrameBase_get_scrolling
 };
 
+#define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase2, iface)
+
+static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+
+    return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
+}
+
+static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+
+    return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
+}
+
+static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+
+    return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
+}
+
+static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
+        LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
+        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
+        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->content_window) {
+        IHTMLWindow2_AddRef(HTMLWINDOW2(This->content_window));
+        *p = HTMLWINDOW2(This->content_window);
+    }else {
+        WARN("NULL content window\n");
+        *p = NULL;
+    }
+    return S_OK;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(!This->content_window || !This->content_window->doc) {
+        FIXME("no document associated\n");
+        return E_FAIL;
+    }
+
+    return IHTMLDocument2_get_readyState(HTMLDOC(&This->content_window->doc->basedoc), p);
+}
+
+static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%x)\n", This, v);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
+{
+    HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+#undef HTMLFRAMEBASE2_THIS
+
+static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
+    HTMLFrameBase2_QueryInterface,
+    HTMLFrameBase2_AddRef,
+    HTMLFrameBase2_Release,
+    HTMLFrameBase2_GetTypeInfoCount,
+    HTMLFrameBase2_GetTypeInfo,
+    HTMLFrameBase2_GetIDsOfNames,
+    HTMLFrameBase2_Invoke,
+    HTMLFrameBase2_get_contentWindow,
+    HTMLFrameBase2_put_onload,
+    HTMLFrameBase2_get_onload,
+    HTMLFrameBase2_put_onreadystatechange,
+    HTMLFrameBase2_get_onreadystatechange,
+    HTMLFrameBase2_get_readyState,
+    HTMLFrameBase2_put_allowTransparency,
+    HTMLFrameBase2_get_allowTransparency
+};
+
 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
 {
     if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
         TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
         *ppv = HTMLFRAMEBASE(This);
+    }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
+        TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
+        *ppv = HTMLFRAMEBASE2(This);
     }else {
         return HTMLElement_QI(&This->element.node, riid, ppv);
     }
@@ -257,26 +533,34 @@ HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
 
 void HTMLFrameBase_destructor(HTMLFrameBase *This)
 {
-    if(This->content_window) {
+    if(This->content_window)
         This->content_window->frame_element = NULL;
-        IHTMLWindow2_Release(HTMLWINDOW2(This->content_window));
-    }
+
+    if(This->nsframe)
+        nsIDOMHTMLFrameElement_Release(This->nsframe);
+    if(This->nsiframe)
+        nsIDOMHTMLIFrameElement_Release(This->nsiframe);
 
     HTMLElement_destructor(&This->element.node);
 }
 
 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
-        HTMLWindow *content_window, dispex_static_data_t *dispex_data)
+        dispex_static_data_t *dispex_data)
 {
+    nsresult nsres;
+
     This->lpIHTMLFrameBaseVtbl = &HTMLFrameBaseVtbl;
+    This->lpIHTMLFrameBase2Vtbl = &HTMLFrameBase2Vtbl;
 
     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
 
-    if(content_window) {
-        IHTMLWindow2_AddRef(HTMLWINDOW2(content_window));
-        content_window->frame_element = This;
-    }
-    This->content_window = content_window;
+    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
+    if(NS_FAILED(nsres)) {
+        nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
+        if(NS_FAILED(nsres))
+            ERR("Could not get nsIDOMHTML[I]Frame interface\n");
+    }else
+        This->nsiframe = NULL;
 }
 
 typedef struct {
@@ -299,28 +583,87 @@ static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
     HTMLFrameBase_destructor(&This->framebase);
 }
 
+static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
+{
+    HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
+
+    if(!This->framebase.content_window || !This->framebase.content_window->doc) {
+        *p = NULL;
+        return S_OK;
+    }
+
+    *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc);
+    IDispatch_AddRef(*p);
+    return S_OK;
+}
+
+static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
+        DWORD grfdex, DISPID *pid)
+{
+    HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
+
+    if(!This->framebase.content_window)
+        return DISP_E_UNKNOWNNAME;
+
+    return search_window_props(This->framebase.content_window, name, grfdex, pid);
+}
+
+static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
+        WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
+{
+    HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
+
+    if(!This->framebase.content_window) {
+        ERR("no content window to invoke on\n");
+        return E_FAIL;
+    }
+
+    return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller);
+}
+
+static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
+{
+    HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
+    nsIDOMDocument *nsdoc;
+    nsresult nsres;
+    HRESULT hres;
+
+    nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
+    if(NS_FAILED(nsres) || !nsdoc) {
+        ERR("GetContentDocument failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    hres = set_frame_doc(&This->framebase, nsdoc);
+    nsIDOMDocument_Release(nsdoc);
+    return hres;
+}
+
 #undef HTMLFRAME_NODE_THIS
 
 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
     HTMLFrameElement_QI,
-    HTMLFrameElement_destructor
+    HTMLFrameElement_destructor,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    HTMLFrameElement_get_document,
+    NULL,
+    HTMLFrameElement_get_dispid,
+    HTMLFrameElement_invoke,
+    HTMLFrameElement_bind_to_tree
 };
 
-HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLWindow *content_window)
+HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
 {
-    nsIDOMHTMLFrameElement *nsframe;
     HTMLFrameElement *ret;
-    nsresult nsres;
 
     ret = heap_alloc_zero(sizeof(HTMLFrameElement));
 
     ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
 
-    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
-    if(NS_FAILED(nsres))
-        ERR("Could not get nsIDOMHTMLFrameElement iface: %08x\n", nsres);
-
-    HTMLFrameBase_Init(&ret->framebase, doc, nselem, content_window, NULL);
+    HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL);
 
     return &ret->framebase.element;
 }
index daef946..ddb32c8 100644 (file)
@@ -33,189 +33,101 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 typedef struct {
     HTMLFrameBase framebase;
-    const IHTMLFrameBase2Vtbl  *lpIHTMLFrameBase2Vtbl;
-
-    LONG ref;
-
-    nsIDOMHTMLIFrameElement *nsiframe;
 } HTMLIFrame;
 
-#define HTMLFRAMEBASE2(x)  (&(x)->lpIHTMLFrameBase2Vtbl)
-
-#define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLFrameBase2, iface)
-
-static HRESULT WINAPI HTMLIFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-
-    return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->framebase.element.node), riid, ppv);
-}
-
-static ULONG WINAPI HTMLIFrameBase2_AddRef(IHTMLFrameBase2 *iface)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-
-    return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node));
-}
-
-static ULONG WINAPI HTMLIFrameBase2_Release(IHTMLFrameBase2 *iface)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-
-    return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node));
-}
+#define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
 
-static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
+static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
 {
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
-}
+    HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
-        LCID lcid, ITypeInfo **ppTInfo)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+    return HTMLFrameBase_QI(&This->framebase, riid, ppv);
 }
 
-static HRESULT WINAPI HTMLIFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
-        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
+static void HTMLIFrame_destructor(HTMLDOMNode *iface)
 {
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
-}
+    HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-static HRESULT WINAPI HTMLIFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
-        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
-        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+    HTMLFrameBase_destructor(&This->framebase);
 }
 
-static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
+static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
 {
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-
-    TRACE("(%p)->(%p)\n", This, p);
+    HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-    if(This->framebase.content_window) {
-        IHTMLWindow2_AddRef(HTMLWINDOW2(This->framebase.content_window));
-        *p = HTMLWINDOW2(This->framebase.content_window);
-    }else {
-        WARN("NULL content window\n");
+    if(!This->framebase.content_window || !This->framebase.content_window->doc) {
         *p = NULL;
+        return S_OK;
     }
-    return S_OK;
-}
 
-static HRESULT WINAPI HTMLIFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
-    return E_NOTIMPL;
+    *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc);
+    IDispatch_AddRef(*p);
+    return S_OK;
 }
 
-static HRESULT WINAPI HTMLIFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
+static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
+        DWORD grfdex, DISPID *pid)
 {
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
-}
+    HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-static HRESULT WINAPI HTMLIFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
-    return E_NOTIMPL;
-}
+    if(!This->framebase.content_window)
+        return DISP_E_UNKNOWNNAME;
 
-static HRESULT WINAPI HTMLIFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    return search_window_props(This->framebase.content_window, name, grfdex, pid);
 }
 
-static HRESULT WINAPI HTMLIFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
+static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
+        WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
 {
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
-}
+    HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-static HRESULT WINAPI HTMLIFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%x)\n", This, v);
-    return E_NOTIMPL;
-}
+    if(!This->framebase.content_window) {
+        ERR("no content window to invoke on\n");
+        return E_FAIL;
+    }
 
-static HRESULT WINAPI HTMLIFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
-{
-    HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller);
 }
 
-#undef HTMLFRAMEBASE2_THIS
-
-static const IHTMLFrameBase2Vtbl HTMLIFrameBase2Vtbl = {
-    HTMLIFrameBase2_QueryInterface,
-    HTMLIFrameBase2_AddRef,
-    HTMLIFrameBase2_Release,
-    HTMLIFrameBase2_GetTypeInfoCount,
-    HTMLIFrameBase2_GetTypeInfo,
-    HTMLIFrameBase2_GetIDsOfNames,
-    HTMLIFrameBase2_Invoke,
-    HTMLIFrameBase2_get_contentWindow,
-    HTMLIFrameBase2_put_onload,
-    HTMLIFrameBase2_get_onload,
-    HTMLIFrameBase2_put_onreadystatechange,
-    HTMLIFrameBase2_get_onreadystatechange,
-    HTMLIFrameBase2_get_readyState,
-    HTMLIFrameBase2_put_allowTransparency,
-    HTMLIFrameBase2_get_allowTransparency
-};
-
-#define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
-
-static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
+static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
 {
     HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
 
-    *ppv = NULL;
-
-    if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
-        TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
-        *ppv = HTMLFRAMEBASE2(This);
-    }else {
-        return HTMLFrameBase_QI(&This->framebase, riid, ppv);
-    }
-
-    IUnknown_AddRef((IUnknown*)*ppv);
-    return S_OK;
+    return IHTMLFrameBase2_get_readyState(HTMLFRAMEBASE2(&This->framebase), p);
 }
 
-static void HTMLIFrame_destructor(HTMLDOMNode *iface)
+static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
 {
     HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
+    nsIDOMDocument *nsdoc;
+    nsresult nsres;
+    HRESULT hres;
 
-    if(This->nsiframe)
-        nsIDOMHTMLIFrameElement_Release(This->nsiframe);
+    nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
+    if(NS_FAILED(nsres) || !nsdoc) {
+        ERR("GetContentDocument failed: %08x\n", nsres);
+        return E_FAIL;
+    }
 
-    HTMLFrameBase_destructor(&This->framebase);
+    hres = set_frame_doc(&This->framebase, nsdoc);
+    nsIDOMDocument_Release(nsdoc);
+    return hres;
 }
 
 #undef HTMLIFRAME_NODE_THIS
 
 static const NodeImplVtbl HTMLIFrameImplVtbl = {
     HTMLIFrame_QI,
-    HTMLIFrame_destructor
+    HTMLIFrame_destructor,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    HTMLIFrame_get_document,
+    HTMLIFrame_get_readystate,
+    HTMLIFrame_get_dispid,
+    HTMLIFrame_invoke,
+    HTMLIFrame_bind_to_tree
 };
 
 static const tid_t HTMLIFrame_iface_tids[] = {
@@ -236,55 +148,15 @@ static dispex_static_data_t HTMLIFrame_dispex = {
     HTMLIFrame_iface_tids
 };
 
-static HTMLWindow *get_content_window(nsIDOMHTMLIFrameElement *nsiframe)
-{
-    HTMLWindow *ret;
-    nsIDOMWindow *nswindow;
-    nsIDOMDocument *nsdoc;
-    nsresult nsres;
-
-    nsres = nsIDOMHTMLIFrameElement_GetContentDocument(nsiframe, &nsdoc);
-    if(NS_FAILED(nsres)) {
-        ERR("GetContentDocument failed: %08x\n", nsres);
-        return NULL;
-    }
-
-    if(!nsdoc) {
-        FIXME("NULL contentDocument\n");
-        return NULL;
-    }
-
-    nswindow = get_nsdoc_window(nsdoc);
-    nsIDOMDocument_Release(nsdoc);
-    if(!nswindow)
-        return NULL;
-
-    ret = nswindow_to_window(nswindow);
-    nsIDOMWindow_Release(nswindow);
-    if(!ret)
-        ERR("Could not get window object\n");
-
-    return ret;
-}
-
-HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLWindow *content_window)
+HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
 {
     HTMLIFrame *ret;
-    nsresult nsres;
 
     ret = heap_alloc_zero(sizeof(HTMLIFrame));
 
-    ret->lpIHTMLFrameBase2Vtbl = &HTMLIFrameBase2Vtbl;
     ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
 
-    nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe);
-    if(NS_FAILED(nsres))
-        ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres);
-
-    if(!content_window)
-        content_window = get_content_window(ret->nsiframe);
-
-    HTMLFrameBase_Init(&ret->framebase, doc, nselem, content_window, &HTMLIFrame_dispex);
+    HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
 
     return &ret->framebase.element;
 }
index bfccdd5..87fe498 100644 (file)
@@ -39,7 +39,7 @@ typedef struct {
     nsIDOMHTMLImageElement *nsimg;
 } HTMLImgElement;
 
-#define HTMLIMG(x)  (&(x)->lpHTMLImgElementVtbl)
+#define HTMLIMG(x)  ((IHTMLImgElement*)  &(x)->lpHTMLImgElementVtbl)
 
 #define HTMLIMG_THIS(iface) DEFINE_THIS(HTMLImgElement, HTMLImgElement, iface)
 
@@ -437,8 +437,24 @@ static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
 {
     HTMLImgElement *This = HTMLIMG_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsAString strName;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsAString_Init(&strName, NULL);
+    nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName);
+    if(NS_SUCCEEDED(nsres)) {
+        const PRUnichar *str;
+
+        nsAString_GetData(&strName, &str);
+        *p = *str ? SysAllocString(str) : NULL;
+    }else {
+        ERR("GetName failed: %08x\n", nsres);
+    }
+    nsAString_Finish(&strName);
+
+    return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
 }
 
 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
@@ -572,11 +588,24 @@ static void HTMLImgElement_destructor(HTMLDOMNode *iface)
     HTMLElement_destructor(&This->element.node);
 }
 
+static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
+{
+    HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
+
+    return IHTMLImgElement_get_readyState(HTMLIMG(This), p);
+}
+
 #undef HTMLIMG_NODE_THIS
 
 static const NodeImplVtbl HTMLImgElementImplVtbl = {
     HTMLImgElement_QI,
-    HTMLImgElement_destructor
+    HTMLImgElement_destructor,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    HTMLImgElement_get_readystate
 };
 
 static const tid_t HTMLImgElement_iface_tids[] = {
index 3b91429..93df9e0 100644 (file)
@@ -154,12 +154,12 @@ static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v)
 
     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
 
-    if(!This->window || !This->window->doc) {
-        FIXME("No document available\n");
+    if(!This->window) {
+        FIXME("No window available\n");
         return E_FAIL;
     }
 
-    return navigate_url(This->window->doc, v);
+    return navigate_url(This->window, v, This->window->url);
 }
 
 static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
diff --git a/reactos/dll/win32/mshtml/htmlscreen.c b/reactos/dll/win32/mshtml/htmlscreen.c
new file mode 100644 (file)
index 0000000..cc3f4b2
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright 2009 Jacek Caban for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ole2.h"
+
+#include "wine/debug.h"
+
+#include "mshtml_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
+
+typedef struct {
+    DispatchEx dispex;
+    const IHTMLScreenVtbl *lpIHTMLScreenVtbl;
+
+    LONG ref;
+} HTMLScreen;
+
+#define HTMLSCREEN(x)  ((IHTMLScreen*)  &(x)->lpIHTMLScreenVtbl)
+
+#define HTMLSCREEN_THIS(iface) DEFINE_THIS(HTMLScreen, IHTMLScreen, iface)
+
+static HRESULT WINAPI HTMLScreen_QueryInterface(IHTMLScreen *iface, REFIID riid, void **ppv)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+
+    *ppv = NULL;
+
+    if(IsEqualGUID(&IID_IUnknown, riid)) {
+        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+        *ppv = HTMLSCREEN(This);
+    }else if(IsEqualGUID(&IID_IHTMLScreen, riid)) {
+        TRACE("(%p)->(IID_IHTMLScreen %p)\n", This, ppv);
+        *ppv = HTMLSCREEN(This);
+    }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
+        return *ppv ? S_OK : E_NOINTERFACE;
+    }
+
+    if(*ppv) {
+        IUnknown_AddRef((IUnknown*)*ppv);
+        return S_OK;
+    }
+
+    WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI HTMLScreen_AddRef(IHTMLScreen *iface)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    LONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI HTMLScreen_Release(IHTMLScreen *iface)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    LONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    if(!ref) {
+        release_dispex(&This->dispex);
+        heap_free(This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI HTMLScreen_GetTypeInfoCount(IHTMLScreen *iface, UINT *pctinfo)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_GetTypeInfo(IHTMLScreen *iface, UINT iTInfo,
+        LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_GetIDsOfNames(IHTMLScreen *iface, REFIID riid,
+        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_Invoke(IHTMLScreen *iface, DISPID dispIdMember,
+        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)\n", This);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_colorDepth(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    *p = GetDeviceCaps(get_display_dc(), BITSPIXEL);
+    return S_OK;
+}
+
+static HRESULT WINAPI HTMLScreen_put_bufferDepth(IHTMLScreen *iface, LONG v)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%d)\n", This, v);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_bufferDepth(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_width(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    *p = GetDeviceCaps(get_display_dc(), HORZRES);
+    return S_OK;
+}
+
+static HRESULT WINAPI HTMLScreen_get_height(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    *p = GetDeviceCaps(get_display_dc(), VERTRES);
+    return S_OK;
+}
+
+static HRESULT WINAPI HTMLScreen_put_updateInterval(IHTMLScreen *iface, LONG v)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%d)\n", This, v);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_updateInterval(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_availHeight(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_availWidth(IHTMLScreen *iface, LONG *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLScreen_get_fontSmoothingEnabled(IHTMLScreen *iface, VARIANT_BOOL *p)
+{
+    HTMLScreen *This = HTMLSCREEN_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+#undef HTMLSCREEN_THIS
+
+static const IHTMLScreenVtbl HTMLSreenVtbl = {
+    HTMLScreen_QueryInterface,
+    HTMLScreen_AddRef,
+    HTMLScreen_Release,
+    HTMLScreen_GetTypeInfoCount,
+    HTMLScreen_GetTypeInfo,
+    HTMLScreen_GetIDsOfNames,
+    HTMLScreen_Invoke,
+    HTMLScreen_get_colorDepth,
+    HTMLScreen_put_bufferDepth,
+    HTMLScreen_get_bufferDepth,
+    HTMLScreen_get_width,
+    HTMLScreen_get_height,
+    HTMLScreen_put_updateInterval,
+    HTMLScreen_get_updateInterval,
+    HTMLScreen_get_availHeight,
+    HTMLScreen_get_availWidth,
+    HTMLScreen_get_fontSmoothingEnabled
+};
+
+static const tid_t HTMLScreen_iface_tids[] = {
+    IHTMLScreen_tid,
+    0
+};
+static dispex_static_data_t HTMLScreen_dispex = {
+    NULL,
+    DispHTMLScreen_tid,
+    NULL,
+    HTMLScreen_iface_tids
+};
+
+HRESULT HTMLScreen_Create(IHTMLScreen **ret)
+{
+    HTMLScreen *screen;
+
+    screen = heap_alloc_zero(sizeof(HTMLScreen));
+    if(!screen)
+        return E_OUTOFMEMORY;
+
+    screen->lpIHTMLScreenVtbl = &HTMLSreenVtbl;
+    screen->ref = 1;
+
+    init_dispex(&screen->dispex, (IUnknown*)HTMLSCREEN(screen), &HTMLScreen_dispex);
+
+    *ret = HTMLSCREEN(screen);
+    return S_OK;
+}
index a038c55..d86f398 100644 (file)
@@ -39,7 +39,7 @@ typedef struct {
     nsIDOMHTMLScriptElement *nsscript;
 } HTMLScriptElement;
 
-#define HTMLSCRIPT(x)  (&(x)->lpHTMLScriptElementVtbl)
+#define HTMLSCRIPT(x)  ((IHTMLScriptElement*)  &(x)->lpHTMLScriptElementVtbl)
 
 #define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface)
 
@@ -299,11 +299,24 @@ static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
     HTMLElement_destructor(&This->element.node);
 }
 
+static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
+{
+    HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
+
+    return IHTMLScriptElement_get_readyState(HTMLSCRIPT(This), p);
+}
+
 #undef HTMLSCRIPT_NODE_THIS
 
 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
     HTMLScriptElement_QI,
-    HTMLScriptElement_destructor
+    HTMLScriptElement_destructor,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    HTMLScriptElement_get_readystate
 };
 
 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
index 13ac74e..467464a 100644 (file)
@@ -49,6 +49,8 @@ static const WCHAR attrBackgroundRepeat[] =
     {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0};
 static const WCHAR attrBorder[] =
     {'b','o','r','d','e','r',0};
+static const WCHAR attrBorderBottom[] =
+    {'b','o','r','d','e','r','-','b','o','t','t','o','m',0};
 static const WCHAR attrBorderBottomColor[] =
     {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0};
 static const WCHAR attrBorderBottomStyle[] =
@@ -65,12 +67,16 @@ static const WCHAR attrBorderLeftStyle[] =
     {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0};
 static const WCHAR attrBorderLeftWidth[] =
     {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0};
+static const WCHAR attrBorderRight[] =
+    {'b','o','r','d','e','r','-','r','i','g','h','t',0};
 static const WCHAR attrBorderRightColor[] =
     {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0};
 static const WCHAR attrBorderRightStyle[] =
     {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0};
 static const WCHAR attrBorderRightWidth[] =
     {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0};
+static const WCHAR attrBorderTop[] =
+    {'b','o','r','d','e','r','-','t','o','p',0};
 static const WCHAR attrBorderTopColor[] =
     {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0};
 static const WCHAR attrBorderStyle[] =
@@ -167,6 +173,7 @@ static const struct{
     {attrBackgroundPositionY,  DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY},
     {attrBackgroundRepeat,     DISPID_IHTMLSTYLE_BACKGROUNDREPEAT},
     {attrBorder,               DISPID_IHTMLSTYLE_BORDER},
+    {attrBorderBottom,         DISPID_IHTMLSTYLE_BORDERBOTTOM},
     {attrBorderBottomColor,    DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR},
     {attrBorderBottomStyle,    DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE},
     {attrBorderBottomWidth,    DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH},
@@ -175,10 +182,12 @@ static const struct{
     {attrBorderLeftColor,      DISPID_IHTMLSTYLE_BORDERLEFTCOLOR},
     {attrBorderLeftStyle,      DISPID_IHTMLSTYLE_BORDERLEFTSTYLE},
     {attrBorderLeftWidth,      DISPID_IHTMLSTYLE_BORDERLEFTWIDTH},
+    {attrBorderRight,          DISPID_IHTMLSTYLE_BORDERRIGHT},
     {attrBorderRightColor,     DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR},
     {attrBorderRightStyle,     DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE},
     {attrBorderRightWidth,     DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH},
     {attrBorderStyle,          DISPID_IHTMLSTYLE_BORDERSTYLE},
+    {attrBorderTop,            DISPID_IHTMLSTYLE_BORDERTOP},
     {attrBorderTopColor,       DISPID_IHTMLSTYLE_BORDERTOPCOLOR},
     {attrBorderTopStyle,       DISPID_IHTMLSTYLE_BORDERTOPSTYLE},
     {attrBorderTopWidth,       DISPID_IHTMLSTYLE_BORDERTOPWIDTH},
@@ -1210,15 +1219,19 @@ static HRESULT WINAPI HTMLStyle_get_lineHeight(IHTMLStyle *iface, VARIANT *p)
 static HRESULT WINAPI HTMLStyle_put_marginTop(IHTMLStyle *iface, VARIANT v)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(v%d)\n", This, V_VT(&v));
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(v%d)\n", This, V_VT(&v));
+
+    return set_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, &v, 0);
 }
 
 static HRESULT WINAPI HTMLStyle_get_marginTop(IHTMLStyle *iface, VARIANT *p)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_nsstyle_attr_var(This->nsstyle, STYLEID_MARGIN_TOP, p, 0);
 }
 
 static HRESULT WINAPI HTMLStyle_put_marginRight(IHTMLStyle *iface, VARIANT v)
@@ -1433,43 +1446,43 @@ static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p)
 static HRESULT WINAPI HTMLStyle_put_borderTop(IHTMLStyle *iface, BSTR v)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+    return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX);
 }
 
 static HRESULT WINAPI HTMLStyle_get_borderTop(IHTMLStyle *iface, BSTR *p)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+    return get_style_attr(This, STYLEID_BORDER_TOP, p);
 }
 
 static HRESULT WINAPI HTMLStyle_put_borderRight(IHTMLStyle *iface, BSTR v)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+    return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX);
 }
 
 static HRESULT WINAPI HTMLStyle_get_borderRight(IHTMLStyle *iface, BSTR *p)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+    return get_style_attr(This, STYLEID_BORDER_RIGHT, p);
 }
 
 static HRESULT WINAPI HTMLStyle_put_borderBottom(IHTMLStyle *iface, BSTR v)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+    return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX);
 }
 
 static HRESULT WINAPI HTMLStyle_get_borderBottom(IHTMLStyle *iface, BSTR *p)
 {
     HTMLStyle *This = HTMLSTYLE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+    return get_style_attr(This, STYLEID_BORDER_BOTTOM, p);
 }
 
 static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v)
index 4252caa..7168eec 100644 (file)
@@ -42,6 +42,7 @@ typedef enum {
     STYLEID_BACKGROUND_POSITION_Y,
     STYLEID_BACKGROUND_REPEAT,
     STYLEID_BORDER,
+    STYLEID_BORDER_BOTTOM,
     STYLEID_BORDER_BOTTOM_COLOR,
     STYLEID_BORDER_BOTTOM_STYLE,
     STYLEID_BORDER_BOTTOM_WIDTH,
@@ -50,10 +51,12 @@ typedef enum {
     STYLEID_BORDER_LEFT_COLOR,
     STYLEID_BORDER_LEFT_STYLE,
     STYLEID_BORDER_LEFT_WIDTH,
+    STYLEID_BORDER_RIGHT,
     STYLEID_BORDER_RIGHT_COLOR,
     STYLEID_BORDER_RIGHT_STYLE,
     STYLEID_BORDER_RIGHT_WIDTH,
     STYLEID_BORDER_STYLE,
+    STYLEID_BORDER_TOP,
     STYLEID_BORDER_TOP_COLOR,
     STYLEID_BORDER_TOP_STYLE,
     STYLEID_BORDER_TOP_WIDTH,
index ff5fff0..aa9531c 100644 (file)
@@ -212,15 +212,19 @@ static HRESULT WINAPI HTMLStyle2_get_bottom(IHTMLStyle2 *iface, VARIANT *p)
 static HRESULT WINAPI HTMLStyle2_put_right(IHTMLStyle2 *iface, VARIANT v)
 {
     HTMLStyle *This = HTMLSTYLE2_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_nsstyle_attr_var(This->nsstyle, STYLEID_RIGHT, &v, 0);
 }
 
 static HRESULT WINAPI HTMLStyle2_get_right(IHTMLStyle2 *iface, VARIANT *p)
 {
     HTMLStyle *This = HTMLSTYLE2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_nsstyle_attr_var(This->nsstyle, STYLEID_RIGHT, p, 0);
 }
 
 static HRESULT WINAPI HTMLStyle2_put_pixelBottom(IHTMLStyle2 *iface, LONG v)
index 505e91e..56fd3df 100644 (file)
@@ -103,7 +103,15 @@ static HRESULT WINAPI HTMLStyle3_get_layoutFlow(IHTMLStyle3 *iface, BSTR *p)
 static HRESULT WINAPI HTMLStyle3_put_zoom(IHTMLStyle3 *iface, VARIANT v)
 {
     HTMLStyle *This = HTMLSTYLE3_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    /* zoom property is IE CSS extension that is mostly used as a hack to workaround IE bugs.
+     * The value is set to 1 then. We can safely ignore setting zoom to 1. */
+    if(V_VT(&v) == VT_I4 && V_I4(&v) == 1)
+        return S_OK;
+
+    FIXME("stub for %s\n", debugstr_variant(&v));
     return E_NOTIMPL;
 }
 
index 7699748..6357f77 100644 (file)
@@ -584,7 +584,7 @@ HTMLElement *HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
 
     HTMLElement_Init(&ret->element, doc, nselem, &HTMLTable_dispex);
 
-    ConnectionPoint_Init(&ret->cp, &ret->element.cp_container, &DIID_HTMLTableEvents);
+    ConnectionPoint_Init(&ret->cp, &ret->element.cp_container, &DIID_HTMLTableEvents, NULL);
 
     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableElement, (void**)&ret->nstable);
     if(NS_FAILED(nsres))
index 35fa01b..46b5d87 100644 (file)
@@ -189,5 +189,5 @@ void HTMLTextContainer_Init(HTMLTextContainer *This, HTMLDocumentNode *doc, nsID
 
     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
 
-    ConnectionPoint_Init(&This->cp, &This->element.cp_container, &DIID_HTMLTextContainerEvents);
+    ConnectionPoint_Init(&This->cp, &This->element.cp_container, &DIID_HTMLTextContainerEvents, NULL);
 }
index 799a137..1c2c2da 100644 (file)
@@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 struct HTMLDOMTextNode {
     HTMLDOMNode node;
     const IHTMLDOMTextNodeVtbl   *lpIHTMLDOMTextNodeVtbl;
+
+    nsIDOMText *nstext;
 };
 
 #define HTMLTEXT(x)  (&(x)->lpIHTMLDOMTextNodeVtbl)
@@ -119,8 +121,17 @@ static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *St
 static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
 {
     HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    PRUint32 length = 0;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsres = nsIDOMText_GetLength(This->nstext, &length);
+    if(NS_FAILED(nsres))
+        ERR("GetLength failed: %08x\n", nsres);
+
+    *p = length;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
@@ -170,6 +181,9 @@ static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface)
 {
     HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
 
+    if(This->nstext)
+        IHTMLDOMTextNode_Release(This->nstext);
+
     HTMLDOMNode_destructor(&This->node);
 }
 
@@ -195,7 +209,8 @@ static dispex_static_data_t HTMLDOMTextNode_dispex = {
 
 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
 {
-    HTMLDOMTextNode *ret ;
+    HTMLDOMTextNode *ret;
+    nsresult nsres;
 
     ret = heap_alloc_zero(sizeof(*ret));
     ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
@@ -204,5 +219,9 @@ HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
     init_dispex(&ret->node.dispex, (IUnknown*)HTMLTEXT(ret), &HTMLDOMTextNode_dispex);
     HTMLDOMNode_Init(doc, &ret->node, nsnode);
 
+    nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
+    if(NS_FAILED(nsres))
+        ERR("Could not get nsIDOMText iface: %08x\n", nsres);
+
     return &ret->node;
 }
index 9f3b3e7..4a2babe 100644 (file)
@@ -24,6 +24,7 @@
 #include "winbase.h"
 #include "winuser.h"
 #include "ole2.h"
+#include "mshtmdid.h"
 
 #include "wine/debug.h"
 #include "wine/unicode.h"
@@ -100,6 +101,42 @@ static void release_children(HTMLWindow *This)
     }
 }
 
+static HRESULT get_location(HTMLWindow *This, HTMLLocation **ret)
+{
+    if(This->location) {
+        IHTMLLocation_AddRef(HTMLLOCATION(This->location));
+    }else {
+        HRESULT hres;
+
+        hres = HTMLLocation_Create(This, &This->location);
+        if(FAILED(hres))
+            return hres;
+    }
+
+    *ret = This->location;
+    return S_OK;
+}
+
+static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
+{
+    if(!window->doc) {
+        FIXME("No document\n");
+        return E_FAIL;
+    }
+
+    return set_event_handler(&window->doc->body_event_target, window->doc, eid, var);
+}
+
+static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
+{
+    if(!window->doc) {
+        FIXME("No document\n");
+        return E_FAIL;
+    }
+
+    return get_event_handler(&window->doc->body_event_target, eid, var);
+}
+
 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
 
 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
@@ -126,6 +163,9 @@ static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID rii
     }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
         TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
         *ppv = HTMLWINDOW3(This);
+    }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
+        TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
+        *ppv = HTMLWINDOW4(This);
     }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
         return *ppv ? S_OK : E_NOINTERFACE;
     }
@@ -165,6 +205,9 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
         window_set_docnode(This, NULL);
         release_children(This);
 
+        if(This->frame_element)
+            This->frame_element->content_window = NULL;
+
         if(This->option_factory) {
             This->option_factory->window = NULL;
             IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
@@ -180,8 +223,9 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
             IHTMLLocation_Release(HTMLLOCATION(This->location));
         }
 
-        if(This->event_target)
-            release_event_target(This->event_target);
+        if(This->screen)
+            IHTMLScreen_Release(This->screen);
+
         for(i=0; i < This->global_prop_cnt; i++)
             heap_free(This->global_props[i].name);
 
@@ -190,6 +234,10 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
 
         heap_free(This->global_props);
         release_script_hosts(This);
+
+        if(This->nswindow)
+            nsIDOMWindow_Release(This->nswindow);
+
         list_remove(&This->entry);
         release_dispex(&This->dispex);
         heap_free(This);
@@ -232,11 +280,122 @@ static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMembe
             pVarResult, pExcepInfo, puArgErr);
 }
 
+static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
+{
+    PRUint32 length;
+    nsIDOMWindow *nsWindow;
+    nsresult nsres;
+
+    nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
+    if(NS_FAILED(nsres)) {
+        FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    if(index >= length)
+        return DISP_E_MEMBERNOTFOUND;
+
+    nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
+    if(NS_FAILED(nsres)) {
+        FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    *ret = nswindow_to_window(nsWindow);
+
+    nsIDOMWindow_Release(nsWindow);
+
+    return S_OK;
+}
+
 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
-    return E_NOTIMPL;
+    nsIDOMWindowCollection *nsFrames;
+    HTMLWindow *window;
+    HRESULT hres;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
+
+    nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
+    if(NS_FAILED(nsres)) {
+        FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
+        return E_FAIL;
+    }
+
+    if(V_VT(pvarIndex) == VT_I4) {
+        int index = V_I4(pvarIndex);
+        TRACE("Getting index %d\n", index);
+        if(index < 0) {
+            hres = DISP_E_MEMBERNOTFOUND;
+            goto cleanup;
+        }
+        hres = get_frame_by_index(nsFrames, index, &window);
+        if(FAILED(hres))
+            goto cleanup;
+    }else if(V_VT(pvarIndex) == VT_UINT) {
+        unsigned int index = V_UINT(pvarIndex);
+        TRACE("Getting index %u\n", index);
+        hres = get_frame_by_index(nsFrames, index, &window);
+        if(FAILED(hres))
+            goto cleanup;
+    }else if(V_VT(pvarIndex) == VT_BSTR) {
+        BSTR str = V_BSTR(pvarIndex);
+        PRUint32 length, i;
+
+        TRACE("Getting name %s\n", wine_dbgstr_w(str));
+
+        nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
+
+        window = NULL;
+        for(i = 0; i < length && !window; ++i) {
+            HTMLWindow *cur_window;
+            nsIDOMWindow *nsWindow;
+            BSTR id;
+
+            nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
+            if(NS_FAILED(nsres)) {
+                FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
+                hres = E_FAIL;
+                goto cleanup;
+            }
+
+            cur_window = nswindow_to_window(nsWindow);
+
+            nsIDOMWindow_Release(nsWindow);
+
+            hres = IHTMLElement_get_id(HTMLELEM(&cur_window->frame_element->element), &id);
+            if(FAILED(hres)) {
+                FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
+                goto cleanup;
+            }
+
+            if(!strcmpW(id, str))
+                window = cur_window;
+
+            SysFreeString(id);
+        }
+
+        if(!window) {
+            hres = DISP_E_MEMBERNOTFOUND;
+            goto cleanup;
+        }
+    }else {
+        hres = E_INVALIDARG;
+        goto cleanup;
+    }
+
+    IHTMLWindow2_AddRef(HTMLWINDOW2(window));
+    V_VT(pvarResult) = VT_DISPATCH;
+    V_DISPATCH(pvarResult) = (IDispatch*)window;
+
+    hres = S_OK;
+
+cleanup:
+    nsIDOMWindowCollection_Release(nsFrames);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
@@ -268,8 +427,12 @@ static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    FIXME("(%p)->(%p): semi-stub\n", This, p);
+
+    /* FIXME: Should return a separate Window object */
+    *p = (IHTMLFramesCollection2*)HTMLWINDOW2(This);
+    HTMLWindow2_AddRef(iface);
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
@@ -472,20 +635,16 @@ static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageEleme
 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
+    HTMLLocation *location;
+    HRESULT hres;
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    if(This->location) {
-        IHTMLLocation_AddRef(HTMLLOCATION(This->location));
-    }else {
-        HRESULT hres;
-
-        hres = HTMLLocation_Create(This, &This->location);
-        if(FAILED(hres))
-            return hres;
-    }
+    hres = get_location(This, &location);
+    if(FAILED(hres))
+        return hres;
 
-    *p = HTMLLOCATION(This->location);
+    *p = HTMLLOCATION(location);
     return S_OK;
 }
 
@@ -578,8 +737,15 @@ static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->parent) {
+        *p = HTMLWINDOW2(This->parent);
+        IHTMLWindow2_AddRef(*p);
+    }else
+        *p = NULL;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
@@ -605,9 +771,16 @@ static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p
 
 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
 {
-    HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    HTMLWindow *This = HTMLWINDOW2_THIS(iface), *curr;
+    TRACE("(%p)->(%p)\n", This, p);
+
+    curr = This;
+    while(curr->parent)
+        curr = curr->parent;
+    *p = HTMLWINDOW2(curr);
+    IHTMLWindow2_AddRef(*p);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
@@ -738,15 +911,19 @@ static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
+
+    return set_window_event(This, EVENTID_RESIZE, &v);
 }
 
 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    return get_window_event(This, EVENTID_RESIZE, p);
 }
 
 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
@@ -818,8 +995,20 @@ static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VA
 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(!This->screen) {
+        HRESULT hres;
+
+        hres = HTMLScreen_Create(&This->screen);
+        if(FAILED(hres))
+            return hres;
+    }
+
+    *p = This->screen;
+    IHTMLScreen_AddRef(This->screen);
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
@@ -1220,7 +1409,12 @@ static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, I
 
     TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
 
-    return attach_event(&This->event_target, &This->doc_obj->basedoc, event, pDisp, pfResult);
+    if(!This->doc) {
+        FIXME("No document\n");
+        return E_FAIL;
+    }
+
+    return attach_event(&This->doc->body_event_target, &This->doc->basedoc, event, pDisp, pfResult);
 }
 
 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
@@ -1354,6 +1548,99 @@ static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
     HTMLWindow3_showModelessDialog
 };
 
+#define HTMLWINDOW4_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow4, iface)
+
+static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
+}
+
+static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
+}
+
+static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IHTMLWindow2_Release(HTMLWINDOW2(This));
+}
+
+static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
+}
+
+static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
+                                              LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
+}
+
+static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
+                                                LPOLESTR *rgszNames, UINT cNames,
+                                                LCID lcid, DISPID *rgDispId)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
+}
+
+static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
+                            REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+                            VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+
+    return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
+            pVarResult, pExcepInfo, puArgErr);
+}
+
+static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
+                            IDispatch **ppPopup)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+    FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
+{
+    HTMLWindow *This = HTMLWINDOW4_THIS(iface);
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->frame_element) {
+        *p = HTMLFRAMEBASE(This->frame_element);
+        IHTMLFrameBase_AddRef(*p);
+    }else
+        *p = NULL;
+
+    return S_OK;
+}
+
+#undef HTMLWINDOW4_THIS
+
+static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
+    HTMLWindow4_QueryInterface,
+    HTMLWindow4_AddRef,
+    HTMLWindow4_Release,
+    HTMLWindow4_GetTypeInfoCount,
+    HTMLWindow4_GetTypeInfo,
+    HTMLWindow4_GetIDsOfNames,
+    HTMLWindow4_Invoke,
+    HTMLWindow4_createPopup,
+    HTMLWindow4_get_frameElement
+};
+
 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
 
 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
@@ -1457,15 +1744,11 @@ static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
     return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
 }
 
-static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
+HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
 {
-    HTMLWindow *This = DISPEX_THIS(iface);
+    DWORD i;
     ScriptHost *script_host;
     DISPID id;
-    DWORD i;
-    HRESULT hres;
-
-    TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
 
     for(i=0; i < This->global_prop_cnt; i++) {
         /* FIXME: case sensitivity */
@@ -1489,6 +1772,20 @@ static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName,
         return S_OK;
     }
 
+    return DISP_E_UNKNOWNNAME;
+}
+
+static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
+{
+    HTMLWindow *This = DISPEX_THIS(iface);
+    HRESULT hres;
+
+    TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
+
+    hres = search_window_props(This, bstrName, grfdex, pid);
+    if(hres != DISP_E_UNKNOWNNAME)
+        return hres;
+
     hres = IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
     if(hres != DISP_E_UNKNOWNNAME)
         return hres;
@@ -1520,6 +1817,21 @@ static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID
 
     TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
 
+    if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
+        HTMLLocation *location;
+        HRESULT hres;
+
+        TRACE("forwarding to location.href\n");
+
+        hres = get_location(This, &location);
+        if(FAILED(hres))
+            return hres;
+
+        hres = IDispatchEx_InvokeEx(DISPATCHEX(&location->dispex), DISPID_VALUE, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
+        IHTMLLocation_Release(HTMLLOCATION(location));
+        return hres;
+    }
+
     return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
 }
 
@@ -1601,6 +1913,7 @@ static const IDispatchExVtbl WindowDispExVtbl = {
 static const tid_t HTMLWindow_iface_tids[] = {
     IHTMLWindow2_tid,
     IHTMLWindow3_tid,
+    IHTMLWindow4_tid,
     0
 };
 
@@ -1633,6 +1946,7 @@ HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTML
 
     window->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
     window->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
+    window->lpHTMLWindow4Vtbl = &HTMLWindow4Vtbl;
     window->lpIDispatchExVtbl = &WindowDispExVtbl;
     window->ref = 1;
     window->doc_obj = doc_obj;
index 58ac724..e47c284 100644 (file)
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
-#define GECKO_FILE_NAME "wine_gecko-" GECKO_VERSION "-x86.cab"
+#ifdef __i386__
+#define GECKO_ARCH "x86"
+#else
+#define GECKO_ARCH ""
+#endif
+
+#define GECKO_FILE_NAME "wine_gecko-" GECKO_VERSION "-" GECKO_ARCH ".cab"
 
 static const WCHAR mshtml_keyW[] =
     {'S','o','f','t','w','a','r','e',
@@ -187,7 +193,7 @@ static BOOL install_from_unix_file(const char *file_name)
     int fd;
     BOOL ret;
 
-    static WCHAR *(*wine_get_dos_file_name)(const char*);
+    static WCHAR * (CDECL *wine_get_dos_file_name)(const char*);
     static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
 
     fd = open(file_name, O_RDONLY);
@@ -430,7 +436,8 @@ static LPWSTR get_url(void)
 
     static const WCHAR wszGeckoUrl[] = {'G','e','c','k','o','U','r','l',0};
     static const WCHAR httpW[] = {'h','t','t','p'};
-    static const WCHAR v_formatW[] = {'?','a','r','c','h','=','x','8','6','&','v','=',0};
+    static const WCHAR arch_formatW[] = {'?','a','r','c','h','='};
+    static const WCHAR v_formatW[] = {'&','v','='};
 
     /* @@ Wine registry key: HKCU\Software\Wine\MSHTML */
     res = RegOpenKeyW(HKEY_CURRENT_USER, mshtml_keyW, &hkey);
@@ -448,8 +455,15 @@ static LPWSTR get_url(void)
     }
 
     if(returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) {
-        strcatW(url, v_formatW);
-        MultiByteToWideChar(CP_ACP, 0, GECKO_VERSION, -1, url+strlenW(url), size/sizeof(WCHAR)-strlenW(url));
+        DWORD len;
+
+        len = strlenW(url);
+        memcpy(url+len, arch_formatW, sizeof(arch_formatW));
+        len += sizeof(arch_formatW)/sizeof(WCHAR);
+        len += MultiByteToWideChar(CP_ACP, 0, GECKO_ARCH, sizeof(GECKO_ARCH), url+len, size/sizeof(WCHAR)-len)-1;
+        memcpy(url+len, v_formatW, sizeof(v_formatW));
+        len += sizeof(v_formatW)/sizeof(WCHAR);
+        MultiByteToWideChar(CP_ACP, 0, GECKO_VERSION, -1, url+len, size/sizeof(WCHAR)-len);
     }
 
     TRACE("Got URL %s\n", debugstr_w(url));
@@ -512,6 +526,9 @@ BOOL install_wine_gecko(BOOL silent)
 {
     HANDLE hsem;
 
+    if(!*GECKO_ARCH)
+        return FALSE;
+
     SetLastError(ERROR_SUCCESS);
     hsem = CreateSemaphoreA( NULL, 0, 1, "mshtml_install_semaphore");
 
index 6a358e5..1e30066 100644 (file)
@@ -47,6 +47,7 @@ HINSTANCE hInst;
 DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
 
 static HINSTANCE shdoclc = NULL;
+static HDC display_dc;
 
 static void thread_detach(void)
 {
@@ -71,6 +72,8 @@ static void process_detach(void)
         FreeLibrary(shdoclc);
     if(mshtml_tls != TLS_OUT_OF_INDEXES)
         TlsFree(mshtml_tls);
+    if(display_dc)
+        DeleteObject(display_dc);
 }
 
 HINSTANCE get_shdoclc(void)
@@ -84,6 +87,21 @@ HINSTANCE get_shdoclc(void)
     return shdoclc = LoadLibraryExW(wszShdoclc, NULL, LOAD_LIBRARY_AS_DATAFILE);
 }
 
+HDC get_display_dc(void)
+{
+    static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
+
+    if(!display_dc) {
+        HDC hdc;
+
+        hdc = CreateICW(displayW, NULL, NULL, NULL);
+        if(InterlockedCompareExchangePointer((void**)&display_dc, hdc, NULL))
+            DeleteObject(hdc);
+    }
+
+    return display_dc;
+}
+
 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
 {
     switch(fdwReason) {
index 97f9dd1..562a68a 100644 (file)
@@ -29,6 +29,7 @@
        <file>htmlelem3.c</file>
        <file>htmlelemcol.c</file>
        <file>htmlevent.c</file>
+       <file>htmlform.c</file>
        <file>htmlframebase.c</file>
        <file>htmlgeneric.c</file>
        <file>htmliframe.c</file>
@@ -37,6 +38,7 @@
        <file>htmllocation.c</file>
        <file>htmlnode.c</file>
        <file>htmloption.c</file>
+       <file>htmlscreen.c</file>
        <file>htmlscript.c</file>
        <file>htmlselect.c</file>
        <file>htmlstyle.c</file>
index 43601ae..68b3393 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "wingdi.h"
 #include "docobj.h"
+#include "comcat.h"
 #include "mshtml.h"
 #include "mshtmhst.h"
 #include "hlink.h"
@@ -51,7 +52,6 @@
 typedef struct HTMLDOMNode HTMLDOMNode;
 typedef struct ConnectionPoint ConnectionPoint;
 typedef struct BSCallback BSCallback;
-typedef struct nsChannelBSC nsChannelBSC;
 typedef struct event_target_t event_target_t;
 
 /* NOTE: make sure to keep in sync with dispex.c */
@@ -66,6 +66,7 @@ typedef enum {
     DispHTMLDocument_tid,
     DispHTMLDOMTextNode_tid,
     DispHTMLElementCollection_tid,
+    DispHTMLFormElement_tid,
     DispHTMLGenericElement_tid,
     DispHTMLIFrame_tid,
     DispHTMLImg_tid,
@@ -73,12 +74,14 @@ typedef enum {
     DispHTMLLocation_tid,
     DispHTMLNavigator_tid,
     DispHTMLOptionElement_tid,
+    DispHTMLScreen_tid,
     DispHTMLSelectElement_tid,
     DispHTMLStyle_tid,
     DispHTMLTable_tid,
     DispHTMLTableRow_tid,
     DispHTMLUnknownElement_tid,
     DispHTMLWindow2_tid,
+    HTMLDocumentEvents_tid,
     IHTMLAnchorElement_tid,
     IHTMLBodyElement_tid,
     IHTMLBodyElement2_tid,
@@ -101,6 +104,8 @@ typedef enum {
     IHTMLElement4_tid,
     IHTMLElementCollection_tid,
     IHTMLEventObj_tid,
+    IHTMLFiltersCollection_tid,
+    IHTMLFormElement_tid,
     IHTMLFrameBase_tid,
     IHTMLFrameBase2_tid,
     IHTMLGenericElement_tid,
@@ -109,6 +114,7 @@ typedef enum {
     IHTMLInputElement_tid,
     IHTMLLocation_tid,
     IHTMLOptionElement_tid,
+    IHTMLScreen_tid,
     IHTMLSelectElement_tid,
     IHTMLStyle_tid,
     IHTMLStyle2_tid,
@@ -120,6 +126,7 @@ typedef enum {
     IHTMLUniqueName_tid,
     IHTMLWindow2_tid,
     IHTMLWindow3_tid,
+    IHTMLWindow4_tid,
     IOmNavigator_tid,
     LAST_tid
 } tid_t;
@@ -156,6 +163,7 @@ void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
 void release_dispex(DispatchEx*);
 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
+HRESULT get_dispids(tid_t,DWORD*,DISPID**);
 
 typedef struct HTMLDocumentNode HTMLDocumentNode;
 typedef struct HTMLDocumentObj HTMLDocumentObj;
@@ -215,6 +223,7 @@ struct HTMLWindow {
     DispatchEx dispex;
     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
     const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
+    const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl;
     const IDispatchExVtbl  *lpIDispatchExVtbl;
 
     LONG ref;
@@ -233,7 +242,6 @@ struct HTMLWindow {
     IMoniker *mon;
     LPOLESTR url;
 
-    event_target_t *event_target;
     IHTMLEventObj *event;
 
     SCRIPTMODE scriptmode;
@@ -242,6 +250,7 @@ struct HTMLWindow {
     HTMLOptionElementFactory *option_factory;
     HTMLImageElementFactory *image_factory;
     HTMLLocation *location;
+    IHTMLScreen *screen;
 
     global_prop_t *global_props;
     DWORD global_prop_cnt;
@@ -258,17 +267,25 @@ typedef enum {
     EDITMODE        
 } USERMODE;
 
-typedef struct {
+typedef struct _cp_static_data_t {
+    tid_t tid;
+    void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
+    DWORD id_cnt;
+    DISPID *ids;
+} cp_static_data_t;
+
+typedef struct ConnectionPointContainer {
     const IConnectionPointContainerVtbl  *lpConnectionPointContainerVtbl;
 
     ConnectionPoint *cp_list;
     IUnknown *outer;
+    struct ConnectionPointContainer *forward_container;
 } ConnectionPointContainer;
 
 struct ConnectionPoint {
     const IConnectionPointVtbl *lpConnectionPointVtbl;
 
-    IConnectionPointContainer *container;
+    ConnectionPointContainer *container;
 
     union {
         IUnknown *unk;
@@ -278,6 +295,7 @@ struct ConnectionPoint {
     DWORD sinks_size;
 
     const IID *iid;
+    cp_static_data_t *data;
 
     ConnectionPoint *next;
 };
@@ -296,7 +314,7 @@ struct HTMLDocument {
     const IOleDocumentVtbl                *lpOleDocumentVtbl;
     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
-    const IViewObject2Vtbl                *lpViewObject2Vtbl;
+    const IViewObjectExVtbl               *lpViewObjectExVtbl;
     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
     const IServiceProviderVtbl            *lpServiceProviderVtbl;
     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
@@ -305,6 +323,7 @@ struct HTMLDocument {
     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
     const IDispatchExVtbl                 *lpIDispatchExVtbl;
     const ISupportErrorInfoVtbl           *lpSupportErrorInfoVtbl;
+    const IObjectWithSiteVtbl             *lpObjectWithSiteVtbl;
 
     IUnknown *unk_impl;
     IDispatchEx *dispex;
@@ -320,6 +339,9 @@ struct HTMLDocument {
     ConnectionPoint cp_htmldocevents;
     ConnectionPoint cp_htmldocevents2;
     ConnectionPoint cp_propnotif;
+    ConnectionPoint cp_dispatch;
+
+    IOleAdviseHolder *advise_holder;
 };
 
 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
@@ -359,12 +381,14 @@ struct HTMLDocumentObj {
     HWND hwnd;
     HWND tooltips_hwnd;
 
+    BOOL request_uiactivate;
     BOOL in_place_active;
     BOOL ui_active;
     BOOL window_active;
     BOOL has_key_path;
     BOOL container_locked;
     BOOL focus;
+    INT download_state;
 
     USERMODE usermode;
     LPWSTR mime;
@@ -399,7 +423,6 @@ struct NSContainer {
 
     HWND hwnd;
 
-    nsChannelBSC *bscallback; /* hack */
     HWND reset_focus; /* hack */
 };
 
@@ -410,9 +433,6 @@ typedef struct {
 
     LONG ref;
 
-    nsIChannel *channel;
-    nsIHttpChannel *http_channel;
-    nsIHttpChannelInternal *http_channel_internal;
     nsIWineURI *uri;
     nsIInputStream *post_data_stream;
     nsILoadGroup *load_group;
@@ -423,6 +443,7 @@ typedef struct {
     char *content_type;
     char *charset;
     PRUint32 response_status;
+    UINT url_scheme;
 } nsChannel;
 
 typedef struct {
@@ -432,6 +453,11 @@ typedef struct {
     HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
     HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
     HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
+    HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
+    HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
+    HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
+    HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
+    HRESULT (*bind_to_tree)(HTMLDOMNode*);
 } NodeImplVtbl;
 
 struct HTMLDOMNode {
@@ -445,6 +471,7 @@ struct HTMLDOMNode {
     nsIDOMNode *nsnode;
     HTMLDocumentNode *doc;
     event_target_t *event_target;
+    ConnectionPointContainer *cp_container;
 
     HTMLDOMNode *next;
 };
@@ -471,9 +498,13 @@ typedef struct {
 struct HTMLFrameBase {
     HTMLElement element;
 
-    const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
+    const IHTMLFrameBaseVtbl   *lpIHTMLFrameBaseVtbl;
+    const IHTMLFrameBase2Vtbl  *lpIHTMLFrameBase2Vtbl;
 
     HTMLWindow *content_window;
+
+    nsIDOMHTMLFrameElement *nsframe;
+    nsIDOMHTMLIFrameElement *nsiframe;
 };
 
 typedef struct _mutation_queue_t {
@@ -499,8 +530,10 @@ struct HTMLDocumentNode {
     nsIDOMHTMLDocument *nsdoc;
     HTMLDOMNode *nodes;
     BOOL content_ready;
+    event_target_t *body_event_target;
 
     IInternetSecurityManager *secmgr;
+    ICatInformation *catmgr;
     nsDocumentEventListener *nsevent_listener;
     BOOL *event_vector;
 
@@ -514,6 +547,7 @@ struct HTMLDocumentNode {
 
 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
 #define HTMLWINDOW3(x)   ((IHTMLWindow3*)                 &(x)->lpHTMLWindow3Vtbl)
+#define HTMLWINDOW4(x)   ((IHTMLWindow4*)                 &(x)->lpHTMLWindow4Vtbl)
 
 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
@@ -529,8 +563,9 @@ struct HTMLDocumentNode {
 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
-#define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
-#define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
+#define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObjectExVtbl)
+#define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObjectExVtbl)
+#define VIEWOBJEX(x)      ((IViewObjectEx*)               &(x)->lpViewObjectExVtbl)
 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
@@ -541,6 +576,7 @@ struct HTMLDocumentNode {
 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
 #define PERSISTHIST(x)   ((IPersistHistory*)              &(x)->lpPersistHistoryVtbl)
 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
+#define OBJSITE(x)       ((IObjectWithSite*)              &(x)->lpObjectWithSiteVtbl)
 
 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
@@ -573,10 +609,11 @@ struct HTMLDocumentNode {
 
 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*)               &(x)->lpIHTMLFrameBaseVtbl)
+#define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*)             &(x)->lpIHTMLFrameBase2Vtbl)
 
 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
-#define HTMLIMGFACTORY(x)  ((IHTMLImageElementFactory*)  &(x)->lpHTMLImageElementFactoryVtbl)
-#define HTMLLOCATION(x)  ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
+#define HTMLIMGFACTORY(x)  ((IHTMLImageElementFactory*)   &(x)->lpHTMLImageElementFactoryVtbl)
+#define HTMLLOCATION(x)    ((IHTMLLocation*)              &(x)->lpHTMLLocationVtbl)
 
 #define DISPATCHEX(x)    ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
 
@@ -599,6 +636,7 @@ HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
 IOmNavigator *OmNavigator_Create(void);
+HRESULT HTMLScreen_Create(IHTMLScreen**);
 
 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
@@ -614,7 +652,7 @@ void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
 
 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
 
-void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
+void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
 
@@ -642,9 +680,12 @@ void release_nsio(void);
 BOOL install_wine_gecko(BOOL);
 
 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
+HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**);
 
 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
-HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*);
+HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
+HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
+HRESULT load_nsuri(HTMLWindow*,nsIWineURI*,DWORD);
 
 void call_property_onchanged(ConnectionPoint*,DISPID);
 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
@@ -652,10 +693,8 @@ HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
 void nsfree(void*);
 
-void nsACString_Init(nsACString*,const char*);
 void nsACString_SetData(nsACString*,const char*);
 PRUint32 nsACString_GetData(const nsACString*,const char**);
-void nsACString_Finish(nsACString*);
 
 void nsAString_Init(nsAString*,const PRUnichar*);
 void nsAString_SetData(nsAString*,const PRUnichar*);
@@ -703,8 +742,9 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
 HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
-HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*);
-HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*);
+HTMLElement *HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
+HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
+HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
 HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
 HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
@@ -720,7 +760,7 @@ void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_s
 void HTMLElement2_Init(HTMLElement*);
 void HTMLElement3_Init(HTMLElement*);
 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
-void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*,dispex_static_data_t*);
+void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
 
 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
 void HTMLDOMNode_destructor(HTMLDOMNode*);
@@ -741,6 +781,7 @@ IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
 void set_script_mode(HTMLWindow*,SCRIPTMODE);
 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
 IDispatch *get_script_disp(ScriptHost*);
+HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
 
 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
@@ -917,6 +958,7 @@ static inline void windowref_release(windowref_t *ref)
         heap_free(ref);
 }
 
+HDC get_display_dc(void);
 HINSTANCE get_shdoclc(void);
 
 extern HINSTANCE hInst;
index 84c9241..372c467 100644 (file)
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 enum {
+    MUTATION_BINDTOTREE,
     MUTATION_COMMENT,
     MUTATION_ENDLOAD,
-    MUTATION_FRAME,
-    MUTATION_IFRAME,
     MUTATION_SCRIPT
 };
 
@@ -271,87 +270,25 @@ static void pop_mutation_queue(HTMLDocumentNode *doc)
     heap_free(tmp);
 }
 
-static nsresult init_nsdoc_window(HTMLDocumentNode *doc, nsIDOMDocument *nsdoc, HTMLWindow **ret)
+static void bind_to_tree(HTMLDocumentNode *doc, nsISupports *nsiface)
 {
-    nsIDOMWindow *nswindow;
-
-    nswindow = get_nsdoc_window(nsdoc);
-    if(!nswindow)
-        return NS_ERROR_FAILURE;
-
-    if(!nswindow_to_window(nswindow)) {
-        HTMLWindow *window;
-        HRESULT hres;
-
-        hres = HTMLWindow_Create(doc->basedoc.doc_obj, nswindow, doc->basedoc.window, &window);
-        if(SUCCEEDED(hres))
-            *ret = window;
-    }
-
-    nsIDOMWindow_Release(nswindow);
-    return NS_OK;
-}
-
-static nsresult init_iframe_window(HTMLDocumentNode *doc, nsISupports *nsunk)
-{
-    nsIDOMHTMLIFrameElement *nsiframe;
-    HTMLWindow *window = NULL;
-    nsIDOMDocument *nsdoc;
+    nsIDOMNode *nsnode;
+    HTMLDOMNode *node;
     nsresult nsres;
 
-    nsres = nsISupports_QueryInterface(nsunk, &IID_nsIDOMHTMLIFrameElement, (void**)&nsiframe);
-    if(NS_FAILED(nsres)) {
-        ERR("Could not get nsIDOMHTMLIFrameElement: %08x\n", nsres);
-        return nsres;
-    }
-
-    nsres = nsIDOMHTMLIFrameElement_GetContentDocument(nsiframe, &nsdoc);
-    nsIDOMHTMLIFrameElement_Release(nsiframe);
-    if(NS_FAILED(nsres) || !nsdoc) {
-        ERR("GetContentDocument failed: %08x\n", nsres);
-        return nsres;
-    }
-
-    nsres = init_nsdoc_window(doc, nsdoc, &window);
-
-    if(window) {
-        HTMLIFrame_Create(doc, (nsIDOMHTMLElement*)nsiframe, window);
-        IHTMLWindow2_Release(HTMLWINDOW2(window));
-    }
-
-    nsIDOMDocument_Release(nsdoc);
-    return nsres;
-}
-
-static nsresult init_frame_window(HTMLDocumentNode *doc, nsISupports *nsunk)
-{
-    nsIDOMHTMLFrameElement *nsframe;
-    HTMLWindow *window = NULL;
-    nsIDOMDocument *nsdoc;
-    nsresult nsres;
-
-    nsres = nsISupports_QueryInterface(nsunk, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
-    if(NS_FAILED(nsres)) {
-        ERR("Could not get nsIDOMHTMLFrameElement: %08x\n", nsres);
-        return nsres;
-    }
-
-    nsres = nsIDOMHTMLFrameElement_GetContentDocument(nsframe, &nsdoc);
-    nsIDOMHTMLFrameElement_Release(nsframe);
-    if(NS_FAILED(nsres) || !nsdoc) {
-        ERR("GetContentDocument failed: %08x\n", nsres);
-        return nsres;
-    }
-
-    nsres = init_nsdoc_window(doc, nsdoc, &window);
+    nsres = nsISupports_QueryInterface(nsiface, &IID_nsIDOMNode, (void**)&nsnode);
+    if(NS_FAILED(nsres))
+        return;
 
-    if(window) {
-        HTMLFrameElement_Create(doc, (nsIDOMHTMLElement*)nsframe, window);
-        IHTMLWindow2_Release(HTMLWINDOW2(window));
+    node = get_node(doc, nsnode, TRUE);
+    nsIDOMNode_Release(nsnode);
+    if(!node) {
+        ERR("Could not get node\n");
+        return;
     }
 
-    nsIDOMDocument_Release(nsdoc);
-    return nsres;
+    if(node->vtbl->bind_to_tree)
+        node->vtbl->bind_to_tree(node);
 }
 
 /* Calls undocumented 69 cmd of CGID_Explorer */
@@ -426,6 +363,10 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
 
     while(This->mutation_queue) {
         switch(This->mutation_queue->type) {
+        case MUTATION_BINDTOTREE:
+            bind_to_tree(This, This->mutation_queue->nsiface);
+            break;
+
         case MUTATION_COMMENT: {
             nsIDOMComment *nscomment;
             nsAString comment_str;
@@ -477,14 +418,6 @@ static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
             handle_end_load(This);
             break;
 
-        case MUTATION_FRAME:
-            init_frame_window(This, This->mutation_queue->nsiface);
-            break;
-
-        case MUTATION_IFRAME:
-            init_iframe_window(This, This->mutation_queue->nsiface);
-            break;
-
         case MUTATION_SCRIPT: {
             nsIDOMHTMLScriptElement *nsscript;
 
@@ -689,7 +622,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
     if(NS_SUCCEEDED(nsres)) {
         TRACE("iframe node\n");
 
-        push_mutation_queue(This, MUTATION_IFRAME, (nsISupports*)nsiframe);
+        push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsiframe);
         nsIDOMHTMLIFrameElement_Release(nsiframe);
     }
 
@@ -697,7 +630,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
     if(NS_SUCCEEDED(nsres)) {
         TRACE("frame node\n");
 
-        push_mutation_queue(This, MUTATION_FRAME, (nsISupports*)nsframe);
+        push_mutation_queue(This, MUTATION_BINDTOTREE, (nsISupports*)nsframe);
         nsIDOMHTMLFrameElement_Release(nsframe);
     }
 }
index 727eaef..b85de92 100644 (file)
 #include "windef.h"
 #include "winbase.h"
 #include "winuser.h"
+#include "winreg.h"
 #include "ole2.h"
 #include "hlguids.h"
 #include "shlguid.h"
+#include "wininet.h"
+#include "shlwapi.h"
 
 #include "wine/debug.h"
 #include "wine/unicode.h"
@@ -41,8 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 #define CONTENT_LENGTH "Content-Length"
 #define UTF16_STR "utf-16"
 
-static WCHAR emptyW[] = {0};
-
 typedef struct {
     const nsIInputStreamVtbl *lpInputStreamVtbl;
 
@@ -951,6 +952,21 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
                && (BYTE)This->nsstream->buf[1] == 0xfe)
                 This->nschannel->charset = heap_strdupA(UTF16_STR);
 
+            if(!This->nschannel->content_type) {
+                WCHAR *mime;
+
+                hres = FindMimeFromData(NULL, NULL, This->nsstream->buf, This->nsstream->buf_size, NULL, 0, &mime, 0);
+                if(FAILED(hres))
+                    return hres;
+
+                TRACE("Found MIME %s\n", debugstr_w(mime));
+
+                This->nschannel->content_type = heap_strdupWtoA(mime);
+                CoTaskMemFree(mime);
+                if(!This->nschannel->content_type)
+                    return E_OUTOFMEMORY;
+            }
+
             on_start_nsrequest(This);
 
             if(This->window)
@@ -1066,6 +1082,12 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW
 
         heap_free(This->nschannel->content_type);
         This->nschannel->content_type = heap_strdupWtoA(status_text);
+        break;
+    case BINDSTATUS_REDIRECTING:
+        TRACE("redirect to %s\n", debugstr_w(status_text));
+
+        /* FIXME: We should find a better way to handle this */
+        nsIWineURI_SetWineURL(This->nschannel->uri, status_text);
     }
 
     return S_OK;
@@ -1231,25 +1253,77 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
     return hres;
 }
 
-HRESULT navigate_url(HTMLDocumentNode *doc, OLECHAR *url)
+HRESULT load_nsuri(HTMLWindow *window, nsIWineURI *uri, DWORD flags)
+{
+    nsIWebNavigation *web_navigation;
+    nsIDocShell *doc_shell;
+    nsresult nsres;
+
+    nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
+    if(NS_FAILED(nsres)) {
+        ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
+    nsIWebNavigation_Release(web_navigation);
+    if(NS_FAILED(nsres)) {
+        ERR("Could not get nsIDocShell: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, flags, FALSE);
+    nsIDocShell_Release(doc_shell);
+    if(NS_FAILED(nsres)) {
+        WARN("LoadURI failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    return S_OK;
+}
+
+HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url)
 {
-    OLECHAR *translated_url = NULL;
+    WCHAR url[INTERNET_MAX_URL_LENGTH];
+    nsIWineURI *uri;
     HRESULT hres;
 
-    if(!url)
-        url = emptyW;
+    if(!new_url) {
+        *url = 0;
+    }else if(base_url) {
+        DWORD len = 0;
+
+        hres = CoInternetCombineUrl(base_url, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
+                url, sizeof(url)/sizeof(WCHAR), &len, 0);
+        if(FAILED(hres))
+            return hres;
+    }else {
+        strcpyW(url, new_url);
+    }
+
+    if(window->doc_obj && window->doc_obj->hostui) {
+        OLECHAR *translated_url = NULL;
 
-    if(doc->basedoc.doc_obj->hostui) {
-        hres = IDocHostUIHandler_TranslateUrl(doc->basedoc.doc_obj->hostui, 0, url,
+        hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url,
                 &translated_url);
-        if(hres == S_OK)
-            url = translated_url;
+        if(hres == S_OK) {
+            strcpyW(url, translated_url);
+            CoTaskMemFree(translated_url);
+        }
     }
 
-    hres = hlink_frame_navigate(&doc->basedoc, url, NULL, 0);
+    if(window->doc_obj && window == window->doc_obj->basedoc.window) {
+        hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0);
+        if(SUCCEEDED(hres))
+            return S_OK;
+        TRACE("hlink_frame_navigate failed: %08x\n", hres);
+    }
+
+    hres = create_doc_uri(window, url, &uri);
     if(FAILED(hres))
-        FIXME("hlink_frame_navigate failed: %08x\n", hres);
+        return hres;
 
-    CoTaskMemFree(translated_url);
+    hres = load_nsuri(window, uri, LOAD_FLAGS_NONE);
+    nsIWineURI_Release(uri);
     return hres;
 }
index 2150a0f..6858897 100644 (file)
@@ -533,7 +533,7 @@ void nsfree(void *mem)
     nsIMemory_Free(nsmem, mem);
 }
 
-void nsACString_Init(nsACString *str, const char *data)
+static void nsACString_Init(nsACString *str, const char *data)
 {
     NS_CStringContainerInit(str);
     if(data)
@@ -550,7 +550,7 @@ PRUint32 nsACString_GetData(const nsACString *str, const char **data)
     return NS_CStringGetData(str, data, NULL);
 }
 
-void nsACString_Finish(nsACString *str)
+static void nsACString_Finish(nsACString *str)
 {
     NS_CStringContainerFinish(str);
 }
@@ -1149,6 +1149,7 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener
     nsIWineURI *wine_uri;
     nsACString spec_str;
     const char *spec;
+    BOOL is_doc_uri;
     nsresult nsres;
 
     nsACString_Init(&spec_str, NULL);
@@ -1165,29 +1166,12 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener
         return NS_ERROR_NOT_IMPLEMENTED;
     }
 
-    nsIWineURI_SetNSContainer(wine_uri, This);
-    nsIWineURI_SetIsDocumentURI(wine_uri, TRUE);
+    nsIWineURI_GetIsDocumentURI(wine_uri, &is_doc_uri);
 
-    if(This->bscallback) {
-        IMoniker *mon = get_channelbsc_mon(This->bscallback);
+    if(!is_doc_uri) {
+        nsIWineURI_SetNSContainer(wine_uri, This);
+        nsIWineURI_SetIsDocumentURI(wine_uri, TRUE);
 
-        if(mon) {
-            LPWSTR wine_url;
-            HRESULT hres;
-
-            hres = IMoniker_GetDisplayName(mon, NULL, 0, &wine_url);
-            if(SUCCEEDED(hres)) {
-                nsIWineURI_SetWineURL(wine_uri, wine_url);
-                CoTaskMemFree(wine_url);
-            }else {
-                WARN("GetDisplayName failed: %08x\n", hres);
-            }
-
-            IMoniker_Release(mon);
-        }
-
-        *_retval = FALSE;
-    }else if(This->doc) {
         *_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri);
     }
 
index 7c4c09b..46f057f 100644 (file)
@@ -185,17 +185,19 @@ static void handle_docobj_load(HTMLDocumentObj *doc)
 
     hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
     if(SUCCEEDED(hres)) {
-        VARIANT state, progress;
-
-        V_VT(&progress) = VT_I4;
-        V_I4(&progress) = 0;
-        IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
-                               &progress, NULL);
-
-        V_VT(&state) = VT_I4;
-        V_I4(&state) = 0;
-        IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE, OLECMDEXECOPT_DONTPROMPTUSER,
-                               &state, NULL);
+        if(doc->download_state) {
+            VARIANT state, progress;
+
+            V_VT(&progress) = VT_I4;
+            V_I4(&progress) = 0;
+            IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS,
+                    OLECMDEXECOPT_DONTPROMPTUSER, &progress, NULL);
+
+            V_VT(&state) = VT_I4;
+            V_I4(&state) = 0;
+            IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
+                    OLECMDEXECOPT_DONTPROMPTUSER, &state, NULL);
+        }
 
         IOleCommandTarget_Exec(olecmd, &CGID_ShellDocView, 103, 0, NULL, NULL);
         IOleCommandTarget_Exec(olecmd, &CGID_MSHTML, IDM_PARSECOMPLETE, 0, NULL, NULL);
@@ -203,6 +205,7 @@ static void handle_docobj_load(HTMLDocumentObj *doc)
 
         IOleCommandTarget_Release(olecmd);
     }
+    doc->download_state = 0;
 }
 
 static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event)
index 19f29b0..af11762 100644 (file)
@@ -119,7 +119,6 @@ typedef nsISupports nsIDOMDOMImplementation;
 typedef nsISupports nsIDOMCDATASection;
 typedef nsISupports nsIDOMProcessingInstruction;
 typedef nsISupports nsIDOMEntityReference;
-typedef nsISupports nsIDOMHTMLFormElement;
 typedef nsISupports nsIDOMHTMLOptionsCollection;
 typedef nsISupports nsIWebProgressListener;
 typedef nsISupports nsIDOMCSSValue;
@@ -140,6 +139,16 @@ typedef nsISupports nsIContent;
 typedef nsISupports nsINode;
 typedef nsISupports nsIStyleSheet;
 typedef nsISupports nsIStyleRule;
+typedef nsISupports nsIVariant;
+typedef nsISupports nsIDOMUserDataHandler;
+typedef nsISupports nsIDocShellLoadInfo;
+typedef nsISupports nsISHEntry;
+typedef nsISupports nsIPresShell;
+typedef nsISupports nsIContentViewer;
+typedef nsISupports nsIDocumentCharsetInfo;
+typedef nsISupports nsILayoutHistoryState;
+typedef nsISupports nsISecureBrowserUI;
+typedef nsISupports nsIDOMStorage;
 
 [
     object,
@@ -601,6 +610,37 @@ interface nsIDOMNodeList : nsISupports
     nsresult GetLength(PRUint32 *aLength);
 }
 
+[
+    object,
+    uuid(29fb2a18-1dd2-11b2-8dd9-a6fd5d5ad12f),
+    local
+    /* NOT_FROZEN */
+]
+interface nsIDOM3Node : nsISupports
+{
+    enum NSDOCPOSITION {
+        DISCONNECTED = 1,
+        PRECEDING = 2,
+        FOLLOWING = 4,
+        CONTAINS = 8,
+        CONTAINED_BY = 16,
+        IMPLEMENTATION_SPECIFIC = 32
+    };
+
+    nsresult GetBaseURI(nsAString *aBaseURI);
+    nsresult CompareDocumentPosition(nsIDOMNode *other, PRUint16 *_retval);
+    nsresult GetTextContent(nsAString *aTextContent);
+    nsresult SetTextContent(const nsAString *aTextContent);
+    nsresult IsSameNode(nsIDOMNode *other, PRBool *_retval);
+    nsresult LookupPrefix(const nsAString *namespaceURI, PRBool *_retval);
+    nsresult IsDefaultNamespace(const nsAString *namespaceURI, PRBool *_retval);
+    nsresult LookupNamespaceURI(const nsAString *prefix, nsAString _retval);
+    nsresult IsEqualNode(nsIDOMNode *arg, PRBool *_retval);
+    nsresult GetFeature(const nsAString *feature, const nsAString *version, nsISupports **_retval);
+    nsresult SetUserData(const nsAString *key, nsIVariant *data, nsIDOMUserDataHandler *handler, nsIVariant **_retval);
+    nsresult GetUserData(const nsAString *key, nsIVariant **_retval);
+}
+
 [
     object,
     uuid(a6cf907c-15b3-11d2-932e-00805f8add32),
@@ -763,8 +803,10 @@ interface nsIDOMNSHTMLElement : nsISupports
     nsresult SetTabIndex(PRInt32 aTabIndex);
     nsresult GetContentEditable(nsAString *aContentEditable);
     nsresult SetContentEditable(const nsAString *aContentEditable);
-    nsresult blur();
-    nsresult focus();
+    nsresult GetDraggable(PRBool *aDraggable);
+    nsresult SetDraggable(PRBool aDraggable);
+    nsresult Blur();
+    nsresult Focus();
     nsresult ScrollIntoView(PRBool top);
     nsresult GetSpellcheck(PRBool *aSpellcheck);
     nsresult SetSpellcheck(PRBool aSpellcheck);
@@ -1179,6 +1221,32 @@ interface nsIDOMHTMLBodyElement : nsIDOMHTMLElement
     nsresult SetVLink(const nsAString *aVLink);
 }
 
+[
+    object,
+    uuid(a6cf908f-15b3-11d2-932e-00805f8add32),
+    local
+    /* FROZEN */
+]
+interface nsIDOMHTMLFormElement : nsIDOMHTMLElement
+{
+    nsresult GetElements(nsIDOMHTMLCollection **aElements);
+    nsresult GetLength(PRInt32 *aLength);
+    nsresult GetName(nsAString *aName);
+    nsresult SetName(const nsAString *aName);
+    nsresult GetAcceptCharset(nsAString *aAcceptCharset);
+    nsresult SetAcceptCharset(const nsAString *aAcceptCharset);
+    nsresult GetAction(nsAString *aAction);
+    nsresult SetAction(const nsAString *aAction);
+    nsresult GetEnctype(nsAString *aEnctype);
+    nsresult SetEnctype(const nsAString *aEnctype);
+    nsresult GetMethod(nsAString *aMethod);
+    nsresult SetMethod(const nsAString *aMethod);
+    nsresult GetTarget(nsAString *aTarget);
+    nsresult SetTarget(const nsAString *aTarget);
+    nsresult Submit();
+    nsresult Reset();
+}
+
 [
     object,
     uuid(a6cf9093-15b3-11d2-932e-00805f8add32),
@@ -1638,7 +1706,8 @@ interface nsIBaseWindow : nsISupports
     nsresult SetTitle(const PRUnichar *aTitle);
 }
 
-cpp_quote("#define LOAD_FLAGS_NONE 0")
+cpp_quote("#define LOAD_FLAGS_NONE           0x00000")
+cpp_quote("#define LOAD_INITIAL_DOCUMENT_URI 0x80000")
 
 [
     object,
@@ -2156,7 +2225,7 @@ interface nsIDOMMouseEvent : nsIDOMUIEvent
     nsresult GetAltKey(PRBool *aAltKey);
     nsresult GetMetaKey(PRBool *aMetaKey);
     nsresult GetButton(PRUint16 *aButton);
-    nsresult GetRelatedTarget(nsIDOMEventTarget * *aRelatedTarget);
+    nsresult GetRelatedTarget(nsIDOMEventTarget **aRelatedTarget);
     nsresult InitMouseEvent(const nsAString *typeArg, PRBool canBubbleArg, PRBool cancelableArg,
             nsIDOMAbstractView *viewArg, PRInt32 detailArg, PRInt32 screenXArg, PRInt32 screenYArg,
             PRInt32 clientXArg, PRInt32 clientYArg, PRBool ctrlKeyArg, PRBool altKeyArg,
@@ -2284,7 +2353,7 @@ interface nsIProfile : nsISupports
     nsresult GetProfileCount(PRInt32 *aProfileCount);
     nsresult GetProfileList(PRUint32 *length, PRUnichar ***profileNames);
     nsresult ProfileExists(const PRUnichar *profileName, PRBool *_retval);
-    nsresult GetCurrentProfile(PRUnichar * *aCurrentProfile);
+    nsresult GetCurrentProfile(PRUnichar **aCurrentProfile);
     nsresult SetCurrentProfile(const PRUnichar * aCurrentProfile);
     nsresult ShutDownCurrentProfile(PRUint32 shutDownType);
     nsresult CreateNewProfile(const PRUnichar *profileName,
@@ -2617,6 +2686,88 @@ interface nsIHTMLEditor : nsISupports
     nsresult SetReturnInParagraphCreatesNewParagraph([in] PRBool prb);
 }
 
+[
+    object,
+    uuid(8adfb831-1053-4a19-884d-bcdad7277b4b),
+    local
+    /* NOT_FROZEN */
+]
+interface nsIDocShell : nsISupports
+{
+    nsresult LoadURI(nsIURI *uri, nsIDocShellLoadInfo *loadInfo, PRUint32 aLoadFlags, PRBool firstParty);
+    nsresult LoadStream(nsIInputStream *aStream, nsIURI *aURI, const nsACString *aContentType,
+            const nsACString *aContentCharset, nsIDocShellLoadInfo *aLoadInfo);
+    nsresult InternalLoad(nsIURI *aURI, nsIURI *aReferrer, nsISupports *aOwner, PRUint32 aFlags, const PRUnichar *aWindowTarget,
+            const char *aTypeHint, nsIInputStream *aPostDataStream, nsIInputStream *aHeadersStream, PRUint32 aLoadFlags,
+            nsISHEntry *aSHEntry, PRBool firstParty, nsIDocShell **aDocShell, nsIRequest **aRequest);
+    nsresult CreateLoadInfo(nsIDocShellLoadInfo **loadInfo);
+    nsresult PrepareForNewContentModel();
+    nsresult SetCurrentURI(nsIURI *aURI);
+    nsresult FirePageHideNotification(PRBool isUnload);
+    nsresult GetPresContext(void /*nsPresContext*/ **aPresContext);
+    nsresult GetPresShell(nsIPresShell **aPresShell);
+    nsresult GetEldestPresShell(nsIPresShell **aEldestPresShell);
+    nsresult GetContentViewer(nsIContentViewer **aContentViewer);
+    nsresult GetChromeEventHandler(nsIDOMEventTarget **aChromeEventHandler);
+    nsresult SetChromeEventHandler(nsIDOMEventTarget *aChromeEventHandler);
+    nsresult GetDocumentCharsetInfo(nsIDocumentCharsetInfo **aDocumentCharsetInfo);
+    nsresult SetDocumentCharsetInfo(nsIDocumentCharsetInfo *aDocumentCharsetInfo);
+    nsresult GetAllowPlugins(PRBool *aAllowPlugins);
+    nsresult SetAllowPlugins(PRBool aAllowPlugins);
+    nsresult GetAllowJavascript(PRBool *aAllowJavascript);
+    nsresult SetAllowJavascript(PRBool aAllowJavascript);
+    nsresult GetAllowMetaRedirects(PRBool *aAllowMetaRedirects);
+    nsresult SetAllowMetaRedirects(PRBool aAllowMetaRedirects);
+    nsresult GetAllowSubframes(PRBool *aAllowSubframes);
+    nsresult SetAllowSubframes(PRBool aAllowSubframes);
+    nsresult GetAllowImages(PRBool *aAllowImages);
+    nsresult SetAllowImages(PRBool aAllowImages);
+    nsresult GetAllowDNSPrefetch(PRBool *aAllowDNSPrefetch);
+    nsresult SetAllowDNSPrefetch(PRBool aAllowDNSPrefetch);
+    nsresult GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimpleEnumerator **_retval);
+    nsresult GetAppType(PRUint32 *aAppType);
+    nsresult SetAppType(PRUint32 aAppType);
+    nsresult GetAllowAuth(PRBool *aAllowAuth);
+    nsresult SetAllowAuth(PRBool aAllowAuth);
+    nsresult GetZoom(float *aZoom);
+    nsresult SetZoom(float aZoom);
+    nsresult GetMarginWidth(PRInt32 *aMarginWidth);
+    nsresult SetMarginWidth(PRInt32 aMarginWidth);
+    nsresult GetMarginHeight(PRInt32 *aMarginHeight);
+    nsresult SetMarginHeight(PRInt32 aMarginHeight);
+    nsresult TabToTreeOwner(PRBool forward, PRBool *tookFocus);
+    nsresult GetBusyFlags(PRUint32 *aBusyFlags);
+    nsresult GetLoadType(PRUint32 *aLoadType);
+    nsresult SetLoadType(PRUint32 aLoadType);
+    nsresult IsBeingDestroyed(PRBool *_retval);
+    nsresult GetIsExecutingOnLoadHandler(PRBool *aIsExecutingOnLoadHandler);
+    nsresult GetLayoutHistoryState(nsILayoutHistoryState **aLayoutHistoryState);
+    nsresult SetLayoutHistoryState(nsILayoutHistoryState *aLayoutHistoryState);
+    nsresult GetShouldSaveLayoutState(PRBool *aShouldSaveLayoutState);
+    nsresult GetSecurityUI(nsISecureBrowserUI **aSecurityUI);
+    nsresult SetSecurityUI(nsISecureBrowserUI *aSecurityUI);
+    nsresult SuspendRefreshURIs();
+    nsresult ResumeRefreshURIs();
+    nsresult BeginRestore(nsIContentViewer *viewer, PRBool top);
+    nsresult FinishRestore();
+    nsresult GetRestoringDocument(PRBool *aRestoringDocument);
+    nsresult GetUseErrorPages(PRBool *aUseErrorPages);
+    nsresult SetUseErrorPages(PRBool aUseErrorPages);
+    nsresult GetPreviousTransIndex(PRInt32 *aPreviousTransIndex);
+    nsresult GetLoadedTransIndex(PRInt32 *aLoadedTransIndex);
+    nsresult HistoryPurged(PRInt32 numEntries);
+    nsresult GetSessionStorageForURI(nsIURI *uri, nsIDOMStorage **_retval);
+    nsresult GetSessionStorageForPrincipal(nsIPrincipal *principal, PRBool create, nsIDOMStorage **_retval);
+    nsresult AddSessionStorage(nsIPrincipal *principal, nsIDOMStorage *storage);
+    nsresult GetCurrentDocumentChannel(nsIChannel **aCurrentDocumentChannel);
+    nsresult SetChildOffset(PRUint32 offset);
+    nsresult GetIsInUnload(PRBool *aIsInUnload);
+    nsresult GetChannelIsUnsafe(PRBool *aChannelIsUnsafe);
+    void DetachEditorFromWindow();
+    nsresult GetIsOffScreenBrowser(PRBool *aIsOffScreenBrowser);
+    nsresult SetIsOffScreenBrowser(PRBool aIsOffScreenBrowser);
+}
+
 [
     object,
     uuid(365d600b-868a-452a-8de8-f46fad8fee53),
@@ -2685,11 +2836,14 @@ interface nsIWineURI : nsIURL
 {
     typedef struct NSContainer NSContainer;
     typedef struct HTMLWindow HTMLWindow;
+    typedef struct nsChannelBSC nsChannelBSC;
 
     nsresult GetNSContainer(NSContainer **aNSContainer);
     nsresult SetNSContainer(NSContainer *aNSContainer);
     nsresult GetWindow(HTMLWindow **aHTMLWindow);
     nsresult SetWindow(HTMLWindow *aHTMLWindow);
+    nsresult GetChannelBSC(nsChannelBSC **aChannelBSC);
+    nsresult SetChannelBSC(nsChannelBSC *aChannelBSC);
     nsresult GetIsDocumentURI(PRBool *aIsDocumentURI);
     nsresult SetIsDocumentURI(PRBool aIsDocumentURI);
     nsresult GetWineURL(LPCWSTR *aURL);
index 9792747..46fdcbc 100644 (file)
@@ -38,8 +38,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
-#define LOAD_INITIAL_DOCUMENT_URI 0x80000
-
 #define NS_IOSERVICE_CLASSNAME "nsIOService"
 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
 
@@ -60,6 +58,7 @@ typedef struct {
     nsIURL *nsurl;
     NSContainer *container;
     windowref_t *window_ref;
+    nsChannelBSC *channel_bsc;
     LPWSTR wine_url;
     PRBool is_doc_uri;
     BOOL use_wine_url;
@@ -158,6 +157,11 @@ static BOOL before_async_open(nsChannel *channel, NSContainer *container)
     return hres != S_OK;
 }
 
+static inline BOOL is_http_channel(nsChannel *This)
+{
+    return This->url_scheme == URL_SCHEME_HTTP || This->url_scheme == URL_SCHEME_HTTP;
+}
+
 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
 
 static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, nsQIResult result)
@@ -175,13 +179,13 @@ static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef r
         *result = NSCHANNEL(This);
     }else if(IsEqualGUID(&IID_nsIHttpChannel, riid)) {
         TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This, result);
-        *result = This->http_channel ? NSHTTPCHANNEL(This) : NULL;
+        *result = is_http_channel(This) ? NSHTTPCHANNEL(This) : NULL;
     }else if(IsEqualGUID(&IID_nsIUploadChannel, riid)) {
         TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This, result);
         *result = NSUPCHANNEL(This);
     }else if(IsEqualGUID(&IID_nsIHttpChannelInternal, riid)) {
         TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This, result);
-        *result = This->http_channel_internal ? NSHTTPINTERNAL(This) : NULL;
+        *result = is_http_channel(This) ? NSHTTPINTERNAL(This) : NULL;
     }else {
         TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
         *result = NULL;
@@ -212,12 +216,6 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
 
     if(!ref) {
         nsIWineURI_Release(This->uri);
-        if(This->channel)
-            nsIChannel_Release(This->channel);
-        if(This->http_channel)
-            nsIHttpChannel_Release(This->http_channel);
-        if(This->http_channel_internal)
-            nsIHttpChannel_Release(This->http_channel_internal);
         if(This->owner)
             nsISupports_Release(This->owner);
         if(This->post_data_stream)
@@ -240,10 +238,7 @@ static nsresult NSAPI nsChannel_GetName(nsIHttpChannel *iface, nsACString *aName
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aName);
-
-    if(This->channel)
-        return nsIChannel_GetName(This->channel, aName);
+    FIXME("(%p)->(%p)\n", This, aName);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -252,12 +247,8 @@ static nsresult NSAPI nsChannel_IsPending(nsIHttpChannel *iface, PRBool *_retval
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, _retval);
-
-    if(This->channel)
-        return nsIChannel_IsPending(This->channel, _retval);
+    FIXME("(%p)->(%p)\n", This, _retval);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -265,12 +256,8 @@ static nsresult NSAPI nsChannel_GetStatus(nsIHttpChannel *iface, nsresult *aStat
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aStatus);
+    WARN("(%p)->(%p) returning NS_OK\n", This, aStatus);
 
-    if(This->channel)
-        return nsIChannel_GetStatus(This->channel, aStatus);
-
-    TRACE("returning NS_OK\n");
     return *aStatus = NS_OK;
 }
 
@@ -278,12 +265,8 @@ static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%08x)\n", This, aStatus);
-
-    if(This->channel)
-        return nsIChannel_Cancel(This->channel, aStatus);
+    FIXME("(%p)->(%08x)\n", This, aStatus);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -291,12 +274,8 @@ static nsresult NSAPI nsChannel_Suspend(nsIHttpChannel *iface)
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)\n", This);
-
-    if(This->channel)
-        return nsIChannel_Suspend(This->channel);
+    FIXME("(%p)\n", This);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -304,12 +283,8 @@ static nsresult NSAPI nsChannel_Resume(nsIHttpChannel *iface)
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)\n", This);
-
-    if(This->channel)
-        return nsIChannel_Resume(This->channel);
+    FIXME("(%p)\n", This);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -336,11 +311,8 @@ static nsresult NSAPI nsChannel_SetLoadGroup(nsIHttpChannel *iface, nsILoadGroup
         nsILoadGroup_Release(This->load_group);
     if(aLoadGroup)
         nsILoadGroup_AddRef(aLoadGroup);
-
     This->load_group = aLoadGroup;
 
-    if(This->channel)
-        return nsIChannel_SetLoadGroup(This->channel, aLoadGroup);
     return NS_OK;
 }
 
@@ -361,9 +333,6 @@ static nsresult NSAPI nsChannel_SetLoadFlags(nsIHttpChannel *iface, nsLoadFlags
     TRACE("(%p)->(%08x)\n", This, aLoadFlags);
 
     This->load_flags = aLoadFlags;
-
-    if(This->channel)
-        return nsIChannel_SetLoadFlags(This->channel, aLoadFlags);
     return NS_OK;
 }
 
@@ -391,9 +360,6 @@ static nsresult NSAPI nsChannel_SetOriginalURI(nsIHttpChannel *iface, nsIURI *aO
 
     nsIURI_AddRef(aOriginalURI);
     This->original_uri = aOriginalURI;
-
-    if(This->channel)
-        return nsIChannel_SetOriginalURI(This->channel, aOriginalURI);
     return NS_OK;
 }
 
@@ -415,9 +381,6 @@ static nsresult NSAPI nsChannel_GetOwner(nsIHttpChannel *iface, nsISupports **aO
 
     TRACE("(%p)->(%p)\n", This, aOwner);
 
-    if(This->channel)
-        return nsIChannel_GetOwner(This->channel, aOwner);
-
     if(This->owner)
         nsISupports_AddRef(This->owner);
     *aOwner = This->owner;
@@ -431,9 +394,6 @@ static nsresult NSAPI nsChannel_SetOwner(nsIHttpChannel *iface, nsISupports *aOw
 
     TRACE("(%p)->(%p)\n", This, aOwner);
 
-    if(This->channel)
-        return nsIChannel_SetOwner(This->channel, aOwner);
-
     if(aOwner)
         nsISupports_AddRef(aOwner);
     if(This->owner)
@@ -471,8 +431,6 @@ static nsresult NSAPI nsChannel_SetNotificationCallbacks(nsIHttpChannel *iface,
 
     This->notif_callback = aNotificationCallbacks;
 
-    if(This->channel)
-        return nsIChannel_SetNotificationCallbacks(This->channel, aNotificationCallbacks);
     return NS_OK;
 }
 
@@ -480,12 +438,8 @@ static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISuppor
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aSecurityInfo);
-
-    if(This->channel)
-        return nsIChannel_GetSecurityInfo(This->channel, aSecurityInfo);
+    FIXME("(%p)->(%p)\n", This, aSecurityInfo);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -500,9 +454,6 @@ static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString
         return S_OK;
     }
 
-    if(This->channel)
-        return nsIChannel_GetContentType(This->channel, aContentType);
-
     WARN("unknown type\n");
     return NS_ERROR_FAILURE;
 }
@@ -522,9 +473,6 @@ static nsresult NSAPI nsChannel_SetContentType(nsIHttpChannel *iface,
     heap_free(This->content_type);
     This->content_type = heap_strdupA(content_type);
 
-    if(This->channel)
-        return nsIChannel_SetContentType(This->channel, aContentType);
-
     return NS_OK;
 }
 
@@ -540,13 +488,6 @@ static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
         return NS_OK;
     }
 
-    if(This->channel) {
-        nsresult nsres = nsIChannel_GetContentCharset(This->channel, aContentCharset);
-        const char *ch;
-        nsACString_GetData(aContentCharset, &ch);
-        return nsres;
-    }
-
     nsACString_SetData(aContentCharset, "");
     return NS_OK;
 }
@@ -556,12 +497,8 @@ static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aContentCharset);
-
-    if(This->channel)
-        return nsIChannel_SetContentCharset(This->channel, aContentCharset);
+    FIXME("(%p)->(%p)\n", This, aContentCharset);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -569,12 +506,8 @@ static nsresult NSAPI nsChannel_GetContentLength(nsIHttpChannel *iface, PRInt32
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aContentLength);
+    FIXME("(%p)->(%p)\n", This, aContentLength);
 
-    if(This->channel)
-        return nsIChannel_GetContentLength(This->channel, aContentLength);
-
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -582,12 +515,8 @@ static nsresult NSAPI nsChannel_SetContentLength(nsIHttpChannel *iface, PRInt32
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%d)\n", This, aContentLength);
+    FIXME("(%p)->(%d)\n", This, aContentLength);
 
-    if(This->channel)
-        return nsIChannel_SetContentLength(This->channel, aContentLength);
-
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -595,12 +524,8 @@ static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_re
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, _retval);
-
-    if(This->channel)
-        return nsIChannel_Open(This->channel, _retval);
+    FIXME("(%p)->(%p)\n", This, _retval);
 
-    FIXME("default action not implemented\n");
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -844,21 +769,21 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
     }
 
     if(!window) {
-        TRACE("window = NULL\n");
-        return This->channel
-            ? nsIChannel_AsyncOpen(This->channel, aListener, aContext)
-            : NS_ERROR_UNEXPECTED;
+        ERR("window = NULL\n");
+        return NS_ERROR_UNEXPECTED;
     }
 
-    if(is_doc_uri && (This->load_flags & LOAD_INITIAL_DOCUMENT_URI)) {
-        if(window->doc_obj->nscontainer->bscallback) {
-            NSContainer *nscontainer = window->doc_obj->nscontainer;
+    if(is_doc_uri && window == window->doc_obj->basedoc.window) {
+        nsChannelBSC *channel_bsc;
 
-            channelbsc_set_channel(nscontainer->bscallback, This, aListener, aContext);
+        nsIWineURI_GetChannelBSC(This->uri, &channel_bsc);
+        if(channel_bsc) {
+            channelbsc_set_channel(channel_bsc, This, aListener, aContext);
+            IUnknown_Release((IUnknown*)channel_bsc);
 
-            if(nscontainer->doc->mime) {
+            if(window->doc_obj->mime) {
                 heap_free(This->content_type);
-                This->content_type = heap_strdupWtoA(nscontainer->doc->mime);
+                This->content_type = heap_strdupWtoA(window->doc_obj->mime);
             }
 
             open = FALSE;
@@ -874,8 +799,7 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
     if(open)
         nsres = async_open(This, window, is_doc_uri, aListener, aContext);
 
-    if(window)
-        IHTMLWindow2_Release(HTMLWINDOW2(window));
+    IHTMLWindow2_Release(HTMLWINDOW2(window));
     return nsres;
 }
 
@@ -883,10 +807,7 @@ static nsresult NSAPI nsChannel_GetRequestMethod(nsIHttpChannel *iface, nsACStri
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aRequestMethod);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetRequestMethod(This->http_channel, aRequestMethod);
+    FIXME("(%p)->(%p)\n", This, aRequestMethod);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -896,10 +817,7 @@ static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aRequestMethod);
-
-    if(This->http_channel)
-        return nsIHttpChannel_SetRequestMethod(This->http_channel, aRequestMethod);
+    FIXME("(%p)->(%p)\n", This, aRequestMethod);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -908,10 +826,7 @@ static nsresult NSAPI nsChannel_GetReferrer(nsIHttpChannel *iface, nsIURI **aRef
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aReferrer);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetReferrer(This->http_channel, aReferrer);
+    FIXME("(%p)->(%p)\n", This, aReferrer);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -920,12 +835,9 @@ static nsresult NSAPI nsChannel_SetReferrer(nsIHttpChannel *iface, nsIURI *aRefe
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aReferrer);
-
-    if(This->http_channel)
-        return nsIHttpChannel_SetReferrer(This->http_channel, aReferrer);
+    FIXME("(%p)->(%p)\n", This, aReferrer);
 
-    return NS_ERROR_NOT_IMPLEMENTED;
+    return NS_OK;
 }
 
 static nsresult NSAPI nsChannel_GetRequestHeader(nsIHttpChannel *iface,
@@ -933,10 +845,7 @@ static nsresult NSAPI nsChannel_GetRequestHeader(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p %p)\n", This, aHeader, _retval);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetRequestHeader(This->http_channel, aHeader, _retval);
+    FIXME("(%p)->(%p %p)\n", This, aHeader, _retval);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -946,12 +855,9 @@ static nsresult NSAPI nsChannel_SetRequestHeader(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p %p %x)\n", This, aHeader, aValue, aMerge);
+    FIXME("(%p)->(%p %p %x)\n", This, aHeader, aValue, aMerge);
 
-    if(This->http_channel)
-        return nsIHttpChannel_SetRequestHeader(This->http_channel, aHeader, aValue, aMerge);
-
-    return NS_ERROR_NOT_IMPLEMENTED;
+    return NS_OK;
 }
 
 static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface,
@@ -959,10 +865,7 @@ static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aVisitor);
-
-    if(This->http_channel)
-        return nsIHttpChannel_VisitRequestHeaders(This->http_channel, aVisitor);
+    FIXME("(%p)->(%p)\n", This, aVisitor);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -971,10 +874,7 @@ static nsresult NSAPI nsChannel_GetAllowPipelining(nsIHttpChannel *iface, PRBool
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aAllowPipelining);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetAllowPipelining(This->http_channel, aAllowPipelining);
+    FIXME("(%p)->(%p)\n", This, aAllowPipelining);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -983,10 +883,7 @@ static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, PRBool
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%x)\n", This, aAllowPipelining);
-
-    if(This->http_channel)
-        return nsIHttpChannel_SetAllowPipelining(This->http_channel, aAllowPipelining);
+    FIXME("(%p)->(%x)\n", This, aAllowPipelining);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -995,10 +892,7 @@ static nsresult NSAPI nsChannel_GetRedirectionLimit(nsIHttpChannel *iface, PRUin
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aRedirectionLimit);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetRedirectionLimit(This->http_channel, aRedirectionLimit);
+    FIXME("(%p)->(%p)\n", This, aRedirectionLimit);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1007,10 +901,7 @@ static nsresult NSAPI nsChannel_SetRedirectionLimit(nsIHttpChannel *iface, PRUin
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%u)\n", This, aRedirectionLimit);
-
-    if(This->http_channel)
-        return nsIHttpChannel_SetRedirectionLimit(This->http_channel, aRedirectionLimit);
+    FIXME("(%p)->(%u)\n", This, aRedirectionLimit);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1026,9 +917,7 @@ static nsresult NSAPI nsChannel_GetResponseStatus(nsIHttpChannel *iface, PRUint3
         return NS_OK;
     }
 
-    if(This->http_channel)
-        return nsIHttpChannel_GetResponseStatus(This->http_channel, aResponseStatus);
-
+    WARN("No response status\n");
     return NS_ERROR_UNEXPECTED;
 }
 
@@ -1037,10 +926,7 @@ static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aResponseStatusText);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetResponseStatusText(This->http_channel, aResponseStatusText);
+    FIXME("(%p)->(%p)\n", This, aResponseStatusText);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1050,10 +936,7 @@ static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aRequestSucceeded);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetRequestSucceeded(This->http_channel, aRequestSucceeded);
+    FIXME("(%p)->(%p)\n", This, aRequestSucceeded);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1063,10 +946,7 @@ static nsresult NSAPI nsChannel_GetResponseHeader(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p %p)\n", This, header, _retval);
-
-    if(This->http_channel)
-        return nsIHttpChannel_GetResponseHeader(This->http_channel, header, _retval);
+    FIXME("(%p)->(%p %p)\n", This, header, _retval);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1076,10 +956,7 @@ static nsresult NSAPI nsChannel_SetResponseHeader(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p %p %x)\n", This, header, value, merge);
-
-    if(This->http_channel)
-        return nsIHttpChannel_SetResponseHeader(This->http_channel, header, value, merge);
+    FIXME("(%p)->(%p %p %x)\n", This, header, value, merge);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1089,10 +966,7 @@ static nsresult NSAPI nsChannel_VisitResponseHeaders(nsIHttpChannel *iface,
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, aVisitor);
-
-    if(This->http_channel)
-        return nsIHttpChannel_VisitResponseHeaders(This->http_channel, aVisitor);
+    FIXME("(%p)->(%p)\n", This, aVisitor);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1101,10 +975,7 @@ static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, PRBool
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, _retval);
-
-    if(This->http_channel)
-        return nsIHttpChannel_IsNoStoreResponse(This->http_channel, _retval);
+    FIXME("(%p)->(%p)\n", This, _retval);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1113,10 +984,7 @@ static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, PRBool
 {
     nsChannel *This = NSCHANNEL_THIS(iface);
 
-    TRACE("(%p)->(%p)\n", This, _retval);
-
-    if(This->http_channel)
-        return nsIHttpChannel_IsNoCacheResponse(This->http_channel, _retval);
+    FIXME("(%p)->(%p)\n", This, _retval);
 
     return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1200,7 +1068,6 @@ static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
 {
     nsChannel *This = NSUPCHANNEL_THIS(iface);
     const char *content_type;
-    nsresult nsres;
 
     TRACE("(%p)->(%p %p %d)\n", This, aStream, aContentType, aContentLength);
 
@@ -1222,20 +1089,6 @@ static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
     if(aStream)
         nsIInputStream_AddRef(aStream);
 
-    if(This->post_data_stream) {
-        nsIUploadChannel *upload_channel;
-
-        nsres = nsIChannel_QueryInterface(This->channel, &IID_nsIUploadChannel,
-                (void**)&upload_channel);
-        if(NS_SUCCEEDED(nsres)) {
-            nsres = nsIUploadChannel_SetUploadStream(upload_channel, aStream, aContentType, aContentLength);
-            nsIUploadChannel_Release(upload_channel);
-            if(NS_FAILED(nsres))
-                WARN("SetUploadStream failed: %08x\n", nsres);
-
-        }
-    }
-
     return NS_OK;
 }
 
@@ -1288,10 +1141,8 @@ static nsresult NSAPI nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInterna
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_GetDocumentURI(This->http_channel_internal, aDocumentURI);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1299,10 +1150,8 @@ static nsresult NSAPI nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInterna
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_SetDocumentURI(This->http_channel_internal, aDocumentURI);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1310,10 +1159,8 @@ static nsresult NSAPI nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInte
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_GetRequestVersion(This->http_channel_internal, major, minor);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1321,10 +1168,8 @@ static nsresult NSAPI nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInt
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_GetResponseVersion(This->http_channel_internal, major, minor);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1332,10 +1177,8 @@ static nsresult NSAPI nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal *if
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_SetCookie(This->http_channel_internal, aCookieHeader);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1343,10 +1186,8 @@ static nsresult NSAPI nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelI
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_SetupFallbackChannel(This->http_channel_internal, aFallbackKey);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1354,10 +1195,8 @@ static nsresult NSAPI nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHtt
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_GetForceAllowThirdPartyCookie(This->http_channel_internal, aForceThirdPartyCookie);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1365,10 +1204,8 @@ static nsresult NSAPI nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHtt
 {
     nsChannel *This = NSHTTPINTERNAL_THIS(iface);
 
-    TRACE("(%p)->()\n", This);
+    FIXME("(%p)->()\n", This);
 
-    if(This->http_channel_internal)
-        return nsIHttpChannelInternal_SetForceAllowThirdPartyCookie(This->http_channel_internal, aForceThirdPartyCookie);
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -1506,7 +1343,7 @@ static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme)
 
     TRACE("(%p)->(%p)\n", This, aScheme);
 
-    if(This->use_wine_url && strcmpW(This->wine_url, about_blankW)) {
+    if(This->use_wine_url) {
         /*
          * For Gecko we set scheme to unknown so it won't be handled
          * as any special case.
@@ -2220,6 +2057,32 @@ static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow
     return NS_OK;
 }
 
+static nsresult NSAPI nsURI_GetChannelBSC(nsIWineURI *iface, nsChannelBSC **aChannelBSC)
+{
+    nsURI *This = NSURI_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, aChannelBSC);
+
+    if(This->channel_bsc)
+        IUnknown_AddRef((IUnknown*)This->channel_bsc);
+    *aChannelBSC = This->channel_bsc;
+    return NS_OK;
+}
+
+static nsresult NSAPI nsURI_SetChannelBSC(nsIWineURI *iface, nsChannelBSC *aChannelBSC)
+{
+    nsURI *This = NSURI_THIS(iface);
+
+    TRACE("(%p)->(%p)\n", This, aChannelBSC);
+
+    if(This->channel_bsc)
+        IUnknown_Release((IUnknown*)This->channel_bsc);
+    if(aChannelBSC)
+        IUnknown_AddRef((IUnknown*)aChannelBSC);
+    This->channel_bsc = aChannelBSC;
+    return NS_OK;
+}
+
 static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI)
 {
     nsURI *This = NSURI_THIS(iface);
@@ -2267,11 +2130,15 @@ static nsresult NSAPI nsURI_SetWineURL(nsIWineURI *iface, LPCWSTR aURL)
         This->wine_url = heap_alloc(len*sizeof(WCHAR));
         memcpy(This->wine_url, aURL, len*sizeof(WCHAR));
 
-        /* FIXME: Always use wine url */
-        This->use_wine_url =
-               strncmpW(aURL, wszFtp,   sizeof(wszFtp)/sizeof(WCHAR))
-            && strncmpW(aURL, wszHttp,  sizeof(wszHttp)/sizeof(WCHAR))
-            && strncmpW(aURL, wszHttps, sizeof(wszHttps)/sizeof(WCHAR));
+        if(This->uri) {
+            /* FIXME: Always use wine url */
+            This->use_wine_url =
+                   strncmpW(aURL, wszFtp,   sizeof(wszFtp)/sizeof(WCHAR))
+                && strncmpW(aURL, wszHttp,  sizeof(wszHttp)/sizeof(WCHAR))
+                && strncmpW(aURL, wszHttps, sizeof(wszHttps)/sizeof(WCHAR));
+        }else {
+            This->use_wine_url = TRUE;
+        }
     }else {
         This->wine_url = NULL;
         This->use_wine_url = FALSE;
@@ -2334,6 +2201,8 @@ static const nsIWineURIVtbl nsWineURIVtbl = {
     nsURI_SetNSContainer,
     nsURI_GetWindow,
     nsURI_SetWindow,
+    nsURI_GetChannelBSC,
+    nsURI_SetChannelBSC,
     nsURI_GetIsDocumentURI,
     nsURI_SetIsDocumentURI,
     nsURI_GetWineURL,
@@ -2361,6 +2230,22 @@ static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *contain
     return NS_OK;
 }
 
+HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsIWineURI **ret)
+{
+    nsIWineURI *uri;
+    nsresult nsres;
+
+    nsres = create_uri(NULL, window, window->doc_obj->nscontainer, &uri);
+    if(NS_FAILED(nsres))
+        return E_FAIL;
+
+    nsIWineURI_SetWineURL(uri, url);
+    nsIWineURI_SetIsDocumentURI(uri, TRUE);
+
+    *ret = uri;
+    return S_OK;
+}
+
 typedef struct {
     const nsIProtocolHandlerVtbl  *lpProtocolHandlerVtbl;
 
@@ -2607,38 +2492,25 @@ static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *
     }
 
     if(aBaseURI) {
-        nsACString base_uri_str;
-        const char *base_uri = NULL;
-
-        nsACString_Init(&base_uri_str, NULL);
+        PARSEDURLA parsed_url = {sizeof(PARSEDURLA)};
 
-        nsres = nsIURI_GetSpec(aBaseURI, &base_uri_str);
+        nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsIWineURI, (void**)&base_wine_uri);
         if(NS_SUCCEEDED(nsres)) {
-            nsACString_GetData(&base_uri_str, &base_uri);
-            TRACE("base_uri=%s\n", debugstr_a(base_uri));
+            nsIWineURI_GetWineURL(base_wine_uri, &base_wine_url);
+            nsIWineURI_GetWindow(base_wine_uri, &window);
+            TRACE("base url: %s window: %p\n", debugstr_w(base_wine_url), window);
+        }else if(FAILED(ParseURLA(spec, &parsed_url))) {
+            TRACE("not wraping\n");
+            return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
         }else {
-            ERR("GetSpec failed: %08x\n", nsres);
+            WARN("Could not get base nsIWineURI: %08x\n", nsres);
         }
-
-        nsACString_Finish(&base_uri_str);
     }
 
     nsres = nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, &uri);
     if(NS_FAILED(nsres))
         TRACE("NewURI failed: %08x\n", nsres);
 
-    if(aBaseURI) {
-        nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsIWineURI, (void**)&base_wine_uri);
-        if(NS_SUCCEEDED(nsres)) {
-            nsIWineURI_GetWindow(base_wine_uri, &window);
-            nsIWineURI_GetWineURL(base_wine_uri, &base_wine_url);
-        }else {
-            TRACE("Could not get base nsIWineURI: %08x\n", nsres);
-        }
-    }
-
-    TRACE("window = %p\n", window);
-
     nsres = create_uri(uri, window, NULL, &wine_uri);
     *_retval = (nsIURI*)wine_uri;
 
@@ -2682,25 +2554,18 @@ static nsresult NSAPI nsIOService_NewFileURI(nsIIOService *iface, nsIFile *aFile
 static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI *aURI,
                                                      nsIChannel **_retval)
 {
-    nsIChannel *channel = NULL;
+    PARSEDURLW parsed_url = {sizeof(PARSEDURLW)};
     nsChannel *ret;
     nsIWineURI *wine_uri;
+    const WCHAR *url;
     nsresult nsres;
 
     TRACE("(%p %p)\n", aURI, _retval);
 
-    nsres = nsIIOService_NewChannelFromURI(nsio, aURI, &channel);
-    if(NS_FAILED(nsres) && nsres != NS_ERROR_UNKNOWN_PROTOCOL) {
-        WARN("NewChannelFromURI failed: %08x\n", nsres);
-        *_retval = channel;
-        return nsres;
-    }
-
     nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
     if(NS_FAILED(nsres)) {
-        WARN("Could not get nsIWineURI: %08x\n", nsres);
-        *_retval = channel;
-        return channel ? NS_OK : NS_ERROR_UNEXPECTED;
+        TRACE("Could not get nsIWineURI: %08x\n", nsres);
+        return nsIIOService_NewChannelFromURI(nsio, aURI, _retval);
     }
 
     ret = heap_alloc_zero(sizeof(nsChannel));
@@ -2709,16 +2574,13 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI
     ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
     ret->lpIHttpChannelInternalVtbl = &nsHttpChannelInternalVtbl;
     ret->ref = 1;
-    ret->channel = channel;
     ret->uri = wine_uri;
 
     nsIURI_AddRef(aURI);
     ret->original_uri = aURI;
 
-    if(channel) {
-        nsIChannel_QueryInterface(channel, &IID_nsIHttpChannel, (void**)&ret->http_channel);
-        nsIChannel_QueryInterface(channel, &IID_nsIHttpChannelInternal, (void**)&ret->http_channel_internal);
-    }
+    nsIWineURI_GetWineURL(wine_uri, &url);
+    ret->url_scheme = url && SUCCEEDED(ParseURLW(url, &parsed_url)) ? parsed_url.nScheme : URL_SCHEME_UNKNOWN;
 
     *_retval = NSCHANNEL(ret);
     return NS_OK;
index e9cb204..3dec3dc 100644 (file)
@@ -250,6 +250,9 @@ static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
         IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
 
     HTMLDocument_LockContainer(This->doc_obj, FALSE);
+
+    if(This->advise_holder)
+        IOleAdviseHolder_SendOnClose(This->advise_holder);
     
     return S_OK;
 }
@@ -380,22 +383,46 @@ static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect,
 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
 {
     HTMLDocument *This = OLEOBJ_THIS(iface);
-    FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
+
+    if(!pdwConnection)
+        return E_INVALIDARG;
+
+    if(!pAdvSink) {
+        *pdwConnection = 0;
+        return E_INVALIDARG;
+    }
+
+    if(!This->advise_holder) {
+        CreateOleAdviseHolder(&This->advise_holder);
+        if(!This->advise_holder)
+            return E_OUTOFMEMORY;
+    }
+
+    return IOleAdviseHolder_Advise(This->advise_holder, pAdvSink, pdwConnection);
 }
 
 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
 {
     HTMLDocument *This = OLEOBJ_THIS(iface);
-    FIXME("(%p)->(%d)\n", This, dwConnection);
-    return E_NOTIMPL;
+    TRACE("(%p)->(%d)\n", This, dwConnection);
+
+    if(!This->advise_holder)
+        return OLE_E_NOCONNECTION;
+
+    return IOleAdviseHolder_Unadvise(This->advise_holder, dwConnection);
 }
 
 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
 {
     HTMLDocument *This = OLEOBJ_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, ppenumAdvise);
-    return E_NOTIMPL;
+
+    if(!This->advise_holder) {
+        *ppenumAdvise = NULL;
+        return S_OK;
+    }
+
+    return IOleAdviseHolder_EnumAdvise(This->advise_holder, ppenumAdvise);
 }
 
 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
@@ -705,6 +732,54 @@ static const IOleControlVtbl OleControlVtbl = {
     OleControl_FreezeEvents
 };
 
+/**********************************************************
+ * IObjectWithSite implementation
+ */
+
+#define OBJSITE_THIS(iface) DEFINE_THIS(HTMLDocument, ObjectWithSite, iface)
+
+static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid, void **ppvObject)
+{
+    HTMLDocument *This = OBJSITE_THIS(iface);
+    return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
+}
+
+static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
+{
+    HTMLDocument *This = OBJSITE_THIS(iface);
+    return IHTMLDocument2_AddRef(HTMLDOC(This));
+}
+
+static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
+{
+    HTMLDocument *This = OBJSITE_THIS(iface);
+    return IHTMLDocument2_Release(HTMLDOC(This));
+}
+
+static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
+{
+    HTMLDocument *This = OBJSITE_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, pUnkSite);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite* iface, REFIID riid, PVOID *ppvSite)
+{
+    HTMLDocument *This = OBJSITE_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, ppvSite);
+    return E_NOTIMPL;
+}
+
+#undef OBJSITE_THIS
+
+static const IObjectWithSiteVtbl ObjectWithSiteVtbl = {
+    ObjectWithSite_QueryInterface,
+    ObjectWithSite_AddRef,
+    ObjectWithSite_Release,
+    ObjectWithSite_SetSite,
+    ObjectWithSite_GetSite
+};
+
 void HTMLDocument_LockContainer(HTMLDocumentObj *This, BOOL fLock)
 {
     IOleContainer *container;
@@ -726,4 +801,5 @@ void HTMLDocument_OleObj_Init(HTMLDocument *This)
     This->lpOleObjectVtbl = &OleObjectVtbl;
     This->lpOleDocumentVtbl = &OleDocumentVtbl;
     This->lpOleControlVtbl = &OleControlVtbl;
+    This->lpObjectWithSiteVtbl = &ObjectWithSiteVtbl;
 }
index f3d23bd..d3014b8 100644 (file)
 #include "wine/unicode.h"
 
 #include "mshtml_private.h"
+#include "htmlevent.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
+typedef struct {
+    task_t header;
+    HTMLDocumentObj *doc;
+    BOOL set_download;
+} download_proc_task_t;
+
 static BOOL use_gecko_script(LPCWSTR url)
 {
     static const WCHAR fileW[] = {'f','i','l','e',':'};
     static const WCHAR aboutW[] = {'a','b','o','u','t',':'};
+    static const WCHAR resW[] = {'r','e','s',':'};
 
     return strncmpiW(fileW, url, sizeof(fileW)/sizeof(WCHAR))
-        && strncmpiW(aboutW, url, sizeof(aboutW)/sizeof(WCHAR));
+        && strncmpiW(aboutW, url, sizeof(aboutW)/sizeof(WCHAR))
+        && strncmpiW(resW, url, sizeof(resW)/sizeof(WCHAR));
 }
 
 void set_current_mon(HTMLWindow *This, IMoniker *mon)
@@ -117,7 +126,8 @@ static void set_progress_proc(task_t *_task)
 
 static void set_downloading_proc(task_t *_task)
 {
-    HTMLDocumentObj *doc = ((docobj_task_t*)_task)->doc;
+    download_proc_task_t *task = (download_proc_task_t*)_task;
+    HTMLDocumentObj *doc = task->doc;
     IOleCommandTarget *olecmd;
     HRESULT hres;
 
@@ -129,16 +139,20 @@ static void set_downloading_proc(task_t *_task)
     if(!doc->client)
         return;
 
-    hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
-    if(SUCCEEDED(hres)) {
-        VARIANT var;
+    if(task->set_download) {
+        hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
+        if(SUCCEEDED(hres)) {
+            VARIANT var;
+
+            V_VT(&var) = VT_I4;
+            V_I4(&var) = 1;
 
-        V_VT(&var) = VT_I4;
-        V_I4(&var) = 1;
+            IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
+                    OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
+            IOleCommandTarget_Release(olecmd);
+        }
 
-        IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE, OLECMDEXECOPT_DONTPROMPTUSER,
-                               &var, NULL);
-        IOleCommandTarget_Release(olecmd);
+        doc->download_state = 1;
     }
 
     if(doc->hostui) {
@@ -152,13 +166,14 @@ static void set_downloading_proc(task_t *_task)
     }
 }
 
-static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc)
+static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BOOL set_download)
 {
     nsChannelBSC *bscallback;
     LPOLESTR url = NULL;
     docobj_task_t *task;
+    download_proc_task_t *download_task;
+    nsIWineURI *nsuri;
     HRESULT hres;
-    nsresult nsres;
 
     if(pibc) {
         IUnknown *unk = NULL;
@@ -239,34 +254,32 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc)
         }
     }
 
+    hres = create_doc_uri(This->window, url, &nsuri);
+    CoTaskMemFree(url);
+    if(FAILED(hres))
+        return hres;
+
     bscallback = create_channelbsc(mon);
 
+    nsIWineURI_SetChannelBSC(nsuri, bscallback);
+    hres = load_nsuri(This->window, nsuri, LOAD_INITIAL_DOCUMENT_URI);
+    nsIWineURI_SetChannelBSC(nsuri, NULL);
+    if(SUCCEEDED(hres))
+        set_window_bscallback(This->window, bscallback);
+    IUnknown_Release((IUnknown*)bscallback);
+    if(FAILED(hres))
+        return hres;
+
     if(This->doc_obj->frame) {
         task = heap_alloc(sizeof(docobj_task_t));
         task->doc = This->doc_obj;
         push_task(&task->header, set_progress_proc, This->doc_obj->basedoc.task_magic);
     }
 
-    task = heap_alloc(sizeof(docobj_task_t));
-    task->doc = This->doc_obj;
-    push_task(&task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic);
-
-    if(This->doc_obj->nscontainer) {
-        This->doc_obj->nscontainer->bscallback = bscallback;
-        nsres = nsIWebNavigation_LoadURI(This->doc_obj->nscontainer->navigation, url,
-                LOAD_FLAGS_NONE, NULL, NULL, NULL);
-        This->doc_obj->nscontainer->bscallback = NULL;
-        if(NS_FAILED(nsres)) {
-            WARN("LoadURI failed: %08x\n", nsres);
-            IUnknown_Release((IUnknown*)bscallback);
-            CoTaskMemFree(url);
-            return E_FAIL;
-        }
-    }
-
-    set_window_bscallback(This->window, bscallback);
-    IUnknown_Release((IUnknown*)bscallback);
-    CoTaskMemFree(url);
+    download_task = heap_alloc(sizeof(download_proc_task_t));
+    download_task->doc = This->doc_obj;
+    download_task->set_download = set_download;
+    push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic);
 
     return S_OK;
 }
@@ -274,8 +287,11 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc)
 void set_ready_state(HTMLWindow *window, READYSTATE readystate)
 {
     window->readystate = readystate;
-    if(window->doc_obj->basedoc.window == window)
+    if(window->doc_obj && window->doc_obj->basedoc.window == window)
         call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
+    if(window->frame_element)
+        fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
+                   window->frame_element->element.node.nsnode, NULL);
 }
 
 static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)
@@ -359,7 +375,7 @@ static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAva
 
     TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
 
-    hres = set_moniker(This, pimkName, pibc);
+    hres = set_moniker(This, pimkName, pibc, TRUE);
     if(FAILED(hres))
         return hres;
 
@@ -620,7 +636,7 @@ static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM
         return hres;
     }
 
-    hres = set_moniker(This, mon, NULL);
+    hres = set_moniker(This, mon, NULL, TRUE);
     IMoniker_Release(mon);
     if(FAILED(hres))
         return hres;
@@ -665,8 +681,45 @@ static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
 {
     HTMLDocument *This = PERSTRINIT_THIS(iface);
-    FIXME("(%p)\n", This);
-    return E_NOTIMPL;
+    IMoniker *mon;
+    HGLOBAL body;
+    LPSTREAM stream;
+    HRESULT hres;
+
+    static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
+    static const WCHAR html_bodyW[] = {'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
+
+    TRACE("(%p)\n", This);
+
+    body = GlobalAlloc(0, sizeof(html_bodyW));
+    if(!body)
+        return E_OUTOFMEMORY;
+    memcpy(body, html_bodyW, sizeof(html_bodyW));
+
+    hres = CreateURLMoniker(NULL, about_blankW, &mon);
+    if(FAILED(hres)) {
+        WARN("CreateURLMoniker failed: %08x\n", hres);
+        GlobalFree(body);
+        return hres;
+    }
+
+    hres = set_moniker(This, mon, NULL, FALSE);
+    IMoniker_Release(mon);
+    if(FAILED(hres)) {
+        GlobalFree(body);
+        return hres;
+    }
+
+    hres = CreateStreamOnHGlobal(body, TRUE, &stream);
+    if(FAILED(hres)) {
+        GlobalFree(body);
+        return hres;
+    }
+
+    hres = channelbsc_load_stream(This->window->bscallback, stream);
+
+    IStream_Release(stream);
+    return hres;
 }
 
 #undef PERSTRINIT_THIS
index 7df0dd6..efd2605 100644 (file)
@@ -895,7 +895,7 @@ BOOL find_global_prop(HTMLWindow *window, BSTR name, DWORD flags, ScriptHost **r
 
         hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
         if(SUCCEEDED(hres)) {
-            hres = IDispatchEx_GetDispID(dispex, name, flags, ret_id);
+            hres = IDispatchEx_GetDispID(dispex, name, flags & (~fdexNameEnsure), ret_id);
             IDispatchEx_Release(dispex);
         }else {
             FIXME("No IDispatchEx\n");
index 8938943..e35a83b 100644 (file)
@@ -84,7 +84,7 @@ static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHost
             pContext, cbContext, dwFlags, dwReserved);
 }
 
-static DWORD confirm_safety(HTMLDocumentNode *This, const WCHAR *url, IUnknown *obj)
+static HRESULT confirm_safety(HTMLDocumentNode *This, const WCHAR *url, struct CONFIRMSAFETY *cs, DWORD *ret)
 {
     DWORD policy, enabled_opts, supported_opts;
     IObjectSafety *obj_safety;
@@ -94,12 +94,29 @@ static DWORD confirm_safety(HTMLDocumentNode *This, const WCHAR *url, IUnknown *
 
     hres = IInternetSecurityManager_ProcessUrlAction(This->secmgr, url, URLACTION_SCRIPT_SAFE_ACTIVEX,
             (BYTE*)&policy, sizeof(policy), NULL, 0, 0, 0);
-    if(FAILED(hres) || policy != URLPOLICY_ALLOW)
-        return URLPOLICY_DISALLOW;
+    if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
+        *ret = URLPOLICY_DISALLOW;
+        return S_OK;
+    }
+
+    hres = IUnknown_QueryInterface(cs->pUnk, &IID_IObjectSafety, (void**)&obj_safety);
+    if(FAILED(hres)) {
+        CATID scripting_catid = CATID_SafeForScripting;
+
+        if(!This->catmgr) {
+            hres = CoCreateInstance(&CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER,
+                    &IID_ICatInformation, (void**)&This->catmgr);
+            if(FAILED(hres))
+                return hres;
+        }
+
+        hres = ICatInformation_IsClassOfCategories(This->catmgr, &cs->clsid, 1, &scripting_catid, 0, NULL);
+        if(FAILED(hres))
+            return hres;
 
-    hres = IUnknown_QueryInterface(obj, &IID_IObjectSafety, (void**)&obj_safety);
-    if(FAILED(hres))
-        return URLPOLICY_DISALLOW;
+        *ret = hres == S_OK ? URLPOLICY_ALLOW : URLPOLICY_DISALLOW;
+        return S_OK;
+    }
 
     hres = IObjectSafety_GetInterfaceSafetyOptions(obj_safety, &IID_IDispatchEx, &supported_opts, &enabled_opts);
     if(SUCCEEDED(hres)) {
@@ -109,10 +126,9 @@ static DWORD confirm_safety(HTMLDocumentNode *This, const WCHAR *url, IUnknown *
         hres = IObjectSafety_SetInterfaceSafetyOptions(obj_safety, &IID_IDispatchEx, enabled_opts, enabled_opts);
     }
     IObjectSafety_Release(obj_safety);
-    if(FAILED(hres))
-        return URLPOLICY_DISALLOW;
 
-    return URLPOLICY_ALLOW;
+    *ret = SUCCEEDED(hres) ? URLPOLICY_ALLOW : URLPOLICY_DISALLOW;
+    return S_OK;
 }
 
 static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHostSecurityManager *iface, REFGUID guidKey,
@@ -149,7 +165,9 @@ static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHos
             return E_FAIL;
         }
 
-        policy = confirm_safety(This, url, cs->pUnk);
+        hres = confirm_safety(This, url, cs, &policy);
+        if(FAILED(hres))
+            return hres;
 
         *ppPolicy = CoTaskMemAlloc(sizeof(policy));
         if(!*ppPolicy)
index d120cf4..c77afe4 100644 (file)
@@ -248,9 +248,24 @@ static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFG
         return S_OK;
     }
 
+    if(This->doc_obj->client) {
+        IServiceProvider *sp;
+        HRESULT hres;
+
+        hres = IOleClientSite_QueryInterface(This->doc_obj->client,
+                &IID_IServiceProvider, (void**)&sp);
+        if(SUCCEEDED(hres)) {
+            hres = IServiceProvider_QueryService(sp, guidService, riid, ppv);
+            IServiceProvider_Release(sp);
+
+            if(SUCCEEDED(hres))
+                return hres;
+        }
+    }
+
     FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
     
-    return E_UNEXPECTED;
+    return E_NOINTERFACE;
 }
 
 static const IServiceProviderVtbl ServiceProviderVtbl = {
index e6b94a2..eae51ca 100644 (file)
@@ -199,12 +199,6 @@ HRESULT clear_task_timer(HTMLDocument *doc, BOOL interval, DWORD id)
     return S_OK;
 }
 
-void parse_complete(HTMLDocumentObj *doc)
-{
-    TRACE("(%p)\n", doc);
-
-}
-
 static void call_timer_disp(IDispatch *disp)
 {
     DISPPARAMS dp = {NULL, NULL, 0, 0};
index c068c06..0ece6ec 100644 (file)
@@ -177,12 +177,14 @@ static BOOL is_space_elem(nsIDOMNode *node)
     return ret;
 }
 
-static inline void wstrbuf_init(wstrbuf_t *buf)
+static inline BOOL wstrbuf_init(wstrbuf_t *buf)
 {
     buf->len = 0;
     buf->size = 16;
     buf->buf = heap_alloc(buf->size * sizeof(WCHAR));
+    if (!buf->buf) return FALSE;
     *buf->buf = 0;
+    return TRUE;
 }
 
 static inline void wstrbuf_finish(wstrbuf_t *buf)
@@ -549,13 +551,14 @@ HRESULT get_node_text(HTMLDOMNode *node, BSTR *ret)
     wstrbuf_t buf;
     HRESULT hres = S_OK;
 
-    wstrbuf_init(&buf);
+    if (!wstrbuf_init(&buf))
+        return E_OUTOFMEMORY;
     wstrbuf_append_node_rec(&buf, node->nsnode);
     if(buf.buf) {
         *ret = SysAllocString(buf.buf);
         if(!*ret)
             hres = E_OUTOFMEMORY;
-    }else {
+    } else {
         *ret = NULL;
     }
     wstrbuf_finish(&buf);
@@ -1171,9 +1174,10 @@ static HRESULT WINAPI HTMLTxtRange_get_text(IHTMLTxtRange *iface, BSTR *p)
     if(!This->nsrange)
         return S_OK;
 
-    wstrbuf_init(&buf);
+    if (!wstrbuf_init(&buf))
+        return E_OUTOFMEMORY;
     range_to_string(This, &buf);
-    if(buf.buf)
+    if (buf.buf)
         *p = SysAllocString(buf.buf);
     wstrbuf_finish(&buf);
 
index 0d1d055..f4c62a0 100644 (file)
@@ -342,6 +342,14 @@ static HRESULT activate_window(HTMLDocumentObj *This)
         IOleInPlaceFrame_Release(This->frame);
     This->frame = pIPFrame;
 
+    if(!This->request_uiactivate) {
+        hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
+        if(SUCCEEDED(hres)) {
+            IOleInPlaceSiteEx_RequestUIActivate(ipsiteex);
+            IOleInPlaceSiteEx_Release(ipsiteex);
+        }
+    }
+
     This->window_active = TRUE;
 
     return S_OK;
@@ -466,6 +474,7 @@ static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IO
         IOleInPlaceSite_Release(This->doc_obj->ipsite);
 
     This->doc_obj->ipsite = pIPSite;
+    This->doc_obj->request_uiactivate = TRUE;
     return S_OK;
 }
 
@@ -557,6 +566,10 @@ static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
         ShowWindow(This->doc_obj->hwnd, SW_SHOW);
     }else {
         ShowWindow(This->doc_obj->hwnd, SW_HIDE);
+
+        if(This->doc_obj->in_place_active)
+            IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
+
         if(This->doc_obj->ip_window) {
             IOleInPlaceUIWindow_Release(This->doc_obj->ip_window);
             This->doc_obj->ip_window = NULL;
@@ -574,8 +587,35 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f
     TRACE("(%p)->(%x)\n", This, fUIActivate);
 
     if(!This->doc_obj->ipsite) {
-        FIXME("This->ipsite = NULL\n");
-        return E_FAIL;
+        IOleClientSite *cs = This->doc_obj->client;
+        IOleInPlaceSite *ips;
+
+        if(!cs) {
+            WARN("this->ipsite = NULL\n");
+            return E_UNEXPECTED;
+        }
+
+        hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips);
+        if(SUCCEEDED(hres))
+            This->doc_obj->ipsite = ips;
+        else {
+            hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips);
+            if(SUCCEEDED(hres))
+                This->doc_obj->ipsite = ips;
+            else {
+                hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips);
+                if(SUCCEEDED(hres))
+                    This->doc_obj->ipsite = ips;
+                else {
+                    WARN("this->ipsite = NULL\n");
+                    return E_NOINTERFACE;
+                }
+            }
+        }
+
+        IOleClientSite_AddRef(This->doc_obj->ipsite);
+        This->doc_obj->request_uiactivate = FALSE;
+        HTMLDocument_LockContainer(This->doc_obj, TRUE);
     }
 
     if(fUIActivate) {
@@ -711,27 +751,27 @@ static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
  * IViewObject implementation
  */
 
-#define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObject2, iface)
+#define VIEWOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, ViewObjectEx, iface)
 
-static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppvObject)
+static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppvObject)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
 }
 
-static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
+static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     return IHTMLDocument2_AddRef(HTMLDOC(This));
 }
 
-static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
+static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     return IHTMLDocument2_Release(HTMLDOC(This));
 }
 
-static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
+static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
         DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
         LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
 {
@@ -741,7 +781,7 @@ static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect, L
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
+static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
         DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
@@ -749,7 +789,7 @@ static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwDrawAs
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
+static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
         void *pvAspect, DWORD *pdwFreeze)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
@@ -757,28 +797,28 @@ static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect,
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
+static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     FIXME("(%p)->(%d)\n", This, dwFreeze);
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
+static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     FIXME("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
+static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
     FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
+static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
                                 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
 {
     HTMLDocument *This = VIEWOBJ_THIS(iface);
@@ -786,9 +826,49 @@ static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwDrawAspe
     return E_NOTIMPL;
 }
 
+static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
+{
+    HTMLDocument *This = VIEWOBJ_THIS(iface);
+    FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
+{
+    HTMLDocument *This = VIEWOBJ_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, pdwStatus);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
+        LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
+{
+    HTMLDocument *This = VIEWOBJ_THIS(iface);
+    FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
+         ptlLoc.y, lCloseHint, pHitResult);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
+        LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
+{
+    HTMLDocument *This = VIEWOBJ_THIS(iface);
+    FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
+        DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
+{
+    HTMLDocument *This = VIEWOBJ_THIS(iface);
+    FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd,
+            hicTargetDev, pExtentInfo, pSizel);
+    return E_NOTIMPL;
+}
+
 #undef VIEWOBJ_THIS
 
-static const IViewObject2Vtbl ViewObjectVtbl = {
+static const IViewObjectExVtbl ViewObjectVtbl = {
     ViewObject_QueryInterface,
     ViewObject_AddRef,
     ViewObject_Release,
@@ -798,11 +878,16 @@ static const IViewObject2Vtbl ViewObjectVtbl = {
     ViewObject_Unfreeze,
     ViewObject_SetAdvise,
     ViewObject_GetAdvise,
-    ViewObject_GetExtent
+    ViewObject_GetExtent,
+    ViewObject_GetRect,
+    ViewObject_GetViewStatus,
+    ViewObject_QueryHitPoint,
+    ViewObject_QueryHitRect,
+    ViewObject_GetNaturalExtent
 };
 
 void HTMLDocument_View_Init(HTMLDocument *This)
 {
     This->lpOleDocumentViewVtbl = &OleDocumentViewVtbl;
-    This->lpViewObject2Vtbl = &ViewObjectVtbl;
+    This->lpViewObjectExVtbl = &ViewObjectVtbl;
 }
index 59b04a4..0d12849 100644 (file)
 #define DISPID_IHTMLSCREEN_AVAILWIDTH             (DISPID_SCREEN+7)
 #define DISPID_IHTMLSCREEN_FONTSMOOTHINGENABLED   (DISPID_SCREEN+8)
 
+/* IHTMLScreen2 */
+#define DISPID_IHTMLSCREEN2_LOGICALXDPI  DISPID_SCREEN+9
+#define DISPID_IHTMLSCREEN2_LOGICALYDPI  DISPID_SCREEN+10
+#define DISPID_IHTMLSCREEN2_DEVICEXDPI   DISPID_SCREEN+11
+#define DISPID_IHTMLSCREEN2_DEVICEYDPI   DISPID_SCREEN+12
+
+/* IHTMLScreen3 */
+#define DISPID_IHTMLSCREEN3_SYSTEMXDPI  DISPID_SCREEN+13
+#define DISPID_IHTMLSCREEN3_SYSTEMYDPI  DISPID_SCREEN+14
+
 /* IHTMLOptionElementFactory */
 #define DISPID_IHTMLOPTIONELEMENTFACTORY_CREATE   DISPID_VALUE
 
 #define DISPID_IHTMLFORMELEMENT__NEWENUM   DISPID_NEWENUM
 #define DISPID_IHTMLFORMELEMENT_ITEM       DISPID_VALUE
 
+/* HTMLFormElementEvents */
+#define DISPID_HTMLFORMELEMENTEVENTS_ONSUBMIT  DISPID_EVMETH_ONSUBMIT
+#define DISPID_HTMLFORMELEMENTEVENTS_ONRESET   DISPID_EVMETH_ONRESET
+
+/* HTMLFormElementEvents2 */
+#define DISPID_HTMLFORMELEMENTEVENTS2_ONSUBMIT  DISPID_EVMETH_ONSUBMIT
+#define DISPID_HTMLFORMELEMENTEVENTS2_ONRESET   DISPID_EVMETH_ONRESET
+
 /* IHTMLStyleSheetsCollection */
 #define DISPID_IHTMLSTYLESHEETSCOLLECTION_LENGTH     (DISPID_STYLESHEETS_COL+1)
 #define DISPID_IHTMLSTYLESHEETSCOLLECTION__NEWENUM   DISPID_NEWENUM
index f004e74..4a182f2 100644 (file)
@@ -6420,6 +6420,513 @@ interface IHTMLFormElement : IDispatch
         [retval, out] IDispatch **pdisp);
 }
 
+/*****************************************************************************
+ *    DispHTMLFormElement dispinterface
+ */
+[
+    hidden,
+    uuid(3050F510-98B5-11CF-BB82-00AA00BDCE0B)
+]
+dispinterface DispHTMLFormElement
+{
+properties:
+methods:
+    WINE_HTMLDATAELEMENT_DISPINTERFACE_DECL;
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_ACTION)]
+    void action(BSTR v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_ACTION)]
+    BSTR action();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_ENCODING)]
+    void encoding(BSTR v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_ENCODING)]
+    BSTR encoding();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_METHOD)]
+    void method(BSTR v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_METHOD)]
+    BSTR method();
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_ELEMENTS)]
+    IDispatch *elements();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_TARGET)]
+    void target(BSTR v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_TARGET)]
+    BSTR target();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_NAME)]
+    void name(BSTR v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_NAME)]
+    BSTR name();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_ONSUBMIT)]
+    void onsubmit(VARIANT v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_ONSUBMIT)]
+    VARIANT onsubmit();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_ONRESET)]
+    void onreset(VARIANT v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_ONRESET)]
+    VARIANT onreset();
+
+    [id(DISPID_IHTMLFORMELEMENT_SUBMIT)]
+    void submit();
+
+    [id(DISPID_IHTMLFORMELEMENT_RESET)]
+    void reset();
+
+    [propput, id(DISPID_IHTMLFORMELEMENT_LENGTH)]
+    void length(long v);
+
+    [propget, id(DISPID_IHTMLFORMELEMENT_LENGTH)]
+    long length();
+
+    [propget, id(DISPID_IHTMLFORMELEMENT__NEWENUM), hidden, restricted]
+    IUnknown *_newEnum();
+
+    [id(DISPID_IHTMLFORMELEMENT_ITEM)]
+    IDispatch *item(VARIANT name, VARIANT index);
+
+    [id(DISPID_IHTMLFORMELEMENT_TAGS)]
+    IDispatch *tags(VARIANT tagName);
+}
+
+[
+    hidden,
+    uuid(3050F364-98B5-11CF-BB82-00AA00BDCE0B)
+]
+dispinterface HTMLFormElementEvents
+{
+properties:
+methods:
+    [id(DISPID_HTMLELEMENTEVENTS_ONHELP)]
+    VARIANT_BOOL onhelp();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCLICK)]
+    VARIANT_BOOL onclick();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDBLCLICK)]
+    VARIANT_BOOL ondblclick();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONKEYPRESS)]
+    VARIANT_BOOL onkeypress();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONKEYDOWN)]
+    void onkeydown();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONKEYUP)]
+    void onkeyup();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEOUT)]
+    void onmouseout();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEOVER)]
+    void onmouseover();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEMOVE)]
+    void onmousemove();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN)]
+    void onmousedown();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEUP)]
+    void onmouseup();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONSELECTSTART)]
+    VARIANT_BOOL onselectstart();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONFILTERCHANGE)]
+    void onfilterchange();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAGSTART)]
+    VARIANT_BOOL ondragstart();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREUPDATE)]
+    VARIANT_BOOL onbeforeupdate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONAFTERUPDATE)]
+    void onafterupdate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONERRORUPDATE)]
+    VARIANT_BOOL onerrorupdate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONROWEXIT)]
+    VARIANT_BOOL onrowexit();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONROWENTER)]
+    void onrowenter();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDATASETCHANGED)]
+    void ondatasetchanged();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDATAAVAILABLE)]
+    void ondataavailable();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDATASETCOMPLETE)]
+    void ondatasetcomplete();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONLOSECAPTURE)]
+    void onlosecapture();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONPROPERTYCHANGE)]
+    void onpropertychange();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONSCROLL)]
+    void onscroll();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONFOCUS)]
+    void onfocus();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBLUR)]
+    void onblur();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONRESIZE)]
+    void onresize();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAG)]
+    VARIANT_BOOL ondrag();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAGEND)]
+    void ondragend();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAGENTER)]
+    VARIANT_BOOL ondragenter();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAGOVER)]
+    VARIANT_BOOL ondragover();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDRAGLEAVE)]
+    void ondragleave();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDROP)]
+    VARIANT_BOOL ondrop();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFORECUT)]
+    VARIANT_BOOL onbeforecut();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCUT)]
+    VARIANT_BOOL oncut();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFORECOPY)]
+    VARIANT_BOOL onbeforecopy();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCOPY)]
+    VARIANT_BOOL oncopy();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREPASTE)]
+    VARIANT_BOOL onbeforepaste();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONPASTE)]
+    VARIANT_BOOL onpaste();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCONTEXTMENU)]
+    VARIANT_BOOL oncontextmenu();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONROWSDELETE)]
+    void onrowsdelete();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONROWSINSERTED)]
+    void onrowsinserted();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCELLCHANGE)]
+    void oncellchange();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONREADYSTATECHANGE)]
+    void onreadystatechange();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREEDITFOCUS)]
+    void onbeforeeditfocus();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONLAYOUTCOMPLETE)]
+    void onlayoutcomplete();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONPAGE)]
+    void onpage();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREDEACTIVATE)]
+    VARIANT_BOOL onbeforedeactivate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREACTIVATE)]
+    VARIANT_BOOL onbeforeactivate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOVE)]
+    void onmove();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONCONTROLSELECT)]
+    VARIANT_BOOL oncontrolselect();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOVESTART)]
+    VARIANT_BOOL onmovestart();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOVEEND)]
+    void onmoveend();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONRESIZESTART)]
+    VARIANT_BOOL onresizestart();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONRESIZEEND)]
+    void onresizeend();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEENTER)]
+    void onmouseenter();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSELEAVE)]
+    void onmouseleave();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEWHEEL)]
+    VARIANT_BOOL onmousewheel();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONACTIVATE)]
+    void onactivate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONDEACTIVATE)]
+    void ondeactivate();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSIN)]
+    void onfocusin();
+
+    [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSOUT)]
+    void onfocusout();
+
+    [id(DISPID_HTMLFORMELEMENTEVENTS_ONSUBMIT)]
+    VARIANT_BOOL onsubmit();
+
+    [id(DISPID_HTMLFORMELEMENTEVENTS_ONRESET)]
+    VARIANT_BOOL onreset();
+};
+
+interface IHTMLEventObj;
+
+[
+    hidden,
+    uuid(3050F614-98B5-11CF-BB82-00AA00BDCE0B)
+]
+dispinterface HTMLFormElementEvents2
+{
+properties:
+methods:
+    [id(DISPID_HTMLELEMENTEVENTS2_ONHELP)]
+    VARIANT_BOOL onhelp([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCLICK)]
+    VARIANT_BOOL onclick([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDBLCLICK)]
+    VARIANT_BOOL ondblclick([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONKEYPRESS)]
+    VARIANT_BOOL onkeypress([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONKEYDOWN)]
+    void onkeydown([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONKEYUP)]
+    void onkeyup([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEOUT)]
+    void onmouseout([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEOVER)]
+    void onmouseover([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEMOVE)]
+    void onmousemove([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEDOWN)]
+    void onmousedown([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEUP)]
+    void onmouseup([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONSELECTSTART)]
+    VARIANT_BOOL onselectstart([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONFILTERCHANGE)]
+    void onfilterchange([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAGSTART)]
+    VARIANT_BOOL ondragstart([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFOREUPDATE)]
+    VARIANT_BOOL onbeforeupdate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONAFTERUPDATE)]
+    void onafterupdate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONERRORUPDATE)]
+    VARIANT_BOOL onerrorupdate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONROWEXIT)]
+    VARIANT_BOOL onrowexit([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONROWENTER)]
+    void onrowenter([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDATASETCHANGED)]
+    void ondatasetchanged([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDATAAVAILABLE)]
+    void ondataavailable([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDATASETCOMPLETE)]
+    void ondatasetcomplete([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONLOSECAPTURE)]
+    void onlosecapture([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONPROPERTYCHANGE)]
+    void onpropertychange([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONSCROLL)]
+    void onscroll([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONFOCUS)]
+    void onfocus([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBLUR)]
+    void onblur([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONRESIZE)]
+    void onresize([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAG)]
+    VARIANT_BOOL ondrag([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAGEND)]
+    void ondragend([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAGENTER)]
+    VARIANT_BOOL ondragenter([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAGOVER)]
+    VARIANT_BOOL ondragover([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDRAGLEAVE)]
+    void ondragleave([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDROP)]
+    VARIANT_BOOL ondrop([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFORECUT)]
+    VARIANT_BOOL onbeforecut([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCUT)]
+    VARIANT_BOOL oncut([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFORECOPY)]
+    VARIANT_BOOL onbeforecopy([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCOPY)]
+    VARIANT_BOOL oncopy([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFOREPASTE)]
+    VARIANT_BOOL onbeforepaste([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONPASTE)]
+    VARIANT_BOOL onpaste([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCONTEXTMENU)]
+    VARIANT_BOOL oncontextmenu([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONROWSDELETE)]
+    void onrowsdelete([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONROWSINSERTED)]
+    void onrowsinserted([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCELLCHANGE)]
+    void oncellchange([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONREADYSTATECHANGE)]
+    void onreadystatechange([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONLAYOUTCOMPLETE)]
+    void onlayoutcomplete([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONPAGE)]
+    void onpage([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEENTER)]
+    void onmouseenter([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSELEAVE)]
+    void onmouseleave([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONACTIVATE)]
+    void onactivate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONDEACTIVATE)]
+    void ondeactivate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFOREDEACTIVATE)]
+    VARIANT_BOOL onbeforedeactivate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONBEFOREACTIVATE)]
+    VARIANT_BOOL onbeforeactivate([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONFOCUSIN)]
+    void onfocusin([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONFOCUSOUT)]
+    void onfocusout([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOVE)]
+    void onmove([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONCONTROLSELECT)]
+    VARIANT_BOOL oncontrolselect([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOVESTART)]
+    VARIANT_BOOL onmovestart([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOVEEND)]
+    void onmoveend([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONRESIZESTART)]
+    VARIANT_BOOL onresizestart([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONRESIZEEND)]
+    void onresizeend([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLELEMENTEVENTS2_ONMOUSEWHEEL)]
+    VARIANT_BOOL onmousewheel([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLFORMELEMENTEVENTS2_ONSUBMIT)]
+    VARIANT_BOOL onsubmit([in] IHTMLEventObj* pEvtObj);
+
+    [id(DISPID_HTMLFORMELEMENTEVENTS2_ONRESET)]
+    VARIANT_BOOL onreset([in] IHTMLEventObj* pEvtObj);
+};
+
+[
+    noncreatable,
+    uuid(3050F24D-98B5-11CF-BB82-00AA00BDCE0B)
+]
+coclass HTMLFormElement
+{
+    [default]           dispinterface DispHTMLFormElement;
+    [source, default]   dispinterface HTMLFormElementEvents;
+    [source]            dispinterface HTMLFormElementEvents2;
+                        interface IHTMLElement;
+                        interface IHTMLElement2;
+                        interface IHTMLElement3;
+                        interface IHTMLElement4;
+                        interface IHTMLUniqueName;
+                        interface IHTMLDOMNode;
+                        interface IHTMLDOMNode2;
+                        interface IHTMLDOMConstructor;
+                        interface IHTMLFormElement;
+}
+
 /*****************************************************************************
  *    IHTMLTextContainer interface
  */
@@ -9758,6 +10265,69 @@ interface IHTMLWindow5 : IDispatch
     HRESULT XMLHttpRequest([retval, out] VARIANT * p);
 };
 
+/*****************************************************************************
+ *    DispHTMLScreen dispinterface
+ */
+[
+    hidden,
+    uuid(3050f591-98b5-11cf-bb82-00aa00bdce0b)
+]
+dispinterface DispHTMLScreen
+{
+properties:
+methods:
+    [propget, id(DISPID_IHTMLSCREEN_COLORDEPTH)]
+    long colorDepth();
+
+    [propput, id(DISPID_IHTMLSCREEN_BUFFERDEPTH)]
+    void bufferDepth(long v);
+
+    [propget, id(DISPID_IHTMLSCREEN_BUFFERDEPTH)]
+    long bufferDepth();
+
+    [propget, id(DISPID_IHTMLSCREEN_WIDTH)]
+    long width();
+
+    [propget, id(DISPID_IHTMLSCREEN_HEIGHT)]
+    long height();
+
+    [propput, id(DISPID_IHTMLSCREEN_UPDATEINTERVAL)]
+    void updateInterval(long v);
+
+    [propget, id(DISPID_IHTMLSCREEN_UPDATEINTERVAL)]
+    long updateInterval();
+
+    [propget, id(DISPID_IHTMLSCREEN_AVAILHEIGHT)]
+    long availHeight();
+
+    [propget, id(DISPID_IHTMLSCREEN_AVAILWIDTH)]
+    long availWidth();
+
+    [propget, id(DISPID_IHTMLSCREEN_FONTSMOOTHINGENABLED)]
+    VARIANT_BOOL fontSmoothingEnabled();
+
+    [propget, id(DISPID_IHTMLSCREEN2_LOGICALXDPI)]
+    long logicalXDPI();
+
+    [propget, id(DISPID_IHTMLSCREEN2_LOGICALYDPI)]
+    long logicalYDPI();
+
+    [propget, id(DISPID_IHTMLSCREEN2_DEVICEXDPI)]
+    long deviceXDPI();
+
+    [propget, id(DISPID_IHTMLSCREEN2_DEVICEYDPI)]
+    long deviceYDPI();
+
+    [propget, id(DISPID_IHTMLSCREEN3_SYSTEMXDPI)]
+    long systemXDPI();
+
+    [propget, id(DISPID_IHTMLSCREEN3_SYSTEMYDPI)]
+    long systemYDPI();
+
+    [propget, id(DISPID_IHTMLDOMCONSTRUCTOR_CONSTRUCTOR), hidden]
+    IDispatch *constructor();
+}
+
 /*****************************************************************************
  *    DispHTMLWindow2 dispinterface
  */
@@ -14515,4 +15085,45 @@ interface IHTMLEditServices : IUnknown
         [in] SELECTION_TYPE eType);
 }
 
+/*****************************************************************************
+ *    IElementBehaviorSite interface
+ */
+[
+    odl,
+    uuid(3050F427-98B5-11CF-BB82-00AA00BDCE0B)
+]
+interface IElementBehaviorSite : IUnknown {
+    HRESULT GetElement([out, retval] IHTMLElement **ppElement);
+    HRESULT RegisterNotification([in] long lEvent);
+}
+
+/*****************************************************************************
+ *    IElementBehavior interface
+ */
+[
+    odl,
+    uuid(3050F425-98B5-11CF-BB82-00AA00BDCE0B)
+]
+interface IElementBehavior : IUnknown {
+    HRESULT Init([in] IElementBehaviorSite *pBehaviorSite);
+    HRESULT Notify([in] long lEvent,  [in, out] VARIANT *pVar);
+    HRESULT Detach();
+}
+
+/*****************************************************************************
+ *    IElementBehaviorFactory interface
+ */
+[
+    odl,
+    uuid(3050f429-98b5-11cf-bb82-00aa00bdce0b)
+]
+interface IElementBehaviorFactory : IUnknown
+{
+    HRESULT FindBehavior(
+        [in] BSTR bstrBehavior,
+        [in] BSTR bstrBehaviorUrl,
+        [in] IElementBehaviorSite *pSite,
+        [out] IElementBehavior **ppBehavior);
+}
+
 } /* library MSHTML */