mshtml: Move cmdtable_t to HTMLDocumentNode.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-03-12 16:11:33 +01:00 committed by Alexandre Julliard
parent b384f5b3a4
commit 34c84fd1a0
3 changed files with 274 additions and 293 deletions

View File

@ -144,17 +144,17 @@ static nsresult get_ns_command_state(GeckoBrowser *This, const char *cmd, nsICom
return nsres; return nsres;
} }
static DWORD query_ns_edit_status(HTMLDocument *This, const char *nscmd) static DWORD query_ns_edit_status(HTMLDocumentNode *doc, const char *nscmd)
{ {
nsICommandParams *nsparam; nsICommandParams *nsparam;
cpp_bool b = FALSE; cpp_bool b = FALSE;
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE) if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
return OLECMDF_SUPPORTED; return OLECMDF_SUPPORTED;
if(This->doc_obj->nscontainer && nscmd) { if(nscmd) {
nsparam = create_nscommand_params(); nsparam = create_nscommand_params();
get_ns_command_state(This->doc_obj->nscontainer, nscmd, nsparam); get_ns_command_state(doc->browser, nscmd, nsparam);
nsICommandParams_GetBooleanValue(nsparam, NSSTATE_ALL, &b); nsICommandParams_GetBooleanValue(nsparam, NSSTATE_ALL, &b);
@ -164,33 +164,30 @@ static DWORD query_ns_edit_status(HTMLDocument *This, const char *nscmd)
return OLECMDF_SUPPORTED | OLECMDF_ENABLED | (b ? OLECMDF_LATCHED : 0); return OLECMDF_SUPPORTED | OLECMDF_ENABLED | (b ? OLECMDF_LATCHED : 0);
} }
static void set_ns_align(HTMLDocument *This, const char *align_str) static void set_ns_align(HTMLDocumentNode *doc, const char *align_str)
{ {
nsICommandParams *nsparam; nsICommandParams *nsparam;
if(!This->doc_obj->nscontainer)
return;
nsparam = create_nscommand_params(); nsparam = create_nscommand_params();
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, align_str); nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, align_str);
do_ns_command(This->doc_node, NSCMD_ALIGN, nsparam); do_ns_command(doc, NSCMD_ALIGN, nsparam);
nsICommandParams_Release(nsparam); nsICommandParams_Release(nsparam);
} }
static DWORD query_align_status(HTMLDocument *This, const WCHAR *align) static DWORD query_align_status(HTMLDocumentNode *doc, const WCHAR *align)
{ {
DWORD ret = OLECMDF_SUPPORTED | OLECMDF_ENABLED; DWORD ret = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
nsAString justify_str; nsAString justify_str;
cpp_bool b; cpp_bool b;
nsresult nsres; nsresult nsres;
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE) if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
return OLECMDF_SUPPORTED; return OLECMDF_SUPPORTED;
nsAString_Init(&justify_str, align); nsAString_Init(&justify_str, align);
nsres = nsIDOMHTMLDocument_QueryCommandState(This->doc_node->nsdoc, &justify_str, &b); nsres = nsIDOMHTMLDocument_QueryCommandState(doc->nsdoc, &justify_str, &b);
nsAString_Finish(&justify_str); nsAString_Finish(&justify_str);
if(NS_SUCCEEDED(nsres) && b) if(NS_SUCCEEDED(nsres) && b)
ret |= OLECMDF_LATCHED; ret |= OLECMDF_LATCHED;
@ -199,12 +196,12 @@ static DWORD query_align_status(HTMLDocument *This, const WCHAR *align)
} }
static nsISelection *get_ns_selection(HTMLDocument *This) static nsISelection *get_ns_selection(HTMLDocumentNode *doc)
{ {
nsISelection *nsselection = NULL; nsISelection *nsselection = NULL;
nsresult nsres; nsresult nsres;
nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection); nsres = nsIDOMWindow_GetSelection(doc->basedoc.window->nswindow, &nsselection);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("GetSelection failed %08x\n", nsres); ERR("GetSelection failed %08x\n", nsres);
@ -259,9 +256,9 @@ static void remove_child_attr(nsIDOMElement *elem, LPCWSTR tag, nsAString *attr_
nsIDOMNodeList_Release(node_list); nsIDOMNodeList_Release(node_list);
} }
static void get_font_size(HTMLDocument *This, WCHAR *ret) static void get_font_size(HTMLDocumentNode *doc, WCHAR *ret)
{ {
nsISelection *nsselection = get_ns_selection(This); nsISelection *nsselection = get_ns_selection(doc);
nsIDOMElement *elem = NULL; nsIDOMElement *elem = NULL;
nsIDOMNode *node = NULL, *tmp_node; nsIDOMNode *node = NULL, *tmp_node;
nsAString tag_str; nsAString tag_str;
@ -320,7 +317,7 @@ static void get_font_size(HTMLDocument *This, WCHAR *ret)
nsIDOMNode_Release(node); nsIDOMNode_Release(node);
} }
static void set_font_size(HTMLDocument *This, LPCWSTR size) static void set_font_size(HTMLDocumentNode *doc, LPCWSTR size)
{ {
nsISelection *nsselection; nsISelection *nsselection;
cpp_bool collapsed; cpp_bool collapsed;
@ -330,12 +327,7 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size)
nsAString size_str; nsAString size_str;
nsAString val_str; nsAString val_str;
if(!This->doc_node->nsdoc) { nsselection = get_ns_selection(doc);
WARN("NULL nsdoc\n");
return;
}
nsselection = get_ns_selection(This);
if(!nsselection) if(!nsselection)
return; return;
@ -348,7 +340,7 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size)
} }
} }
create_nselem(This->doc_node, fontW, &elem); create_nselem(doc, fontW, &elem);
nsAString_InitDepend(&size_str, sizeW); nsAString_InitDepend(&size_str, sizeW);
nsAString_InitDepend(&val_str, size); nsAString_InitDepend(&val_str, size);
@ -376,7 +368,7 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size)
nsAString_Finish(&size_str); nsAString_Finish(&size_str);
set_dirty(This->doc_node->browser, VARIANT_TRUE); set_dirty(doc->browser, VARIANT_TRUE);
} }
static void handle_arrow_key(HTMLDocumentNode *doc, nsIDOMEvent *event, nsIDOMKeyEvent *key_event, const char * const cmds[4]) static void handle_arrow_key(HTMLDocumentNode *doc, nsIDOMEvent *event, nsIDOMKeyEvent *key_event, const char * const cmds[4])
@ -501,34 +493,28 @@ void handle_edit_load(HTMLDocument *This)
get_editor_controller(This->doc_obj->nscontainer); get_editor_controller(This->doc_obj->nscontainer);
} }
static void set_ns_fontname(HTMLDocument *This, const char *fontname) static void set_ns_fontname(HTMLDocumentNode *doc, const char *fontname)
{ {
nsICommandParams *nsparam = create_nscommand_params(); nsICommandParams *nsparam = create_nscommand_params();
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, fontname); nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, fontname);
do_ns_command(This->doc_node, NSCMD_FONTFACE, nsparam); do_ns_command(doc, NSCMD_FONTFACE, nsparam);
nsICommandParams_Release(nsparam); nsICommandParams_Release(nsparam);
} }
static HRESULT exec_delete(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_delete(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%p %p)\n", This, in, out); TRACE("(%p)->(%p %p)\n", doc, in, out);
if(This->doc_obj->nscontainer) do_ns_editor_command(doc->browser, NSCMD_DELETECHARFORWARD);
do_ns_editor_command(This->doc_obj->nscontainer, NSCMD_DELETECHARFORWARD);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_fontname(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%p %p)\n", This, in, out); TRACE("(%p)->(%p %p)\n", doc, in, out);
if(!This->doc_obj->nscontainer) {
update_doc(This->doc_obj, UPDATE_UI);
return E_FAIL;
}
if(in) { if(in) {
char *stra; char *stra;
@ -541,10 +527,10 @@ static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
TRACE("%s\n", debugstr_w(V_BSTR(in))); TRACE("%s\n", debugstr_w(V_BSTR(in)));
stra = heap_strdupWtoA(V_BSTR(in)); stra = heap_strdupWtoA(V_BSTR(in));
set_ns_fontname(This, stra); set_ns_fontname(doc, stra);
heap_free(stra); heap_free(stra);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
} }
if(out) { if(out) {
@ -559,7 +545,7 @@ static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
nsparam = create_nscommand_params(); nsparam = create_nscommand_params();
nsres = get_ns_command_state(This->doc_obj->nscontainer, NSCMD_FONTFACE, nsparam); nsres = get_ns_command_state(doc->browser, NSCMD_FONTFACE, nsparam);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
return S_OK; return S_OK;
@ -578,9 +564,9 @@ static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
return S_OK; return S_OK;
} }
static HRESULT exec_forecolor(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_forecolor(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%p %p)\n", This, in, out); TRACE("(%p)->(%p %p)\n", doc, in, out);
if(in) { if(in) {
if(V_VT(in) == VT_I4) { if(V_VT(in) == VT_I4) {
@ -591,14 +577,14 @@ static HRESULT exec_forecolor(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
V_I4(in)&0xff, (V_I4(in)>>8)&0xff, (V_I4(in)>>16)&0xff); V_I4(in)&0xff, (V_I4(in)>>8)&0xff, (V_I4(in)>>16)&0xff);
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, color_str); nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, color_str);
do_ns_command(This->doc_node, NSCMD_FONTCOLOR, nsparam); do_ns_command(doc, NSCMD_FONTCOLOR, nsparam);
nsICommandParams_Release(nsparam); nsICommandParams_Release(nsparam);
}else { }else {
FIXME("unsupported forecolor %s\n", debugstr_variant(in)); FIXME("unsupported forecolor %s\n", debugstr_variant(in));
} }
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
} }
if(out) { if(out) {
@ -609,14 +595,14 @@ static HRESULT exec_forecolor(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
return S_OK; return S_OK;
} }
static HRESULT exec_fontsize(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_fontsize(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%p %p)\n", This, in, out); TRACE("(%p)->(%p %p)\n", doc, in, out);
if(out) { if(out) {
WCHAR val[10] = {0}; WCHAR val[10] = {0};
get_font_size(This, val); get_font_size(doc, val);
V_VT(out) = VT_I4; V_VT(out) = VT_I4;
V_I4(out) = strtolW(val, NULL, 10); V_I4(out) = strtolW(val, NULL, 10);
} }
@ -627,189 +613,189 @@ static HRESULT exec_fontsize(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
WCHAR size[10]; WCHAR size[10];
static const WCHAR format[] = {'%','d',0}; static const WCHAR format[] = {'%','d',0};
wsprintfW(size, format, V_I4(in)); wsprintfW(size, format, V_I4(in));
set_font_size(This, size); set_font_size(doc, size);
break; break;
} }
case VT_BSTR: case VT_BSTR:
set_font_size(This, V_BSTR(in)); set_font_size(doc, V_BSTR(in));
break; break;
default: default:
FIXME("unsupported fontsize %s\n", debugstr_variant(in)); FIXME("unsupported fontsize %s\n", debugstr_variant(in));
} }
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
} }
return S_OK; return S_OK;
} }
static HRESULT exec_font(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_font(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
FIXME("(%p)->(%p %p)\n", This, in, out); FIXME("(%p)->(%p %p)\n", doc, in, out);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_bold(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_bold(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_BOLD, NULL); do_ns_command(doc, NSCMD_BOLD, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_italic(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_italic(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_ITALIC, NULL); do_ns_command(doc, NSCMD_ITALIC, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd) static HRESULT query_justify(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
static const PRUnichar justifycenterW[] = {'j','u','s','t','i','f','y','c','e','n','t','e','r',0}; static const PRUnichar justifycenterW[] = {'j','u','s','t','i','f','y','c','e','n','t','e','r',0};
static const PRUnichar justifyrightW[] = {'j','u','s','t','i','f','y','r','i','g','h','t',0}; static const PRUnichar justifyrightW[] = {'j','u','s','t','i','f','y','r','i','g','h','t',0};
switch(cmd->cmdID) { switch(cmd->cmdID) {
case IDM_JUSTIFYCENTER: case IDM_JUSTIFYCENTER:
TRACE("(%p) IDM_JUSTIFYCENTER\n", This); TRACE("(%p) IDM_JUSTIFYCENTER\n", doc);
cmd->cmdf = query_align_status(This, justifycenterW); cmd->cmdf = query_align_status(doc, justifycenterW);
break; break;
case IDM_JUSTIFYLEFT: case IDM_JUSTIFYLEFT:
TRACE("(%p) IDM_JUSTIFYLEFT\n", This); TRACE("(%p) IDM_JUSTIFYLEFT\n", doc);
/* FIXME: We should set OLECMDF_LATCHED only if it's set explicitly. */ /* FIXME: We should set OLECMDF_LATCHED only if it's set explicitly. */
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE) if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
cmd->cmdf = OLECMDF_SUPPORTED; cmd->cmdf = OLECMDF_SUPPORTED;
else else
cmd->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED; cmd->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
break; break;
case IDM_JUSTIFYRIGHT: case IDM_JUSTIFYRIGHT:
TRACE("(%p) IDM_JUSTIFYRIGHT\n", This); TRACE("(%p) IDM_JUSTIFYRIGHT\n", doc);
cmd->cmdf = query_align_status(This, justifyrightW); cmd->cmdf = query_align_status(doc, justifyrightW);
break; break;
} }
return S_OK; return S_OK;
} }
static HRESULT exec_justifycenter(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_justifycenter(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
set_ns_align(This, NSALIGN_CENTER); set_ns_align(doc, NSALIGN_CENTER);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_justifyleft(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_justifyleft(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
set_ns_align(This, NSALIGN_LEFT); set_ns_align(doc, NSALIGN_LEFT);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_justifyright(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_justifyright(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
set_ns_align(This, NSALIGN_RIGHT); set_ns_align(doc, NSALIGN_RIGHT);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_underline(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_underline(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_UNDERLINE, NULL); do_ns_command(doc, NSCMD_UNDERLINE, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_horizontalline(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_horizontalline(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_INSERTHR, NULL); do_ns_command(doc, NSCMD_INSERTHR, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_orderlist(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_orderlist(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_OL, NULL); do_ns_command(doc, NSCMD_OL, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_unorderlist(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_unorderlist(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_UL, NULL); do_ns_command(doc, NSCMD_UL, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_indent(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_indent(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_INDENT, NULL); do_ns_command(doc, NSCMD_INDENT, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_outdent(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_outdent(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", doc);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
do_ns_command(This->doc_node, NSCMD_OUTDENT, NULL); do_ns_command(doc, NSCMD_OUTDENT, NULL);
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
return S_OK; return S_OK;
} }
static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_composesettings(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
WCHAR *ptr; WCHAR *ptr;
@ -818,25 +804,25 @@ static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIAN
return E_INVALIDARG; return E_INVALIDARG;
} }
TRACE("(%p)->(%x %s)\n", This, cmdexecopt, debugstr_w(V_BSTR(in))); TRACE("(%p)->(%x %s)\n", doc, cmdexecopt, debugstr_w(V_BSTR(in)));
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
ptr = V_BSTR(in); ptr = V_BSTR(in);
if(*ptr == '1') if(*ptr == '1')
exec_bold(This, cmdexecopt, NULL, NULL); exec_bold(doc, cmdexecopt, NULL, NULL);
ptr = strchrW(ptr, ','); ptr = strchrW(ptr, ',');
if(!ptr) if(!ptr)
return S_OK; return S_OK;
if(*++ptr == '1') if(*++ptr == '1')
exec_italic(This, cmdexecopt, NULL, NULL); exec_italic(doc, cmdexecopt, NULL, NULL);
ptr = strchrW(ptr, ','); ptr = strchrW(ptr, ',');
if(!ptr) if(!ptr)
return S_OK; return S_OK;
if(*++ptr == '1') if(*++ptr == '1')
exec_underline(This, cmdexecopt, NULL, NULL); exec_underline(doc, cmdexecopt, NULL, NULL);
ptr = strchrW(ptr, ','); ptr = strchrW(ptr, ',');
if(!ptr) if(!ptr)
return S_OK; return S_OK;
@ -847,7 +833,7 @@ static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIAN
V_VT(&v) = VT_I4; V_VT(&v) = VT_I4;
V_I4(&v) = *ptr-'0'; V_I4(&v) = *ptr-'0';
exec_fontsize(This, cmdexecopt, &v, NULL); exec_fontsize(doc, cmdexecopt, &v, NULL);
} }
ptr = strchrW(ptr, ','); ptr = strchrW(ptr, ',');
if(!ptr) if(!ptr)
@ -872,7 +858,7 @@ static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIAN
V_VT(&v) = VT_BSTR; V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(ptr); V_BSTR(&v) = SysAllocString(ptr);
exec_fontname(This, cmdexecopt, &v, NULL); exec_fontname(doc, cmdexecopt, &v, NULL);
SysFreeString(V_BSTR(&v)); SysFreeString(V_BSTR(&v));
} }
@ -880,108 +866,96 @@ static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIAN
return S_OK; return S_OK;
} }
HRESULT editor_exec_copy(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) HRESULT editor_exec_copy(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
do_ns_editor_command(doc->browser, NSCMD_COPY);
if(!This->doc_obj->nscontainer)
return E_FAIL;
do_ns_editor_command(This->doc_obj->nscontainer, NSCMD_COPY);
return S_OK; return S_OK;
} }
HRESULT editor_exec_cut(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) HRESULT editor_exec_cut(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
do_ns_editor_command(doc->browser, NSCMD_CUT);
if(!This->doc_obj->nscontainer)
return E_FAIL;
do_ns_editor_command(This->doc_obj->nscontainer, NSCMD_CUT);
return S_OK; return S_OK;
} }
HRESULT editor_exec_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) HRESULT editor_exec_paste(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
update_doc(This->doc_obj, UPDATE_UI); update_doc(doc->browser->doc, UPDATE_UI);
do_ns_editor_command(doc->browser, NSCMD_PASTE);
if(!This->doc_obj->nscontainer)
return E_FAIL;
do_ns_editor_command(This->doc_obj->nscontainer, NSCMD_PASTE);
return S_OK; return S_OK;
} }
static HRESULT exec_setdirty(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_setdirty(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); TRACE("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(!in) if(!in)
return S_OK; return S_OK;
if(V_VT(in) == VT_BOOL) if(V_VT(in) == VT_BOOL)
set_dirty(This->doc_node->browser, V_BOOL(in)); set_dirty(doc->browser, V_BOOL(in));
else else
FIXME("unsupported arg %s\n", debugstr_variant(in)); FIXME("unsupported arg %s\n", debugstr_variant(in));
return S_OK; return S_OK;
} }
static HRESULT query_edit_status(HTMLDocument *This, OLECMD *cmd) static HRESULT query_edit_status(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
switch(cmd->cmdID) { switch(cmd->cmdID) {
case IDM_DELETE: case IDM_DELETE:
TRACE("CGID_MSHTML: IDM_DELETE\n"); TRACE("CGID_MSHTML: IDM_DELETE\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_FONTNAME: case IDM_FONTNAME:
TRACE("CGID_MSHTML: IDM_FONTNAME\n"); TRACE("CGID_MSHTML: IDM_FONTNAME\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_FONTSIZE: case IDM_FONTSIZE:
TRACE("CGID_MSHTML: IDM_FONTSIZE\n"); TRACE("CGID_MSHTML: IDM_FONTSIZE\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_BOLD: case IDM_BOLD:
TRACE("CGID_MSHTML: IDM_BOLD\n"); TRACE("CGID_MSHTML: IDM_BOLD\n");
cmd->cmdf = query_ns_edit_status(This, NSCMD_BOLD); cmd->cmdf = query_ns_edit_status(doc, NSCMD_BOLD);
break; break;
case IDM_FORECOLOR: case IDM_FORECOLOR:
TRACE("CGID_MSHTML: IDM_FORECOLOR\n"); TRACE("CGID_MSHTML: IDM_FORECOLOR\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_ITALIC: case IDM_ITALIC:
TRACE("CGID_MSHTML: IDM_ITALIC\n"); TRACE("CGID_MSHTML: IDM_ITALIC\n");
cmd->cmdf = query_ns_edit_status(This, NSCMD_ITALIC); cmd->cmdf = query_ns_edit_status(doc, NSCMD_ITALIC);
break; break;
case IDM_UNDERLINE: case IDM_UNDERLINE:
TRACE("CGID_MSHTML: IDM_UNDERLINE\n"); TRACE("CGID_MSHTML: IDM_UNDERLINE\n");
cmd->cmdf = query_ns_edit_status(This, NSCMD_UNDERLINE); cmd->cmdf = query_ns_edit_status(doc, NSCMD_UNDERLINE);
break; break;
case IDM_HORIZONTALLINE: case IDM_HORIZONTALLINE:
TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n"); TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_ORDERLIST: case IDM_ORDERLIST:
TRACE("CGID_MSHTML: IDM_ORDERLIST\n"); TRACE("CGID_MSHTML: IDM_ORDERLIST\n");
cmd->cmdf = query_ns_edit_status(This, NSCMD_OL); cmd->cmdf = query_ns_edit_status(doc, NSCMD_OL);
break; break;
case IDM_UNORDERLIST: case IDM_UNORDERLIST:
TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n"); TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
cmd->cmdf = query_ns_edit_status(This, NSCMD_UL); cmd->cmdf = query_ns_edit_status(doc, NSCMD_UL);
break; break;
case IDM_INDENT: case IDM_INDENT:
TRACE("CGID_MSHTML: IDM_INDENT\n"); TRACE("CGID_MSHTML: IDM_INDENT\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_OUTDENT: case IDM_OUTDENT:
TRACE("CGID_MSHTML: IDM_OUTDENT\n"); TRACE("CGID_MSHTML: IDM_OUTDENT\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
case IDM_HYPERLINK: case IDM_HYPERLINK:
TRACE("CGID_MSHTML: IDM_HYPERLINK\n"); TRACE("CGID_MSHTML: IDM_HYPERLINK\n");
cmd->cmdf = query_ns_edit_status(This, NULL); cmd->cmdf = query_ns_edit_status(doc, NULL);
break; break;
} }
@ -1098,7 +1072,7 @@ static INT_PTR CALLBACK hyperlink_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LP
} }
} }
static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_hyperlink(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
nsAString href_str, ns_url; nsAString href_str, ns_url;
nsIHTMLEditor *html_editor; nsIHTMLEditor *html_editor;
@ -1112,7 +1086,7 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
static const WCHAR aW[] = {'a',0}; static const WCHAR aW[] = {'a',0};
static const WCHAR hrefW[] = {'h','r','e','f',0}; static const WCHAR hrefW[] = {'h','r','e','f',0};
TRACE("%p, 0x%x, %p, %p\n", This, cmdexecopt, in, out); TRACE("%p, 0x%x, %p, %p\n", doc, cmdexecopt, in, out);
if (cmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER) if (cmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER)
{ {
@ -1130,17 +1104,17 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
return OLECMDERR_E_CANCELED; return OLECMDERR_E_CANCELED;
} }
if(!This->doc_node->nsdoc) { if(!doc->nsdoc) {
WARN("NULL nsdoc\n"); WARN("NULL nsdoc\n");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
nsselection = get_ns_selection(This); nsselection = get_ns_selection(doc);
if (!nsselection) if (!nsselection)
return E_FAIL; return E_FAIL;
/* create an element for the link */ /* create an element for the link */
create_nselem(This->doc_node, aW, &anchor_elem); create_nselem(doc, aW, &anchor_elem);
nsAString_InitDepend(&href_str, hrefW); nsAString_InitDepend(&href_str, hrefW);
nsAString_InitDepend(&ns_url, url); nsAString_InitDepend(&ns_url, url);
@ -1154,7 +1128,7 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
nsIDOMNode *unused_node; nsIDOMNode *unused_node;
nsIDOMText *text_node; nsIDOMText *text_node;
nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &ns_url, &text_node); nsIDOMHTMLDocument_CreateTextNode(doc->nsdoc, &ns_url, &text_node);
/* wrap the <a> tags around the text element */ /* wrap the <a> tags around the text element */
nsIDOMElement_AppendChild(anchor_elem, (nsIDOMNode*)text_node, &unused_node); nsIDOMElement_AppendChild(anchor_elem, (nsIDOMNode*)text_node, &unused_node);
@ -1164,7 +1138,7 @@ static HRESULT exec_hyperlink(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
nsAString_Finish(&ns_url); nsAString_Finish(&ns_url);
nsIEditor_QueryInterface(This->doc_obj->nscontainer->editor, &IID_nsIHTMLEditor, (void **)&html_editor); nsIEditor_QueryInterface(doc->browser->editor, &IID_nsIHTMLEditor, (void **)&html_editor);
if (html_editor) { if (html_editor) {
nsresult nsres; nsresult nsres;
@ -1216,7 +1190,7 @@ void init_editor(HTMLDocument *This)
{ {
update_doc(This->doc_obj, UPDATE_UI); update_doc(This->doc_obj, UPDATE_UI);
set_ns_fontname(This, "Times New Roman"); set_ns_fontname(This->doc_node, "Times New Roman");
} }
HRESULT browser_is_dirty(GeckoBrowser *browser) HRESULT browser_is_dirty(GeckoBrowser *browser)

View File

@ -1115,8 +1115,8 @@ HRESULT elem_unique_id(unsigned id, BSTR *p) DECLSPEC_HIDDEN;
/* commands */ /* commands */
typedef struct { typedef struct {
DWORD id; DWORD id;
HRESULT (*query)(HTMLDocument*,OLECMD*); HRESULT (*query)(HTMLDocumentNode*,OLECMD*);
HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*); HRESULT (*exec)(HTMLDocumentNode*,DWORD,VARIANT*,VARIANT*);
} cmdtable_t; } cmdtable_t;
extern const cmdtable_t editmode_cmds[] DECLSPEC_HIDDEN; extern const cmdtable_t editmode_cmds[] DECLSPEC_HIDDEN;
@ -1137,9 +1137,9 @@ HRESULT do_query_service(IUnknown*,REFGUID,REFIID,void**) DECLSPEC_HIDDEN;
HRESULT setup_edit_mode(HTMLDocumentObj*) DECLSPEC_HIDDEN; HRESULT setup_edit_mode(HTMLDocumentObj*) DECLSPEC_HIDDEN;
void init_editor(HTMLDocument*) DECLSPEC_HIDDEN; void init_editor(HTMLDocument*) DECLSPEC_HIDDEN;
void handle_edit_event(HTMLDocumentNode*,nsIDOMEvent*) DECLSPEC_HIDDEN; void handle_edit_event(HTMLDocumentNode*,nsIDOMEvent*) DECLSPEC_HIDDEN;
HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN; HRESULT editor_exec_copy(HTMLDocumentNode*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN; HRESULT editor_exec_cut(HTMLDocumentNode*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN; HRESULT editor_exec_paste(HTMLDocumentNode*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
void handle_edit_load(HTMLDocument*) DECLSPEC_HIDDEN; void handle_edit_load(HTMLDocument*) DECLSPEC_HIDDEN;
HRESULT browser_is_dirty(GeckoBrowser*) DECLSPEC_HIDDEN; HRESULT browser_is_dirty(GeckoBrowser*) DECLSPEC_HIDDEN;
void set_dirty(GeckoBrowser*,VARIANT_BOOL) DECLSPEC_HIDDEN; void set_dirty(GeckoBrowser*,VARIANT_BOOL) DECLSPEC_HIDDEN;

View File

@ -63,13 +63,13 @@ void do_ns_command(HTMLDocumentNode *doc, const char *cmd, nsICommandParams *nsp
nsICommandManager_Release(cmdmgr); nsICommandManager_Release(cmdmgr);
} }
static nsIClipboardCommands *get_clipboard_commands(HTMLDocument *doc) static nsIClipboardCommands *get_clipboard_commands(HTMLDocumentNode *doc)
{ {
nsIClipboardCommands *clipboard_commands; nsIClipboardCommands *clipboard_commands;
nsIDocShell *doc_shell; nsIDocShell *doc_shell;
nsresult nsres; nsresult nsres;
nsres = get_nsinterface((nsISupports*)doc->window->nswindow, &IID_nsIDocShell, (void**)&doc_shell); nsres = get_nsinterface((nsISupports*)doc->basedoc.window->nswindow, &IID_nsIDocShell, (void**)&doc_shell);
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("Could not get nsIDocShell interface\n"); ERR("Could not get nsIDocShell interface\n");
return NULL; return NULL;
@ -94,33 +94,33 @@ static inline HTMLDocument *impl_from_IOleCommandTarget(IOleCommandTarget *iface
return CONTAINING_RECORD(iface, HTMLDocument, IOleCommandTarget_iface); return CONTAINING_RECORD(iface, HTMLDocument, IOleCommandTarget_iface);
} }
static HRESULT exec_open(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_open(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_new(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_new(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_save(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_save(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_save_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_save_as(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_save_copy_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_save_copy_as(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -236,21 +236,18 @@ static void set_default_templates(nsIPrintSettings *settings)
} }
static HRESULT exec_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_print(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
nsIWebBrowserPrint *nsprint; nsIWebBrowserPrint *nsprint;
nsIPrintSettings *settings; nsIPrintSettings *settings;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%d %s %p)\n", This, nCmdexecopt, debugstr_variant(pvaIn), pvaOut); TRACE("(%p)->(%d %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
if(pvaOut) if(pvaOut)
FIXME("unsupported pvaOut\n"); FIXME("unsupported pvaOut\n");
if(!This->doc_obj->nscontainer) nsres = get_nsinterface((nsISupports*)doc->browser->webbrowser, &IID_nsIWebBrowserPrint,
return S_OK;
nsres = get_nsinterface((nsISupports*)This->doc_obj->nscontainer->webbrowser, &IID_nsIWebBrowserPrint,
(void**)&nsprint); (void**)&nsprint);
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("Could not get nsIWebBrowserPrint: %08x\n", nsres); ERR("Could not get nsIWebBrowserPrint: %08x\n", nsres);
@ -321,73 +318,71 @@ static HRESULT exec_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn,
return S_OK; return S_OK;
} }
static HRESULT exec_print_preview(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_print_preview(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_page_setup(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_spell(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_spell(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_properties(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_properties(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_cut(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_cut(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_copy(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_copy(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
TRACE("(%p)->(%d %s %p)\n", This, nCmdexecopt, debugstr_variant(pvaIn), pvaOut); TRACE("(%p)->(%d %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
do_ns_command(This->doc_node, NSCMD_COPY, NULL); do_ns_command(doc, NSCMD_COPY, NULL);
return S_OK; return S_OK;
} }
static HRESULT exec_paste(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_paste(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_paste_special(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_paste_special(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_undo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_undo(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_rendo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_rendo(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_select_all(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_select_all(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *in, VARIANT *out)
{ {
HTMLDocumentNode *doc = This->doc_node; TRACE("(%p)\n", doc);
TRACE("(%p)\n", This);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
@ -400,21 +395,21 @@ static HRESULT exec_select_all(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *i
return S_OK; return S_OK;
} }
static HRESULT exec_clear_selection(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_clear_selection(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_zoom(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_get_zoom_range(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_get_zoom_range(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -451,17 +446,24 @@ static void refresh_destr(task_t *_task)
heap_free(task); heap_free(task);
} }
static HRESULT exec_refresh(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_refresh(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
HTMLDocumentObj *doc_obj;
refresh_task_t *task; refresh_task_t *task;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%d %s %p)\n", This, nCmdexecopt, debugstr_variant(pvaIn), pvaOut); TRACE("(%p)->(%d %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
if(This->doc_obj->client) { if(doc != doc->browser->doc->basedoc.doc_node) {
FIXME("Unsupported on frame documents\n");
return E_NOTIMPL;
}
doc_obj = doc->browser->doc;
if(doc_obj->client) {
IOleCommandTarget *olecmd; IOleCommandTarget *olecmd;
hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, (void**)&olecmd); hres = IOleClientSite_QueryInterface(doc_obj->client, &IID_IOleCommandTarget, (void**)&olecmd);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = IOleCommandTarget_Exec(olecmd, &CGID_DocHostCommandHandler, 2300, nCmdexecopt, pvaIn, pvaOut); hres = IOleCommandTarget_Exec(olecmd, &CGID_DocHostCommandHandler, 2300, nCmdexecopt, pvaIn, pvaOut);
IOleCommandTarget_Release(olecmd); IOleCommandTarget_Release(olecmd);
@ -470,52 +472,52 @@ static HRESULT exec_refresh(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaI
} }
} }
if(!This->window) if(!doc->basedoc.window)
return E_UNEXPECTED; return E_UNEXPECTED;
task = heap_alloc(sizeof(*task)); task = heap_alloc(sizeof(*task));
if(!task) if(!task)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface); IHTMLWindow2_AddRef(&doc->basedoc.window->base.IHTMLWindow2_iface);
task->window = This->window; task->window = doc->basedoc.window;
return push_task(&task->header, refresh_proc, refresh_destr, This->window->task_magic); return push_task(&task->header, refresh_proc, refresh_destr, doc->basedoc.window->task_magic);
} }
static HRESULT exec_stop(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_stop(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_stop_download(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_stop_download(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_find(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_find(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_delete(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_delete(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_enable_interaction(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_enable_interaction(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_on_unload(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_on_unload(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
TRACE("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); TRACE("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
/* Tests show that we have nothing more to do here */ /* Tests show that we have nothing more to do here */
@ -527,39 +529,39 @@ static HRESULT exec_on_unload(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pv
return S_OK; return S_OK;
} }
static HRESULT exec_show_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_show_page_setup(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_show_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_show_print(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_close(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_close(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_set_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_set_print_template(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_get_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_get_print_template(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
FIXME("(%p)->(%d %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut); FIXME("(%p)->(%d %p %p)\n", doc, nCmdexecopt, pvaIn, pvaOut);
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT exec_optical_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) static HRESULT exec_optical_zoom(HTMLDocumentNode *doc, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{ {
TRACE("(%p)->(%d %s %p)\n", This, nCmdexecopt, debugstr_variant(pvaIn), pvaOut); TRACE("(%p)->(%d %s %p)\n", doc, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
if(pvaIn && V_VT(pvaIn) != VT_I4) { if(pvaIn && V_VT(pvaIn) != VT_I4) {
FIXME("Unsupported argument %s\n", debugstr_variant(pvaIn)); FIXME("Unsupported argument %s\n", debugstr_variant(pvaIn));
@ -567,50 +569,50 @@ static HRESULT exec_optical_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT
} }
if(pvaIn) if(pvaIn)
set_viewer_zoom(This->doc_obj->nscontainer, (float)V_I4(pvaIn)/100); set_viewer_zoom(doc->browser, (float)V_I4(pvaIn)/100);
if(pvaOut) { if(pvaOut) {
V_VT(pvaOut) = VT_I4; V_VT(pvaOut) = VT_I4;
V_I4(pvaOut) = get_viewer_zoom(This->doc_obj->nscontainer)*100; V_I4(pvaOut) = get_viewer_zoom(doc->browser) * 100;
} }
return S_OK; return S_OK;
} }
static HRESULT query_mshtml_copy(HTMLDocument *This, OLECMD *cmd) static HRESULT query_mshtml_copy(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
FIXME("(%p)\n", This); FIXME("(%p)\n", doc);
cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED; cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED;
return S_OK; return S_OK;
} }
static HRESULT exec_mshtml_copy(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_mshtml_copy(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); TRACE("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(This->doc_node->browser->usermode == EDITMODE) if(doc->browser->usermode == EDITMODE)
return editor_exec_copy(This, cmdexecopt, in, out); return editor_exec_copy(doc, cmdexecopt, in, out);
do_ns_command(This->doc_node, NSCMD_COPY, NULL); do_ns_command(doc, NSCMD_COPY, NULL);
return S_OK; return S_OK;
} }
static HRESULT query_mshtml_cut(HTMLDocument *This, OLECMD *cmd) static HRESULT query_mshtml_cut(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
FIXME("(%p)\n", This); FIXME("(%p)\n", doc);
cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED; cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED;
return S_OK; return S_OK;
} }
static HRESULT exec_mshtml_cut(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_mshtml_cut(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
nsIClipboardCommands *clipboard_commands; nsIClipboardCommands *clipboard_commands;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); TRACE("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(This->doc_node->browser->usermode == EDITMODE) if(doc->browser->usermode == EDITMODE)
return editor_exec_cut(This, cmdexecopt, in, out); return editor_exec_cut(doc, cmdexecopt, in, out);
clipboard_commands = get_clipboard_commands(This); clipboard_commands = get_clipboard_commands(doc);
if(!clipboard_commands) if(!clipboard_commands)
return E_UNEXPECTED; return E_UNEXPECTED;
@ -624,24 +626,24 @@ static HRESULT exec_mshtml_cut(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in
return S_OK; return S_OK;
} }
static HRESULT query_mshtml_paste(HTMLDocument *This, OLECMD *cmd) static HRESULT query_mshtml_paste(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
FIXME("(%p)\n", This); FIXME("(%p)\n", doc);
cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED; cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED;
return S_OK; return S_OK;
} }
static HRESULT exec_mshtml_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_mshtml_paste(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
nsIClipboardCommands *clipboard_commands; nsIClipboardCommands *clipboard_commands;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); TRACE("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(This->doc_node->browser->usermode == EDITMODE) if(doc->browser->usermode == EDITMODE)
return editor_exec_paste(This, cmdexecopt, in, out); return editor_exec_paste(doc, cmdexecopt, in, out);
clipboard_commands = get_clipboard_commands(This); clipboard_commands = get_clipboard_commands(doc);
if(!clipboard_commands) if(!clipboard_commands)
return E_UNEXPECTED; return E_UNEXPECTED;
@ -655,52 +657,52 @@ static HRESULT exec_mshtml_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *
return S_OK; return S_OK;
} }
static HRESULT query_selall_status(HTMLDocument *This, OLECMD *cmd) static HRESULT query_selall_status(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
TRACE("(%p)->(%p)\n", This, cmd); TRACE("(%p)->(%p)\n", doc, cmd);
cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED; cmd->cmdf = OLECMDF_SUPPORTED|OLECMDF_ENABLED;
return S_OK; return S_OK;
} }
static HRESULT exec_browsemode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_browsemode(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
WARN("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); WARN("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
This->doc_node->browser->usermode = BROWSEMODE; doc->browser->usermode = BROWSEMODE;
return S_OK; return S_OK;
} }
static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_editmode(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); TRACE("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
if(in || out) if(in || out)
FIXME("unsupported args\n"); FIXME("unsupported args\n");
return setup_edit_mode(This->doc_obj); return setup_edit_mode(doc->browser->doc);
} }
static HRESULT exec_htmleditmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_htmleditmode(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
FIXME("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); FIXME("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
return S_OK; return S_OK;
} }
static HRESULT exec_baselinefont3(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) static HRESULT exec_baselinefont3(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
FIXME("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); FIXME("(%p)->(%08x %p %p)\n", doc, cmdexecopt, in, out);
return S_OK; return S_OK;
} }
static HRESULT exec_respectvisibility_indesign(HTMLDocument *This, DWORD cmdexecopt, static HRESULT exec_respectvisibility_indesign(HTMLDocumentNode *doc, DWORD cmdexecopt,
VARIANT *in, VARIANT *out) VARIANT *in, VARIANT *out)
{ {
TRACE("(%p)->(%x %s %p)\n", This, cmdexecopt, debugstr_variant(in), out); TRACE("(%p)->(%x %s %p)\n", doc, cmdexecopt, debugstr_variant(in), out);
/* This is turned on by default in Gecko. */ /* This is turned on by default in Gecko. */
if(!in || V_VT(in) != VT_BOOL || !V_BOOL(in)) if(!in || V_VT(in) != VT_BOOL || !V_BOOL(in))
@ -709,7 +711,7 @@ static HRESULT exec_respectvisibility_indesign(HTMLDocument *This, DWORD cmdexec
return S_OK; return S_OK;
} }
static HRESULT query_enabled_stub(HTMLDocument *This, OLECMD *cmd) static HRESULT query_enabled_stub(HTMLDocumentNode *doc, OLECMD *cmd)
{ {
switch(cmd->cmdID) { switch(cmd->cmdID) {
case IDM_PRINT: case IDM_PRINT:
@ -731,7 +733,7 @@ static HRESULT query_enabled_stub(HTMLDocument *This, OLECMD *cmd)
static const struct { static const struct {
OLECMDF cmdf; OLECMDF cmdf;
HRESULT (*func)(HTMLDocument*,DWORD,VARIANT*,VARIANT*); HRESULT (*func)(HTMLDocumentNode*,DWORD,VARIANT*,VARIANT*);
} exec_table[] = { } exec_table[] = {
{0}, {0},
{ OLECMDF_SUPPORTED, exec_open }, /* OLECMDID_OPEN */ { OLECMDF_SUPPORTED, exec_open }, /* OLECMDID_OPEN */
@ -811,7 +813,7 @@ static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
return htmldoc_release(This); return htmldoc_release(This);
} }
static HRESULT query_from_table(HTMLDocument *This, const cmdtable_t *cmdtable, OLECMD *cmd) static HRESULT query_from_table(HTMLDocumentNode *doc, const cmdtable_t *cmdtable, OLECMD *cmd)
{ {
const cmdtable_t *iter = cmdtable; const cmdtable_t *iter = cmdtable;
@ -823,7 +825,7 @@ static HRESULT query_from_table(HTMLDocument *This, const cmdtable_t *cmdtable,
if(!iter->id || !iter->query) if(!iter->id || !iter->query)
return OLECMDERR_E_NOTSUPPORTED; return OLECMDERR_E_NOTSUPPORTED;
return iter->query(This, cmd); return iter->query(doc, cmd);
} }
static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup, static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
@ -836,6 +838,8 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
if(pCmdText) if(pCmdText)
FIXME("Unsupported pCmdText\n"); FIXME("Unsupported pCmdText\n");
if(!This->doc_node->browser)
return E_UNEXPECTED;
if(!cCmds) if(!cCmds)
return S_OK; return S_OK;
@ -880,9 +884,9 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
ULONG i; ULONG i;
for(i=0; i<cCmds; i++) { for(i=0; i<cCmds; i++) {
hres = query_from_table(This, base_cmds, prgCmds+i); hres = query_from_table(This->doc_node, base_cmds, prgCmds+i);
if(hres == OLECMDERR_E_NOTSUPPORTED) if(hres == OLECMDERR_E_NOTSUPPORTED)
hres = query_from_table(This, editmode_cmds, prgCmds+i); hres = query_from_table(This->doc_node, editmode_cmds, prgCmds+i);
if(hres == OLECMDERR_E_NOTSUPPORTED) if(hres == OLECMDERR_E_NOTSUPPORTED)
FIXME("CGID_MSHTML: unsupported cmdID %d\n", prgCmds[i].cmdID); FIXME("CGID_MSHTML: unsupported cmdID %d\n", prgCmds[i].cmdID);
} }
@ -894,7 +898,7 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
return OLECMDERR_E_UNKNOWNGROUP; return OLECMDERR_E_UNKNOWNGROUP;
} }
static HRESULT exec_from_table(HTMLDocument *This, const cmdtable_t *cmdtable, DWORD cmdid, static HRESULT exec_from_table(HTMLDocumentNode *doc, const cmdtable_t *cmdtable, DWORD cmdid,
DWORD cmdexecopt, VARIANT *in, VARIANT *out) DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{ {
const cmdtable_t *iter = cmdtable; const cmdtable_t *iter = cmdtable;
@ -905,7 +909,7 @@ static HRESULT exec_from_table(HTMLDocument *This, const cmdtable_t *cmdtable, D
if(!iter->id || !iter->exec) if(!iter->id || !iter->exec)
return OLECMDERR_E_NOTSUPPORTED; return OLECMDERR_E_NOTSUPPORTED;
return iter->exec(This, cmdexecopt, in, out); return iter->exec(doc, cmdexecopt, in, out);
} }
static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup, static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
@ -913,13 +917,16 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
{ {
HTMLDocument *This = impl_from_IOleCommandTarget(iface); HTMLDocument *This = impl_from_IOleCommandTarget(iface);
if(!This->doc_node->browser)
return E_UNEXPECTED;
if(!pguidCmdGroup) { if(!pguidCmdGroup) {
if(nCmdID < OLECMDID_OPEN || nCmdID >= ARRAY_SIZE(exec_table) || !exec_table[nCmdID].func) { if(nCmdID < OLECMDID_OPEN || nCmdID >= ARRAY_SIZE(exec_table) || !exec_table[nCmdID].func) {
WARN("Unsupported cmdID = %d\n", nCmdID); WARN("Unsupported cmdID = %d\n", nCmdID);
return OLECMDERR_E_NOTSUPPORTED; return OLECMDERR_E_NOTSUPPORTED;
} }
return exec_table[nCmdID].func(This, nCmdexecopt, pvaIn, pvaOut); return exec_table[nCmdID].func(This->doc_node, nCmdexecopt, pvaIn, pvaOut);
}else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) { }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
FIXME("unsupported nCmdID %d of CGID_Explorer group\n", nCmdID); FIXME("unsupported nCmdID %d of CGID_Explorer group\n", nCmdID);
TRACE("%p %p\n", pvaIn, pvaOut); TRACE("%p %p\n", pvaIn, pvaOut);
@ -928,9 +935,9 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
FIXME("unsupported nCmdID %d of CGID_ShellDocView group\n", nCmdID); FIXME("unsupported nCmdID %d of CGID_ShellDocView group\n", nCmdID);
return OLECMDERR_E_NOTSUPPORTED; return OLECMDERR_E_NOTSUPPORTED;
}else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) { }else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
HRESULT hres = exec_from_table(This, base_cmds, nCmdID, nCmdexecopt, pvaIn, pvaOut); HRESULT hres = exec_from_table(This->doc_node, base_cmds, nCmdID, nCmdexecopt, pvaIn, pvaOut);
if(hres == OLECMDERR_E_NOTSUPPORTED) if(hres == OLECMDERR_E_NOTSUPPORTED)
hres = exec_from_table(This, editmode_cmds, nCmdID, hres = exec_from_table(This->doc_node, editmode_cmds, nCmdID,
nCmdexecopt, pvaIn, pvaOut); nCmdexecopt, pvaIn, pvaOut);
if(hres == OLECMDERR_E_NOTSUPPORTED) if(hres == OLECMDERR_E_NOTSUPPORTED)
FIXME("unsupported nCmdID %d of CGID_MSHTML group\n", nCmdID); FIXME("unsupported nCmdID %d of CGID_MSHTML group\n", nCmdID);