[IEFRAME] Sync with Wine Staging 1.7.55. CORE-10536
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 17 Nov 2015 20:19:58 +0000 (20:19 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 17 Nov 2015 20:19:58 +0000 (20:19 +0000)
svn path=/trunk/; revision=69928

reactos/dll/win32/ieframe/dochost.c
reactos/dll/win32/ieframe/frame.c
reactos/dll/win32/ieframe/ieframe.h
reactos/dll/win32/ieframe/iexplore.c
reactos/dll/win32/ieframe/navigate.c
reactos/dll/win32/ieframe/oleobject.c
reactos/dll/win32/ieframe/shellbrowser.c
reactos/dll/win32/ieframe/view.c
reactos/dll/win32/ieframe/webbrowser.c
reactos/media/doc/README.WINE

index 66d1777..820cb6c 100644 (file)
@@ -73,6 +73,37 @@ void abort_dochost_tasks(DocHost *This, task_proc_t proc)
     }
 }
 
+void on_commandstate_change(DocHost *doc_host, LONG command, VARIANT_BOOL enable)
+{
+    DISPPARAMS dispparams;
+    VARIANTARG params[2];
+
+    TRACE("command=%d enable=%d\n", command, enable);
+
+    dispparams.cArgs = 2;
+    dispparams.cNamedArgs = 0;
+    dispparams.rgdispidNamedArgs = NULL;
+    dispparams.rgvarg = params;
+
+    V_VT(params) = VT_BOOL;
+    V_BOOL(params) = enable ? VARIANT_TRUE : VARIANT_FALSE;
+
+    V_VT(params+1) = VT_I4;
+    V_I4(params+1) = command;
+
+    call_sink(doc_host->cps.wbe2, DISPID_COMMANDSTATECHANGE, &dispparams);
+
+    doc_host->container_vtbl->on_command_state_change(doc_host, command, enable);
+}
+
+void update_navigation_commands(DocHost *dochost)
+{
+    unsigned pos = dochost->travellog.loading_pos == -1 ? dochost->travellog.position : dochost->travellog.loading_pos;
+
+    on_commandstate_change(dochost, CSC_NAVIGATEBACK, pos > 0);
+    on_commandstate_change(dochost, CSC_NAVIGATEFORWARD, pos < dochost->travellog.length);
+}
+
 static void notif_complete(DocHost *This, DISPID dispid)
 {
     DISPPARAMS dispparams;
@@ -388,25 +419,32 @@ static void update_travellog(DocHost *This)
 {
     travellog_entry_t *new_entry;
 
-    if(This->travellog.loading_pos == -1) {
-        /* Clear forward history. */
-        if(!This->travellog.log) {
-            This->travellog.log = heap_alloc(4 * sizeof(*This->travellog.log));
-            if(!This->travellog.log)
-                return;
+    static const WCHAR about_schemeW[] = {'a','b','o','u','t',':'};
 
-            This->travellog.size = 4;
-        }else if(This->travellog.size < This->travellog.position+1) {
-            travellog_entry_t *new_travellog;
+    if(This->url && !strncmpiW(This->url, about_schemeW, sizeof(about_schemeW)/sizeof(*about_schemeW))) {
+        TRACE("Skipping about URL\n");
+        return;
+    }
 
-            new_travellog = heap_realloc(This->travellog.log, This->travellog.size*2*sizeof(*This->travellog.log));
-            if(!new_travellog)
-                return;
+    if(!This->travellog.log) {
+        This->travellog.log = heap_alloc(4 * sizeof(*This->travellog.log));
+        if(!This->travellog.log)
+            return;
 
-            This->travellog.log = new_travellog;
-            This->travellog.size *= 2;
-        }
+        This->travellog.size = 4;
+    }else if(This->travellog.size < This->travellog.position+1) {
+        travellog_entry_t *new_travellog;
 
+        new_travellog = heap_realloc(This->travellog.log, This->travellog.size*2*sizeof(*This->travellog.log));
+        if(!new_travellog)
+            return;
+
+        This->travellog.log = new_travellog;
+        This->travellog.size *= 2;
+    }
+
+    if(This->travellog.loading_pos == -1) {
+        /* Clear forward history. */
         while(This->travellog.length > This->travellog.position)
             free_travellog_entry(This->travellog.log + --This->travellog.length);
     }
@@ -455,7 +493,7 @@ void create_doc_view_hwnd(DocHost *This)
         doc_view_atom = RegisterClassExW(&wndclass);
     }
 
-    This->container_vtbl->GetDocObjRect(This, &rect);
+    This->container_vtbl->get_docobj_rect(This, &rect);
     This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
          wszShell_DocObject_View,
          WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
@@ -575,6 +613,11 @@ void release_dochost_client(DocHost *This)
         IOleInPlaceFrame_Release(This->frame);
         This->frame = NULL;
     }
+
+    if(This->olecmd) {
+        IOleCommandTarget_Release(This->olecmd);
+        This->olecmd = NULL;
+    }
 }
 
 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
@@ -627,8 +670,18 @@ static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
     if(!pguidCmdGroup) {
         switch(nCmdID) {
         case OLECMDID_UPDATECOMMANDS:
+            if(!This->olecmd)
+                return E_NOTIMPL;
+            return IOleCommandTarget_Exec(This->olecmd, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
         case OLECMDID_SETDOWNLOADSTATE:
-            return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+            if(This->olecmd)
+                return IOleCommandTarget_Exec(This->olecmd, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+
+            if(!pvaIn || V_VT(pvaIn) != VT_I4)
+                return E_INVALIDARG;
+
+            notify_download_state(This, V_I4(pvaIn));
+            return S_OK;
         default:
             FIXME("Unimplemented cmdid %d\n", nCmdID);
             return E_NOTIMPL;
@@ -691,6 +744,7 @@ static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
         switch(nCmdID) {
         case CMDID_EXPLORER_UPDATEHISTORY:
             update_travellog(This);
+            update_navigation_commands(This);
             return S_OK;
 
         default:
@@ -707,8 +761,11 @@ static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
         }
     }
 
-    if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup))
-        return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+    if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
+        if(!This->olecmd)
+            return E_NOTIMPL;
+        return IOleCommandTarget_Exec(This->olecmd, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+    }
 
     FIXME("Unimplemented cmdid %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
     return E_NOTIMPL;
index 9dfcce4..73fea37 100644 (file)
@@ -137,7 +137,7 @@ static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface,
 {
     DocHost *This = impl_from_IOleInPlaceFrame(iface);
     TRACE("(%p)->(%s)\n", This, debugstr_w(pszStatusText));
-    return This->container_vtbl->SetStatusText(This, pszStatusText);
+    return This->container_vtbl->set_status_text(This, pszStatusText);
 }
 
 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
index 33ab0d3..36a0867 100644 (file)
@@ -120,10 +120,10 @@ typedef struct _IDocHostContainerVtbl
 {
     ULONG (*addref)(DocHost*);
     ULONG (*release)(DocHost*);
-    void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
-    HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
-    void (WINAPI* SetURL)(DocHost*,LPCWSTR);
-    HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
+    void (*get_docobj_rect)(DocHost*,RECT*);
+    HRESULT (*set_status_text)(DocHost*,const WCHAR*);
+    void (*on_command_state_change)(DocHost*,LONG,BOOL);
+    void (*set_url)(DocHost*,const WCHAR*);
 } IDocHostContainerVtbl;
 
 struct DocHost {
@@ -145,6 +145,7 @@ struct DocHost {
     IDispatch *client_disp;
     IDocHostUIHandler *hostui;
     IOleInPlaceFrame *frame;
+    IOleCommandTarget *olecmd;
 
     IUnknown *document;
     IOleDocumentView *view;
@@ -208,6 +209,10 @@ struct WebBrowser {
     IOleContainer *container;
     IOleInPlaceSiteEx *inplace;
 
+    IAdviseSink *sink;
+    DWORD sink_aspects;
+    DWORD sink_flags;
+
     /* window context */
 
     HWND frame_hwnd;
@@ -243,6 +248,7 @@ struct InternetExplorer {
 
     HWND frame_hwnd;
     HWND status_hwnd;
+    HWND toolbar_hwnd;
     HMENU menu;
     BOOL nohome;
 
@@ -290,6 +296,8 @@ void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
 void on_commandstate_change(DocHost*,LONG,VARIANT_BOOL) DECLSPEC_HIDDEN;
+void notify_download_state(DocHost*,BOOL) DECLSPEC_HIDDEN;
+void update_navigation_commands(DocHost *dochost) DECLSPEC_HIDDEN;
 
 #define WM_DOCHOSTTASK (WM_USER+0x300)
 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,task_destr_t,BOOL) DECLSPEC_HIDDEN;
index 9a32b6c..06c86b4 100644 (file)
@@ -389,7 +389,7 @@ static void ie_dialog_properties(HWND hwnd)
 }
 #endif
 
-static void add_tb_separator(HWND hwnd)
+static void add_tb_separator(InternetExplorer *ie)
 {
     TBBUTTON btn;
 
@@ -397,10 +397,10 @@ static void add_tb_separator(HWND hwnd)
 
     btn.iBitmap = 3;
     btn.fsStyle = BTNS_SEP;
-    SendMessageW(hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
+    SendMessageW(ie->toolbar_hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
 }
 
-static void add_tb_button(HWND hwnd, int bmp, int cmd, int strId)
+static void add_tb_button(InternetExplorer *ie, int bmp, int cmd, int strId)
 {
     TBBUTTON btn;
     WCHAR buf[30];
@@ -414,14 +414,18 @@ static void add_tb_button(HWND hwnd, int bmp, int cmd, int strId)
     btn.dwData = 0;
     btn.iString = (INT_PTR)buf;
 
-    SendMessageW(hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
+    SendMessageW(ie->toolbar_hwnd, TB_ADDBUTTONSW, 1, (LPARAM)&btn);
 }
 
-static void create_rebar(HWND hwnd)
+static void enable_toolbar_button(InternetExplorer *ie, int command, BOOL enable)
+{
+    SendMessageW(ie->toolbar_hwnd, TB_ENABLEBUTTON, command, enable);
+}
+
+static void create_rebar(InternetExplorer *ie)
 {
     HWND hwndRebar;
     HWND hwndAddress;
-    HWND hwndToolbar;
     REBARINFO rebarinf;
     REBARBANDINFOW bandinf;
     WCHAR addr[40];
@@ -432,7 +436,7 @@ static void create_rebar(HWND hwnd)
 
     hwndRebar = CreateWindowExW(WS_EX_TOOLWINDOW, REBARCLASSNAMEW, NULL,
             WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP|CCS_NODIVIDER, 0, 0, 0, 0,
-            hwnd, (HMENU)IDC_BROWSE_REBAR, ieframe_instance, NULL);
+            ie->frame_hwnd, (HMENU)IDC_BROWSE_REBAR, ieframe_instance, NULL);
 
     rebarinf.cbSize = sizeof(rebarinf);
     rebarinf.fMask = 0;
@@ -440,29 +444,29 @@ static void create_rebar(HWND hwnd)
 
     SendMessageW(hwndRebar, RB_SETBARINFO, 0, (LPARAM)&rebarinf);
 
-    hwndToolbar = CreateWindowExW(TBSTYLE_EX_MIXEDBUTTONS, TOOLBARCLASSNAMEW, NULL, TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE | CCS_NORESIZE,
+    ie->toolbar_hwnd = CreateWindowExW(TBSTYLE_EX_MIXEDBUTTONS, TOOLBARCLASSNAMEW, NULL, TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE | CCS_NORESIZE,
             0, 0, 0, 0, hwndRebar, (HMENU)IDC_BROWSE_TOOLBAR, ieframe_instance, NULL);
 
     imagelist = ImageList_LoadImageW(ieframe_instance, MAKEINTRESOURCEW(IDB_IETOOLBAR), 32, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
 
-    SendMessageW(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)imagelist);
-    SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
-    add_tb_button(hwndToolbar, 0, ID_BROWSE_BACK, IDS_TB_BACK);
-    add_tb_button(hwndToolbar, 1, ID_BROWSE_FORWARD, IDS_TB_FORWARD);
-    add_tb_button(hwndToolbar, 2, ID_BROWSE_STOP, IDS_TB_STOP);
-    add_tb_button(hwndToolbar, 3, ID_BROWSE_REFRESH, IDS_TB_REFRESH);
-    add_tb_button(hwndToolbar, 4, ID_BROWSE_HOME, IDS_TB_HOME);
-    add_tb_separator(hwndToolbar);
-    add_tb_button(hwndToolbar, 5, ID_BROWSE_PRINT, IDS_TB_PRINT);
-    SendMessageW(hwndToolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(55,50));
-    SendMessageW(hwndToolbar, TB_GETMAXSIZE, 0, (LPARAM)&toolbar_size);
+    SendMessageW(ie->toolbar_hwnd, TB_SETIMAGELIST, 0, (LPARAM)imagelist);
+    SendMessageW(ie->toolbar_hwnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+    add_tb_button(ie, 0, ID_BROWSE_BACK, IDS_TB_BACK);
+    add_tb_button(ie, 1, ID_BROWSE_FORWARD, IDS_TB_FORWARD);
+    add_tb_button(ie, 2, ID_BROWSE_STOP, IDS_TB_STOP);
+    add_tb_button(ie, 3, ID_BROWSE_REFRESH, IDS_TB_REFRESH);
+    add_tb_button(ie, 4, ID_BROWSE_HOME, IDS_TB_HOME);
+    add_tb_separator(ie);
+    add_tb_button(ie, 5, ID_BROWSE_PRINT, IDS_TB_PRINT);
+    SendMessageW(ie->toolbar_hwnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(55,50));
+    SendMessageW(ie->toolbar_hwnd, TB_GETMAXSIZE, 0, (LPARAM)&toolbar_size);
 
     bandinf.cbSize = sizeof(bandinf);
     bandinf.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE;
     bandinf.fStyle = RBBS_CHILDEDGE;
     bandinf.cxMinChild = toolbar_size.cx;
     bandinf.cyMinChild = toolbar_size.cy+2;
-    bandinf.hwndChild = hwndToolbar;
+    bandinf.hwndChild = ie->toolbar_hwnd;
 
     SendMessageW(hwndRebar, RB_INSERTBANDW, -1, (LPARAM)&bandinf);
 
@@ -484,13 +488,15 @@ static LRESULT iewnd_OnCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
     InternetExplorer* This = (InternetExplorer*)lpcs->lpCreateParams;
     SetWindowLongPtrW(hwnd, 0, (LONG_PTR) lpcs->lpCreateParams);
 
+    This->doc_host.frame_hwnd = This->frame_hwnd = hwnd;
+
     This->menu = create_ie_menu();
 
     This->status_hwnd = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|SBT_NOBORDERS|CCS_NODIVIDER,
                                             NULL, hwnd, IDC_BROWSE_STATUSBAR);
     SendMessageW(This->status_hwnd, SB_SIMPLE, TRUE, 0);
 
-    create_rebar(hwnd);
+    create_rebar(This);
 
     return 0;
 }
@@ -554,9 +560,7 @@ static LRESULT iewnd_OnNotify(InternetExplorer *This, WPARAM wparam, LPARAM lpar
 
 static LRESULT iewnd_OnDestroy(InternetExplorer *This)
 {
-    HWND hwndRebar = GetDlgItem(This->frame_hwnd, IDC_BROWSE_REBAR);
-    HWND hwndToolbar = GetDlgItem(hwndRebar, IDC_BROWSE_TOOLBAR);
-    HIMAGELIST list = (HIMAGELIST)SendMessageW(hwndToolbar, TB_GETIMAGELIST, 0, 0);
+    HIMAGELIST list = (HIMAGELIST)SendMessageW(This->toolbar_hwnd, TB_GETIMAGELIST, 0, 0);
 
     TRACE("%p\n", This);
 
@@ -715,7 +719,7 @@ void unregister_iewindow_class(void)
 
 static void create_frame_hwnd(InternetExplorer *This)
 {
-    This->frame_hwnd = CreateWindowExW(
+    CreateWindowExW(
             WS_EX_WINDOWEDGE,
             szIEWinFrame, wszWineInternetExplorer,
             WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
@@ -723,7 +727,6 @@ static void create_frame_hwnd(InternetExplorer *This)
             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
             NULL, NULL /* FIXME */, ieframe_instance, This);
 
-    This->doc_host.frame_hwnd = This->frame_hwnd;
     create_doc_view_hwnd(&This->doc_host);
 }
 
@@ -744,39 +747,47 @@ static ULONG IEDocHost_release(DocHost *iface)
     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
 }
 
-static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
+static void DocHostContainer_get_docobj_rect(DocHost *This, RECT *rc)
 {
     GetClientRect(This->frame_hwnd, rc);
     adjust_ie_docobj_rect(This->frame_hwnd, rc);
 }
 
-static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost *iface, LPCWSTR text)
+static HRESULT DocHostContainer_set_status_text(DocHost *iface, const WCHAR *text)
 {
     InternetExplorer *This = impl_from_DocHost(iface);
     return update_ie_statustext(This, text);
 }
 
-static void WINAPI DocHostContainer_SetURL(DocHost* iface, LPCWSTR url)
+static void DocHostContainer_on_command_state_change(DocHost *iface, LONG command, BOOL enable)
 {
     InternetExplorer *This = impl_from_DocHost(iface);
 
-    This->nohome = FALSE;
-    SendMessageW(This->frame_hwnd, WM_UPDATEADDRBAR, 0, (LPARAM)url);
+    switch(command) {
+    case CSC_NAVIGATEBACK:
+        enable_toolbar_button(This, ID_BROWSE_BACK, enable);
+        break;
+    case CSC_NAVIGATEFORWARD:
+        enable_toolbar_button(This, ID_BROWSE_FORWARD, enable);
+        break;
+    }
 }
 
-static HRESULT DocHostContainer_exec(DocHost* This, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
-        VARIANT *out)
+static void DocHostContainer_set_url(DocHost* iface, const WCHAR *url)
 {
-    return E_NOTIMPL;
+    InternetExplorer *This = impl_from_DocHost(iface);
+
+    This->nohome = FALSE;
+    SendMessageW(This->frame_hwnd, WM_UPDATEADDRBAR, 0, (LPARAM)url);
 }
 
 static const IDocHostContainerVtbl DocHostContainerVtbl = {
     IEDocHost_addref,
     IEDocHost_release,
-    DocHostContainer_GetDocObjRect,
-    DocHostContainer_SetStatusText,
-    DocHostContainer_SetURL,
-    DocHostContainer_exec
+    DocHostContainer_get_docobj_rect,
+    DocHostContainer_set_status_text,
+    DocHostContainer_on_command_state_change,
+    DocHostContainer_set_url
 };
 
 static HRESULT create_ie(InternetExplorer **ret_obj)
index c1b43f8..7994b09 100644 (file)
@@ -102,7 +102,7 @@ static void set_status_text(BindStatusCallback *This, ULONG statuscode, LPCWSTR
     }
 
     V_VT(&arg) = VT_BSTR;
-    V_BSTR(&arg) = str ? SysAllocString(buffer) : NULL;
+    V_BSTR(&arg) = str ? SysAllocString(buffer) : SysAllocString(emptyW);
     TRACE("=> %s\n", debugstr_w(V_BSTR(&arg)));
 
     call_sink(This->doc_host->cps.wbe2, DISPID_STATUSTEXTCHANGE, &dispparams);
@@ -129,10 +129,17 @@ HRESULT set_dochost_url(DocHost *This, const WCHAR *url)
     heap_free(This->url);
     This->url = new_url;
 
-    This->container_vtbl->SetURL(This, This->url);
+    This->container_vtbl->set_url(This, This->url);
     return S_OK;
 }
 
+void notify_download_state(DocHost *dochost, BOOL is_downloading)
+{
+    DISPPARAMS dwl_dp = {NULL};
+    TRACE("(%x)\n", is_downloading);
+    call_sink(dochost->cps.wbe2, is_downloading ? DISPID_DOWNLOADBEGIN : DISPID_DOWNLOADCOMPLETE, &dwl_dp);
+}
+
 static inline BindStatusCallback *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
 {
     return CONTAINING_RECORD(iface, BindStatusCallback, IBindStatusCallback_iface);
@@ -344,6 +351,8 @@ static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *ifac
     if(!This->doc_host)
         return S_OK;
 
+    if(!This->doc_host->olecmd)
+        notify_download_state(This->doc_host, FALSE);
     if(FAILED(hresult))
         handle_navigation_error(This->doc_host, hresult, This->url, NULL);
 
@@ -759,27 +768,6 @@ static void doc_navigate_task_destr(task_header_t *t)
     heap_free(task);
 }
 
-void on_commandstate_change(DocHost *doc_host, LONG command, VARIANT_BOOL enable)
-{
-    DISPPARAMS dispparams;
-    VARIANTARG params[2];
-
-    TRACE("command=%d enable=%d\n", command, enable);
-
-    dispparams.cArgs = 2;
-    dispparams.cNamedArgs = 0;
-    dispparams.rgdispidNamedArgs = NULL;
-    dispparams.rgvarg = params;
-
-    V_VT(params) = VT_BOOL;
-    V_BOOL(params) = enable;
-
-    V_VT(params+1) = VT_I4;
-    V_I4(params+1) = command;
-
-    call_sink(doc_host->cps.wbe2, DISPID_COMMANDSTATECHANGE, &dispparams);
-}
-
 static void doc_navigate_proc(DocHost *This, task_header_t *t)
 {
     task_doc_navigate_t *task = (task_doc_navigate_t*)t;
@@ -883,6 +871,7 @@ static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mo
         return S_OK;
     }
 
+    notify_download_state(This, TRUE);
     on_commandstate_change(This, CSC_NAVIGATEBACK, VARIANT_FALSE);
     on_commandstate_change(This, CSC_NAVIGATEFORWARD, VARIANT_FALSE);
 
@@ -1089,20 +1078,11 @@ static HRESULT navigate_history(DocHost *This, unsigned travellog_pos)
         return E_NOTIMPL;
     }
 
-    if (travellog_pos < This->travellog.position)
-    {
-        on_commandstate_change(This, CSC_NAVIGATEBACK, VARIANT_FALSE);
-        on_commandstate_change(This, CSC_NAVIGATEFORWARD, VARIANT_TRUE);
-    }
-    else if (travellog_pos > This->travellog.position)
-    {
-        on_commandstate_change(This, CSC_NAVIGATEBACK, VARIANT_TRUE);
-        on_commandstate_change(This, CSC_NAVIGATEFORWARD, VARIANT_FALSE);
-    }
-
     This->travellog.loading_pos = travellog_pos;
     entry = This->travellog.log + This->travellog.loading_pos;
 
+    update_navigation_commands(This);
+
     if(!entry->stream)
         return async_doc_navigate(This, entry->url, NULL, NULL, 0, FALSE);
 
index 313d705..4fe6aa7 100644 (file)
@@ -39,6 +39,22 @@ static LRESULT resize_window(WebBrowser *This, LONG width, LONG height)
     return 0;
 }
 
+static void notify_on_focus(WebBrowser *This, BOOL got_focus)
+{
+    IOleControlSite *control_site;
+    HRESULT hres;
+
+    if(!This->client)
+        return;
+
+    hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&control_site);
+    if(FAILED(hres))
+        return;
+
+    IOleControlSite_OnFocus(control_site, got_focus);
+    IOleControlSite_Release(control_site);
+}
+
 static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     WebBrowser *This;
@@ -57,6 +73,12 @@ static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, L
         return resize_window(This, LOWORD(lParam), HIWORD(lParam));
     case WM_DOCHOSTTASK:
         return process_dochost_tasks(&This->doc_host);
+    case WM_SETFOCUS:
+        notify_on_focus(This, TRUE);
+        break;
+    case WM_KILLFOCUS:
+        notify_on_focus(This, FALSE);
+        break;
     }
 
     return DefWindowProcW(hwnd, msg, wParam, lParam);
@@ -193,6 +215,7 @@ static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site)
         IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd);
 
     SetFocus(This->shell_embedding_hwnd);
+    notify_on_focus(This, TRUE);
 
     return S_OK;
 }
@@ -254,6 +277,11 @@ static void release_client_site(WebBrowser *This)
 {
     release_dochost_client(&This->doc_host);
 
+    if(This->client) {
+        IOleClientSite_Release(This->client);
+        This->client = NULL;
+    }
+
     if(This->shell_embedding_hwnd) {
         DestroyWindow(This->shell_embedding_hwnd);
         This->shell_embedding_hwnd = NULL;
@@ -274,9 +302,9 @@ static void release_client_site(WebBrowser *This)
         This->uiwindow = NULL;
     }
 
-    if(This->client) {
-        IOleClientSite_Release(This->client);
-        This->client = NULL;
+    if(This->sink) {
+        IAdviseSink_Release(This->sink);
+        This->sink = NULL;
     }
 }
 
@@ -420,6 +448,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
 {
     WebBrowser *This = impl_from_IOleObject(iface);
     IDocHostUIHandler *hostui;
+    IOleCommandTarget *olecmd;
     IOleContainer *container;
     IDispatch *disp;
     HRESULT hres;
@@ -464,9 +493,19 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
             ITargetContainer_Release(target_container);
         }
 
+        hres = IOleContainer_QueryInterface(container, &IID_IOleCommandTarget, (void**)&olecmd);
+        if(FAILED(hres))
+            olecmd = NULL;
+
         IOleContainer_Release(container);
+    }else {
+        hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd);
+        if(FAILED(hres))
+            olecmd = NULL;
     }
 
+    This->doc_host.olecmd = olecmd;
+
     create_shell_embedding_hwnd(This);
 
     on_offlineconnected_change(This);
@@ -519,10 +558,11 @@ static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
     if(This->uiwindow)
         IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, NULL, NULL);
 
-    if(This->inplace) {
+    if(This->inplace)
         IOleInPlaceSiteEx_OnUIDeactivate(This->inplace, FALSE);
+    notify_on_focus(This, FALSE);
+    if(This->inplace)
         IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace);
-    }
 
     return IOleObject_SetClientSite(iface, NULL);
 }
@@ -802,7 +842,7 @@ static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObject *iface,
 {
     WebBrowser *This = impl_from_IOleInPlaceObject(iface);
 
-    TRACE("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
+    TRACE("(%p)->(%s %s)\n", This, wine_dbgstr_rect(lprcPosRect), wine_dbgstr_rect(lprcClipRect));
 
     This->pos_rect = *lprcPosRect;
 
index 51dbd01..11ce073 100644 (file)
@@ -742,6 +742,8 @@ static HRESULT WINAPI DocObjectService_FireNavigateComplete2(
 
     TRACE("%p %p %x\n", This, pHTMLWindow2, dwFlags);
 
+    update_navigation_commands(This->doc_host);
+
     if(doc_host->travellog.loading_pos != -1) {
         WARN("histupdate not notified\n");
         doc_host->travellog.position = doc_host->travellog.loading_pos;
index db4a46d..5536d42 100644 (file)
@@ -56,7 +56,7 @@ static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect,
     FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %08lx)\n", This, dwDrawAspect, lindex,
             pvAspect, ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue,
             dwContinue);
-    return E_NOTIMPL;
+    return S_OK;
 }
 
 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwAspect,
@@ -88,16 +88,36 @@ static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, D
         IAdviseSink *pAdvSink)
 {
     WebBrowser *This = impl_from_IViewObject2(iface);
-    FIXME("(%p)->(%d %08x %p)\n", This, aspects, advf, pAdvSink);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%d %08x %p)\n", This, aspects, advf, pAdvSink);
+
+    if (aspects || advf) FIXME("aspects and/or flags not supported yet\n");
+
+    This->sink_aspects = aspects;
+    This->sink_flags = advf;
+    if (This->sink) IAdviseSink_Release(This->sink);
+    This->sink = pAdvSink;
+    if (This->sink) IAdviseSink_AddRef(This->sink);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects,
         DWORD *pAdvf, IAdviseSink **ppAdvSink)
 {
     WebBrowser *This = impl_from_IViewObject2(iface);
-    FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
+
+    if (pAspects) *pAspects = This->sink_aspects;
+    if (pAdvf) *pAdvf = This->sink_flags;
+    if (ppAdvSink)
+    {
+        *ppAdvSink = This->sink;
+        if (*ppAdvSink) IAdviseSink_AddRef(*ppAdvSink);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwAspect, LONG lindex,
index bffcd72..b733305 100644 (file)
@@ -1187,60 +1187,31 @@ static ULONG WebBrowser_release(DocHost *iface)
     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
 }
 
-static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
+static void DocHostContainer_get_docobj_rect(DocHost *This, RECT *rc)
 {
     GetClientRect(This->frame_hwnd, rc);
 }
 
-static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
+static HRESULT DocHostContainer_set_status_text(DocHost *This, const WCHAR *text)
 {
     return E_NOTIMPL;
 }
 
-static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
+static void DocHostContainer_on_command_state_change(DocHost *This, LONG command, BOOL enable)
 {
-
 }
 
-static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
-        VARIANT *out)
+static void DocHostContainer_set_url(DocHost *This, const WCHAR *url)
 {
-    WebBrowser *This = impl_from_DocHost(doc_host);
-    IOleCommandTarget *cmdtrg = NULL;
-    HRESULT hres;
-
-    if(This->client) {
-        hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
-        if(FAILED(hres))
-            cmdtrg = NULL;
-    }
-
-    if(!cmdtrg && This->container) {
-        hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
-        if(FAILED(hres))
-            cmdtrg = NULL;
-    }
-
-    if(!cmdtrg)
-        return E_NOTIMPL;
-
-    hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
-    IOleCommandTarget_Release(cmdtrg);
-    if(SUCCEEDED(hres))
-        TRACE("Exec returned %08x %s\n", hres, debugstr_variant(out));
-    else
-        FIXME("Exec failed\n");
-
-    return hres;
 }
 
 static const IDocHostContainerVtbl DocHostContainerVtbl = {
     WebBrowser_addref,
     WebBrowser_release,
-    DocHostContainer_GetDocObjRect,
-    DocHostContainer_SetStatusText,
-    DocHostContainer_SetURL,
-    DocHostContainer_exec
+    DocHostContainer_get_docobj_rect,
+    DocHostContainer_set_status_text,
+    DocHostContainer_on_command_state_change,
+    DocHostContainer_set_url
 };
 
 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
index c399ab6..fab7ce3 100644 (file)
@@ -76,7 +76,7 @@ reactos/dll/win32/hnetcfg             # Synced to WineStaging-1.7.47
 reactos/dll/win32/httpapi             # Synced to WineStaging-1.7.47
 reactos/dll/win32/iccvid              # Synced to WineStaging-1.7.47
 reactos/dll/win32/icmp                # Out of sync
-reactos/dll/win32/ieframe             # Synced to WineStaging-1.7.47
+reactos/dll/win32/ieframe             # Synced to WineStaging-1.7.55
 reactos/dll/win32/imaadp32.acm        # Synced to WineStaging-1.7.47
 reactos/dll/win32/imagehlp            # Synced to WineStaging-1.7.47
 reactos/dll/win32/imm32               # Synced to Wine-1.7.27