зеркало из https://github.com/mozilla/gecko-dev.git
* Added StartLogging() and StopLogging() methods to nsIEditor,
nsIHTMLEditor, nsITextEditor, and nsIEditorShell and enabled the "Start Log" and "End Log" menu items in the editor test bed. * Modified makefiles for Unix and Win32 to turn on Editor API Logging. * Added action argument to the DeleteSelection() method in nsIEditorShell. * Modified nsJSTxnLog to use nsJSEditorLog when writing it's output.
This commit is contained in:
Родитель
14adea95c5
Коммит
e3bf912523
|
@ -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
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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");
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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");
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
nsresult selectionResult = GetSelection(getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(selectionResult) && selection) {
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* nsAutoSelectionReset
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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<nsIEditor> 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<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
err = textEditor->StartLogging(logFile);
|
||||
}
|
||||
break;
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> 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<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
err = textEditor->StopLogging();
|
||||
}
|
||||
break;
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -31,15 +31,15 @@ class nsJSEditorLog : public nsIHTMLEditor
|
|||
private:
|
||||
|
||||
nsCOMPtr<nsIFileSpec> 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);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
//=============================================================
|
||||
|
||||
|
|
|
@ -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<nsIEditor> 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<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
err = textEditor->StartLogging(logFile);
|
||||
}
|
||||
break;
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> 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<nsITextEditor> textEditor = do_QueryInterface(mEditor);
|
||||
if (textEditor)
|
||||
err = textEditor->StopLogging();
|
||||
}
|
||||
break;
|
||||
case eHTMLTextEditorType:
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> 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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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");
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSelection>selection;
|
||||
nsresult selectionResult = GetSelection(getter_AddRefs(selection));
|
||||
if (NS_SUCCEEDED(selectionResult) && selection) {
|
||||
selection->EndBatchChanges();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* nsAutoSelectionReset
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -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__
|
||||
|
|
|
@ -173,9 +173,9 @@
|
|||
<menuitem name="Test Document" onclick="EditorTestDocument()"/>
|
||||
<menuitem name="Run Unit Tests" onclick="EditorUnitTests()"/>
|
||||
<separator />
|
||||
<menuitem name="Start Journal" onclick=""/>
|
||||
<menuitem name="Stop Journal" onclick=""/>
|
||||
<menuitem name="Run Journal" onclick="EditorRunJournal()"/>
|
||||
<menuitem name="Start Log" onclick="EditorStartLog()"/>
|
||||
<menuitem name="Stop Log" onclick="EditorStopLog()"/>
|
||||
<menuitem name="Run Log" onclick="EditorRunLog()"/>
|
||||
</menu>
|
||||
<menu name="Help">
|
||||
<menuitem name=".About" onclick=""/>
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче