зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug #8309: Need to Flush() during Editor API Logging.
This commit is contained in:
Родитель
b805ab5273
Коммит
3dfd600432
|
@ -134,6 +134,8 @@ nsJSEditorLog::SetTextProperty(nsIAtom *aProperty, const nsString *aAttribute, c
|
|||
PrintUnicode(*aValue);
|
||||
Write("\");\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -160,6 +162,8 @@ nsJSEditorLog::SetParagraphFormat(const nsString& aParagraphFormat)
|
|||
PrintUnicode(aParagraphFormat);
|
||||
Write("\");\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -181,6 +185,8 @@ nsJSEditorLog::RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute
|
|||
PrintUnicode(*aAttribute);
|
||||
Write("\");\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -195,6 +201,8 @@ nsJSEditorLog::DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction)
|
|||
WriteInt("%d", aAction);
|
||||
Write(");\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -210,6 +218,8 @@ nsJSEditorLog::InsertText(const nsString& aStringToInsert)
|
|||
PrintUnicode(aStringToInsert);
|
||||
Write("\");\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -221,6 +231,7 @@ nsJSEditorLog::InsertBreak()
|
|||
|
||||
PrintSelection();
|
||||
Write("window.editorShell.InsertBreak();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -238,6 +249,7 @@ nsJSEditorLog::Undo(PRUint32 aCount)
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.Undo();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -255,6 +267,7 @@ nsJSEditorLog::Redo(PRUint32 aCount)
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.Redo();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -272,6 +285,7 @@ nsJSEditorLog::BeginTransaction()
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.BeginBatchChanges();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -283,6 +297,7 @@ nsJSEditorLog::EndTransaction()
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.EndBatchChanges();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -330,6 +345,7 @@ nsJSEditorLog::SelectAll()
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.SelectAll();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -341,6 +357,7 @@ nsJSEditorLog::BeginningOfDocument()
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.BeginningOfDocument();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -352,6 +369,7 @@ nsJSEditorLog::EndOfDocument()
|
|||
return NS_OK;
|
||||
|
||||
Write("window.editorShell.EndOfDocument();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -396,6 +414,7 @@ nsJSEditorLog::Cut()
|
|||
|
||||
PrintSelection();
|
||||
Write("window.editorShell.Cut();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -408,6 +427,7 @@ nsJSEditorLog::Copy()
|
|||
|
||||
PrintSelection();
|
||||
Write("window.editorShell.Copy();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -420,6 +440,7 @@ nsJSEditorLog::Paste()
|
|||
|
||||
PrintSelection();
|
||||
Write("window.editorShell.Paste();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -432,6 +453,7 @@ nsJSEditorLog::PasteAsQuotation()
|
|||
|
||||
PrintSelection();
|
||||
Write("window.editorShell.PasteAsQuotation();\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -446,6 +468,7 @@ nsJSEditorLog::PasteAsCitedQuotation(const nsString& aCitation)
|
|||
Write("window.editorShell.PasteAsCitedQuotation(\"");
|
||||
PrintUnicode(aCitation);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -460,6 +483,7 @@ nsJSEditorLog::InsertAsQuotation(const nsString& aQuotedText)
|
|||
Write("window.editorShell.InsertAsQuotation(\"");
|
||||
PrintUnicode(aQuotedText);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -476,6 +500,7 @@ nsJSEditorLog::InsertAsCitedQuotation(const nsString& aQuotedText, const nsStrin
|
|||
Write("\", \"");
|
||||
PrintUnicode(aCitation);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -525,6 +550,7 @@ nsJSEditorLog::SetBackgroundColor(const nsString& aColor)
|
|||
Write("window.editorShell.SetBackgroundColor(\"");
|
||||
PrintUnicode(aColor);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -540,6 +566,7 @@ nsJSEditorLog::SetBodyAttribute(const nsString& aAttr, const nsString& aValue)
|
|||
Write("\", \"");
|
||||
PrintUnicode(aValue);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -585,6 +612,7 @@ nsJSEditorLog::InsertLink(nsString& aURL)
|
|||
Write("window.editorShell.InsertLink(\"");
|
||||
PrintUnicode(aURL);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -616,6 +644,7 @@ nsJSEditorLog::InsertImage(nsString& aURL, nsString& aWidth, nsString& aHeight,
|
|||
Write("\", \"");
|
||||
PrintUnicode(aAlignment);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -631,6 +660,7 @@ nsJSEditorLog::InsertList(const nsString& aListType)
|
|||
Write("window.editorShell.InsertList(\"");
|
||||
PrintUnicode(aListType);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -646,6 +676,7 @@ nsJSEditorLog::Indent(const nsString& aIndent)
|
|||
Write("window.editorShell.Indent(\"");
|
||||
PrintUnicode(aIndent);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -661,6 +692,7 @@ nsJSEditorLog::Align(const nsString& aAlign)
|
|||
Write("window.editorShell.Align(\"");
|
||||
PrintUnicode(aAlign);
|
||||
Write("\");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -693,6 +725,7 @@ nsJSEditorLog::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
Write("window.editorShell.InsertElement(n0, ");
|
||||
Write(aDeleteSelection ? "true" : "false");
|
||||
Write(");\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -717,6 +750,7 @@ nsJSEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
|
|||
PrintSelection();
|
||||
PrintNode(node, 0);
|
||||
Write("window.editorShell.InsertLinkAroundSelection(n0);\n");
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -846,10 +880,8 @@ nsJSEditorLog::Write(const char *aBuffer)
|
|||
#endif // VERY_SLOW
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(aBuffer, 1, len, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -866,6 +898,19 @@ nsJSEditorLog::WriteInt(const char *aFormat, PRInt32 aInt)
|
|||
return Write(buf);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJSEditorLog::Flush()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (mFileSpec)
|
||||
result = mFileSpec->flush();
|
||||
else
|
||||
fflush(stdout);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJSEditorLog::PrintUnicode(const nsString &aString)
|
||||
{
|
||||
|
@ -1006,6 +1051,9 @@ nsJSEditorLog::PrintSelection()
|
|||
}
|
||||
|
||||
Write(" ];\nEditorSetSelectionFromOffsets(selRanges);\n");
|
||||
|
||||
Flush();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1223,6 +1271,8 @@ nsJSEditorLog::PrintNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
|||
break;
|
||||
}
|
||||
|
||||
Flush();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ public:
|
|||
/* nsJSEditorLog public methods. */
|
||||
nsresult Write(const char *aBuffer);
|
||||
nsresult WriteInt(const char *aFormat, PRInt32 aInt);
|
||||
nsresult Flush();
|
||||
nsresult PrintUnicode(const nsString &aString);
|
||||
nsresult PrintSelection();
|
||||
nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
|
||||
|
|
|
@ -92,6 +92,7 @@ nsJSTxnLog::WillDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction)
|
|||
Write("WillDo: ");
|
||||
Write(GetString(aTransaction));
|
||||
Write("\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -109,6 +110,7 @@ nsJSTxnLog::DidDo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction, n
|
|||
Write("(");
|
||||
WriteInt("%d", aDoResult);
|
||||
Write(")\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -131,6 +133,8 @@ nsJSTxnLog::WillUndo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction
|
|||
else
|
||||
Write("WillUndoBatch\n");
|
||||
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -158,6 +162,8 @@ nsJSTxnLog::DidUndo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction,
|
|||
Write(")\n");
|
||||
}
|
||||
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -179,6 +185,8 @@ nsJSTxnLog::WillRedo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction
|
|||
else
|
||||
Write("WillRedoBatch\n");
|
||||
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -206,6 +214,8 @@ nsJSTxnLog::DidRedo(nsITransactionManager *aTxMgr, nsITransaction *aTransaction,
|
|||
Write(")\n");
|
||||
}
|
||||
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -220,6 +230,7 @@ nsJSTxnLog::WillBeginBatch(nsITransactionManager *aTxMgr)
|
|||
Write("WillBeginBatch: ");
|
||||
WriteInt("%d", mBatchCount);
|
||||
Write("\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -237,6 +248,7 @@ nsJSTxnLog::DidBeginBatch(nsITransactionManager *aTxMgr, nsresult aResult)
|
|||
Write(" (");
|
||||
WriteInt("%d", aResult);
|
||||
Write(")\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -252,6 +264,7 @@ nsJSTxnLog::WillEndBatch(nsITransactionManager *aTxMgr)
|
|||
Write("WillEndBatch: ");
|
||||
WriteInt("%d", --mBatchCount);
|
||||
Write("\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -269,6 +282,7 @@ nsJSTxnLog::DidEndBatch(nsITransactionManager *aTxMgr, nsresult aResult)
|
|||
Write(" (");
|
||||
WriteInt("%d", aResult);
|
||||
Write(")\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -286,6 +300,7 @@ nsJSTxnLog::WillMerge(nsITransactionManager *aTxMgr, nsITransaction *aTopTransac
|
|||
Write(" <-- ");
|
||||
Write(GetString(aTransaction));
|
||||
Write("\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -307,6 +322,7 @@ nsJSTxnLog::DidMerge(nsITransactionManager *aTxMgr, nsITransaction *aTopTransact
|
|||
Write(", ");
|
||||
WriteInt("%d", aMergeResult);
|
||||
Write(")\n");
|
||||
Flush();
|
||||
|
||||
UNLOCK_LOG(this);
|
||||
|
||||
|
@ -372,3 +388,19 @@ nsJSTxnLog::WriteInt(const char *aFormat, PRInt32 aInt)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJSTxnLog::Flush()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
#ifdef SLOWS_THINGS_WAY_DOWN
|
||||
|
||||
if (mEditorLog)
|
||||
result = mEditorLog->Flush();
|
||||
else
|
||||
fflush(stdout);
|
||||
|
||||
#endif // SLOWS_THINGS_WAY_DOWN
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
nsresult PrintIndent(PRInt32 aIndentLevel);
|
||||
nsresult Write(const char *aBuffer);
|
||||
nsresult WriteInt(const char *aFormat, PRInt32 aInt);
|
||||
nsresult Flush();
|
||||
};
|
||||
|
||||
#endif // nsJSTxnLog_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче