mshtml: Move setup_ns_editing to nsembed.c.

This commit is contained in:
Jacek Caban 2007-06-10 11:35:11 +02:00 committed by Alexandre Julliard
parent bd71f19ef1
commit 791b868ce7
3 changed files with 50 additions and 49 deletions

View File

@ -383,6 +383,7 @@ typedef struct {
extern const cmdtable_t editmode_cmds[];
/* editor */
void set_ns_editmode(NSContainer*);
void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
extern DWORD mshtml_tls;

View File

@ -580,6 +580,54 @@ void nsnode_to_nsstring(nsIDOMNode *nsdoc, nsAString *str)
nsIContentSerializer_Release(serializer);
}
void set_ns_editmode(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: %08x\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: %08x\n", nsres);
return;
}
nsres = nsIWebBrowser_GetContentDOMWindow(This->webbrowser, &dom_window);
if(NS_FAILED(nsres)) {
ERR("Could not get content DOM window: %08x\n", nsres);
nsIEditingSession_Release(editing_session);
return;
}
nsres = nsIEditingSession_MakeWindowEditable(editing_session, dom_window, NULL, FALSE);
nsIEditingSession_Release(editing_session);
nsIDOMWindow_Release(dom_window);
if(NS_FAILED(nsres)) {
ERR("MakeWindowEditable failed: %08x\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));
}
void close_gecko(void)
{
TRACE("()\n");

View File

@ -511,54 +511,6 @@ static HRESULT exec_browsemode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in
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: %08x\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: %08x\n", nsres);
return;
}
nsres = nsIWebBrowser_GetContentDOMWindow(This->webbrowser, &dom_window);
if(NS_FAILED(nsres)) {
ERR("Could not get content DOM window: %08x\n", nsres);
nsIEditingSession_Release(editing_session);
return;
}
nsres = nsIEditingSession_MakeWindowEditable(editing_session, dom_window, NULL, FALSE);
nsIEditingSession_Release(editing_session);
nsIDOMWindow_Release(dom_window);
if(NS_FAILED(nsres)) {
ERR("MakeWindowEditable failed: %08x\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, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
{
IMoniker *mon;
@ -590,7 +542,7 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
}
if(This->nscontainer)
setup_ns_editing(This->nscontainer);
set_ns_editmode(This->nscontainer);
hres = CreateURLMoniker(NULL, wszAboutBlank, &mon);
if(FAILED(hres)) {