--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -50,35 +50,38 @@ class MOZ_RAII nsAutoPlaceHolderBatch
~nsAutoPlaceHolderBatch()
{
if (mEd) {
mEd->EndPlaceHolderTransaction();
}
}
};
+namespace mozilla {
+
/***************************************************************************
* 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 nsAutoEditBatch : public nsAutoPlaceHolderBatch
+class MOZ_RAII AutoEditBatch final : public nsAutoPlaceHolderBatch
{
+private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
- public:
- explicit nsAutoEditBatch(nsIEditor *aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
- : nsAutoPlaceHolderBatch(aEd, nullptr)
- {
- MOZ_GUARD_OBJECT_NOTIFIER_INIT;
- }
- ~nsAutoEditBatch() {}
+
+public:
+ explicit AutoEditBatch(nsIEditor* aEditor
+ MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
+ : nsAutoPlaceHolderBatch(aEditor, nullptr)
+ {
+ MOZ_GUARD_OBJECT_NOTIFIER_INIT;
+ }
+ ~AutoEditBatch() {}
};
-namespace mozilla {
-
/***************************************************************************
* stack based helper class for saving/restoring selection. Note that this
* assumes that the nodes involved are still around afterwards!
*/
class MOZ_RAII AutoSelectionRestorer final
{
private:
// Ref-counted reference to the selection that we are supposed to restore.
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -2198,17 +2198,17 @@ nsEditor::CloneAttributes(nsIDOMNode* aD
return NS_OK;
}
void
nsEditor::CloneAttributes(Element* aDest, Element* aSource)
{
MOZ_ASSERT(aDest && aSource);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Use transaction system for undo only if destination is already in the
// document
NS_ENSURE_TRUE(GetRoot(), );
bool destInBody = GetRoot()->Contains(aDest);
// Clear existing attributes
RefPtr<nsDOMAttributeMap> destAttributes = aDest->Attributes();
--- a/editor/libeditor/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/nsHTMLAbsPosition.cpp
@@ -51,17 +51,17 @@
using namespace mozilla;
using namespace mozilla::dom;
#define BLACK_BG_RGB_TRIGGER 0xd0
NS_IMETHODIMP
nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
{
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this,
aEnabled ? EditAction::setAbsolutePosition :
EditAction::removeAbsolutePosition,
nsIEditor::eNext);
// the line below does not match the code; should it be removed?
// Find out if the selection is collapsed:
RefPtr<Selection> selection = GetSelection();
@@ -156,17 +156,17 @@ nsHTMLEditor::SetElementZIndex(nsIDOMEle
mHTMLCSSUtils->SetCSSProperty(*element, *nsGkAtoms::z_index, zIndexStr);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
{
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this,
(aChange < 0) ? EditAction::decreaseZIndex :
EditAction::increaseZIndex,
nsIEditor::eNext);
// brade: can we get rid of this comment?
// Find out if the selection is collapsed:
RefPtr<Selection> selection = GetSelection();
@@ -436,17 +436,17 @@ nsHTMLEditor::SetFinalPosition(int32_t a
SnapToGrid(newX, newY);
nsAutoString x, y;
x.AppendInt(newX);
y.AppendInt(newY);
// we want one transaction only from a user's point of view
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
nsCOMPtr<Element> absolutelyPositionedObject =
do_QueryInterface(mAbsolutelyPositionedObject);
NS_ENSURE_STATE(absolutelyPositionedObject);
mHTMLCSSUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
*nsGkAtoms::top, newY);
mHTMLCSSUtils->SetCSSPropertyPixels(*absolutelyPositionedObject,
*nsGkAtoms::left, newX);
@@ -479,17 +479,17 @@ nsHTMLEditor::AbsolutelyPositionElement(
mHTMLCSSUtils->GetComputedProperty(*element, *nsGkAtoms::position,
positionStr);
bool isPositioned = (positionStr.EqualsLiteral("absolute"));
// nothing to do if the element is already in the state we want
if (isPositioned == aEnabled)
return NS_OK;
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
if (aEnabled) {
int32_t x, y;
GetElementOrigin(aElement, x, y);
mHTMLCSSUtils->SetCSSProperty(*element, *nsGkAtoms::position,
NS_LITERAL_STRING("absolute"));
@@ -577,17 +577,17 @@ nsHTMLEditor::SetElementPosition(nsIDOME
SetElementPosition(*element, aX, aY);
return NS_OK;
}
void
nsHTMLEditor::SetElementPosition(dom::Element& aElement, int32_t aX, int32_t aY)
{
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
mHTMLCSSUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
}
// self-explanatory
NS_IMETHODIMP
nsHTMLEditor::GetPositionedElement(nsIDOMElement ** aReturn)
{
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -104,17 +104,17 @@ static nsresult FindTargetNode(nsIDOMNod
nsresult
nsHTMLEditor::LoadHTML(const nsAString & aInputString)
{
NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
// force IME commit; set up rules sniffing and batching
ForceCompositionEnd();
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext);
// Get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
nsTextRulesInfo ruleInfo(EditAction::loadHTML);
bool cancel, handled;
@@ -205,17 +205,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
{
NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
// Prevent the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
// force IME commit; set up rules sniffing and batching
ForceCompositionEnd();
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::htmlPaste, nsIEditor::eNext);
// Get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
// create a dom document fragment that represents the structure to paste
nsCOMPtr<nsIDOMNode> fragmentAsNode, streamStartParent, streamEndParent;
@@ -1054,17 +1054,17 @@ nsHTMLEditor::BlobReader::OnResult(const
nsString blobType;
mBlob->GetType(blobType);
NS_ConvertUTF16toUTF8 type(blobType);
nsAutoString stuffToPaste;
nsresult rv = ImgFromData(type, aResult, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoEditBatch beginBatching(mEditor);
+ AutoEditBatch beginBatching(mEditor);
rv = mEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),
mSourceDoc,
mDestinationNode, mDestOffset,
mDoDeleteSelection,
mIsSafe, false);
return rv;
}
@@ -1155,17 +1155,17 @@ nsresult nsHTMLEditor::InsertObject(cons
rv = imageStream->Close();
NS_ENSURE_SUCCESS(rv, rv);
}
nsAutoString stuffToPaste;
rv = ImgFromData(type, imageData, stuffToPaste);
NS_ENSURE_SUCCESS(rv, rv);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
aIsSafe, false);
}
@@ -1211,17 +1211,17 @@ nsHTMLEditor::InsertFromTransferable(nsI
nsAutoCString cfhtml;
textDataObj->GetData(cfhtml);
NS_ASSERTION(cfhtml.Length() <= (len), "Invalid length!");
nsXPIDLString cfcontext, cffragment, cfselection; // cfselection left emtpy for now
rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty())
{
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch 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) {
rv = DoInsertHTMLWithContext(cffragment,
aContextStr, aInfoStr, flavor,
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
@@ -1261,17 +1261,17 @@ nsHTMLEditor::InsertFromTransferable(nsI
nsAutoCString text;
textDataObj->GetData(text);
NS_ASSERTION(text.Length() <= len, "Invalid length!");
stuffToPaste.Assign(NS_ConvertUTF8toUTF16(Substring(text, 0, len)));
}
}
if (!stuffToPaste.IsEmpty()) {
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
if (0 == nsCRT::strcmp(bestFlavor, kHTMLMime)) {
rv = DoInsertHTMLWithContext(stuffToPaste,
aContextStr, aInfoStr, flavor,
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
isSafe);
} else {
@@ -1342,17 +1342,17 @@ nsresult nsHTMLEditor::InsertFromDataTra
GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
NS_ConvertUTF16toUTF8 cfhtml(text);
nsXPIDLString cfcontext, cffragment, cfselection; // cfselection left emtpy for now
nsresult rv = ParseCFHTML(cfhtml, getter_Copies(cffragment), getter_Copies(cfcontext));
if (NS_SUCCEEDED(rv) && !cffragment.IsEmpty())
{
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
if (hasPrivateHTMLFlavor) {
// If we have our private HTML flavor, we will only use the fragment
// from the CF_HTML. The rest comes from the clipboard.
nsAutoString contextString, infoString;
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), aIndex, contextString);
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), aIndex, infoString);
return DoInsertHTMLWithContext(cffragment,
@@ -1373,34 +1373,34 @@ nsresult nsHTMLEditor::InsertFromDataTra
}
}
else if (type.EqualsLiteral(kHTMLMime)) {
nsAutoString text, contextString, infoString;
GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), aIndex, contextString);
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), aIndex, infoString);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
if (type.EqualsLiteral(kHTMLMime)) {
return DoInsertHTMLWithContext(text,
contextString, infoString, type,
aSourceDoc,
aDestinationNode, aDestOffset,
aDoDeleteSelection,
isSafe);
}
}
}
if (type.EqualsLiteral(kTextMime) ||
type.EqualsLiteral(kMozTextInternal)) {
nsAutoString text;
GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
return InsertTextAt(text, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
}
return NS_OK;
}
bool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard)
@@ -1653,17 +1653,17 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsQuota
nsAutoString citation;
return PasteAsCitedQuotation(citation, aSelectionType);
}
NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
int32_t aSelectionType)
{
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// give rules a chance to handle or cancel
@@ -1730,17 +1730,17 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlain
if (flav && 0 == nsCRT::strcmp(flav, kUnicodeMime))
{
nsCOMPtr<nsISupportsString> textDataObj = do_QueryInterface(genericDataObj);
if (textDataObj && len > 0)
{
nsAutoString stuffToPaste;
textDataObj->GetData(stuffToPaste);
NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
rv = InsertAsPlaintextQuotation(stuffToPaste, true, 0);
}
}
free(flav);
return rv;
}
@@ -1846,17 +1846,17 @@ NS_IMETHODIMP
nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
bool aAddCites,
nsIDOMNode **aNodeInserted)
{
// get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement);
bool cancel, handled;
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
@@ -1936,17 +1936,17 @@ nsHTMLEditor::InsertAsCitedQuotation(con
NS_ASSERTION(!aInsertHTML, "InsertAsCitedQuotation: trying to insert html into plaintext editor");
return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
}
// get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement);
bool cancel, handled;
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -1211,17 +1211,17 @@ nsHTMLEditor::ReplaceHeadContentsWithHTM
// Windows linebreaks: Map CRLF to LF:
inputString.ReplaceSubstring(MOZ_UTF16("\r\n"),
MOZ_UTF16("\n"));
// Mac linebreaks: Map any remaining CR to LF:
inputString.ReplaceSubstring(MOZ_UTF16("\r"),
MOZ_UTF16("\n"));
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Get the first range in the selection, for context:
RefPtr<nsRange> range = selection->GetRangeAt(0);
NS_ENSURE_TRUE(range, NS_ERROR_NULL_POINTER);
ErrorResult err;
RefPtr<DocumentFragment> docfrag =
range->CreateContextualFragment(inputString, err);
@@ -1299,17 +1299,17 @@ nsHTMLEditor::RebuildDocumentFromSource(
foundclosehead = false;
}
// a valid close head appears before a found body
if (foundbody && beginclosehead.get() > beginbody.get()) {
foundclosehead = false;
}
// Time to change the document
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
nsReadingIterator<char16_t> endtotal;
aSourceString.EndReading(endtotal);
nsresult res;
if (foundhead) {
if (foundclosehead) {
res = ReplaceHeadContentsWithHTML(Substring(beginhead, beginclosehead));
@@ -1490,17 +1490,17 @@ nsHTMLEditor::InsertElementAtSelection(n
nsresult res = NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
ForceCompositionEnd();
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
RefPtr<Selection> selection = GetSelection();
if (!selection) {
return NS_ERROR_FAILURE;
}
@@ -1928,17 +1928,17 @@ nsHTMLEditor::MakeOrChangeList(const nsA
nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(EditAction::makeList);
ruleInfo.blockType = &aListType;
@@ -2001,17 +2001,17 @@ nsHTMLEditor::RemoveList(const nsAString
nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(EditAction::removeList);
if (aListType.LowerCaseEqualsLiteral("ol"))
@@ -2032,17 +2032,17 @@ nsHTMLEditor::MakeDefinitionItem(const n
nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeDefListItem,
nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(EditAction::makeDefListItem);
ruleInfo.blockType = &aItemType;
@@ -2064,17 +2064,17 @@ nsHTMLEditor::InsertBasicBlock(const nsA
nsresult res;
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::makeBasicBlock,
nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(EditAction::makeBasicBlock);
ruleInfo.blockType = &aBlockType;
@@ -2138,17 +2138,17 @@ nsHTMLEditor::Indent(const nsAString& aI
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
EditAction opID = EditAction::indent;
if (aIndent.LowerCaseEqualsLiteral("outdent"))
{
opID = EditAction::outdent;
}
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(opID);
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
@@ -2210,17 +2210,17 @@ nsHTMLEditor::Indent(const nsAString& aI
//TODO: IMPLEMENT ALIGNMENT!
NS_IMETHODIMP
nsHTMLEditor::Align(const nsAString& aAlignType)
{
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> node;
bool cancel, handled;
// Find out if the selection is collapsed:
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -2631,17 +2631,17 @@ nsHTMLEditor::InsertLinkAroundSelection(
nsAutoString href;
nsresult res = anchor->GetHref(href);
NS_ENSURE_SUCCESS(res, res);
if (href.IsEmpty()) {
return NS_OK;
}
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Set all attributes found on the supplied anchor element
nsCOMPtr<nsIDOMMozNamedAttrMap> attrMap;
aAnchorElement->GetAttributes(getter_AddRefs(attrMap));
NS_ENSURE_TRUE(attrMap, NS_ERROR_FAILURE);
uint32_t count;
attrMap->GetLength(&count);
@@ -3391,17 +3391,17 @@ nsHTMLEditor::DebugUnitTests(int32_t *ou
}
NS_IMETHODIMP
nsHTMLEditor::StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
nsresult aStatus)
{
nsresult rv = NS_OK;
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
if (!mLastStyleSheetURL.IsEmpty())
RemoveStyleSheet(mLastStyleSheetURL);
RefPtr<AddStyleSheetTxn> txn;
rv = CreateTxnForAddStyleSheet(aSheet, getter_AddRefs(txn));
if (!txn) rv = NS_ERROR_NULL_POINTER;
if (NS_SUCCEEDED(rv))
@@ -4526,17 +4526,17 @@ nsHTMLEditor::SetCSSBackgroundColor(cons
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
bool isCollapsed = selection->Collapsed();
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::setTextProperty);
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -119,17 +119,17 @@ nsHTMLEditor::SetInlineProperty(nsIAtom*
if (selection->Collapsed()) {
// Manipulating text attributes on a collapsed selection only sets state
// for the next text insertion
mTypeInState->SetProp(aProperty, aAttribute, aValue);
return NS_OK;
}
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::setTextProperty);
// Protect the edit rules object from dying
@@ -1164,17 +1164,17 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePro
if (!aValue.IsEmpty())
val = &aValue;
return GetInlinePropertyBase(*aProperty, att, val, aFirst, aAny, aAll, &outValue);
}
NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
{
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::resetTextProperties,
nsIEditor::eNext);
nsresult res = RemoveInlinePropertyImpl(nullptr, nullptr);
NS_ENSURE_SUCCESS(res, res);
return ApplyDefaultProperties();
}
@@ -1206,17 +1206,17 @@ nsHTMLEditor::RemoveInlinePropertyImpl(n
if (aProperty) {
mTypeInState->ClearProp(aProperty, *aAttribute);
} else {
mTypeInState->ClearAllProps();
}
return NS_OK;
}
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::removeTextProperty,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(EditAction::removeTextProperty);
// Protect the edit rules object from dying
@@ -1355,17 +1355,17 @@ nsHTMLEditor::RelativeFontChange(FontSiz
// Manipulating text attributes on a collapsed selection only sets state
// for the next text insertion
mTypeInState->SetProp(&atom, EmptyString(), EmptyString());
return NS_OK;
}
// Wrap with txn batching, rules sniffing, and selection preservation code
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
AutoRules beginRulesSniffing(this, EditAction::setTextProperty,
nsIEditor::eNext);
AutoSelectionRestorer selectionRestorer(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this);
// Loop through the ranges in the selection
uint32_t rangeCount = selection->RangeCount();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) {
--- a/editor/libeditor/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/nsHTMLObjectResizer.cpp
@@ -901,17 +901,17 @@ nsHTMLEditor::SetFinalSize(int32_t aX, i
bool setWidth = !mResizedObjectIsAbsolutelyPositioned || (width != mResizedObjectWidth);
bool setHeight = !mResizedObjectIsAbsolutelyPositioned || (height != mResizedObjectHeight);
int32_t x, y;
x = left - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderLeft+mResizedObjectMarginLeft : 0);
y = top - ((mResizedObjectIsAbsolutelyPositioned) ? mResizedObjectBorderTop+mResizedObjectMarginTop : 0);
// we want one transaction only from a user's point of view
- nsAutoEditBatch batchIt(this);
+ AutoEditBatch batchIt(this);
NS_NAMED_LITERAL_STRING(widthStr, "width");
NS_NAMED_LITERAL_STRING(heightStr, "height");
nsCOMPtr<Element> resizedObject = do_QueryInterface(mResizedObject);
NS_ENSURE_TRUE(resizedObject, );
if (mResizedObjectIsAbsolutelyPositioned) {
if (setHeight)
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/nsPlaintextDataTransfer.cpp
@@ -118,17 +118,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
{
nsAutoString stuffToPaste;
textDataObj->GetData(stuffToPaste);
NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
// Sanitize possible carriage returns in the string to be inserted
nsContentUtils::PlatformToDOMLineBreaks(stuffToPaste);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
rv = InsertTextAt(stuffToPaste, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
}
free(bestFlavor);
// Try to scroll the selection into view if the paste/drop succeeded
if (NS_SUCCEEDED(rv))
@@ -147,17 +147,17 @@ nsresult nsPlaintextEditor::InsertFromDa
nsCOMPtr<nsIVariant> data;
DataTransfer::Cast(aDataTransfer)->GetDataAtNoSecurityCheck(NS_LITERAL_STRING("text/plain"), aIndex,
getter_AddRefs(data));
if (data) {
nsAutoString insertText;
data->GetAsAString(insertText);
nsContentUtils::PlatformToDOMLineBreaks(insertText);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
return NS_OK;
}
nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
{
@@ -196,17 +196,17 @@ nsresult nsPlaintextEditor::InsertFromDr
NS_ENSURE_TRUE(destdomdoc, NS_ERROR_NOT_INITIALIZED);
uint32_t numItems = 0;
nsresult rv = dataTransfer->GetMozItemCount(&numItems);
NS_ENSURE_SUCCESS(rv, rv);
if (numItems < 1) return NS_ERROR_FAILURE; // nothing to drop?
// Combine any deletion and drop insertion into one transaction
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
bool deleteSelection = false;
// We have to figure out whether to delete and relocate caret only once
// Parent and offset are under the mouse cursor
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aDropEvent);
NS_ENSURE_TRUE(uiEvent, NS_ERROR_FAILURE);
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -1,16 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPlaintextEditor.h"
-#include "EditorUtils.h" // nsAutoEditBatch, AutoRules
+#include "EditorUtils.h" // AutoEditBatch, AutoRules
#include "gfxFontUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Event.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Element.h"
@@ -748,17 +748,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
{
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext);
// pre-process
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(EditAction::insertBreak);
ruleInfo.maxLength = mMaxTextLength;
@@ -1390,17 +1390,17 @@ nsPlaintextEditor::PasteAsQuotation(int3
if (0 == nsCRT::strcmp(flav, kUnicodeMime) ||
0 == nsCRT::strcmp(flav, kMozTextInternal))
{
nsCOMPtr<nsISupportsString> textDataObj ( do_QueryInterface(genericDataObj) );
if (textDataObj && len > 0)
{
nsAutoString stuffToPaste;
textDataObj->GetData ( stuffToPaste );
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
rv = InsertAsQuotation(stuffToPaste, 0);
}
}
free(flav);
}
return rv;
}
@@ -1421,17 +1421,17 @@ nsPlaintextEditor::InsertAsQuotation(con
// written without thinking won't be so ugly.
if (!aQuotedText.IsEmpty() && (aQuotedText.Last() != char16_t('\n')))
quotedStuff.Append(char16_t('\n'));
// get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement);
bool cancel, handled;
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
if (cancel) return NS_OK; // rules canceled the operation
--- a/editor/libeditor/nsTableEditor.cpp
+++ b/editor/libeditor/nsTableEditor.cpp
@@ -393,17 +393,17 @@ nsHTMLEditor::InsertTableColumn(int32_t
res = GetCellDataAt(table, startRowIndex, startColIndex,
getter_AddRefs(curCell),
&curStartRowIndex, &curStartColIndex,
&rowSpan, &colSpan,
&actualRowSpan, &actualColSpan, &isSelected);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(curCell, NS_ERROR_FAILURE);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// Use column after current cell if requested
if (aAfter)
{
startColIndex += actualColSpan;
//Detect when user is adding after a COLSPAN=0 case
@@ -525,17 +525,17 @@ nsHTMLEditor::InsertTableRow(int32_t aNu
&actualRowSpan, &actualColSpan, &isSelected);
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(curCell, NS_ERROR_FAILURE);
int32_t rowCount, colCount;
res = GetTableSize(table, &rowCount, &colCount);
NS_ENSURE_SUCCESS(res, res);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
if (aAfter)
{
// Use row after current cell
startRowIndex += actualRowSpan;
@@ -703,17 +703,17 @@ nsHTMLEditor::DeleteTable()
RefPtr<Selection> selection;
nsCOMPtr<nsIDOMElement> table;
nsresult res = GetCellContext(getter_AddRefs(selection),
getter_AddRefs(table),
nullptr, nullptr, nullptr, nullptr, nullptr);
NS_ENSURE_SUCCESS(res, res);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
return DeleteTable2(table, selection);
}
NS_IMETHODIMP
nsHTMLEditor::DeleteTableCell(int32_t aNumber)
{
RefPtr<Selection> selection;
nsCOMPtr<nsIDOMElement> table;
@@ -726,17 +726,17 @@ nsHTMLEditor::DeleteTableCell(int32_t aN
getter_AddRefs(cell),
nullptr, nullptr,
&startRowIndex, &startColIndex);
NS_ENSURE_SUCCESS(res, res);
// Don't fail if we didn't find a table or cell
NS_ENSURE_TRUE(table && cell, NS_EDITOR_ELEMENT_NOT_FOUND);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
res = GetFirstSelectedCell(getter_AddRefs(range), getter_AddRefs(firstCell));
NS_ENSURE_SUCCESS(res, res);
@@ -919,17 +919,17 @@ nsHTMLEditor::DeleteTableCellContents()
getter_AddRefs(cell),
nullptr, nullptr,
&startRowIndex, &startColIndex);
NS_ENSURE_SUCCESS(res, res);
// Don't fail if no cell found
NS_ENSURE_TRUE(cell, NS_EDITOR_ELEMENT_NOT_FOUND);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
//Don't let Rules System change the selection
AutoTransactionsConserveSelection dontChangeSelection(this);
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
@@ -1004,17 +1004,17 @@ nsHTMLEditor::DeleteTableColumn(int32_t
// Shortcut the case of deleting all columns in table
if(startColIndex == 0 && aNumber >= colCount)
return DeleteTable2(table, selection);
// Check for counts too high
aNumber = std::min(aNumber,(colCount-startColIndex));
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
// Test if deletion is controlled by selected cells
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
res = GetFirstSelectedCell(getter_AddRefs(range), getter_AddRefs(firstCell));
NS_ENSURE_SUCCESS(res, res);
@@ -1178,17 +1178,17 @@ nsHTMLEditor::DeleteTableRow(int32_t aNu
res = GetTableSize(table, &rowCount, &colCount);
NS_ENSURE_SUCCESS(res, res);
// Shortcut the case of deleting all rows in table
if(startRowIndex == 0 && aNumber >= rowCount)
return DeleteTable2(table, selection);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
res = GetFirstSelectedCell(getter_AddRefs(range), getter_AddRefs(firstCell));
NS_ENSURE_SUCCESS(res, res);
@@ -1694,17 +1694,17 @@ nsHTMLEditor::SplitTableCell()
// We need rowspan and colspan data
res = GetCellSpansAt(table, startRowIndex, startColIndex, actualRowSpan, actualColSpan);
NS_ENSURE_SUCCESS(res, res);
// Must have some span to split
if (actualRowSpan <= 1 && actualColSpan <= 1)
return NS_OK;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// We reset selection
nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
//...so suppress Rules System selection munging
AutoTransactionsConserveSelection dontChangeSelection(this);
@@ -1913,17 +1913,17 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMEl
}
NS_IMETHODIMP
nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
{
nsCOMPtr<Element> sourceCell = do_QueryInterface(aSourceCell);
NS_ENSURE_TRUE(sourceCell, NS_ERROR_NULL_POINTER);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell created by ReplaceContainer
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// Save current selection to restore when done
// This is needed so ReplaceContainer can monitor selection
// when replacing nodes
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
@@ -1965,17 +1965,17 @@ nsHTMLEditor::JoinTableCells(bool aMerge
nsresult res = GetCellContext(nullptr,
getter_AddRefs(table),
getter_AddRefs(targetCell),
nullptr, nullptr,
&startRowIndex, &startColIndex);
NS_ENSURE_SUCCESS(res, res);
if(!table || !targetCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
//Don't let Rules System change the selection
AutoTransactionsConserveSelection dontChangeSelection(this);
// Note: We dont' use nsSetSelectionAfterTableEdit here so the selection
// is retained after joining. This leaves the target cell selected
// as well as the "non-contiguous" cells, so user can see what happened.
nsCOMPtr<nsIDOMElement> firstCell;
@@ -2471,17 +2471,17 @@ nsHTMLEditor::NormalizeTable(nsIDOMEleme
int32_t rowCount, colCount, rowIndex, colIndex;
res = GetTableSize(table, &rowCount, &colCount);
NS_ENSURE_SUCCESS(res, res);
// Save current selection
AutoSelectionRestorer selectionRestorer(selection, this);
- nsAutoEditBatch beginBatching(this);
+ AutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> cell;
int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
bool isSelected;
// Scan all cells in each row to detect bad rowspan values