Jacek Caban : mshtml: Use DOM designMode to switch to editor mode.

Alexandre Julliard julliard at winehq.org
Wed Apr 14 11:24:55 CDT 2010


Module: wine
Branch: master
Commit: 80f0f35c504feb47e982cac74cb6ec91bb6854c0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=80f0f35c504feb47e982cac74cb6ec91bb6854c0

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Apr 13 20:01:41 2010 +0200

mshtml: Use DOM designMode to switch to editor mode.

---

 dlls/mshtml/htmlwindow.c     |   20 ++++++++++++++++++++
 dlls/mshtml/mshtml_private.h |    1 -
 dlls/mshtml/nsembed.c        |   40 ----------------------------------------
 dlls/mshtml/olecmd.c         |    3 ---
 4 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 2aafaa3..5dbea55 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -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)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 4431d9c..3db8d79 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -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*);
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index f3e43c8..8a59007 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -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");
diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c
index b54f064..4d5967a 100644
--- a/dlls/mshtml/olecmd.c
+++ b/dlls/mshtml/olecmd.c
@@ -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;
 




More information about the wine-cvs mailing list