зеркало из https://github.com/mozilla/pjs.git
Remove editorShell from message composer. b=174389, r=ducarroz, sr=sspitzer
This commit is contained in:
Родитель
d42b2c8c8d
Коммит
c3051ddfd0
|
@ -44,7 +44,6 @@
|
|||
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIDOMNode;
|
||||
interface nsIEditorShell;
|
||||
interface nsIEditor;
|
||||
|
||||
typedef long MSG_ComposeSaveType;
|
||||
|
@ -194,9 +193,6 @@ interface nsIMsgCompose : nsISupports {
|
|||
/* ... */
|
||||
readonly attribute nsIEditor editor;
|
||||
|
||||
/* ... */
|
||||
attribute nsIEditorShell editorShell;
|
||||
|
||||
/* ... */
|
||||
readonly attribute nsIDOMWindowInternal domWindow;
|
||||
|
||||
|
@ -219,6 +215,15 @@ interface nsIMsgCompose : nsISupports {
|
|||
attribute boolean bodyModified;
|
||||
|
||||
|
||||
/**
|
||||
* Init the editor THIS USED TO BE [noscript]
|
||||
* Now, this is called after editor is created,
|
||||
* which is triggered by loading startup url from JS.
|
||||
* The completion of document loading is detected by observing
|
||||
* the "obs_documentCreated" command
|
||||
*/
|
||||
void initEditor(in nsIEditor editor, in nsIDOMWindow contentWindow);
|
||||
|
||||
/* The following functions are for internal use, essentially for the listener */
|
||||
|
||||
/* Clear the editor */
|
||||
|
@ -236,9 +241,6 @@ interface nsIMsgCompose : nsISupports {
|
|||
/* set any reply flags on the original message's folder */
|
||||
[noscript] void processReplyFlags();
|
||||
|
||||
/* ... */
|
||||
[noscript] void setEditorFromEditorShell();
|
||||
|
||||
/* ... */
|
||||
[noscript] void convertAndLoadComposeWindow(in nsStringRef aPrefix,
|
||||
in nsStringRef aBuf,
|
||||
|
|
|
@ -233,7 +233,7 @@ var gComposeRecyclingListener = {
|
|||
identityElement.focus();
|
||||
|
||||
InitializeGlobalVariables();
|
||||
window.editorShell.contentWindow.focus();
|
||||
window.content.focus();
|
||||
ComposeStartup(true, params);
|
||||
enableEditableFields();
|
||||
|
||||
|
@ -376,6 +376,7 @@ var defaultController =
|
|||
|
||||
//Edit Menu
|
||||
case "cmd_pasteQuote":
|
||||
case "cmd_rewrap":
|
||||
case "cmd_delete":
|
||||
case "cmd_selectAll":
|
||||
case "cmd_find":
|
||||
|
@ -406,6 +407,7 @@ var defaultController =
|
|||
case "cmd_bold":
|
||||
case "cmd_italic":
|
||||
case "cmd_underline":
|
||||
case "cmd_smiley":
|
||||
case "cmd_strikethrough":
|
||||
case "cmd_superscript":
|
||||
case "cmd_subscript":
|
||||
|
@ -452,8 +454,6 @@ var defaultController =
|
|||
case "cmd_spelling":
|
||||
case "cmd_outputFormat":
|
||||
case "cmd_quoteMessage":
|
||||
case "cmd_rewrap":
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -495,6 +495,8 @@ var defaultController =
|
|||
case "cmd_findNext":
|
||||
//Disable the editor specific edit commands if the focus is not into the body
|
||||
return !focusedElement;
|
||||
case "cmd_rewrap":
|
||||
return !focusedElement;
|
||||
case "cmd_delete":
|
||||
return MessageHasSelectedAttachments();
|
||||
case "cmd_selectAll":
|
||||
|
@ -622,6 +624,13 @@ var defaultController =
|
|||
case "cmd_print" : DoCommandPrint(); break;
|
||||
|
||||
//Edit Menu
|
||||
case "cmd_rewrap" :
|
||||
if (defaultController.isCommandEnabled(command))
|
||||
{
|
||||
gMsgCompose.editor.QueryInterface(Components.interfaces.nsIEditorMailSupport);
|
||||
gMsgCompose.editor.rewrap(false);
|
||||
}
|
||||
break;
|
||||
case "cmd_delete" : if (MessageHasSelectedAttachments()) RemoveSelectedAttachment(); break;
|
||||
case "cmd_selectAll" : if (MessageHasAttachments()) SelectAllAttachments(); break;
|
||||
case "cmd_account" : MsgAccountManager(null); break;
|
||||
|
@ -634,10 +643,6 @@ var defaultController =
|
|||
//Options Menu
|
||||
case "cmd_selectAddress" : if (defaultController.isCommandEnabled(command)) SelectAddress(); break;
|
||||
case "cmd_quoteMessage" : if (defaultController.isCommandEnabled(command)) QuoteSelectedMessage(); break;
|
||||
case "cmd_rewrap" :
|
||||
gMsgCompose.editor.QueryInterface(Components.interfaces.nsIEditorMailSupport);
|
||||
gMsgCompose.editor.rewrap(false);
|
||||
break;
|
||||
default:
|
||||
// dump("##MsgCompose: don't know what to do with command " + command + "!\n");
|
||||
return;
|
||||
|
@ -695,7 +700,9 @@ function CommandUpdate_MsgCompose()
|
|||
|
||||
function updateComposeItems() {
|
||||
try {
|
||||
|
||||
//Edit Menu
|
||||
goUpdateCommand("cmd_rewrap");
|
||||
|
||||
//Insert Menu
|
||||
if (gMsgCompose && gMsgCompose.composeHTML)
|
||||
|
@ -723,6 +730,7 @@ function updateComposeItems() {
|
|||
|
||||
function updateEditItems() {
|
||||
goUpdateCommand("cmd_pasteQuote");
|
||||
goUpdateCommand("cmd_rewrap");
|
||||
goUpdateCommand("cmd_delete");
|
||||
goUpdateCommand("cmd_selectAll");
|
||||
goUpdateCommand("cmd_find");
|
||||
|
@ -1364,32 +1372,26 @@ function ComposeStartup(recycled, aParams)
|
|||
//Lets the compose object knows that we are dealing with a recycled window
|
||||
gMsgCompose.recycledWindow = recycled;
|
||||
|
||||
//Creating a Editor Shell
|
||||
var editorElement = document.getElementById("content-frame");
|
||||
// Get the <editor> element to startup an editor
|
||||
var editorElement = GetCurrentEditorElement();
|
||||
if (!editorElement)
|
||||
{
|
||||
dump("Failed to get editor element!\n");
|
||||
return;
|
||||
}
|
||||
var editorShell = editorElement.editorShell;
|
||||
if (!editorShell)
|
||||
{
|
||||
dump("Failed to create editorShell!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("returnReceiptMenu").setAttribute('checked',
|
||||
gMsgCompose.compFields.returnReceipt);
|
||||
|
||||
if (!recycled) //The editor is already initialized and does not support to be re-initialized.
|
||||
// If recycle, editor is already created
|
||||
if (!recycled)
|
||||
{
|
||||
// save the editorShell in the window. The editor JS expects to find it there.
|
||||
window.editorShell = editorShell;
|
||||
try {
|
||||
var editortype = gMsgCompose.composeHTML ? "htmlmail" : "textmail";
|
||||
editorElement.makeEditable(editortype, true);
|
||||
} catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); }
|
||||
|
||||
// setEditorType MUST be call before setContentWindow
|
||||
if (gMsgCompose.composeHTML)
|
||||
window.editorShell.editorType = "htmlmail";
|
||||
else
|
||||
if (!gMsgCompose.composeHTML)
|
||||
{
|
||||
//Remove HTML toolbar, format and insert menus as we are editing in plain text mode
|
||||
document.getElementById("outputFormatMenu").setAttribute("hidden", true);
|
||||
|
@ -1397,15 +1399,9 @@ function ComposeStartup(recycled, aParams)
|
|||
document.getElementById("formatMenu").setAttribute("hidden", true);
|
||||
document.getElementById("insertMenu").setAttribute("hidden", true);
|
||||
document.getElementById("menu_showFormatToolbar").setAttribute("hidden", true);
|
||||
|
||||
window.editorShell.editorType = "textmail";
|
||||
}
|
||||
window.editorShell.webShellWindow = window;
|
||||
window.editorShell.contentWindow = window._content;
|
||||
|
||||
// Do setup common to Message Composer and Web Composer
|
||||
EditorSharedStartup();
|
||||
|
||||
}
|
||||
|
||||
var msgCompFields = gMsgCompose.compFields;
|
||||
|
@ -1434,10 +1430,54 @@ function ComposeStartup(recycled, aParams)
|
|||
if (attachments)
|
||||
for (i = 0; i < attachments.Count(); i ++)
|
||||
AddAttachment(attachments.QueryElementAt(i, Components.interfaces.nsIMsgAttachment));
|
||||
}
|
||||
}
|
||||
|
||||
gMsgCompose.RegisterStateListener(stateListener);
|
||||
gMsgCompose.editorShell = window.editorShell;
|
||||
|
||||
if (recycled)
|
||||
{
|
||||
// This sets charset and does reply quote insertion
|
||||
gMsgCompose.initEditor(GetCurrentEditor(), window.content);
|
||||
|
||||
if (gMsgCompose.composeHTML)
|
||||
{
|
||||
// Force color picker on toolbar to show document colors
|
||||
onFontColorChange();
|
||||
onBackgroundColorChange();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add an observer to be called when document is done loading,
|
||||
// which creates the editor
|
||||
try {
|
||||
GetCurrentCommandManager().
|
||||
addCommandObserver(gMsgEditorCreationObserver, "obs_documentCreated");
|
||||
|
||||
// Load empty page to create the editor
|
||||
editorElement.webNavigation.loadURI("about:blank", // uri string
|
||||
0, // load flags
|
||||
null, // referrer
|
||||
null, // post-data stream
|
||||
null);
|
||||
} catch (e) {
|
||||
dump(" Failed to startup editor: "+e+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The new, nice, simple way of getting notified when a new editor has been created
|
||||
var gMsgEditorCreationObserver =
|
||||
{
|
||||
observe: function(aSubject, aTopic, aData)
|
||||
{
|
||||
if (aTopic == "obs_documentCreated")
|
||||
{
|
||||
var editor = GetCurrentEditor();
|
||||
if (editor && GetCurrentCommandManager() == aSubject)
|
||||
gMsgCompose.initEditor(editor, window.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1668,7 +1708,7 @@ function GenericSendMessage( msgType )
|
|||
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend")){
|
||||
//We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
|
||||
//therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
|
||||
editorShell.contentWindow.focus();
|
||||
window.content.focus();
|
||||
window.cancelSendMessage = false;
|
||||
try {
|
||||
window.openDialog("chrome://editor/content/EdSpellCheck.xul", "_blank",
|
||||
|
@ -2072,7 +2112,7 @@ function AdjustFocus()
|
|||
}
|
||||
else {
|
||||
//dump("XXX focus on body\n");
|
||||
editorShell.contentWindow.focus();
|
||||
window.content.focus();
|
||||
}
|
||||
SuppressComposeCommandUpdating(false);
|
||||
}
|
||||
|
@ -2632,12 +2672,12 @@ function subjectKeyPress(event)
|
|||
switch(event.keyCode) {
|
||||
case 9:
|
||||
if (!event.shiftKey) {
|
||||
window._content.focus();
|
||||
window.content.focus();
|
||||
event.preventDefault();
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
window._content.focus();
|
||||
window.content.focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2812,7 +2852,7 @@ function SetMsgAttachmentElementFocus()
|
|||
function SetMsgBodyFrameFocus()
|
||||
{
|
||||
SuppressComposeCommandUpdating(true);
|
||||
editorShell.contentWindow.focus();
|
||||
window.content.focus();
|
||||
SuppressComposeCommandUpdating(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
|
||||
<script type="application/x-javascript" src="chrome://editor/content/editor.js"/>
|
||||
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
|
||||
<!--script type="application/x-javascript" src="chrome://editor/content/EditorCommandsDebug.js"/-->
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
|
||||
|
||||
|
@ -120,6 +121,7 @@
|
|||
<!--command id="cmd_pasteQuote"/ DO NOT INCLUDE THOSE PBROCASTER ESLE THE EDIT MENU WILL BE BROKEN! -->
|
||||
<!--command id="cmd_find"/-->
|
||||
<!--command id="cmd_findNext"/-->
|
||||
<command id="cmd_rewrap" oncommand="goDoCommand('cmd_rewrap')"/>
|
||||
<command id="cmd_delete"/>
|
||||
<command id="cmd_selectAll"/>
|
||||
<command id="cmd_account" oncommand="goDoCommand('cmd_account')"/>
|
||||
|
@ -132,7 +134,6 @@
|
|||
<command id="cmd_selectAddress" oncommand="goDoCommand('cmd_selectAddress')"/>
|
||||
<command id="cmd_outputFormat" oncommand="OutputFormatMenuSelect(event.target)"/>
|
||||
<command id="cmd_quoteMessage" oncommand="goDoCommand('cmd_quoteMessage')"/>
|
||||
<command id="cmd_rewrap" oncommand="goDoCommand('cmd_rewrap')"/>
|
||||
<command id="cmd_insert"/>
|
||||
</commandset>
|
||||
|
||||
|
@ -244,6 +245,7 @@
|
|||
<menuitem id="menu_copy"/>
|
||||
<menuitem id="menu_paste"/>
|
||||
<menuitem id="menu_pasteQuote"/>
|
||||
<menuitem label="&editRewrapCmd.label;" accesskey="&editRewrapCmd.accesskey;" command="cmd_rewrap"/>
|
||||
<menuitem id="menu_delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_selectAll"/>
|
||||
|
@ -297,7 +299,6 @@
|
|||
<menuitem label="&selectAddressCmd.label;" accesskey="&selectAddressCmd.accesskey;" command="cmd_selectAddress"/>
|
||||
<menuitem label="&checkSpellingCmd.label;" id="menu_checkspelling" accesskey="&checkSpellingCmd.accesskey;" key="key_checkspelling" command="cmd_spelling"/>
|
||||
<menuitem label=""eCmd.label;" accesskey=""eCmd.accesskey;" command="cmd_quoteMessage"/>
|
||||
<menuitem label="&editRewrapCmd.label;" accesskey="&editRewrapCmd.accesskey;" command="cmd_rewrap" oncommand="editorShell.Rewrap(false)"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="returnReceiptMenu" type="checkbox" label="&returnReceiptMenu.label;" accesskey="&returnReceiptMenu.accesskey;" checked="false" oncommand="ToggleReturnReceipt(event.target)"/>
|
||||
<menu id="outputFormatMenu" label="&outputFormatMenu.label;" accesskey="&outputFormatMenu.accesskey;" command="cmd_outputFormat">
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
<!ENTITY closeCmd.label "Close">
|
||||
|
||||
<!-- Edit menu items -->
|
||||
<!ENTITY editRewrapCmd.label "Rewrap">
|
||||
<!ENTITY editRewrapCmd.accesskey "w">
|
||||
<!ENTITY findCmd.label "Find and Replace...">
|
||||
<!ENTITY findCmd.key "F">
|
||||
<!ENTITY findCmd.accesskey "F">
|
||||
|
@ -131,8 +133,6 @@
|
|||
|
||||
<!ENTITY quoteCmd.label "Quote Message">
|
||||
<!ENTITY quoteCmd.accesskey "Q">
|
||||
<!ENTITY editRewrapCmd.label "Rewrap">
|
||||
<!ENTITY editRewrapCmd.accesskey "R">
|
||||
<!ENTITY selectAddressCmd.label "Select Addresses...">
|
||||
<!ENTITY selectAddressCmd.key "">
|
||||
<!ENTITY selectAddressCmd.accesskey "c">
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
#include "nsMimeTypes.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIEditorShell.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
|
@ -113,6 +112,8 @@
|
|||
#include "nsMsgSimulateError.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
|
||||
// Defines....
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
@ -242,9 +243,7 @@ nsMsgCompose::nsMsgCompose()
|
|||
|
||||
mQuotingToFollow = PR_FALSE;
|
||||
mWhatHolder = 1;
|
||||
mDocumentListener = nsnull;
|
||||
m_window = nsnull;
|
||||
m_editorShell = nsnull;
|
||||
m_editor = nsnull;
|
||||
mQuoteStreamListener=nsnull;
|
||||
mCharsetOverride = PR_FALSE;
|
||||
|
@ -269,11 +268,6 @@ nsMsgCompose::~nsMsgCompose()
|
|||
printf("DISPOSE nsMsgCompose: %x\n", this);
|
||||
#endif
|
||||
|
||||
if (mDocumentListener)
|
||||
{
|
||||
mDocumentListener->SetComposeObj(nsnull);
|
||||
NS_RELEASE(mDocumentListener);
|
||||
}
|
||||
NS_IF_RELEASE(m_compFields);
|
||||
NS_IF_RELEASE(mQuoteStreamListener);
|
||||
}
|
||||
|
@ -470,15 +464,6 @@ nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditorMailSupport *aEditor)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgCompose::SetEditorFromEditorShell()
|
||||
{
|
||||
NS_ASSERTION(m_editorShell, "SetEditorFromEditorShell() but no editor shell yet!");
|
||||
if (!m_editorShell)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return m_editorShell->GetEditor(getter_AddRefs(m_editor));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
|
||||
nsString& aBuf,
|
||||
|
@ -1180,8 +1165,6 @@ NS_IMETHODIMP nsMsgCompose::CloseWindow(PRBool recycleIt)
|
|||
NS_ASSERTION(m_editor, "no editor");
|
||||
if (m_editor)
|
||||
{
|
||||
m_editor->RemoveDocumentStateListener(mDocumentListener);
|
||||
|
||||
// XXX clear undo txn manager?
|
||||
|
||||
rv = m_editor->EnableUndo(PR_FALSE);
|
||||
|
@ -1234,12 +1217,10 @@ NS_IMETHODIMP nsMsgCompose::CloseWindow(PRBool recycleIt)
|
|||
{
|
||||
if (m_editor)
|
||||
{
|
||||
m_editor->RemoveDocumentStateListener(mDocumentListener);
|
||||
m_editorShell = nsnull;
|
||||
m_editor = nsnull;
|
||||
/* The editor will be destroyed during yje close window.
|
||||
* Set it to null to be sure we wont uses it anymore
|
||||
*/
|
||||
m_editor = nsnull;
|
||||
}
|
||||
nsIBaseWindow * aWindow = m_baseWindow;
|
||||
m_baseWindow = nsnull;
|
||||
|
@ -1260,12 +1241,6 @@ nsresult nsMsgCompose::Abort()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::GetEditorShell(nsIEditorShell * *aEditorShell)
|
||||
{
|
||||
NS_IF_ADDREF(*aEditorShell = m_editorShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::GetEditor(nsIEditor * *aEditor)
|
||||
{
|
||||
NS_IF_ADDREF(*aEditor = m_editor);
|
||||
|
@ -1275,51 +1250,54 @@ nsresult nsMsgCompose::GetEditor(nsIEditor * *aEditor)
|
|||
nsresult nsMsgCompose::ClearEditor()
|
||||
{
|
||||
m_editor = nsnull;
|
||||
m_editorShell = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::SetEditorShell(nsIEditorShell * aEditorShell)
|
||||
// This used to be called BEFORE editor was created
|
||||
// (it did the loadUrl that triggered editor creation)
|
||||
// Since editorShell removal, it is called from JS after editor creation
|
||||
// (loadUrl is done in JS)
|
||||
NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, nsIDOMWindow* aContentWindow)
|
||||
{
|
||||
// First, store the editor shell but do not addref it (see sfraser@netscape.com for explanation).
|
||||
m_editorShell = aEditorShell;
|
||||
m_editor = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aEditor);
|
||||
NS_ENSURE_ARG_POINTER(aContentWindow);
|
||||
|
||||
if (nsnull == m_editorShell)
|
||||
return NS_OK;
|
||||
|
||||
//
|
||||
// Now this routine will create a listener for state changes
|
||||
// in the editor and set us as the compose object of interest.
|
||||
//
|
||||
mDocumentListener = new nsMsgDocumentStateListener();
|
||||
if (!mDocumentListener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
m_editor = aEditor;
|
||||
|
||||
mDocumentListener->SetComposeObj(this);
|
||||
NS_ADDREF(mDocumentListener);
|
||||
// Set the charset
|
||||
nsAutoString msgCharSet;
|
||||
msgCharSet.AssignWithConversion(m_compFields->GetCharacterSet());
|
||||
|
||||
// Make sure we setup to listen for editor state changes...
|
||||
m_editorShell->RegisterDocumentStateListener(mDocumentListener);
|
||||
m_editor->SetDocumentCharacterSet(msgCharSet);
|
||||
|
||||
// Set the charset
|
||||
nsAutoString msgCharSet;
|
||||
msgCharSet.AssignWithConversion(m_compFields->GetCharacterSet());
|
||||
m_editorShell->SetDocumentCharacterSet(msgCharSet.get());
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj = do_QueryInterface(m_window);
|
||||
|
||||
if (mRecycledWindow)
|
||||
{
|
||||
// Editor document is already created therefore, we need to call the document
|
||||
// listener ourself in order to make quoting works
|
||||
mDocumentListener->NotifyDocumentCreated();
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
globalObj->GetDocShell(getter_AddRefs(docShell));
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIContentViewer> childCV;
|
||||
NS_ENSURE_SUCCESS(docShell->GetContentViewer(getter_AddRefs(childCV)), NS_ERROR_FAILURE);
|
||||
if (childCV)
|
||||
{
|
||||
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
|
||||
if (markupCV) {
|
||||
NS_ENSURE_SUCCESS(markupCV->SetDefaultCharacterSet(msgCharSet.get()), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(markupCV->SetForceCharacterSet(msgCharSet.get()), NS_ERROR_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now, lets init the editor here!
|
||||
// Just get a blank editor started...
|
||||
m_editorShell->LoadUrl(NS_LITERAL_STRING("about:blank").get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This is what used to be done in mDocumentListener,
|
||||
// nsMsgDocumentStateListener::NotifyDocumentCreated()
|
||||
PRBool quotingToFollow = PR_FALSE;
|
||||
GetQuotingToFollow("ingToFollow);
|
||||
if (quotingToFollow)
|
||||
return BuildQuotedMessageAndSignature();
|
||||
else
|
||||
{
|
||||
NotifyStateListeners(eComposeFieldsReady, NS_OK);
|
||||
return BuildBodyMessageAndSignature();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::GetBodyModified(PRBool * modified)
|
||||
|
@ -3060,80 +3038,6 @@ NS_IMETHODIMP nsMsgComposeSendListener::OnSecurityChange(nsIWebProgress *aWebPro
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// This is a class that will allow us to listen to state changes in the Ender
|
||||
// compose window. This is important since we must wait until we are told Ender
|
||||
// is ready before we do various quoting operations
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMsgDocumentStateListener, nsIDocumentStateListener)
|
||||
|
||||
nsMsgDocumentStateListener::nsMsgDocumentStateListener(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsMsgDocumentStateListener::~nsMsgDocumentStateListener(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsMsgDocumentStateListener::SetComposeObj(nsIMsgCompose *obj)
|
||||
{
|
||||
mWeakComposeObj = getter_AddRefs(NS_GetWeakReference(obj));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDocumentStateListener::NotifyDocumentCreated(void)
|
||||
{
|
||||
// Ok, now the document has been loaded, so we are ready to setup
|
||||
// the compose window and let the user run hog wild!
|
||||
|
||||
// Now, do the appropriate startup operation...signature only
|
||||
// or quoted message and signature...
|
||||
|
||||
#ifdef MSGCOMP_TRACE_PERFORMANCE
|
||||
nsCOMPtr<nsIMsgComposeService> composeService (do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID));
|
||||
composeService->TimeStamp("Editor is done loading about:blank. This is New Compose window time. Time for MIME.", PR_FALSE);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
|
||||
if (compose)
|
||||
{
|
||||
compose->SetEditorFromEditorShell();
|
||||
|
||||
PRBool quotingToFollow = PR_FALSE;
|
||||
compose->GetQuotingToFollow("ingToFollow);
|
||||
if (quotingToFollow)
|
||||
return compose->BuildQuotedMessageAndSignature();
|
||||
else
|
||||
{
|
||||
compose->NotifyStateListeners(eComposeFieldsReady, NS_OK);
|
||||
return compose->BuildBodyMessageAndSignature();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDocumentStateListener::NotifyDocumentWillBeDestroyed(void)
|
||||
{
|
||||
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
|
||||
if (compose)
|
||||
compose->SetEditorShell(nsnull);
|
||||
/* The editor will be destroyed. Set it to null to
|
||||
* be sure we wont use it anymore.
|
||||
*/
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDocumentStateListener::NotifyDocumentStateChanged(PRBool nowDirty)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgCompose::ConvertHTMLToText(nsFileSpec& aSigFile, nsString &aSigData)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
// Forward declares
|
||||
class QuotingOutputStreamListener;
|
||||
class nsMsgComposeSendListener;
|
||||
class nsMsgDocumentStateListener;
|
||||
class nsIAddrDatabase;
|
||||
class nsIEditorMailSupport;
|
||||
|
||||
|
@ -134,7 +133,6 @@ private:
|
|||
PRBool mConvertStructs; // for TagConvertible
|
||||
|
||||
nsCOMPtr<nsIEditor> m_editor;
|
||||
nsIEditorShell *m_editorShell;
|
||||
nsIDOMWindowInternal *m_window;
|
||||
nsCOMPtr<nsIBaseWindow> m_baseWindow;
|
||||
nsMsgCompFields *m_compFields;
|
||||
|
@ -152,7 +150,6 @@ private:
|
|||
nsString mCiteReference;
|
||||
nsCOMPtr<nsIMsgQuote> mQuote;
|
||||
PRBool mQuotingToFollow; // Quoting indicator
|
||||
nsMsgDocumentStateListener *mDocumentListener;
|
||||
MSG_ComposeType mType; // Message type
|
||||
nsCOMPtr<nsISupportsArray> mStateListeners; // contents are nsISupports
|
||||
PRBool mCharsetOverride;
|
||||
|
@ -161,7 +158,6 @@ private:
|
|||
nsCString mSmtpPassword;
|
||||
|
||||
friend class QuotingOutputStreamListener;
|
||||
friend class nsMsgDocumentStateListener;
|
||||
friend class nsMsgComposeSendListener;
|
||||
};
|
||||
|
||||
|
@ -240,29 +236,6 @@ private:
|
|||
MSG_DeliverMode mDeliverMode;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// This is a class that will allow us to listen to state changes in the Ender
|
||||
// compose window. This is important since we must wait until the have this
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsMsgDocumentStateListener : public nsIDocumentStateListener {
|
||||
public:
|
||||
nsMsgDocumentStateListener(void);
|
||||
virtual ~nsMsgDocumentStateListener(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD NotifyDocumentCreated(void);
|
||||
NS_IMETHOD NotifyDocumentWillBeDestroyed(void);
|
||||
NS_IMETHOD NotifyDocumentStateChanged(PRBool nowDirty);
|
||||
|
||||
void SetComposeObj(nsIMsgCompose *obj);
|
||||
|
||||
// class vars.
|
||||
nsWeakPtr mWeakComposeObj;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* nsMsgRecipient
|
||||
******************************************************************************/
|
||||
|
|
Загрузка…
Ссылка в новой задаче