[SHDOCVW]

sync shdocvw with wine 1.1.41

svn path=/trunk/; revision=46302
This commit is contained in:
Christoph von Wittich 2010-03-21 15:08:31 +00:00
parent 4bf2ced778
commit 154813b443
6 changed files with 241 additions and 66 deletions

View file

@ -21,9 +21,14 @@
#include "hlink.h"
#include "exdispid.h"
#include "mshtml.h"
#include "initguid.h"
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
#define DOCHOST_DOCCANNAVIGATE 0
static ATOM doc_view_atom = 0;
void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, BOOL send)
@ -154,16 +159,23 @@ static void advise_prop_notif(DocHost *This, BOOL set)
This->is_prop_notif = set;
}
void set_doc_state(DocHost *This, READYSTATE doc_state)
{
This->doc_state = doc_state;
if(doc_state > This->ready_state)
This->ready_state = doc_state;
}
static void update_ready_state(DocHost *This, READYSTATE ready_state)
{
if(ready_state > READYSTATE_LOADING && This->ready_state <= READYSTATE_LOADING) {
if(ready_state > READYSTATE_LOADING && This->doc_state <= READYSTATE_LOADING)
notif_complete(This, DISPID_NAVIGATECOMPLETE2);
This->ready_state = ready_state;
}
if(ready_state == READYSTATE_COMPLETE && This->ready_state < READYSTATE_COMPLETE) {
This->ready_state = READYSTATE_COMPLETE;
if(ready_state == READYSTATE_COMPLETE && This->doc_state < READYSTATE_COMPLETE) {
set_doc_state(This, READYSTATE_COMPLETE);
notif_complete(This, DISPID_DOCUMENTCOMPLETE);
}else {
set_doc_state(This, ready_state);
}
}
@ -236,7 +248,7 @@ HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
if(SUCCEEDED(hres)) {
if(ready_state == READYSTATE_COMPLETE)
push_ready_state_task(This, READYSTATE_COMPLETE);
else
if(ready_state != READYSTATE_COMPLETE || This->doc_navigate)
advise_prop_notif(This, TRUE);
}
@ -314,6 +326,11 @@ void deactivate_document(DocHost *This)
IHlinkTarget *hlink = NULL;
HRESULT hres;
if(This->doc_navigate) {
IUnknown_Release(This->doc_navigate);
This->doc_navigate = NULL;
}
if(This->is_prop_notif)
advise_prop_notif(This, FALSE);
@ -425,8 +442,34 @@ static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
VARIANT *pvaOut)
{
DocHost *This = OLECMD_THIS(iface);
FIXME("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
nCmdexecopt, pvaIn, pvaOut);
TRACE("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
nCmdexecopt, debugstr_variant(pvaIn), debugstr_variant(pvaOut));
if(!pguidCmdGroup) {
FIXME("Unimplemented cmdid %d\n", nCmdID);
return E_NOTIMPL;
}
if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
switch(nCmdID) {
case DOCHOST_DOCCANNAVIGATE:
if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
return E_INVALIDARG;
if(This->doc_navigate)
IUnknown_Release(This->doc_navigate);
IUnknown_AddRef(V_UNKNOWN(pvaIn));
This->doc_navigate = V_UNKNOWN(pvaIn);
return S_OK;
default:
FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
return E_NOTIMPL;
}
}
FIXME("Unimplemented group %s\n", debugstr_guid(pguidCmdGroup));
return E_NOTIMPL;
}
@ -709,7 +752,7 @@ static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, D
if(FAILED(hres))
return hres;
if(ready_state == READYSTATE_COMPLETE)
if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
advise_prop_notif(This, FALSE);
push_ready_state_task(This, ready_state);

View file

@ -163,7 +163,7 @@ HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv)
TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv);
ret = heap_alloc(sizeof(InternetExplorer));
ret = heap_alloc_zero(sizeof(InternetExplorer));
ret->ref = 0;
ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret);

View file

@ -27,6 +27,7 @@
#include "winreg.h"
#include "shlwapi.h"
#include "wininet.h"
#include "mshtml.h"
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
@ -378,8 +379,7 @@ static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE
return ret;
}
static void on_before_navigate2(DocHost *This, LPCWSTR url, const BYTE *post_data,
ULONG post_data_len, LPWSTR headers, VARIANT_BOOL *cancel)
static void on_before_navigate2(DocHost *This, LPCWSTR url, SAFEARRAY *post_data, LPWSTR headers, VARIANT_BOOL *cancel)
{
VARIANT var_url, var_flags, var_frame_name, var_post_data, var_post_data2, var_headers;
DISPPARAMS dispparams;
@ -404,18 +404,12 @@ static void on_before_navigate2(DocHost *This, LPCWSTR url, const BYTE *post_dat
V_VARIANTREF(params+2) = &var_post_data2;
V_VT(&var_post_data2) = (VT_BYREF|VT_VARIANT);
V_VARIANTREF(&var_post_data2) = &var_post_data;
VariantInit(&var_post_data);
if(post_data_len) {
SAFEARRAYBOUND bound = {post_data_len, 0};
void *data;
if(post_data) {
V_VT(&var_post_data) = VT_UI1|VT_ARRAY;
V_ARRAY(&var_post_data) = SafeArrayCreate(VT_UI1, 1, &bound);
SafeArrayAccessData(V_ARRAY(&var_post_data), &data);
memcpy(data, post_data, post_data_len);
SafeArrayUnaccessData(V_ARRAY(&var_post_data));
V_ARRAY(&var_post_data) = post_data;
}else {
V_VT(&var_post_data) = VT_EMPTY;
}
V_VT(params+3) = (VT_BYREF|VT_VARIANT);
@ -439,8 +433,6 @@ static void on_before_navigate2(DocHost *This, LPCWSTR url, const BYTE *post_dat
call_sink(This->cps.wbe2, DISPID_BEFORENAVIGATE2, &dispparams);
SysFreeString(V_BSTR(&var_url));
if(post_data_len)
SafeArrayDestroy(V_ARRAY(&var_post_data));
}
/* FIXME: urlmon should handle it */
@ -543,15 +535,153 @@ static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCt
return S_OK;
}
static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mon)
static void html_window_navigate(DocHost *This, IHTMLPrivateWindow *window, BSTR url, BSTR headers, SAFEARRAY *post_data)
{
IBindCtx *bindctx;
VARIANT_BOOL cancel = VARIANT_FALSE;
VARIANT headers_var, post_data_var;
WCHAR *new_url;
BSTR empty_str;
DWORD size;
HRESULT hres;
This->ready_state = READYSTATE_LOADING;
size = (strlenW(url)+1)*sizeof(WCHAR);
new_url = CoTaskMemAlloc(size);
if(!new_url)
return;
memcpy(new_url, url, size);
CoTaskMemFree(This->url);
This->url = new_url;
on_before_navigate2(This, bsc->url, bsc->post_data, bsc->post_data_len, bsc->headers, &cancel);
empty_str = SysAllocStringLen(NULL, 0);
if(headers) {
V_VT(&headers_var) = VT_BSTR;
V_BSTR(&headers_var) = headers;
}else {
V_VT(&headers_var) = VT_EMPTY;
}
if(post_data) {
V_VT(&post_data_var) = VT_UI1|VT_ARRAY;
V_ARRAY(&post_data_var) = post_data;
}else {
V_VT(&post_data_var) = VT_EMPTY;
}
set_doc_state(This, READYSTATE_LOADING);
hres = IHTMLPrivateWindow_SuperNavigate(window, url, empty_str, NULL, NULL, &post_data_var, &headers_var, 0);
SysFreeString(empty_str);
if(FAILED(hres))
WARN("SuprtNavigate failed: %08x\n", hres);
}
typedef struct {
task_header_t header;
BSTR url;
BSTR headers;
SAFEARRAY *post_data;
BOOL async_notif;
} task_doc_navigate_t;
static HRESULT free_doc_navigate_task(task_doc_navigate_t *task, BOOL free_task)
{
SysFreeString(task->url);
SysFreeString(task->headers);
if(task->post_data)
SafeArrayDestroy(task->post_data);
if(free_task)
heap_free(task);
return E_OUTOFMEMORY;
}
static void doc_navigate_proc(DocHost *This, task_header_t *t)
{
task_doc_navigate_t *task = (task_doc_navigate_t*)t;
IHTMLPrivateWindow *priv_window;
HRESULT hres;
if(!This->doc_navigate)
return;
if(task->async_notif) {
VARIANT_BOOL cancel = VARIANT_FALSE;
on_before_navigate2(This, task->url, task->post_data, task->headers, &cancel);
if(cancel) {
TRACE("Navigation calnceled\n");
free_doc_navigate_task(task, FALSE);
return;
}
}
hres = IUnknown_QueryInterface(This->doc_navigate, &IID_IHTMLPrivateWindow, (void**)&priv_window);
if(SUCCEEDED(hres)) {
html_window_navigate(This, priv_window, task->url, task->headers, task->post_data);
IHTMLPrivateWindow_Release(priv_window);
}else {
WARN("Could not get IHTMLPrivateWindow iface: %08x\n", hres);
}
free_doc_navigate_task(task, FALSE);
}
static HRESULT async_doc_navigate(DocHost *This, LPCWSTR url, LPCWSTR headers, PBYTE post_data, ULONG post_data_size,
BOOL async_notif)
{
task_doc_navigate_t *task;
task = heap_alloc_zero(sizeof(*task));
if(!task)
return E_OUTOFMEMORY;
task->url = SysAllocString(url);
if(!task->url)
return free_doc_navigate_task(task, TRUE);
if(headers) {
task->headers = SysAllocString(headers);
if(!task->headers)
return free_doc_navigate_task(task, TRUE);
}
if(task->post_data) {
task->post_data = SafeArrayCreateVector(VT_UI1, 0, post_data_size);
if(!task->post_data)
return free_doc_navigate_task(task, TRUE);
memcpy(task->post_data->pvData, post_data, post_data_size);
}
if(!async_notif) {
VARIANT_BOOL cancel = VARIANT_FALSE;
on_before_navigate2(This, task->url, task->post_data, task->headers, &cancel);
if(cancel) {
TRACE("Navigation calnceled\n");
free_doc_navigate_task(task, TRUE);
return S_OK;
}
}
task->async_notif = async_notif;
push_dochost_task(This, &task->header, doc_navigate_proc, FALSE);
return S_OK;
}
static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mon)
{
VARIANT_BOOL cancel = VARIANT_FALSE;
SAFEARRAY *post_data = NULL;
IBindCtx *bindctx;
HRESULT hres;
set_doc_state(This, READYSTATE_LOADING);
if(bsc->post_data) {
post_data = SafeArrayCreateVector(VT_UI1, 0, bsc->post_data_len);
memcpy(post_data->pvData, post_data, bsc->post_data_len);
}
on_before_navigate2(This, bsc->url, post_data, bsc->headers, &cancel);
if(post_data)
SafeArrayDestroy(post_data);
if(cancel) {
FIXME("Navigation canceled\n");
return S_OK;
@ -596,10 +726,10 @@ static void navigate_bsc_proc(DocHost *This, task_header_t *t)
HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
const VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
{
task_navigate_bsc_t *task;
PBYTE post_data = NULL;
ULONG post_data_len = 0;
LPWSTR headers = NULL;
HRESULT hres = S_OK;
TRACE("navigating to %s\n", debugstr_w(url));
@ -626,15 +756,23 @@ HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
TRACE("Headers: %s\n", debugstr_w(headers));
}
task = heap_alloc(sizeof(*task));
task->bsc = create_callback(This, url, post_data, post_data_len, headers);
set_doc_state(This, READYSTATE_LOADING);
This->ready_state = READYSTATE_LOADING;
if(This->doc_navigate) {
hres = async_doc_navigate(This, url, headers, post_data, post_data_len, TRUE);
}else {
task_navigate_bsc_t *task;
task = heap_alloc(sizeof(*task));
task->bsc = create_callback(This, url, post_data, post_data_len, headers);
push_dochost_task(This, &task->header, navigate_bsc_proc, This->url == NULL);
}
if(post_data)
SafeArrayUnaccessData(V_ARRAY(PostData));
push_dochost_task(This, &task->header, navigate_bsc_proc, This->url == NULL);
return S_OK;
return hres;
}
static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
@ -649,6 +787,10 @@ static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
DWORD bindf = 0;
HRESULT hres;
hres = IMoniker_GetDisplayName(mon, 0, NULL, &url);
if(FAILED(hres))
FIXME("GetDisplayName failed: %08x\n", hres);
hres = IBindStatusCallback_QueryInterface(callback, &IID_IHttpNegotiate,
(void**)&http_negotiate);
if(SUCCEEDED(hres)) {
@ -670,16 +812,15 @@ static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
post_data = bindinfo.stgmedData.u.hGlobal;
}
hres = IMoniker_GetDisplayName(mon, 0, NULL, &url);
if(FAILED(hres))
FIXME("GetDisplayName failed: %08x\n", hres);
if(This->doc_navigate) {
hres = async_doc_navigate(This, url, headers, post_data, post_data_len, FALSE);
}else {
bsc = create_callback(This, url, post_data, post_data_len, headers);
hres = navigate_bsc(This, bsc, mon);
IBindStatusCallback_Release(BINDSC(bsc));
}
bsc = create_callback(This, url, post_data, post_data_len, headers);
CoTaskMemFree(url);
hres = navigate_bsc(This, bsc, mon);
IBindStatusCallback_Release(BINDSC(bsc));
CoTaskMemFree(headers);
ReleaseBindInfo(&bindinfo);

View file

@ -960,17 +960,6 @@ void WebBrowser_OleObject_Init(WebBrowser *This)
This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
This->client = NULL;
This->inplace = NULL;
This->container = NULL;
This->frame_hwnd = NULL;
This->uiwindow = NULL;
This->shell_embedding_hwnd = NULL;
memset(&This->pos_rect, 0, sizeof(RECT));
memset(&This->clip_rect, 0, sizeof(RECT));
memset(&This->frameinfo, 0, sizeof(OLEINPLACEFRAMEINFO));
/* Default size is 50x20 pixels, in himetric units */
This->extent.cx = MulDiv( 50, 2540, dpi_x );
This->extent.cy = MulDiv( 20, 2540, dpi_y );

View file

@ -92,6 +92,7 @@ struct DocHost {
IUnknown *document;
IOleDocumentView *view;
IUnknown *doc_navigate;
HWND hwnd;
HWND frame_hwnd;
@ -103,6 +104,7 @@ struct DocHost {
VARIANT_BOOL busy;
READYSTATE ready_state;
READYSTATE doc_state;
DWORD prop_notif_cookie;
BOOL is_prop_notif;
@ -222,6 +224,7 @@ HRESULT dochost_object_available(DocHost*,IUnknown*);
void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
HRESULT go_home(DocHost*);
void set_doc_state(DocHost*,READYSTATE);
#define WM_DOCHOSTTASK (WM_USER+0x300)
void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
@ -262,6 +265,11 @@ static inline void *heap_alloc(size_t len)
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *heap_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);

View file

@ -1115,23 +1115,20 @@ static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, voi
TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
ret = heap_alloc(sizeof(WebBrowser));
ret = heap_alloc_zero(sizeof(WebBrowser));
ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
ret->ref = 0;
ret->ref = 1;
ret->version = version;
DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
ret->register_browser = VARIANT_FALSE;
ret->visible = VARIANT_TRUE;
ret->menu_bar = VARIANT_TRUE;
ret->address_bar = VARIANT_TRUE;
ret->status_bar = VARIANT_TRUE;
ret->tool_bar = VARIANT_TRUE;
ret->full_screen = VARIANT_FALSE;
ret->theater_mode = VARIANT_FALSE;
WebBrowser_OleObject_Init(ret);
WebBrowser_ViewObject_Init(ret);
@ -1139,14 +1136,11 @@ static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, voi
WebBrowser_ClassInfo_Init(ret);
WebBrowser_HlinkFrame_Init(ret);
hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
if(SUCCEEDED(hres)) {
SHDOCVW_LockModule();
}else {
heap_free(ret);
return hres;
}
SHDOCVW_LockModule();
hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
IWebBrowser2_Release(WEBBROWSER(ret));
return hres;
}