From e3990ddf7bfce090ca4557dce505634a269512a4 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 17 Aug 2006 21:00:55 +0200 Subject: [PATCH] mshtml: Switch nsWebBrowset to editing mode in exec_editmod. --- dlls/mshtml/nsiface.idl | 17 +++++++++++++ dlls/mshtml/olecmd.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index ee17638cf35..46e0a235eef 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -108,6 +108,7 @@ typedef nsISupports nsIDOMHTMLFormElement; typedef nsISupports nsIDOMHTMLOptionsCollection; typedef nsISupports nsIDOMHTMLCollection; typedef nsISupports nsIDOMRange; +typedef nsISupports nsIEditor; [ object, @@ -1157,6 +1158,22 @@ interface nsIWindowWatcher : nsISupports nsresult SetActiveWindow(nsIDOMWindow *aActiveWindow); } +[ + object, + uuid(d39fd2b4-3978-45d2-a4be-ba448171b61b) +] +interface nsIEditingSession : nsISupports +{ + nsresult GetEditorStatus(PRUint32 *aEditorStatus); + nsresult MakeWindowEditable(nsIDOMWindow *window, const char *aEditorType, + PRBool doAfterUriLoad); + nsresult WindowIsEditable(nsIDOMWindow *window, PRBool *_retval); + nsresult GetEditorForWindow(nsIDOMWindow *window, nsIEditor **_retval); + nsresult SetupEditorOnWindow(nsIDOMWindow *window); + nsresult TearDownEditorOnWindow(nsIDOMWindow *window); + nsresult SetEditorOnControllers(nsIDOMWindow *aWindow, nsIEditor *aEditor); +} + /* * NOTE: * This is a private Wine interface that is implemented by our implementation diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index 1669aaadb38..a95f5b1b529 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -247,11 +247,59 @@ static HRESULT exec_browsemode(HTMLDocument *This) return S_OK; } +static void setup_ns_editing(NSContainer *This) +{ + nsIInterfaceRequestor *iface_req; + nsIEditingSession *editing_session = NULL; + nsIURIContentListener *listener = NULL; + nsIDOMWindow *dom_window = NULL; + nsresult nsres; + + nsres = nsIWebBrowser_QueryInterface(This->webbrowser, + &IID_nsIInterfaceRequestor, (void**)&iface_req); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIInterfaceRequestor: %08lx\n", nsres); + return; + } + + nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsIEditingSession, + (void**)&editing_session); + nsIInterfaceRequestor_Release(iface_req); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIEditingSession: %08lx\n", nsres); + return; + } + + nsres = nsIWebBrowser_GetContentDOMWindow(This->webbrowser, &dom_window); + nsIDOMWindow_Release(dom_window); + if(NS_FAILED(nsres)) { + ERR("Could not get content DOM window: %08lx\n", nsres); + nsIEditingSession_Release(editing_session); + return; + } + + nsres = nsIEditingSession_MakeWindowEditable(editing_session, dom_window, NULL, FALSE); + nsIEditingSession_Release(editing_session); + if(NS_FAILED(nsres)) { + ERR("MakeWindowEditable failed: %08lx\n", nsres); + return; + } + + /* MakeWindowEditable changes WebBrowser's parent URI content listener. + * It seams to be a bug in Gecko. To workaround it we set our content + * listener again and Gecko's one as its parent. + */ + nsIWebBrowser_GetParentURIContentListener(This->webbrowser, &listener); + nsIURIContentListener_SetParentContentListener(NSURICL(This), listener); + nsIURIContentListener_Release(listener); + nsIWebBrowser_SetParentURIContentListener(This->webbrowser, NSURICL(This)); +} + static HRESULT exec_editmode(HTMLDocument *This) { HRESULT hres; - FIXME("(%p)\n", This); + TRACE("(%p)\n", This); This->usermode = EDITMODE; @@ -306,6 +354,9 @@ static HRESULT exec_editmode(HTMLDocument *This) } } + if(This->nscontainer) + setup_ns_editing(This->nscontainer); + return S_OK; }