Commit aa4d9190 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Move user mode to GeckoBrowser.

parent 98db6a0d
......@@ -95,19 +95,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
static const WCHAR fontW[] = {'f','o','n','t',0};
static const WCHAR sizeW[] = {'s','i','z','e',0};
void set_dirty(HTMLDocument *This, VARIANT_BOOL dirty)
void set_dirty(GeckoBrowser *browser, VARIANT_BOOL dirty)
{
nsresult nsres;
if(This->doc_obj->usermode != EDITMODE || !This->doc_obj->nscontainer || !This->doc_obj->nscontainer->editor)
if(browser->usermode != EDITMODE || !browser->editor)
return;
if(dirty) {
nsres = nsIEditor_IncrementModificationCount(This->doc_obj->nscontainer->editor, 1);
nsres = nsIEditor_IncrementModificationCount(browser->editor, 1);
if(NS_FAILED(nsres))
ERR("IncrementModificationCount failed: %08x\n", nsres);
}else {
nsres = nsIEditor_ResetModificationCount(This->doc_obj->nscontainer->editor);
nsres = nsIEditor_ResetModificationCount(browser->editor);
if(NS_FAILED(nsres))
ERR("ResetModificationCount failed: %08x\n", nsres);
}
......@@ -149,7 +149,7 @@ static DWORD query_ns_edit_status(HTMLDocument *This, const char *nscmd)
nsICommandParams *nsparam;
cpp_bool b = FALSE;
if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
return OLECMDF_SUPPORTED;
if(This->doc_obj->nscontainer && nscmd) {
......@@ -186,7 +186,7 @@ static DWORD query_align_status(HTMLDocument *This, const WCHAR *align)
cpp_bool b;
nsresult nsres;
if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
return OLECMDF_SUPPORTED;
nsAString_Init(&justify_str, align);
......@@ -376,7 +376,7 @@ static void set_font_size(HTMLDocument *This, LPCWSTR size)
nsAString_Finish(&size_str);
set_dirty(This, VARIANT_TRUE);
set_dirty(This->doc_node->browser, VARIANT_TRUE);
}
static void handle_arrow_key(HTMLDocument *This, nsIDOMEvent *event, nsIDOMKeyEvent *key_event, const char * const cmds[4])
......@@ -691,7 +691,7 @@ static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd)
case IDM_JUSTIFYLEFT:
TRACE("(%p) IDM_JUSTIFYLEFT\n", This);
/* FIXME: We should set OLECMDF_LATCHED only if it's set explicitly. */
if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
if(This->doc_node->browser->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
cmd->cmdf = OLECMDF_SUPPORTED;
else
cmd->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
......@@ -925,7 +925,7 @@ static HRESULT exec_setdirty(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
return S_OK;
if(V_VT(in) == VT_BOOL)
set_dirty(This, V_BOOL(in));
set_dirty(This->doc_node->browser, V_BOOL(in));
else
FIXME("unsupported arg %s\n", debugstr_variant(in));
......@@ -1240,10 +1240,10 @@ HRESULT setup_edit_mode(HTMLDocumentObj *doc)
IMoniker *mon;
HRESULT hres;
if(doc->usermode == EDITMODE)
if(doc->nscontainer->usermode == EDITMODE)
return S_OK;
doc->usermode = EDITMODE;
doc->nscontainer->usermode = EDITMODE;
if(doc->basedoc.window->mon) {
CLSID clsid = IID_NULL;
......
......@@ -5458,7 +5458,6 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii
doc->basedoc.doc_obj = doc;
doc->is_mhtml = is_mhtml;
doc->usermode = UNKNOWN_USERMODE;
doc->task_magic = get_task_target_magic();
HTMLDocument_View_Init(doc);
......
......@@ -3641,7 +3641,7 @@ HRESULT update_window_doc(HTMLInnerWindow *window)
if(FAILED(hres))
return hres;
if(outer_window->doc_obj->usermode == EDITMODE) {
if(outer_window->browser->usermode == EDITMODE) {
nsAString mode_str;
nsresult nsres;
......
......@@ -683,7 +683,6 @@ struct HTMLDocumentObj {
BOOL has_popup;
INT download_state;
USERMODE usermode;
LPWSTR mime;
DWORD update;
......@@ -727,6 +726,7 @@ struct GeckoBrowser {
HWND hwnd;
SCRIPTMODE script_mode;
USERMODE usermode;
struct list document_nodes;
struct list outer_windows;
......@@ -1142,7 +1142,7 @@ HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
void handle_edit_load(HTMLDocument*) DECLSPEC_HIDDEN;
HRESULT editor_is_dirty(HTMLDocument*) DECLSPEC_HIDDEN;
void set_dirty(HTMLDocument*,VARIANT_BOOL) DECLSPEC_HIDDEN;
void set_dirty(GeckoBrowser*,VARIANT_BOOL) DECLSPEC_HIDDEN;
extern DWORD mshtml_tls DECLSPEC_HIDDEN;
......
......@@ -262,7 +262,7 @@ static void parse_complete(HTMLDocumentObj *doc)
{
TRACE("(%p)\n", doc);
if(doc->usermode == EDITMODE)
if(doc->nscontainer->usermode == EDITMODE)
init_editor(&doc->basedoc);
call_explorer_69(doc);
......@@ -271,7 +271,7 @@ static void parse_complete(HTMLDocumentObj *doc)
call_property_onchanged(&doc->basedoc.cp_container, 1005);
call_explorer_69(doc);
if(doc->webbrowser && doc->usermode != EDITMODE && !(doc->basedoc.window->load_flags & BINDING_REFRESH))
if(doc->webbrowser && doc->nscontainer->usermode != EDITMODE && !(doc->basedoc.window->load_flags & BINDING_REFRESH))
IDocObjectService_FireNavigateComplete2(doc->doc_object_service, &doc->basedoc.window->base.IHTMLWindow2_iface, 0);
/* FIXME: IE7 calls EnableModelless(TRUE), EnableModelless(FALSE) and sets interactive state here */
......
......@@ -2168,6 +2168,7 @@ HRESULT create_gecko_browser(HTMLDocumentObj *doc, GeckoBrowser **_ret)
ret->doc = doc;
ret->ref = 1;
ret->script_mode = SCRIPTMODE_ACTIVESCRIPT;
ret->usermode = UNKNOWN_USERMODE;
list_init(&ret->document_nodes);
list_init(&ret->outer_windows);
......
......@@ -175,14 +175,14 @@ static nsresult NSAPI handle_keypress(nsIDOMEventListener *iface,
HTMLDocumentNode *doc = This->This->doc;
HTMLDocumentObj *doc_obj;
if(!doc)
if(!doc || !doc->browser)
return NS_ERROR_FAILURE;
doc_obj = doc->basedoc.doc_obj;
TRACE("(%p)->(%p)\n", doc, event);
update_doc(doc_obj, UPDATE_UI);
if(doc_obj->usermode == EDITMODE)
if(doc->browser->usermode == EDITMODE)
handle_edit_event(&doc_obj->basedoc, event);
return NS_OK;
......@@ -198,7 +198,7 @@ static void handle_docobj_load(HTMLDocumentObj *doc)
doc->nscontainer->editor_controller = NULL;
}
if(doc->usermode == EDITMODE)
if(doc->nscontainer->usermode == EDITMODE)
handle_edit_load(&doc->basedoc);
if(doc->client) {
......@@ -262,7 +262,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
update_title(doc_obj);
}
if(doc_obj && doc_obj->usermode!=EDITMODE && doc_obj->doc_object_service
if(doc_obj && doc_obj->nscontainer->usermode != EDITMODE && doc_obj->doc_object_service
&& !(doc->basedoc.window->load_flags & BINDING_REFRESH))
IDocObjectService_FireDocumentComplete(doc_obj->doc_object_service,
&doc->basedoc.window->base.IHTMLWindow2_iface, 0);
......
......@@ -583,7 +583,7 @@ static HRESULT exec_mshtml_copy(HTMLDocument *This, DWORD cmdexecopt, VARIANT *i
{
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out);
if(This->doc_obj->usermode == EDITMODE)
if(This->doc_node->browser->usermode == EDITMODE)
return editor_exec_copy(This, cmdexecopt, in, out);
do_ns_command(This, NSCMD_COPY, NULL);
......@@ -604,7 +604,7 @@ static HRESULT exec_mshtml_cut(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out);
if(This->doc_obj->usermode == EDITMODE)
if(This->doc_node->browser->usermode == EDITMODE)
return editor_exec_cut(This, cmdexecopt, in, out);
clipboard_commands = get_clipboard_commands(This);
......@@ -635,7 +635,7 @@ static HRESULT exec_mshtml_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *
TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out);
if(This->doc_obj->usermode == EDITMODE)
if(This->doc_node->browser->usermode == EDITMODE)
return editor_exec_paste(This, cmdexecopt, in, out);
clipboard_commands = get_clipboard_commands(This);
......@@ -667,7 +667,7 @@ static HRESULT exec_browsemode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in
if(in || out)
FIXME("unsupported args\n");
This->doc_obj->usermode = BROWSEMODE;
This->doc_node->browser->usermode = BROWSEMODE;
return S_OK;
}
......
......@@ -270,7 +270,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite
if(This->doc_obj->client) {
IOleClientSite_Release(This->doc_obj->client);
This->doc_obj->client = NULL;
This->doc_obj->usermode = UNKNOWN_USERMODE;
This->doc_obj->nscontainer->usermode = UNKNOWN_USERMODE;
}
if(This->doc_obj->client_cmdtrg) {
......@@ -433,7 +433,7 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite
OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
}
if(This->doc_obj->usermode == UNKNOWN_USERMODE)
if(This->doc_obj->nscontainer->usermode == UNKNOWN_USERMODE)
IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface, DISPID_AMBIENT_USERMODE);
IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface,
......@@ -886,10 +886,10 @@ static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DIS
if(V_VT(&res) == VT_BOOL) {
if(V_BOOL(&res)) {
This->doc_obj->usermode = BROWSEMODE;
This->doc_obj->nscontainer->usermode = BROWSEMODE;
}else {
FIXME("edit mode is not supported\n");
This->doc_obj->usermode = EDITMODE;
This->doc_obj->nscontainer->usermode = EDITMODE;
}
}else {
FIXME("usermode=%s\n", debugstr_variant(&res));
......
......@@ -230,7 +230,7 @@ static void set_progress_proc(task_t *_task)
IOleCommandTarget_Release(olecmd);
}
if(doc->usermode == EDITMODE && doc->hostui) {
if(doc->nscontainer->usermode == EDITMODE && doc->hostui) {
DOCHOSTUIINFO hostinfo;
memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
......@@ -884,7 +884,7 @@ static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
TRACE("(%p)\n", This);
if(This->doc_obj->usermode == EDITMODE)
if(This->doc_obj->nscontainer->usermode == EDITMODE)
return editor_is_dirty(This);
return S_FALSE;
......@@ -934,7 +934,7 @@ static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, IStream
heap_free(str);
if(fClearDirty)
set_dirty(This, VARIANT_FALSE);
set_dirty(This->doc_obj->nscontainer, VARIANT_FALSE);
return S_OK;
}
......
......@@ -633,7 +633,7 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f
if(This->hostui) {
hres = IDocHostUIHandler_ShowUI(This->hostui,
This->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
This->nscontainer->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
&This->basedoc.IOleInPlaceActiveObject_iface, &This->basedoc.IOleCommandTarget_iface,
This->frame, This->ip_window);
if(FAILED(hres))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment