From 5892a0d82424176db0d4ddcd57412337824cb39a Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Sun, 28 Sep 2003 21:17:24 +0000 Subject: [PATCH] Fix (long broken) editor mode to provide barebones functionality. Update all adamlock addresses to eircom.net. Fix some arcane comments referring to webshell / NGLayout. b=220092 r=blizzard@mozilla.org sr=bzbarsky@mit.edu --- .../activex/src/control/ActiveScriptSite.cpp | 2 +- .../activex/src/control/ActiveScriptSite.h | 2 +- .../activex/src/control/ActiveXTypes.h | 2 +- .../activex/src/control/BrowserDiagnostics.h | 2 +- .../activex/src/control/DropTarget.cpp | 2 +- .../browser/activex/src/control/DropTarget.h | 2 +- .../activex/src/control/HelperAppDlg.cpp | 2 +- .../activex/src/control/HelperAppDlg.h | 3 +- .../activex/src/control/IEHtmlDocument.cpp | 2 +- .../activex/src/control/IEHtmlDocument.h | 2 +- .../browser/activex/src/control/Makefile.in | 2 + .../activex/src/control/MozillaBrowser.cpp | 108 ++++++++---------- .../activex/src/control/MozillaBrowser.h | 10 +- .../activex/src/control/MozillaControl.cpp | 2 +- .../activex/src/control/MozillaControl.idl | 2 +- .../activex/src/control/PropertyDlg.cpp | 2 +- .../browser/activex/src/control/PropertyDlg.h | 2 +- .../browser/activex/src/control/StdAfx.cpp | 2 +- .../browser/activex/src/control/StdAfx.h | 7 +- .../src/control/WebBrowserContainer.cpp | 2 +- .../activex/src/control/WebBrowserContainer.h | 2 +- .../activex/src/control/WindowCreator.cpp | 2 +- .../activex/src/control/WindowCreator.h | 2 +- 23 files changed, 76 insertions(+), 90 deletions(-) diff --git a/embedding/browser/activex/src/control/ActiveScriptSite.cpp b/embedding/browser/activex/src/control/ActiveScriptSite.cpp index 4c453ac8302..1e0e6aaf8a3 100644 --- a/embedding/browser/activex/src/control/ActiveScriptSite.cpp +++ b/embedding/browser/activex/src/control/ActiveScriptSite.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/ActiveScriptSite.h b/embedding/browser/activex/src/control/ActiveScriptSite.h index 2e0c15bbaf8..ff4a7c2b13e 100644 --- a/embedding/browser/activex/src/control/ActiveScriptSite.h +++ b/embedding/browser/activex/src/control/ActiveScriptSite.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/ActiveXTypes.h b/embedding/browser/activex/src/control/ActiveXTypes.h index 6ccfe1a83a1..2ea1162462c 100644 --- a/embedding/browser/activex/src/control/ActiveXTypes.h +++ b/embedding/browser/activex/src/control/ActiveXTypes.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/BrowserDiagnostics.h b/embedding/browser/activex/src/control/BrowserDiagnostics.h index 3b5ce694088..d75a176f082 100644 --- a/embedding/browser/activex/src/control/BrowserDiagnostics.h +++ b/embedding/browser/activex/src/control/BrowserDiagnostics.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/DropTarget.cpp b/embedding/browser/activex/src/control/DropTarget.cpp index 186d2de8ae0..bd46b4bca4b 100644 --- a/embedding/browser/activex/src/control/DropTarget.cpp +++ b/embedding/browser/activex/src/control/DropTarget.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/DropTarget.h b/embedding/browser/activex/src/control/DropTarget.h index 6b347439dae..35baf7bf230 100644 --- a/embedding/browser/activex/src/control/DropTarget.h +++ b/embedding/browser/activex/src/control/DropTarget.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/HelperAppDlg.cpp b/embedding/browser/activex/src/control/HelperAppDlg.cpp index 1bc0dfb98df..012787ea76e 100644 --- a/embedding/browser/activex/src/control/HelperAppDlg.cpp +++ b/embedding/browser/activex/src/control/HelperAppDlg.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/HelperAppDlg.h b/embedding/browser/activex/src/control/HelperAppDlg.h index 418fd0d1871..b1b4f05c744 100644 --- a/embedding/browser/activex/src/control/HelperAppDlg.h +++ b/embedding/browser/activex/src/control/HelperAppDlg.h @@ -20,7 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock + * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/IEHtmlDocument.cpp b/embedding/browser/activex/src/control/IEHtmlDocument.cpp index 69ceccf570a..73e7eaa2145 100644 --- a/embedding/browser/activex/src/control/IEHtmlDocument.cpp +++ b/embedding/browser/activex/src/control/IEHtmlDocument.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/IEHtmlDocument.h b/embedding/browser/activex/src/control/IEHtmlDocument.h index e813d0a69d0..1404b0fbc41 100644 --- a/embedding/browser/activex/src/control/IEHtmlDocument.h +++ b/embedding/browser/activex/src/control/IEHtmlDocument.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/Makefile.in b/embedding/browser/activex/src/control/Makefile.in index cdce31d0319..609729fcd3b 100644 --- a/embedding/browser/activex/src/control/Makefile.in +++ b/embedding/browser/activex/src/control/Makefile.in @@ -56,6 +56,8 @@ REQUIRES = \ helperAppDlg \ exthandler \ mimetype \ + composer \ + commandhandler \ ax_common \ $(NULL) diff --git a/embedding/browser/activex/src/control/MozillaBrowser.cpp b/embedding/browser/activex/src/control/MozillaBrowser.cpp index 5c36202abe7..95a094ea53a 100644 --- a/embedding/browser/activex/src/control/MozillaBrowser.cpp +++ b/embedding/browser/activex/src/control/MozillaBrowser.cpp @@ -21,7 +21,7 @@ * * Contributor(s): * - * Adam Lock + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -180,7 +180,7 @@ CMozillaBrowser::CMozillaBrowser() mBrowserHelperList = NULL; mBrowserHelperListCount = 0; - // Initialise the web shell + // Initialise the web browser Initialize(); } @@ -192,7 +192,7 @@ CMozillaBrowser::~CMozillaBrowser() { NG_TRACE_METHOD(CMozillaBrowser::~CMozillaBrowser); - // Close the web shell + // Close the web browser Terminate(); } @@ -204,10 +204,10 @@ CMozillaBrowser::~CMozillaBrowser() static inline BOOL _IsEqualGUID(REFGUID rguid1, REFGUID rguid2) { return ( - ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] && - ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] && - ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] && - ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]); + ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] && + ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] && + ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] && + ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]); } STDMETHODIMP CMozillaBrowser::InterfaceSupportsErrorInfo(REFIID riid) @@ -411,7 +411,7 @@ LRESULT CMozillaBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& { NG_TRACE_METHOD(CMozillaBrowser::OnCreate); - // Create the NGLayout WebShell + // Create the web browser CreateBrowser(); // TODO create and register a drop target @@ -488,7 +488,7 @@ LRESULT CMozillaBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b rc.left = 0; rc.top = 0; - // Pass resize information down to the WebShell... + // Pass resize information down to the browser... if (mWebBrowserAsWin) { mWebBrowserAsWin->SetPosition(rc.left, rc.top); @@ -956,7 +956,7 @@ LRESULT CMozillaBrowser::OnLinkProperties(WORD wNotifyCode, WORD wID, HWND hWndC /////////////////////////////////////////////////////////////////////////////// -// Initialises the web shell engine +// Initialises the web browser engine HRESULT CMozillaBrowser::Initialize() { #ifdef HACK_NON_REENTRANCY @@ -1089,7 +1089,7 @@ HRESULT CMozillaBrowser::Initialize() return S_OK; } -// Terminates the web shell engine +// Terminates the web browser engine HRESULT CMozillaBrowser::Terminate() { #ifdef HACK_NON_REENTRANCY @@ -1108,7 +1108,7 @@ HRESULT CMozillaBrowser::Terminate() } -// Create and initialise the web shell +// Create and initialise the web browser HRESULT CMozillaBrowser::CreateBrowser() { NG_TRACE_METHOD(CMozillaBrowser::CreateBrowser); @@ -1183,6 +1183,10 @@ HRESULT CMozillaBrowser::CreateBrowser() nsCOMPtr browserAsFocus = do_QueryInterface(mWebBrowser); browserAsFocus->Activate(); + // Get an editor session + mEditingSession = do_GetInterface(mWebBrowser); + mCommandManager = do_GetInterface(mWebBrowser); + // Append browser to browser list sBrowserList.AppendElement(this); @@ -1221,6 +1225,8 @@ HRESULT CMozillaBrowser::DestroyBrowser() mWebBrowserContainer = NULL; } + mEditingSession = nsnull; + mCommandManager = nsnull; mWebBrowser = nsnull; return S_OK; @@ -1231,6 +1237,17 @@ HRESULT CMozillaBrowser::DestroyBrowser() HRESULT CMozillaBrowser::SetEditorMode(BOOL bEnabled) { NG_TRACE_METHOD(CMozillaBrowser::SetEditorMode); + + if (!mEditingSession || !mCommandManager) + return E_FAIL; + + nsCOMPtr domWindow; + nsresult rv = GetDOMWindow(getter_AddRefs(domWindow)); + if (NS_FAILED(rv)) + return E_FAIL; + + rv = mEditingSession->MakeWindowEditable(domWindow, "html", PR_FALSE); + return S_OK; } @@ -1239,38 +1256,22 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID) { NG_TRACE_METHOD(CMozillaBrowser::OnEditorCommand); - static nsIAtom * propB = NS_NewAtom("b"); - static nsIAtom * propI = NS_NewAtom("i"); - static nsIAtom * propU = NS_NewAtom("u"); + nsCOMPtr domWindow; + GetDOMWindow(getter_AddRefs(domWindow)); - if (!mEditModeFlag) - { - return E_UNEXPECTED; - } - if (!mEditor) - { - NG_ASSERT(0); - return E_UNEXPECTED; - } - - nsCOMPtr pHtmlEditor = do_QueryInterface(mEditor); - - bool bToggleInlineProperty = false; - nsIAtom *pInlineProperty = nsnull; + const char *styleCommand = nsnull; + nsICommandParams *commandParams = nsnull; switch (nCmdID) { case IDM_BOLD: - pInlineProperty = propB; - bToggleInlineProperty = true; + styleCommand = "cmd_bold"; break; case IDM_ITALIC: - pInlineProperty = propI; - bToggleInlineProperty = true; + styleCommand = "cmd_italic"; break; case IDM_UNDERLINE: - pInlineProperty = propU; - bToggleInlineProperty = true; + styleCommand = "cmd_underline"; break; // TODO add the rest! @@ -1280,26 +1281,9 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID) break; } - // Does the instruction involve toggling something? e.g. B, U, I - if (bToggleInlineProperty) - { - PRBool bFirst = PR_TRUE; - PRBool bAny = PR_TRUE; - PRBool bAll = PR_TRUE; - - // Set or remove - pHtmlEditor->GetInlineProperty(pInlineProperty, nsAutoString(), nsAutoString(), &bFirst, &bAny, &bAll); - if (bAny) - { - pHtmlEditor->RemoveInlineProperty(pInlineProperty, nsAutoString()); - } - else - { - pHtmlEditor->SetInlineProperty(pInlineProperty, nsAutoString(), nsAutoString()); - } - } - - return S_OK; + return mCommandManager ? + mCommandManager->DoCommand(styleCommand, commandParams, domWindow) : + NS_ERROR_FAILURE; } @@ -2018,14 +2002,14 @@ NS_IMETHODIMP SimpleDirectoryProvider::GetFile(const char *prop, PRBool *persist NS_ENSURE_ARG_POINTER(persistent); NS_ENSURE_ARG_POINTER(_retval); - *_retval = nsnull; - *persistent = PR_TRUE; + *_retval = nsnull; + *persistent = PR_TRUE; // Only need to support NS_APP_APPLICATION_REGISTRY_DIR, NS_APP_APPLICATION_REGISTRY_FILE, and // NS_APP_USER_PROFILES_ROOT_DIR. Unsupported keys fallback to the default service provider nsCOMPtr localFile; - nsresult rv = NS_ERROR_FAILURE; + nsresult rv = NS_ERROR_FAILURE; if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { @@ -2040,10 +2024,10 @@ NS_IMETHODIMP SimpleDirectoryProvider::GetFile(const char *prop, PRBool *persist localFile = mUserProfileDir; } - if (localFile) - return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**) _retval); - - return rv; + if (localFile) + return CallQueryInterface(localFile, _retval); + + return rv; } diff --git a/embedding/browser/activex/src/control/MozillaBrowser.h b/embedding/browser/activex/src/control/MozillaBrowser.h index 83364b37a73..6bb96ee638f 100644 --- a/embedding/browser/activex/src/control/MozillaBrowser.h +++ b/embedding/browser/activex/src/control/MozillaBrowser.h @@ -20,7 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock + * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -355,7 +356,7 @@ protected: // List of browsers static nsVoidArray sBrowserList; - // Pointer to web shell manager + // Pointer to web browser manager CWebBrowserContainer * mWebBrowserContainer; // CComObject to IHTMLDocument implementer CIEHtmlDocumentInstance * mIERootDocument; @@ -363,6 +364,8 @@ protected: // Mozilla interfaces nsCOMPtr mWebBrowser; nsCOMPtr mWebBrowserAsWin; + nsCOMPtr mEditingSession; + nsCOMPtr mCommandManager; // Context menu nsCOMPtr mContextNode; @@ -370,9 +373,6 @@ protected: // Prefs service nsCOMPtr mPrefs; - // Editor associated with this browser instance. - nsCOMPtr mEditor; - // Flag to indicate if browser is created or not BOOL mValidBrowserFlag; // Flag to indicate if browser is in edit mode or not diff --git a/embedding/browser/activex/src/control/MozillaControl.cpp b/embedding/browser/activex/src/control/MozillaControl.cpp index 6e85d0c8cf2..0f954287bfc 100644 --- a/embedding/browser/activex/src/control/MozillaControl.cpp +++ b/embedding/browser/activex/src/control/MozillaControl.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/MozillaControl.idl b/embedding/browser/activex/src/control/MozillaControl.idl index fdc5f034234..946d1f69a1d 100644 --- a/embedding/browser/activex/src/control/MozillaControl.idl +++ b/embedding/browser/activex/src/control/MozillaControl.idl @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/PropertyDlg.cpp b/embedding/browser/activex/src/control/PropertyDlg.cpp index 1ff93595c73..7e696d60088 100644 --- a/embedding/browser/activex/src/control/PropertyDlg.cpp +++ b/embedding/browser/activex/src/control/PropertyDlg.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/PropertyDlg.h b/embedding/browser/activex/src/control/PropertyDlg.h index 237c2b8ff87..3b4ccdf6873 100644 --- a/embedding/browser/activex/src/control/PropertyDlg.h +++ b/embedding/browser/activex/src/control/PropertyDlg.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/StdAfx.cpp b/embedding/browser/activex/src/control/StdAfx.cpp index 4f82cfe0b43..014e701330a 100644 --- a/embedding/browser/activex/src/control/StdAfx.cpp +++ b/embedding/browser/activex/src/control/StdAfx.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/StdAfx.h b/embedding/browser/activex/src/control/StdAfx.h index dbd5adbcc72..00a3a960f7c 100644 --- a/embedding/browser/activex/src/control/StdAfx.h +++ b/embedding/browser/activex/src/control/StdAfx.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -97,10 +97,9 @@ #include "nsISelection.h" #include "nsIPresContext.h" #include "nsIPrompt.h" - -#include "nsEditorCID.h" #include "nsIEditor.h" -#include "nsIHtmlEditor.h" +#include "nsIEditingSession.h" +#include "nsICommandManager.h" #include "nsIDocument.h" #include "nsIDocumentObserver.h" diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 22766c043cb..9861868437c 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.h b/embedding/browser/activex/src/control/WebBrowserContainer.h index f1baf7d9779..bcc719982d2 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.h +++ b/embedding/browser/activex/src/control/WebBrowserContainer.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/WindowCreator.cpp b/embedding/browser/activex/src/control/WindowCreator.cpp index 1115610e56b..13eb4e1ddaa 100644 --- a/embedding/browser/activex/src/control/WindowCreator.cpp +++ b/embedding/browser/activex/src/control/WindowCreator.cpp @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/embedding/browser/activex/src/control/WindowCreator.h b/embedding/browser/activex/src/control/WindowCreator.h index 2a50c3cc8e9..0f613d536b3 100644 --- a/embedding/browser/activex/src/control/WindowCreator.h +++ b/embedding/browser/activex/src/control/WindowCreator.h @@ -20,8 +20,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Adam Lock * + * Adam Lock * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or