mshtml: Switch nsWebBrowset to editing mode in exec_editmod.

This commit is contained in:
Jacek Caban 2006-08-17 21:00:55 +02:00 committed by Alexandre Julliard
parent 684b6c24a3
commit e3990ddf7b
2 changed files with 69 additions and 1 deletions

View File

@ -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

View File

@ -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;
}