mshtml: Use DOM designMode to switch to editor mode.
This commit is contained in:
parent
7cdad62b97
commit
80f0f35c50
|
@ -57,6 +57,26 @@ static void window_set_docnode(HTMLWindow *window, HTMLDocumentNode *doc_node)
|
|||
if(doc_node)
|
||||
htmldoc_addref(&doc_node->basedoc);
|
||||
}
|
||||
|
||||
if(doc_node && window->doc_obj->usermode == EDITMODE) {
|
||||
nsIDOMNSHTMLDocument *nshtmldoc;
|
||||
nsAString mode_str;
|
||||
nsresult nsres;
|
||||
|
||||
static const PRUnichar onW[] = {'o','n',0};
|
||||
|
||||
nsres = nsIDOMHTMLDocument_QueryInterface(doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nshtmldoc);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
nsAString_Init(&mode_str, onW);
|
||||
nsres = nsIDOMNSHTMLDocument_SetDesignMode(nshtmldoc, &mode_str);
|
||||
nsAString_Finish(&mode_str);
|
||||
nsIDOMNSHTMLDocument_Release(nshtmldoc);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("SetDesignMode failed: %08x\n", nsres);
|
||||
}else {
|
||||
ERR("Could not get nsIDOMNSHTMLDocument interface: %08x\n", nsres);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMWindow *get_nsdoc_window(nsIDOMDocument *nsdoc)
|
||||
|
|
|
@ -843,7 +843,6 @@ void update_title(HTMLDocumentObj*);
|
|||
|
||||
/* editor */
|
||||
void init_editor(HTMLDocument*);
|
||||
void set_ns_editmode(NSContainer*);
|
||||
void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
|
||||
HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
|
||||
HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
|
||||
|
|
|
@ -767,46 +767,6 @@ void get_editor_controller(NSContainer *This)
|
|||
}
|
||||
}
|
||||
|
||||
void set_ns_editmode(NSContainer *This)
|
||||
{
|
||||
nsIEditingSession *editing_session = NULL;
|
||||
nsIURIContentListener *listener = NULL;
|
||||
nsIDOMWindow *dom_window = NULL;
|
||||
nsresult nsres;
|
||||
|
||||
nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsIEditingSession,
|
||||
(void**)&editing_session);
|
||||
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, TRUE, TRUE);
|
||||
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");
|
||||
|
|
|
@ -616,9 +616,6 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in,
|
|||
IDocHostUIHandler_HideUI(This->doc_obj->hostui);
|
||||
}
|
||||
|
||||
if(This->doc_obj->nscontainer)
|
||||
set_ns_editmode(This->doc_obj->nscontainer);
|
||||
|
||||
if(This->doc_obj->ui_active) {
|
||||
RECT rcBorderWidths;
|
||||
|
||||
|
|
Loading…
Reference in New Issue