Bug 1387317 - part5: AutoPlaceHolderBatch should take EditorBase instead of nsIEditor r=m_kato

AutoPlaceHolderBatch can take EditorBase class and its inherited class, AutoEditBatch, can be removed if we implement other constructor which doesn't take transaction name.

Additionally, nsIEditor::(Begin|End)PlaceHolderTransaction() are referred only by AutoPlaceHolderBatch.  Therefore, they can be non-public methods and removed from nsIEditor interface.

Note that this patch also repalces "PlaceHolder" with "Placeholder" since it's a word.

MozReview-Commit-ID: 5dw3kcX3bOx

--HG--
extra : rebase_source : e926cc1c2ebea70eb08e43778a8b52912b559b7b
This commit is contained in:
Masayuki Nakano 2017-08-14 14:56:39 +09:00
parent 1bbc0d5920
commit e1a21d5a3e
13 changed files with 100 additions and 110 deletions

View File

@ -956,16 +956,8 @@ EditorBase::EndTransaction()
return NS_OK;
}
// These two routines are similar to the above, but do not use
// the transaction managers batching feature. Instead we use
// a placeholder transaction to wrap up any further transaction
// while the batch is open. The advantage of this is that
// placeholder transactions can later merge, if needed. Merging
// is unavailable between transaction manager batches.
NS_IMETHODIMP
EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
void
EditorBase::BeginPlaceholderTransaction(nsIAtom* aTransactionName)
{
MOZ_ASSERT(mPlaceholderBatch >= 0, "negative placeholder batch count!");
if (!mPlaceholderBatch) {
@ -973,7 +965,7 @@ EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
// time to turn on the batch
BeginUpdateViewBatch();
mPlaceholderTransaction = nullptr;
mPlaceholderName = aName;
mPlaceholderName = aTransactionName;
RefPtr<Selection> selection = GetSelection();
if (selection) {
mSelState.emplace();
@ -989,12 +981,10 @@ EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
}
}
mPlaceholderBatch++;
return NS_OK;
}
NS_IMETHODIMP
EditorBase::EndPlaceHolderTransaction()
void
EditorBase::EndPlaceholderTransaction()
{
MOZ_ASSERT(mPlaceholderBatch > 0,
"zero or negative placeholder batch count when ending batch!");
@ -1057,8 +1047,6 @@ EditorBase::EndPlaceHolderTransaction()
}
}
mPlaceholderBatch--;
return NS_OK;
}
NS_IMETHODIMP
@ -2343,7 +2331,7 @@ EditorBase::CloneAttributes(Element* aDest,
{
MOZ_ASSERT(aDest && aSource);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Use transaction system for undo only if destination is already in the
// document

View File

@ -594,6 +594,18 @@ protected:
nsresult GetSelection(SelectionType aSelectionType,
nsISelection** aSelection);
/**
* (Begin|End)PlaceholderTransaction() are called by AutoPlaceholderBatch.
* This set of methods are similar to the (Begin|End)Transaction(), but do
* not use the transaction managers batching feature. Instead we use a
* placeholder transaction to wrap up any further transaction while the
* batch is open. The advantage of this is that placeholder transactions
* can later merge, if needed. Merging is unavailable between transaction
* manager batches.
*/
void BeginPlaceholderTransaction(nsIAtom* aTransactionName);
void EndPlaceholderTransaction();
public:
/**
* All editor operations which alter the doc should be prefaced
@ -1294,6 +1306,7 @@ protected:
bool mIsHTMLEditorClass;
friend bool NSCanUnload(nsISupports* serviceMgr);
friend class AutoPlaceholderBatch;
friend class AutoRules;
friend class AutoSelectionRestorer;
friend class AutoTransactionsConserveSelection;

View File

@ -143,52 +143,43 @@ EditActionCanceled(nsresult aRv = NS_OK)
/***************************************************************************
* stack based helper class for batching a collection of transactions inside a
* placeholder transaction.
* XXX This is used by mozInlineSpellChecker. Therefore, cannot use concrete
* editor class.
*/
class MOZ_RAII AutoPlaceHolderBatch
class MOZ_RAII AutoPlaceholderBatch final
{
private:
nsCOMPtr<nsIEditor> mEditor;
RefPtr<EditorBase> mEditorBase;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
AutoPlaceHolderBatch(nsIEditor* aEditor,
nsIAtom* aAtom
explicit AutoPlaceholderBatch(EditorBase* aEditorBase
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEditorBase(aEditorBase)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
BeginPlaceholderTransaction(nullptr);
}
AutoPlaceholderBatch(EditorBase* aEditorBase,
nsIAtom* aTransactionName
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEditor(aEditor)
: mEditorBase(aEditorBase)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEditor) {
mEditor->BeginPlaceHolderTransaction(aAtom);
}
BeginPlaceholderTransaction(aTransactionName);
}
~AutoPlaceHolderBatch()
~AutoPlaceholderBatch()
{
if (mEditor) {
mEditor->EndPlaceHolderTransaction();
if (mEditorBase) {
mEditorBase->EndPlaceholderTransaction();
}
}
};
/***************************************************************************
* stack based helper class for batching a collection of txns.
* Note: I changed this to use placeholder batching so that we get
* proper selection save/restore across undo/redo.
*/
class MOZ_RAII AutoEditBatch final : public AutoPlaceHolderBatch
{
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
explicit AutoEditBatch(nsIEditor* aEditor
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoPlaceHolderBatch(aEditor, nullptr)
void BeginPlaceholderTransaction(nsIAtom* aTransactionName)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEditorBase) {
mEditorBase->BeginPlaceholderTransaction(aTransactionName);
}
}
~AutoEditBatch() {}
};
/***************************************************************************

View File

@ -53,7 +53,7 @@ using namespace dom;
NS_IMETHODIMP
HTMLEditor::AbsolutePositionSelection(bool aEnabled)
{
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this,
aEnabled ? EditAction::setAbsolutePosition :
EditAction::removeAbsolutePosition,
@ -180,7 +180,7 @@ HTMLEditor::SetElementZIndex(nsIDOMElement* aElement,
NS_IMETHODIMP
HTMLEditor::RelativeChangeZIndex(int32_t aChange)
{
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this,
(aChange < 0) ? EditAction::decreaseZIndex :
EditAction::increaseZIndex,
@ -466,7 +466,7 @@ HTMLEditor::SetFinalPosition(int32_t aX,
y.AppendInt(newY);
// we want one transaction only from a user's point of view
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
nsCOMPtr<Element> absolutelyPositionedObject =
do_QueryInterface(mAbsolutelyPositionedObject);
@ -510,7 +510,7 @@ HTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
if (isPositioned == aEnabled)
return NS_OK;
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
if (aEnabled) {
int32_t x, y;
@ -613,7 +613,7 @@ HTMLEditor::SetElementPosition(Element& aElement,
int32_t aX,
int32_t aY)
{
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
}

View File

@ -1016,7 +1016,7 @@ HTMLEditor::TypedText(const nsAString& aString,
{
MOZ_ASSERT(!aString.IsEmpty() || aAction != eTypedText);
AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
AutoPlaceholderBatch batch(this, nsGkAtoms::TypingTxnName);
if (aAction == eTypedBR) {
// only inserts a br node
@ -1230,7 +1230,7 @@ HTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
// Mac linebreaks: Map any remaining CR to LF:
inputString.ReplaceSubstring(u"\r", u"\n");
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Get the first range in the selection, for context:
RefPtr<nsRange> range = selection->GetRangeAt(0);
@ -1318,7 +1318,7 @@ HTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
}
// Time to change the document
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
nsReadingIterator<char16_t> endtotal;
aSourceString.EndReading(endtotal);
@ -1538,7 +1538,7 @@ HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
CommitComposition();
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
@ -1997,7 +1997,7 @@ HTMLEditor::MakeOrChangeList(const nsAString& aListType,
bool cancel, handled;
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext);
// pre-process
@ -2068,7 +2068,7 @@ HTMLEditor::RemoveList(const nsAString& aListType)
bool cancel, handled;
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext);
// pre-process
@ -2103,7 +2103,7 @@ HTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
bool cancel, handled;
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeDefListItem,
nsIEditor::eNext);
@ -2136,7 +2136,7 @@ HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
bool cancel, handled;
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeBasicBlock,
nsIEditor::eNext);
@ -2208,7 +2208,7 @@ HTMLEditor::Indent(const nsAString& aIndent)
if (aIndent.LowerCaseEqualsLiteral("outdent")) {
opID = EditAction::outdent;
}
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
// pre-process
@ -2277,7 +2277,7 @@ HTMLEditor::Align(const nsAString& aAlignType)
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> rules(mRules);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext);
bool cancel, handled;
@ -2689,7 +2689,7 @@ HTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
return NS_OK;
}
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Set all attributes found on the supplied anchor element
nsCOMPtr<nsIDOMMozNamedAttrMap> attrMap;
@ -3452,7 +3452,7 @@ HTMLEditor::StyleSheetLoaded(StyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
if (!mLastStyleSheetURL.IsEmpty())
RemoveStyleSheet(mLastStyleSheetURL);
@ -4535,7 +4535,7 @@ HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
bool isCollapsed = selection->Collapsed();
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);

View File

@ -103,7 +103,7 @@ HTMLEditor::LoadHTML(const nsAString& aInputString)
// force IME commit; set up rules sniffing and batching
CommitComposition();
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext);
// Get selection
@ -198,7 +198,7 @@ HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
// force IME commit; set up rules sniffing and batching
CommitComposition();
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::htmlPaste, nsIEditor::eNext);
// Get selection
@ -1024,7 +1024,7 @@ HTMLEditor::BlobReader::OnResult(const nsACString& aResult)
nsresult rv = ImgFromData(type, aResult, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
AutoEditBatch beginBatching(mHTMLEditor);
AutoPlaceholderBatch beginBatching(mHTMLEditor);
rv = mHTMLEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(),
EmptyString(),
NS_LITERAL_STRING(kFileMime),
@ -1120,7 +1120,7 @@ HTMLEditor::InsertObject(const nsACString& aType,
rv = ImgFromData(type, imageData, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),
aSourceDoc,
@ -1174,7 +1174,7 @@ HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty()) {
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// If we have our private HTML flavor, we will only use the fragment
// from the CF_HTML. The rest comes from the clipboard.
if (havePrivateHTMLFlavor) {
@ -1224,7 +1224,7 @@ HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
}
if (!stuffToPaste.IsEmpty()) {
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
if (bestFlavor.EqualsLiteral(kHTMLMime)) {
rv = DoInsertHTMLWithContext(stuffToPaste,
aContextStr, aInfoStr, flavor,
@ -1308,7 +1308,7 @@ HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
nsresult rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty()) {
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
if (hasPrivateHTMLFlavor) {
// If we have our private HTML flavor, we will only use the fragment
@ -1337,7 +1337,7 @@ HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), aIndex, contextString);
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), aIndex, infoString);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
if (type.EqualsLiteral(kHTMLMime)) {
return DoInsertHTMLWithContext(text,
contextString, infoString, type,
@ -1354,7 +1354,7 @@ HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
nsAutoString text;
GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
return InsertTextAt(text, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
}
@ -1632,7 +1632,7 @@ NS_IMETHODIMP
HTMLEditor::PasteAsCitedQuotation(const nsAString& aCitation,
int32_t aSelectionType)
{
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
@ -1708,7 +1708,7 @@ HTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
nsAutoString stuffToPaste;
textDataObj->GetData(stuffToPaste);
NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste, true, 0);
}
}
@ -1835,7 +1835,7 @@ HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
@ -1935,7 +1935,7 @@ HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);

View File

@ -906,7 +906,7 @@ HTMLEditor::SetFinalSize(int32_t aX,
y = top - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderTop+mResizedObjectMarginTop : 0);
// we want one transaction only from a user's point of view
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
if (mResizedObjectIsAbsolutelyPositioned) {
if (setHeight) {

View File

@ -122,7 +122,7 @@ HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
return NS_OK;
}
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
@ -1180,7 +1180,7 @@ HTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom* aProperty,
NS_IMETHODIMP
HTMLEditor::RemoveAllInlineProperties()
{
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::resetTextProperties,
nsIEditor::eNext);
@ -1224,7 +1224,7 @@ HTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
return NS_OK;
}
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::removeTextProperty,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
@ -1381,7 +1381,7 @@ HTMLEditor::RelativeFontChange(FontSize aDir)
}
// Wrap with txn batching, rules sniffing, and selection preservation code
AutoEditBatch batchIt(this);
AutoPlaceholderBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::setTextProperty,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);

View File

@ -415,7 +415,7 @@ HTMLEditor::InsertTableColumn(int32_t aNumber,
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(curCell, NS_ERROR_FAILURE);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
@ -550,7 +550,7 @@ HTMLEditor::InsertTableRow(int32_t aNumber,
rv = GetTableSize(table, &rowCount, &colCount);
NS_ENSURE_SUCCESS(rv, rv);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
@ -732,7 +732,7 @@ HTMLEditor::DeleteTable()
nullptr, nullptr, nullptr, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
return DeleteTable2(table, selection);
}
@ -755,7 +755,7 @@ HTMLEditor::DeleteTableCell(int32_t aNumber)
// Don't fail if we didn't find a table or cell
NS_ENSURE_TRUE(table && cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
@ -944,7 +944,7 @@ HTMLEditor::DeleteTableCellContents()
NS_ENSURE_TRUE(cell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
//Don't let Rules System change the selection
@ -1028,7 +1028,7 @@ HTMLEditor::DeleteTableColumn(int32_t aNumber)
// Check for counts too high
aNumber = std::min(aNumber,(colCount-startColIndex));
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
@ -1194,7 +1194,7 @@ HTMLEditor::DeleteTableRow(int32_t aNumber)
return DeleteTable2(table, selection);
}
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
@ -1734,7 +1734,7 @@ HTMLEditor::SplitTableCell()
return NS_OK;
}
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
@ -1962,7 +1962,7 @@ HTMLEditor::SwitchTableCellHeaderType(nsIDOMElement* aSourceCell,
nsCOMPtr<Element> sourceCell = do_QueryInterface(aSourceCell);
NS_ENSURE_TRUE(sourceCell, NS_ERROR_NULL_POINTER);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent auto insertion of BR in new cell created by ReplaceContainer
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
@ -2015,7 +2015,7 @@ HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
return NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND;
}
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
//Don't let Rules System change the selection
AutoTransactionsConserveSelection dontChangeSelection(this);
@ -2510,7 +2510,7 @@ HTMLEditor::NormalizeTable(nsIDOMElement* aTable)
// Save current selection
AutoSelectionRestorer selectionRestorer(selection, this);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);

View File

@ -9,7 +9,7 @@
#include "TextEditUtils.h"
#include "gfxFontUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/EditorUtils.h" // AutoEditBatch, AutoRules
#include "mozilla/EditorUtils.h" // AutoPlaceholderBatch, AutoRules
#include "mozilla/HTMLEditor.h"
#include "mozilla/mozalloc.h"
#include "mozilla/Preferences.h"
@ -400,7 +400,7 @@ TextEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
NS_IMETHODIMP
TextEditor::TypedText(const nsAString& aString, ETypingAction aAction)
{
AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
AutoPlaceholderBatch batch(this, nsGkAtoms::TypingTxnName);
switch (aAction) {
case eTypedText:
@ -596,7 +596,7 @@ TextEditor::DeleteSelection(EDirection aAction,
nsCOMPtr<nsIEditRules> rules(mRules);
// delete placeholder txns merge.
AutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName);
AutoPlaceholderBatch batch(this, nsGkAtoms::DeleteTxnName);
AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
// pre-process
@ -649,7 +649,7 @@ TextEditor::InsertText(const nsAString& aStringToInsert)
if (ShouldHandleIMEComposition()) {
opID = EditAction::insertIMEText;
}
AutoPlaceHolderBatch batch(this, nullptr);
AutoPlaceholderBatch batch(this, nullptr);
AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
// pre-process
@ -687,7 +687,7 @@ TextEditor::InsertLineBreak()
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> rules(mRules);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext);
// pre-process
@ -765,7 +765,7 @@ TextEditor::SetText(const nsAString& aString)
nsCOMPtr<nsIEditRules> rules(mRules);
// delete placeholder txns merge.
AutoPlaceHolderBatch batch(this, nullptr);
AutoPlaceholderBatch batch(this, nullptr);
AutoRules beginRulesSniffing(this, EditAction::setText, nsIEditor::eNext);
// pre-process
@ -869,10 +869,10 @@ TextEditor::UpdateIMEComposition(WidgetCompositionEvent* aCompsitionChangeEvent)
nsresult rv;
{
AutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName);
AutoPlaceholderBatch batch(this, nsGkAtoms::IMETxnName);
MOZ_ASSERT(mIsInEditAction,
"AutoPlaceHolderBatch should've notified the observes of before-edit");
"AutoPlaceholderBatch should've notified the observes of before-edit");
rv = InsertText(aCompsitionChangeEvent->mData);
if (caretP) {
@ -1404,7 +1404,7 @@ TextEditor::PasteAsQuotation(int32_t aSelectionType)
if (textDataObj && len > 0) {
nsAutoString stuffToPaste;
textDataObj->GetData ( stuffToPaste );
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
rv = InsertAsQuotation(stuffToPaste, 0);
}
}
@ -1435,7 +1435,7 @@ TextEditor::InsertAsQuotation(const nsAString& aQuotedText,
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
// give rules a chance to handle or cancel

View File

@ -123,7 +123,7 @@ TextEditor::InsertTextFromTransferable(nsITransferable* aTransferable,
// Sanitize possible carriage returns in the string to be inserted
nsContentUtils::PlatformToDOMLineBreaks(stuffToPaste);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
rv = InsertTextAt(stuffToPaste, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
}
@ -153,7 +153,7 @@ TextEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
data->GetAsAString(insertText);
nsContentUtils::PlatformToDOMLineBreaks(insertText);
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
@ -206,7 +206,7 @@ TextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
}
// Combine any deletion and drop insertion into one transaction
AutoEditBatch beginBatching(this);
AutoPlaceholderBatch beginBatching(this);
bool deleteSelection = false;

View File

@ -265,8 +265,6 @@ interface nsIEditor : nsISupports
*/
void endTransaction();
void beginPlaceHolderTransaction(in nsIAtom name);
void endPlaceHolderTransaction();
boolean shouldTxnSetSelection();
/** Set the flag that prevents insertElementTxn from changing the selection

View File

@ -970,7 +970,7 @@ mozInlineSpellChecker::ReplaceWord(nsIDOMNode *aNode, int32_t aOffset,
res = range->CloneRange(getter_AddRefs(editorRange));
NS_ENSURE_SUCCESS(res, res);
AutoPlaceHolderBatch phb(mTextEditor, nullptr);
AutoPlaceholderBatch phb(mTextEditor, nullptr);
nsCOMPtr<nsISelection> selection;
res = mTextEditor->GetSelection(getter_AddRefs(selection));