diff --git a/editor/base/Makefile.in b/editor/base/Makefile.in index b34128e3bcd9..a4a8fbb15e5d 100644 --- a/editor/base/Makefile.in +++ b/editor/base/Makefile.in @@ -65,10 +65,14 @@ CPPSRCS = \ nsAOLCiter.cpp \ nsEditorShell.cpp \ nsEditorShellFactory.cpp \ + nsJSEditorLog.cpp \ + nsJSTxnLog.cpp \ $(NULL) MODULE = editor +DEFINES += -DENABLE_JS_EDITOR_LOG + include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk diff --git a/editor/base/makefile.win b/editor/base/makefile.win index dc2dd1ce423e..6f2c6ba0ccbf 100644 --- a/editor/base/makefile.win +++ b/editor/base/makefile.win @@ -60,6 +60,8 @@ CPPSRCS = \ nsAOLCiter.cpp \ nsEditorShell.cpp \ nsEditorShellFactory.cpp \ + nsJSEditorLog.cpp \ + nsJSTxnLog.cpp \ $(NULL) CPP_OBJS = \ @@ -102,6 +104,8 @@ CPP_OBJS = \ .\$(OBJDIR)\nsAOLCiter.obj \ .\$(OBJDIR)\nsEditorShell.obj \ .\$(OBJDIR)\nsEditorShellFactory.obj \ + .\$(OBJDIR)\nsJSEditorLog.obj \ + .\$(OBJDIR)\nsJSTxnLog.obj \ $(NULL) MODULE=editor @@ -110,6 +114,8 @@ MAKE_OBJ_TYPE = DLL DLLNAME = ender DLL=.\$(OBJDIR)\$(DLLNAME).dll +DEFINES = -DENABLE_JS_EDITOR_LOG $(DEFINES) + LCFLAGS = \ $(LCFLAGS) \ $(DEFINES) \ diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index 5a3f7a2ac1f7..ece596c635d6 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -59,6 +59,7 @@ #ifdef ENABLE_JS_EDITOR_LOG #include "nsJSEditorLog.h" +#include "nsJSTxnLog.h" #endif // ENABLE_JS_EDITOR_LOG // transactions the editor knows how to build @@ -318,6 +319,7 @@ nsEditor::nsEditor() , mDoc(nsnull) #ifdef ENABLE_JS_EDITOR_LOG , mJSEditorLog(nsnull) +, mJSTxnLog(nsnull) #endif // ENABLE_JS_EDITOR_LOG { //initialize member variables here @@ -350,11 +352,9 @@ nsEditor::~nsEditor() } #ifdef ENABLE_JS_EDITOR_LOG - if (mJSEditorLog) - { - delete mJSEditorLog; - mJSEditorLog = 0; - } + + StopLogging(); + #endif // ENABLE_JS_EDITOR_LOG // Release service pointers @@ -560,12 +560,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) return NS_OK; } -// #define DEBUG_WITH_JS_EDITOR_LOG -// #define DEBUG_WITH_JS_TXN_LOG -#ifdef DEBUG_WITH_JS_TXN_LOG -#include "nsJSTxnLog.h" -#endif - NS_IMETHODIMP nsEditor::EnableUndo(PRBool aEnable) { @@ -582,24 +576,6 @@ nsEditor::EnableUndo(PRBool aEnable) printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; } - -#ifdef DEBUG_WITH_JS_TXN_LOG - nsJSTxnLog *log = new nsJSTxnLog(); - if (log) - { - NS_ADDREF(log); - result = mTxnMgr->AddListener(log); - NS_RELEASE(log); - } -#endif - -#ifdef ENABLE_JS_EDITOR_LOG -#ifdef DEBUG_WITH_JS_EDITOR_LOG - - mJSEditorLog = new nsJSEditorLog(this); - -#endif -#endif // ENABLE_JS_EDITOR_LOG } mTxnMgr->SetMaxTransactionCount(-1); } @@ -958,26 +934,7 @@ nsEditor::BeginTransaction() mJSEditorLog->BeginTransaction(); #endif // ENABLE_JS_EDITOR_LOG - NS_PRECONDITION(mUpdateCount>=0, "bad state"); - - nsCOMPtrselection; - nsresult selectionResult = GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(selectionResult) && selection) { - selection->StartBatchChanges(); - } - - if (nsnull!=mViewManager) - { - if (0==mUpdateCount) - { -#ifdef HACK_FORCE_REDRAW - mViewManager->DisableRefresh(); -#else - mViewManager->BeginUpdateViewBatch(); -#endif - } - mUpdateCount++; - } + BeginUpdateViewBatch(); if ((nsITransactionManager *)nsnull!=mTxnMgr.get()) { @@ -997,32 +954,12 @@ nsEditor::EndTransaction() mJSEditorLog->EndTransaction(); #endif // ENABLE_JS_EDITOR_LOG - NS_PRECONDITION(mUpdateCount>0, "bad state"); - if ((nsITransactionManager *)nsnull!=mTxnMgr.get()) { mTxnMgr->EndBatch(); } - if (nsnull!=mViewManager) - { - mUpdateCount--; - if (0==mUpdateCount) - { -#ifdef HACK_FORCE_REDRAW - mViewManager->EnableRefresh(); - HACKForceRedraw(); -#else - mViewManager->EndUpdateViewBatch(); -#endif - } - } - - nsCOMPtrselection; - nsresult selectionResult = GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(selectionResult) && selection) { - selection->EndBatchChanges(); - } + EndUpdateViewBatch(); return NS_OK; } @@ -1498,7 +1435,6 @@ nsEditor::InsertText(const nsString& aStringToInsert) if (mJSEditorLog) mJSEditorLog->InsertText(aStringToInsert); - nsAutoEditBatch aeb(this); #endif // ENABLE_JS_EDITOR_LOG EditAggregateTxn *aggTxn = nsnull; @@ -1510,8 +1446,10 @@ nsEditor::InsertText(const nsString& aStringToInsert) InsertTextTxn *txn; result = CreateTxnForInsertText(aStringToInsert, nsnull, &txn); // insert at the current selection if ((NS_SUCCEEDED(result)) && txn) { + BeginUpdateViewBatch(); aggTxn->AppendChild(txn); - result = Do(aggTxn); + result = Do(aggTxn); + EndUpdateViewBatch(); } else if (NS_ERROR_EDITOR_NO_SELECTION==result) { result = DoInitialInsert(aStringToInsert); @@ -3139,6 +3077,59 @@ nsEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) return NS_OK; } +NS_IMETHODIMP +nsEditor::StartLogging(nsIFileSpec *aLogFile) +{ +#ifdef ENABLE_JS_EDITOR_LOG + + mJSEditorLog = new nsJSEditorLog(this, aLogFile); + + if (!mJSEditorLog) + return NS_ERROR_OUT_OF_MEMORY; + + if (mTxnMgr) + { + mJSTxnLog = new nsJSTxnLog(mJSEditorLog); + + if (mJSTxnLog) + { + NS_ADDREF(mJSTxnLog); + mTxnMgr->AddListener(mJSTxnLog); + } + else + return NS_ERROR_OUT_OF_MEMORY; + } + +#endif // ENABLE_JS_EDITOR_LOG + + return NS_OK; +} + +NS_IMETHODIMP +nsEditor::StopLogging() +{ +#ifdef ENABLE_JS_EDITOR_LOG + + if (mTxnMgr && mJSTxnLog) + mTxnMgr->RemoveListener(mJSTxnLog); + + if (mJSTxnLog) + { + NS_RELEASE(mJSTxnLog); + mJSTxnLog = 0; + } + + if (mJSEditorLog) + { + delete mJSEditorLog; + mJSEditorLog = 0; + } + +#endif // ENABLE_JS_EDITOR_LOG + + return NS_OK; +} + NS_IMETHODIMP nsEditor::DebugDumpContent() const { @@ -4023,6 +4014,60 @@ nsresult nsEditor::GetString(const nsString& name, nsString& value) return result; } +nsresult nsEditor::BeginUpdateViewBatch() +{ + NS_PRECONDITION(mUpdateCount>=0, "bad state"); + + nsCOMPtrselection; + nsresult selectionResult = GetSelection(getter_AddRefs(selection)); + if (NS_SUCCEEDED(selectionResult) && selection) { + selection->StartBatchChanges(); + } + + if (nsnull!=mViewManager) + { + if (0==mUpdateCount) + { +#ifdef HACK_FORCE_REDRAW + mViewManager->DisableRefresh(); +#else + mViewManager->BeginUpdateViewBatch(); +#endif + } + mUpdateCount++; + } + + return NS_OK; +} + + +nsresult nsEditor::EndUpdateViewBatch() +{ + NS_PRECONDITION(mUpdateCount>0, "bad state"); + + if (nsnull!=mViewManager) + { + mUpdateCount--; + if (0==mUpdateCount) + { +#ifdef HACK_FORCE_REDRAW + mViewManager->EnableRefresh(); + HACKForceRedraw(); +#else + mViewManager->EndUpdateViewBatch(); +#endif + } + } + + nsCOMPtrselection; + nsresult selectionResult = GetSelection(getter_AddRefs(selection)); + if (NS_SUCCEEDED(selectionResult) && selection) { + selection->EndBatchChanges(); + } + + return NS_OK; +} + /****************************************************************************** * nsAutoSelectionReset *****************************************************************************/ diff --git a/editor/base/nsEditor.h b/editor/base/nsEditor.h index a71420a50681..cb0886048122 100644 --- a/editor/base/nsEditor.h +++ b/editor/base/nsEditor.h @@ -32,6 +32,7 @@ #include "TransactionFactory.h" #include "nsIComponentManager.h" #include "nsIEditProperty.h" +#include "nsIFileSpec.h" class nsIEditActionListener; class nsIDOMCharacterData; @@ -56,6 +57,7 @@ class nsILocale; #ifdef ENABLE_JS_EDITOR_LOG class nsJSEditorLog; +class nsJSTxnLog; #endif // ENABLE_JS_EDITOR_LOG //This is the monitor for the editor. @@ -90,6 +92,7 @@ protected: #ifdef ENABLE_JS_EDITOR_LOG nsJSEditorLog *mJSEditorLog; + nsJSTxnLog *mJSTxnLog; #endif // ENABLE_JS_EDITOR_LOG public: @@ -223,6 +226,9 @@ public: NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed); + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); + /*END nsIEditor interfaces*/ @@ -523,6 +529,9 @@ public: nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection); nsresult GetString(const nsString& name, nsString& value); + + nsresult BeginUpdateViewBatch(void); + nsresult EndUpdateViewBatch(void); }; diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 265d503c1e1c..1af2ad0cb7ee 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -1336,13 +1336,27 @@ nsEditorShell::SelectAll() NS_IMETHODIMP -nsEditorShell::DeleteSelection() +nsEditorShell::DeleteSelection(PRInt32 action) { nsresult err = NS_NOINTERFACE; - + nsIEditor::ECollapsedSelectionAction selectionAction; + + switch(action) + { + case nsIEditor::eDeleteRight: + selectionAction = nsIEditor::eDeleteRight; + break; + case nsIEditor::eDeleteLeft: + selectionAction = nsIEditor::eDeleteLeft; + break; + default: + selectionAction = nsIEditor::eDoNothing; + break; + } + nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) - err = editor->DeleteSelection(nsIEditor::eDoNothing); + err = editor->DeleteSelection(selectionAction); return err; } @@ -2230,6 +2244,70 @@ nsEditorShell::RunUnitTests() return NS_OK; } +NS_IMETHODIMP +nsEditorShell::StartLogging(nsIFileSpec *logFile) +{ + nsresult err = NS_OK; + +#if 1 + + switch (mEditorType) + { + case ePlainTextEditorType: + { + nsCOMPtr textEditor = do_QueryInterface(mEditor); + if (textEditor) + err = textEditor->StartLogging(logFile); + } + break; + case eHTMLTextEditorType: + { + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + err = htmlEditor->StartLogging(logFile); + } + break; + default: + err = NS_ERROR_NOT_IMPLEMENTED; + } + +#endif + + return err; +} + +NS_IMETHODIMP +nsEditorShell::StopLogging() +{ + nsresult err = NS_OK; + +#if 1 + + switch (mEditorType) + { + case ePlainTextEditorType: + { + nsCOMPtr textEditor = do_QueryInterface(mEditor); + if (textEditor) + err = textEditor->StopLogging(); + } + break; + case eHTMLTextEditorType: + { + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + err = htmlEditor->StopLogging(); + } + break; + default: + err = NS_ERROR_NOT_IMPLEMENTED; + } + +#endif + + return err; +} + #ifdef XP_MAC #pragma mark - #endif diff --git a/editor/base/nsEditorShell.h b/editor/base/nsEditorShell.h index ee8cc62fb9b1..077fc1babf4a 100644 --- a/editor/base/nsEditorShell.h +++ b/editor/base/nsEditorShell.h @@ -115,7 +115,7 @@ class nsEditorShell : public nsIEditorShell, NS_IMETHOD InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnichar *cite); NS_IMETHOD SelectAll(); - NS_IMETHOD DeleteSelection(); + NS_IMETHOD DeleteSelection(PRInt32 direction); /* void Find (); */ NS_IMETHOD Find(); @@ -164,6 +164,10 @@ class nsEditorShell : public nsIEditorShell, /* void RunUnitTests (); */ NS_IMETHOD RunUnitTests(); + /* void BeginLogging (); */ + NS_IMETHOD StartLogging(nsIFileSpec *logFile); + NS_IMETHOD StopLogging(); + /* Spell check interface */ NS_IMETHOD StartSpellChecking(PRUnichar **_retval); diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index 9f8508326f7e..9f68deeebbaf 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -2607,3 +2607,16 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) return NS_ERROR_NOT_IMPLEMENTED; #endif } + +NS_IMETHODIMP +nsHTMLEditor::StartLogging(nsIFileSpec *aLogFile) +{ + return nsTextEditor::StartLogging(aLogFile); +} + +NS_IMETHODIMP +nsHTMLEditor::StopLogging() +{ + return nsTextEditor::StopLogging(); +} + diff --git a/editor/base/nsHTMLEditor.h b/editor/base/nsHTMLEditor.h index f02dbbc2df59..8dbafbfc1d41 100644 --- a/editor/base/nsHTMLEditor.h +++ b/editor/base/nsHTMLEditor.h @@ -113,6 +113,11 @@ public: NS_IMETHOD OutputTextToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride = nsnull); NS_IMETHOD OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride = nsnull); +// Logging methods + + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); + // End of methods implemented in nsEditor //============================================================= // HTML Editing methods diff --git a/editor/base/nsJSEditorLog.cpp b/editor/base/nsJSEditorLog.cpp index 61a35b3127f7..8abff0f578fc 100644 --- a/editor/base/nsJSEditorLog.cpp +++ b/editor/base/nsJSEditorLog.cpp @@ -34,29 +34,20 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -nsJSEditorLog::nsJSEditorLog(nsIEditor *aEditor) +nsJSEditorLog::nsJSEditorLog(nsIEditor *aEditor, nsIFileSpec *aLogFile) { mRefCnt = 0; mEditor = aEditor; - mDepth = 0; mLocked = -1; - nsresult result = NS_NewFileSpec(getter_AddRefs(mFileSpec)); + mFileSpec = do_QueryInterface(aLogFile); - if (NS_SUCCEEDED(result)) - { - if (mFileSpec) - { - result = mFileSpec->SetUnixStyleFilePath("journal.js.NEW"); + nsresult result; - if (NS_SUCCEEDED(result)) - { - result = mFileSpec->openStreamForWriting(); - } - } - else - result = NS_ERROR_NULL_POINTER; - } + if (mFileSpec) + result = mFileSpec->openStreamForWriting(); + else + result = NS_ERROR_NULL_POINTER; if (NS_FAILED(result)) { @@ -706,6 +697,12 @@ nsJSEditorLog::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) return NS_OK; } +NS_IMETHODIMP +nsJSEditorLog::SaveHLineSettings(nsIDOMElement* aElement) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + NS_IMETHODIMP nsJSEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { @@ -808,6 +805,18 @@ nsJSEditorLog::EndComposition(void) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsJSEditorLog::StartLogging(nsIFileSpec *aLogFile) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsJSEditorLog::StopLogging() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + nsresult nsJSEditorLog::Write(const char *aBuffer) { @@ -827,10 +836,14 @@ nsJSEditorLog::Write(const char *aBuffer) if (NS_FAILED(result)) return result; +#ifdef VERY_SLOW + result = mFileSpec->flush(); if (NS_FAILED(result)) return result; + +#endif // VERY_SLOW } else { diff --git a/editor/base/nsJSEditorLog.h b/editor/base/nsJSEditorLog.h index 4f0a945101ab..01afa8c7253a 100644 --- a/editor/base/nsJSEditorLog.h +++ b/editor/base/nsJSEditorLog.h @@ -31,15 +31,15 @@ class nsJSEditorLog : public nsIHTMLEditor private: nsCOMPtr mFileSpec; - nsIEditor *mEditor; - PRInt32 mLocked; - PRInt32 mDepth; + nsIEditor *mEditor; + PRInt32 mLocked; + PRInt32 mDepth; public: /** The default constructor. */ - nsJSEditorLog(nsIEditor *aEditor); + nsJSEditorLog(nsIEditor *aEditor, nsIFileSpec *aLogFile); /** The default destructor. */ @@ -124,6 +124,7 @@ public: NS_IMETHOD GetSelectedElement(const nsString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn); NS_IMETHOD InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection); + NS_IMETHOD SaveHLineSettings(nsIDOMElement* aElement); NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement); NS_IMETHOD SelectElement(nsIDOMElement* aElement); NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement); @@ -139,6 +140,8 @@ public: NS_IMETHOD BeginComposition(void); NS_IMETHOD SetCompositionString(const nsString& aCompositionString); NS_IMETHOD EndComposition(void); + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); /* nsJSEditorLog public methods. */ nsresult Write(const char *aBuffer); diff --git a/editor/base/nsJSTxnLog.cpp b/editor/base/nsJSTxnLog.cpp index 9d1b0e42d8d9..cad85a436904 100644 --- a/editor/base/nsJSTxnLog.cpp +++ b/editor/base/nsJSTxnLog.cpp @@ -17,6 +17,7 @@ */ #include +#include "nsJSEditorLog.h" #include "nsJSTxnLog.h" #define LOCK_LOG(doc) @@ -24,11 +25,12 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -nsJSTxnLog::nsJSTxnLog() +nsJSTxnLog::nsJSTxnLog(nsJSEditorLog *aEditorLog) { mRefCnt = 0; mIndentLevel = 0; mBatchCount = 0; + mEditorLog = aEditorLog; } nsJSTxnLog::~nsJSTxnLog() @@ -87,7 +89,9 @@ nsJSTxnLog::WillDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction) LOCK_LOG(this); PrintIndent(mIndentLevel++); - printf("WillDo: %s\n", GetString(aTransaction)); + Write("WillDo: "); + Write(GetString(aTransaction)); + Write("\n"); UNLOCK_LOG(this); @@ -100,7 +104,11 @@ nsJSTxnLog::DidDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, n LOCK_LOG(this); PrintIndent(--mIndentLevel); - printf("DidDo: %s (%d)\n", GetString(aTransaction), aDoResult); + Write("DidDo: "); + Write(GetString(aTransaction)); + Write("("); + WriteInt("%d", aDoResult); + Write(")\n"); UNLOCK_LOG(this); @@ -115,9 +123,13 @@ nsJSTxnLog::WillUndo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction PrintIndent(mIndentLevel++); if (aTransaction) - printf("WillUndo: %s\n", GetString(aTransaction)); + { + Write("WillUndo: "); + Write(GetString(aTransaction)); + Write("\n"); + } else - printf("WillUndoBatch\n"); + Write("WillUndoBatch\n"); UNLOCK_LOG(this); @@ -132,9 +144,19 @@ nsJSTxnLog::DidUndo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, PrintIndent(--mIndentLevel); if (aTransaction) - printf("DidUndo: %s (%d)\n", GetString(aTransaction), aUndoResult); + { + Write("DidUndo: "); + Write(GetString(aTransaction)); + Write("("); + WriteInt("%d", aUndoResult); + Write(")\n"); + } else - printf("EndUndoBatch (%d)\n", aUndoResult); + { + Write("EndUndoBatch ("); + WriteInt("%d", aUndoResult); + Write(")\n"); + } UNLOCK_LOG(this); @@ -149,9 +171,13 @@ nsJSTxnLog::WillRedo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction PrintIndent(mIndentLevel++); if (aTransaction) - printf("WillRedo: %s\n", GetString(aTransaction)); + { + Write("WillRedo: "); + Write(GetString(aTransaction)); + Write("\n"); + } else - printf("WillRedoBatch\n"); + Write("WillRedoBatch\n"); UNLOCK_LOG(this); @@ -166,9 +192,19 @@ nsJSTxnLog::DidRedo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, PrintIndent(--mIndentLevel); if (aTransaction) - printf("DidRedo: %s (%d)\n", GetString(aTransaction), aRedoResult); + { + Write("DidRedo: "); + Write(GetString(aTransaction)); + Write(" ("); + WriteInt("%d", aRedoResult); + Write(")\n"); + } else - printf("DidRedoBatch (%d)\n", aRedoResult); + { + Write("DidRedoBatch ("); + WriteInt("%d", aRedoResult); + Write(")\n"); + } UNLOCK_LOG(this); @@ -181,7 +217,9 @@ nsJSTxnLog::WillBeginBatch(nsITransactionManager *aTxMgr) LOCK_LOG(this); PrintIndent(mIndentLevel); - printf("WillBeginBatch: %d\n", mBatchCount); + Write("WillBeginBatch: "); + WriteInt("%d", mBatchCount); + Write("\n"); UNLOCK_LOG(this); @@ -194,7 +232,11 @@ nsJSTxnLog::DidBeginBatch(nsITransactionManager *aTxMgr, nsresult aResult) LOCK_LOG(this); PrintIndent(mIndentLevel++); - printf("DidBeginBatch: %d (%d)\n", mBatchCount++, aResult); + Write("DidBeginBatch: "); + WriteInt("%d", mBatchCount++); + Write(" ("); + WriteInt("%d", aResult); + Write(")\n"); UNLOCK_LOG(this); @@ -207,7 +249,9 @@ nsJSTxnLog::WillEndBatch(nsITransactionManager *aTxMgr) LOCK_LOG(this); PrintIndent(--mIndentLevel); - printf("WillEndBatch: %d\n", --mBatchCount); + Write("WillEndBatch: "); + WriteInt("%d", --mBatchCount); + Write("\n"); UNLOCK_LOG(this); @@ -220,7 +264,11 @@ nsJSTxnLog::DidEndBatch(nsITransactionManager *aTxMgr, nsresult aResult) LOCK_LOG(this); PrintIndent(mIndentLevel); - printf("DidEndBatch: %d (%d)\n", mBatchCount, aResult); + Write("DidEndBatch: "); + WriteInt("%d", mBatchCount); + Write(" ("); + WriteInt("%d", aResult); + Write(")\n"); UNLOCK_LOG(this); @@ -233,8 +281,11 @@ nsJSTxnLog::WillMerge(nsITransactionManager *aTxMgr, nsITransaction *aTopTransac LOCK_LOG(this); PrintIndent(mIndentLevel); - printf("WillMerge: %s <-- %s\n", - GetString(aTopTransaction), GetString(aTransaction)); + Write("WillMerge: "); + Write(GetString(aTopTransaction)); + Write(" <-- "); + Write(GetString(aTransaction)); + Write("\n"); UNLOCK_LOG(this); @@ -247,9 +298,15 @@ nsJSTxnLog::DidMerge(nsITransactionManager *aTxMgr, nsITransaction *aTopTransact LOCK_LOG(this); PrintIndent(mIndentLevel); - printf("DidMerge: %s <-- %s (%s, %d)\n", - GetString(aTopTransaction), GetString(aTransaction), - aDidMerge ? "TRUE" : "FALSE", aMergeResult); + Write("DidMerge: "); + Write(GetString(aTopTransaction)); + Write(" <-- "); + Write(GetString(aTransaction)); + Write(" ("); + Write(aDidMerge ? "TRUE" : "FALSE"); + Write(", "); + WriteInt("%d", aMergeResult); + Write(")\n"); UNLOCK_LOG(this); @@ -279,10 +336,39 @@ nsJSTxnLog::PrintIndent(PRInt32 aIndentLevel) { PRInt32 i; - printf(" // "); + Write(" // "); for (i = 0; i < aIndentLevel; i++) - printf(" "); + Write(" "); return NS_OK; } + +nsresult +nsJSTxnLog::Write(const char *aBuffer) +{ + if (!aBuffer) + return NS_ERROR_NULL_POINTER; + + if (mEditorLog) + mEditorLog->Write(aBuffer); + else + printf(aBuffer); + + return NS_OK; +} + +nsresult +nsJSTxnLog::WriteInt(const char *aFormat, PRInt32 aInt) +{ + if (!aFormat) + return NS_ERROR_NULL_POINTER; + + if (mEditorLog) + mEditorLog->WriteInt(aFormat, aInt); + else + printf(aFormat, aInt); + + return NS_OK; +} + diff --git a/editor/base/nsJSTxnLog.h b/editor/base/nsJSTxnLog.h index 8c5fa5c19cbf..b7dd7d2e5f2f 100644 --- a/editor/base/nsJSTxnLog.h +++ b/editor/base/nsJSTxnLog.h @@ -23,6 +23,8 @@ #include "nsITransactionManager.h" #include "nsITransactionListener.h" +class nsJSEditorLog; + /** implementation of a transaction listener object. * */ @@ -30,6 +32,7 @@ class nsJSTxnLog : public nsITransactionListener { private: + nsJSEditorLog *mEditorLog; PRInt32 mIndentLevel; PRInt32 mBatchCount; @@ -37,7 +40,7 @@ public: /** The default constructor. */ - nsJSTxnLog(); + nsJSTxnLog(nsJSEditorLog *aEditorLog=0); /** The default destructor. */ @@ -66,6 +69,8 @@ private: /* nsJSTxnLog private methods. */ const char *GetString(nsITransaction *aTransaction); nsresult PrintIndent(PRInt32 aIndentLevel); + nsresult Write(const char *aBuffer); + nsresult WriteInt(const char *aFormat, PRInt32 aInt); }; #endif // nsJSTxnLog_h__ diff --git a/editor/base/nsTextEditor.cpp b/editor/base/nsTextEditor.cpp index 1cf2842b7ac7..6d6a2bb7c4a5 100644 --- a/editor/base/nsTextEditor.cpp +++ b/editor/base/nsTextEditor.cpp @@ -2708,3 +2708,15 @@ nsTextEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) #endif } +NS_IMETHODIMP +nsTextEditor::StartLogging(nsIFileSpec *aLogFile) +{ + return nsEditor::StartLogging(aLogFile); +} + +NS_IMETHODIMP +nsTextEditor::StopLogging() +{ + return nsEditor::StopLogging(); +} + diff --git a/editor/base/nsTextEditor.h b/editor/base/nsTextEditor.h index a240c2174116..ee51779ddf37 100644 --- a/editor/base/nsTextEditor.h +++ b/editor/base/nsTextEditor.h @@ -118,6 +118,12 @@ public: // Plain text wrapping control NS_IMETHOD GetBodyWrapWidth(PRInt32 *aWrapColumn); NS_IMETHOD SetBodyWrapWidth(PRInt32 aWrapColumn); + +// Logging methods + + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); + // End of methods implemented in nsEditor //============================================================= diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 265d503c1e1c..1af2ad0cb7ee 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -1336,13 +1336,27 @@ nsEditorShell::SelectAll() NS_IMETHODIMP -nsEditorShell::DeleteSelection() +nsEditorShell::DeleteSelection(PRInt32 action) { nsresult err = NS_NOINTERFACE; - + nsIEditor::ECollapsedSelectionAction selectionAction; + + switch(action) + { + case nsIEditor::eDeleteRight: + selectionAction = nsIEditor::eDeleteRight; + break; + case nsIEditor::eDeleteLeft: + selectionAction = nsIEditor::eDeleteLeft; + break; + default: + selectionAction = nsIEditor::eDoNothing; + break; + } + nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) - err = editor->DeleteSelection(nsIEditor::eDoNothing); + err = editor->DeleteSelection(selectionAction); return err; } @@ -2230,6 +2244,70 @@ nsEditorShell::RunUnitTests() return NS_OK; } +NS_IMETHODIMP +nsEditorShell::StartLogging(nsIFileSpec *logFile) +{ + nsresult err = NS_OK; + +#if 1 + + switch (mEditorType) + { + case ePlainTextEditorType: + { + nsCOMPtr textEditor = do_QueryInterface(mEditor); + if (textEditor) + err = textEditor->StartLogging(logFile); + } + break; + case eHTMLTextEditorType: + { + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + err = htmlEditor->StartLogging(logFile); + } + break; + default: + err = NS_ERROR_NOT_IMPLEMENTED; + } + +#endif + + return err; +} + +NS_IMETHODIMP +nsEditorShell::StopLogging() +{ + nsresult err = NS_OK; + +#if 1 + + switch (mEditorType) + { + case ePlainTextEditorType: + { + nsCOMPtr textEditor = do_QueryInterface(mEditor); + if (textEditor) + err = textEditor->StopLogging(); + } + break; + case eHTMLTextEditorType: + { + nsCOMPtr htmlEditor = do_QueryInterface(mEditor); + if (htmlEditor) + err = htmlEditor->StopLogging(); + } + break; + default: + err = NS_ERROR_NOT_IMPLEMENTED; + } + +#endif + + return err; +} + #ifdef XP_MAC #pragma mark - #endif diff --git a/editor/composer/src/nsEditorShell.h b/editor/composer/src/nsEditorShell.h index ee8cc62fb9b1..077fc1babf4a 100644 --- a/editor/composer/src/nsEditorShell.h +++ b/editor/composer/src/nsEditorShell.h @@ -115,7 +115,7 @@ class nsEditorShell : public nsIEditorShell, NS_IMETHOD InsertAsCitedQuotation(const PRUnichar *quotedText, const PRUnichar *cite); NS_IMETHOD SelectAll(); - NS_IMETHOD DeleteSelection(); + NS_IMETHOD DeleteSelection(PRInt32 direction); /* void Find (); */ NS_IMETHOD Find(); @@ -164,6 +164,10 @@ class nsEditorShell : public nsIEditorShell, /* void RunUnitTests (); */ NS_IMETHOD RunUnitTests(); + /* void BeginLogging (); */ + NS_IMETHOD StartLogging(nsIFileSpec *logFile); + NS_IMETHOD StopLogging(); + /* Spell check interface */ NS_IMETHOD StartSpellChecking(PRUnichar **_retval); diff --git a/editor/idl/nsIEditorShell.idl b/editor/idl/nsIEditorShell.idl index 8fe5a2cefdf5..67ad653b9d04 100644 --- a/editor/idl/nsIEditorShell.idl +++ b/editor/idl/nsIEditorShell.idl @@ -18,6 +18,7 @@ #include "nsISupports.idl" #include "domstubs.idl" +#include "nsIFileSpec.idl" %{C++ @@ -26,6 +27,7 @@ class nsIDOMWindow; class nsIDOMDocument; class nsIDOMSelection; class nsIDOMElement; +class nsIFileSpec; %} @@ -73,7 +75,7 @@ interface nsIEditorShell : nsISupports void InsertAsCitedQuotation(in wstring quotedText, in wstring cite); void SelectAll(); - void DeleteSelection(); + void DeleteSelection(in PRInt32 action); void Find(); void FindNext(); @@ -109,6 +111,9 @@ interface nsIEditorShell : nsISupports void BeginBatchChanges(); void EndBatchChanges(); void RunUnitTests(); + + void StartLogging(in nsIFileSpec logFile); + void StopLogging(); }; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 5a3f7a2ac1f7..ece596c635d6 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -59,6 +59,7 @@ #ifdef ENABLE_JS_EDITOR_LOG #include "nsJSEditorLog.h" +#include "nsJSTxnLog.h" #endif // ENABLE_JS_EDITOR_LOG // transactions the editor knows how to build @@ -318,6 +319,7 @@ nsEditor::nsEditor() , mDoc(nsnull) #ifdef ENABLE_JS_EDITOR_LOG , mJSEditorLog(nsnull) +, mJSTxnLog(nsnull) #endif // ENABLE_JS_EDITOR_LOG { //initialize member variables here @@ -350,11 +352,9 @@ nsEditor::~nsEditor() } #ifdef ENABLE_JS_EDITOR_LOG - if (mJSEditorLog) - { - delete mJSEditorLog; - mJSEditorLog = 0; - } + + StopLogging(); + #endif // ENABLE_JS_EDITOR_LOG // Release service pointers @@ -560,12 +560,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) return NS_OK; } -// #define DEBUG_WITH_JS_EDITOR_LOG -// #define DEBUG_WITH_JS_TXN_LOG -#ifdef DEBUG_WITH_JS_TXN_LOG -#include "nsJSTxnLog.h" -#endif - NS_IMETHODIMP nsEditor::EnableUndo(PRBool aEnable) { @@ -582,24 +576,6 @@ nsEditor::EnableUndo(PRBool aEnable) printf("ERROR: Failed to get TransactionManager instance.\n"); return NS_ERROR_NOT_AVAILABLE; } - -#ifdef DEBUG_WITH_JS_TXN_LOG - nsJSTxnLog *log = new nsJSTxnLog(); - if (log) - { - NS_ADDREF(log); - result = mTxnMgr->AddListener(log); - NS_RELEASE(log); - } -#endif - -#ifdef ENABLE_JS_EDITOR_LOG -#ifdef DEBUG_WITH_JS_EDITOR_LOG - - mJSEditorLog = new nsJSEditorLog(this); - -#endif -#endif // ENABLE_JS_EDITOR_LOG } mTxnMgr->SetMaxTransactionCount(-1); } @@ -958,26 +934,7 @@ nsEditor::BeginTransaction() mJSEditorLog->BeginTransaction(); #endif // ENABLE_JS_EDITOR_LOG - NS_PRECONDITION(mUpdateCount>=0, "bad state"); - - nsCOMPtrselection; - nsresult selectionResult = GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(selectionResult) && selection) { - selection->StartBatchChanges(); - } - - if (nsnull!=mViewManager) - { - if (0==mUpdateCount) - { -#ifdef HACK_FORCE_REDRAW - mViewManager->DisableRefresh(); -#else - mViewManager->BeginUpdateViewBatch(); -#endif - } - mUpdateCount++; - } + BeginUpdateViewBatch(); if ((nsITransactionManager *)nsnull!=mTxnMgr.get()) { @@ -997,32 +954,12 @@ nsEditor::EndTransaction() mJSEditorLog->EndTransaction(); #endif // ENABLE_JS_EDITOR_LOG - NS_PRECONDITION(mUpdateCount>0, "bad state"); - if ((nsITransactionManager *)nsnull!=mTxnMgr.get()) { mTxnMgr->EndBatch(); } - if (nsnull!=mViewManager) - { - mUpdateCount--; - if (0==mUpdateCount) - { -#ifdef HACK_FORCE_REDRAW - mViewManager->EnableRefresh(); - HACKForceRedraw(); -#else - mViewManager->EndUpdateViewBatch(); -#endif - } - } - - nsCOMPtrselection; - nsresult selectionResult = GetSelection(getter_AddRefs(selection)); - if (NS_SUCCEEDED(selectionResult) && selection) { - selection->EndBatchChanges(); - } + EndUpdateViewBatch(); return NS_OK; } @@ -1498,7 +1435,6 @@ nsEditor::InsertText(const nsString& aStringToInsert) if (mJSEditorLog) mJSEditorLog->InsertText(aStringToInsert); - nsAutoEditBatch aeb(this); #endif // ENABLE_JS_EDITOR_LOG EditAggregateTxn *aggTxn = nsnull; @@ -1510,8 +1446,10 @@ nsEditor::InsertText(const nsString& aStringToInsert) InsertTextTxn *txn; result = CreateTxnForInsertText(aStringToInsert, nsnull, &txn); // insert at the current selection if ((NS_SUCCEEDED(result)) && txn) { + BeginUpdateViewBatch(); aggTxn->AppendChild(txn); - result = Do(aggTxn); + result = Do(aggTxn); + EndUpdateViewBatch(); } else if (NS_ERROR_EDITOR_NO_SELECTION==result) { result = DoInitialInsert(aStringToInsert); @@ -3139,6 +3077,59 @@ nsEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) return NS_OK; } +NS_IMETHODIMP +nsEditor::StartLogging(nsIFileSpec *aLogFile) +{ +#ifdef ENABLE_JS_EDITOR_LOG + + mJSEditorLog = new nsJSEditorLog(this, aLogFile); + + if (!mJSEditorLog) + return NS_ERROR_OUT_OF_MEMORY; + + if (mTxnMgr) + { + mJSTxnLog = new nsJSTxnLog(mJSEditorLog); + + if (mJSTxnLog) + { + NS_ADDREF(mJSTxnLog); + mTxnMgr->AddListener(mJSTxnLog); + } + else + return NS_ERROR_OUT_OF_MEMORY; + } + +#endif // ENABLE_JS_EDITOR_LOG + + return NS_OK; +} + +NS_IMETHODIMP +nsEditor::StopLogging() +{ +#ifdef ENABLE_JS_EDITOR_LOG + + if (mTxnMgr && mJSTxnLog) + mTxnMgr->RemoveListener(mJSTxnLog); + + if (mJSTxnLog) + { + NS_RELEASE(mJSTxnLog); + mJSTxnLog = 0; + } + + if (mJSEditorLog) + { + delete mJSEditorLog; + mJSEditorLog = 0; + } + +#endif // ENABLE_JS_EDITOR_LOG + + return NS_OK; +} + NS_IMETHODIMP nsEditor::DebugDumpContent() const { @@ -4023,6 +4014,60 @@ nsresult nsEditor::GetString(const nsString& name, nsString& value) return result; } +nsresult nsEditor::BeginUpdateViewBatch() +{ + NS_PRECONDITION(mUpdateCount>=0, "bad state"); + + nsCOMPtrselection; + nsresult selectionResult = GetSelection(getter_AddRefs(selection)); + if (NS_SUCCEEDED(selectionResult) && selection) { + selection->StartBatchChanges(); + } + + if (nsnull!=mViewManager) + { + if (0==mUpdateCount) + { +#ifdef HACK_FORCE_REDRAW + mViewManager->DisableRefresh(); +#else + mViewManager->BeginUpdateViewBatch(); +#endif + } + mUpdateCount++; + } + + return NS_OK; +} + + +nsresult nsEditor::EndUpdateViewBatch() +{ + NS_PRECONDITION(mUpdateCount>0, "bad state"); + + if (nsnull!=mViewManager) + { + mUpdateCount--; + if (0==mUpdateCount) + { +#ifdef HACK_FORCE_REDRAW + mViewManager->EnableRefresh(); + HACKForceRedraw(); +#else + mViewManager->EndUpdateViewBatch(); +#endif + } + } + + nsCOMPtrselection; + nsresult selectionResult = GetSelection(getter_AddRefs(selection)); + if (NS_SUCCEEDED(selectionResult) && selection) { + selection->EndBatchChanges(); + } + + return NS_OK; +} + /****************************************************************************** * nsAutoSelectionReset *****************************************************************************/ diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index a71420a50681..cb0886048122 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -32,6 +32,7 @@ #include "TransactionFactory.h" #include "nsIComponentManager.h" #include "nsIEditProperty.h" +#include "nsIFileSpec.h" class nsIEditActionListener; class nsIDOMCharacterData; @@ -56,6 +57,7 @@ class nsILocale; #ifdef ENABLE_JS_EDITOR_LOG class nsJSEditorLog; +class nsJSTxnLog; #endif // ENABLE_JS_EDITOR_LOG //This is the monitor for the editor. @@ -90,6 +92,7 @@ protected: #ifdef ENABLE_JS_EDITOR_LOG nsJSEditorLog *mJSEditorLog; + nsJSTxnLog *mJSTxnLog; #endif // ENABLE_JS_EDITOR_LOG public: @@ -223,6 +226,9 @@ public: NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed); + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); + /*END nsIEditor interfaces*/ @@ -523,6 +529,9 @@ public: nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection); nsresult GetString(const nsString& name, nsString& value); + + nsresult BeginUpdateViewBatch(void); + nsresult EndUpdateViewBatch(void); }; diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 9f8508326f7e..9f68deeebbaf 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -2607,3 +2607,16 @@ nsHTMLEditor::DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed) return NS_ERROR_NOT_IMPLEMENTED; #endif } + +NS_IMETHODIMP +nsHTMLEditor::StartLogging(nsIFileSpec *aLogFile) +{ + return nsTextEditor::StartLogging(aLogFile); +} + +NS_IMETHODIMP +nsHTMLEditor::StopLogging() +{ + return nsTextEditor::StopLogging(); +} + diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index f02dbbc2df59..8dbafbfc1d41 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -113,6 +113,11 @@ public: NS_IMETHOD OutputTextToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride = nsnull); NS_IMETHOD OutputHTMLToStream(nsIOutputStream* aOutputStream,nsString* aCharsetOverride = nsnull); +// Logging methods + + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile); + NS_IMETHOD StopLogging(); + // End of methods implemented in nsEditor //============================================================= // HTML Editing methods diff --git a/editor/public/nsIEditor.h b/editor/public/nsIEditor.h index 81dde3b09bc9..f3158bfb88c5 100644 --- a/editor/public/nsIEditor.h +++ b/editor/public/nsIEditor.h @@ -26,6 +26,7 @@ class nsIDOMElement; class nsIDOMNode; class nsITransaction; class nsIEditActionListener; +class nsIFileSpec; /* Editor interface to outside world @@ -387,6 +388,12 @@ public: /* Run unit tests. Noop in optimized builds */ NS_IMETHOD DebugUnitTests(PRInt32 *outNumTests, PRInt32 *outNumTestsFailed)=0; + + /* Start logging */ + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0; + + /* Stop logging */ + NS_IMETHOD StopLogging()=0; }; #endif //nsIEditor_h__ diff --git a/editor/public/nsIHTMLEditor.h b/editor/public/nsIHTMLEditor.h index 7f4bd497794b..86e0934c3faa 100644 --- a/editor/public/nsIHTMLEditor.h +++ b/editor/public/nsIHTMLEditor.h @@ -35,6 +35,7 @@ class nsStringArray; class nsIAtom; class nsIOutputStream; class nsIDOMWindow; +class nsIFileSpec; /** * The HTML editor interface. @@ -194,6 +195,10 @@ public: NS_IMETHOD SetCompositionString(const nsString& aCompositionString)=0; NS_IMETHOD EndComposition(void)=0; + + // Logging Methods + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0; + NS_IMETHOD StopLogging()=0; }; #endif //nsIEditor_h__ diff --git a/editor/public/nsITextEditor.h b/editor/public/nsITextEditor.h index c2bc974aabca..6aecd160ae5d 100644 --- a/editor/public/nsITextEditor.h +++ b/editor/public/nsITextEditor.h @@ -31,6 +31,7 @@ class nsISupportsArray; class nsIAtom; class nsIOutputStream; class nsString; +class nsIFileSpec; #define TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text entry is allowed via events #define TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially @@ -364,6 +365,10 @@ public: NS_IMETHOD SetCompositionString(const nsString& aCompositionString)=0; NS_IMETHOD EndComposition(void)=0; + +// Logging Methods + NS_IMETHOD StartLogging(nsIFileSpec *aLogFile)=0; + NS_IMETHOD StopLogging()=0; }; #endif //nsIEditor_h__ diff --git a/editor/ui/composer/content/EditorAppShell.xul b/editor/ui/composer/content/EditorAppShell.xul index e10f7eae862f..485da917cf65 100644 --- a/editor/ui/composer/content/EditorAppShell.xul +++ b/editor/ui/composer/content/EditorAppShell.xul @@ -173,9 +173,9 @@ - - - + + + diff --git a/editor/ui/composer/content/EditorCommands.js b/editor/ui/composer/content/EditorCommands.js index 0e32ab82c00a..7d9b0478cba9 100644 --- a/editor/ui/composer/content/EditorCommands.js +++ b/editor/ui/composer/content/EditorCommands.js @@ -422,13 +422,35 @@ function EditorGetScriptFileSpec() return fs; } -function EditorRunJournal() +function EditorStartLog() +{ + var fs; + + if (window.editorShell) + { + fs = Components.classes["component://netscape/filespec"].createInstance(); + fs = fs.QueryInterface(Components.interfaces.nsIFileSpec); + fs.UnixStyleFilePath = "journal.js"; + + window.editorShell.StartLogging(fs); + + fs = null; + } +} + +function EditorStopLog() +{ + if (window.editorShell) + { + window.editorShell.StopLogging(); + } +} + +function EditorRunLog() { var fs; - // dump("Executing script ...\n"); fs = EditorGetScriptFileSpec(); EditorExecuteScript(fs); - // dump("Done executing script!\n"); } function EditorGetNodeFromOffsets(offsets)