Bug 1260651 part.10 Rename nsAutoRules to mozilla::AutoRules r=mccr8

MozReview-Commit-ID: u3MVijmoBv
This commit is contained in:
Masayuki Nakano 2016-06-23 18:15:42 +09:00
parent 6e4532ff79
commit 04f769e958
10 changed files with 99 additions and 87 deletions

View File

@ -95,41 +95,42 @@ class MOZ_RAII nsAutoSelectionReset
void Abort(); void Abort();
}; };
namespace mozilla {
/*************************************************************************** /***************************************************************************
* stack based helper class for StartOperation()/EndOperation() sandwich * stack based helper class for StartOperation()/EndOperation() sandwich
*/ */
class MOZ_RAII nsAutoRules class MOZ_RAII AutoRules final
{ {
public: public:
AutoRules(nsEditor* aEditor, EditAction aAction,
nsAutoRules(nsEditor *ed, EditAction action, nsIEditor::EDirection aDirection
nsIEditor::EDirection aDirection MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mEditor(aEditor)
: mEd(ed), mDoNothing(false) , mDoNothing(false)
{ {
MOZ_GUARD_OBJECT_NOTIFIER_INIT; MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEd && !mEd->mAction) // mAction will already be set if this is nested call // mAction will already be set if this is nested call
{ if (mEditor && !mEditor->mAction) {
mEd->StartOperation(action, aDirection); mEditor->StartOperation(aAction, aDirection);
} } else {
else mDoNothing = true; // nested calls will end up here mDoNothing = true; // nested calls will end up here
}
~nsAutoRules()
{
if (mEd && !mDoNothing)
{
mEd->EndOperation();
} }
} }
protected: ~AutoRules()
nsEditor *mEd; {
if (mEditor && !mDoNothing) {
mEditor->EndOperation();
}
}
protected:
nsEditor* mEditor;
bool mDoNothing; bool mDoNothing;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
}; };
namespace mozilla {
/*************************************************************************** /***************************************************************************
* stack based helper class for turning off active selection adjustment * stack based helper class for turning off active selection adjustment
* by low level transactions * by low level transactions

View File

@ -16,7 +16,7 @@
#include "DeleteRangeTxn.h" // for DeleteRangeTxn #include "DeleteRangeTxn.h" // for DeleteRangeTxn
#include "DeleteTextTxn.h" // for DeleteTextTxn #include "DeleteTextTxn.h" // for DeleteTextTxn
#include "EditAggregateTxn.h" // for EditAggregateTxn #include "EditAggregateTxn.h" // for EditAggregateTxn
#include "EditorUtils.h" // for nsAutoRules, etc #include "EditorUtils.h" // for AutoRules, etc
#include "EditTxn.h" // for EditTxn #include "EditTxn.h" // for EditTxn
#include "IMETextTxn.h" // for IMETextTxn #include "IMETextTxn.h" // for IMETextTxn
#include "InsertNodeTxn.h" // for InsertNodeTxn #include "InsertNodeTxn.h" // for InsertNodeTxn
@ -808,7 +808,7 @@ nsEditor::Undo(uint32_t aCount)
CanUndo(&hasTxnMgr, &hasTransaction); CanUndo(&hasTxnMgr, &hasTransaction);
NS_ENSURE_TRUE(hasTransaction, NS_OK); NS_ENSURE_TRUE(hasTransaction, NS_OK);
nsAutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone); AutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone);
if (!mTxnMgr) { if (!mTxnMgr) {
return NS_OK; return NS_OK;
@ -847,7 +847,7 @@ nsEditor::Redo(uint32_t aCount)
CanRedo(&hasTxnMgr, &hasTransaction); CanRedo(&hasTxnMgr, &hasTransaction);
NS_ENSURE_TRUE(hasTransaction, NS_OK); NS_ENSURE_TRUE(hasTransaction, NS_OK);
nsAutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone); AutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone);
if (!mTxnMgr) { if (!mTxnMgr) {
return NS_OK; return NS_OK;
@ -1346,7 +1346,7 @@ nsEditor::CreateNode(nsIAtom* aTag,
{ {
MOZ_ASSERT(aTag && aParent); MOZ_ASSERT(aTag && aParent);
nsAutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::eNext);
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {
listener->WillCreateNode(nsDependentAtomString(aTag), listener->WillCreateNode(nsDependentAtomString(aTag),
@ -1387,7 +1387,7 @@ nsEditor::InsertNode(nsIDOMNode* aNode, nsIDOMNode* aParent, int32_t aPosition)
nsresult nsresult
nsEditor::InsertNode(nsIContent& aNode, nsINode& aParent, int32_t aPosition) nsEditor::InsertNode(nsIContent& aNode, nsINode& aParent, int32_t aPosition)
{ {
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {
listener->WillInsertNode(aNode.AsDOMNode(), aParent.AsDOMNode(), listener->WillInsertNode(aNode.AsDOMNode(), aParent.AsDOMNode(),
@ -1425,8 +1425,7 @@ nsEditor::SplitNode(nsIDOMNode* aNode,
nsIContent* nsIContent*
nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult) nsEditor::SplitNode(nsIContent& aNode, int32_t aOffset, ErrorResult& aResult)
{ {
nsAutoRules beginRulesSniffing(this, EditAction::splitNode, AutoRules beginRulesSniffing(this, EditAction::splitNode, nsIEditor::eNext);
nsIEditor::eNext);
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {
listener->WillSplitNode(aNode.AsDOMNode(), aOffset); listener->WillSplitNode(aNode.AsDOMNode(), aOffset);
@ -1470,8 +1469,8 @@ nsEditor::JoinNodes(nsINode& aLeftNode, nsINode& aRightNode)
nsCOMPtr<nsINode> parent = aLeftNode.GetParentNode(); nsCOMPtr<nsINode> parent = aLeftNode.GetParentNode();
MOZ_ASSERT(parent); MOZ_ASSERT(parent);
nsAutoRules beginRulesSniffing(this, EditAction::joinNode, AutoRules beginRulesSniffing(this, EditAction::joinNode,
nsIEditor::ePrevious); nsIEditor::ePrevious);
// Remember some values; later used for saved selection updating. // Remember some values; later used for saved selection updating.
// Find the offset between the nodes to be joined. // Find the offset between the nodes to be joined.
@ -1513,7 +1512,8 @@ nsEditor::DeleteNode(nsIDOMNode* aNode)
nsresult nsresult
nsEditor::DeleteNode(nsINode* aNode) nsEditor::DeleteNode(nsINode* aNode)
{ {
nsAutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::ePrevious); AutoRules beginRulesSniffing(this, EditAction::createNode,
nsIEditor::ePrevious);
// save node location for selection updating code. // save node location for selection updating code.
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {
@ -2596,7 +2596,8 @@ nsEditor::DeleteText(nsGenericDOMDataNode& aCharData, uint32_t aOffset,
CreateTxnForDeleteText(aCharData, aOffset, aLength); CreateTxnForDeleteText(aCharData, aOffset, aLength);
NS_ENSURE_STATE(txn); NS_ENSURE_STATE(txn);
nsAutoRules beginRulesSniffing(this, EditAction::deleteText, nsIEditor::ePrevious); AutoRules beginRulesSniffing(this, EditAction::deleteText,
nsIEditor::ePrevious);
// Let listeners know what's up // Let listeners know what's up
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {
@ -3995,7 +3996,7 @@ nsEditor::DeleteSelectionImpl(EDirection aAction,
if (NS_SUCCEEDED(res)) if (NS_SUCCEEDED(res))
{ {
nsAutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction); AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
// Notify nsIEditActionListener::WillDelete[Selection|Text|Node] // Notify nsIEditActionListener::WillDelete[Selection|Text|Node]
if (!deleteNode) { if (!deleteNode) {
for (auto& listener : mActionListeners) { for (auto& listener : mActionListeners) {

View File

@ -54,6 +54,7 @@ class nsString;
class nsTransactionManager; class nsTransactionManager;
namespace mozilla { namespace mozilla {
class AutoRules;
class AutoTransactionsConserveSelection; class AutoTransactionsConserveSelection;
class ErrorResult; class ErrorResult;
class TextComposition; class TextComposition;
@ -885,9 +886,9 @@ protected:
bool mHidingCaret; // whether caret is hidden forcibly. bool mHidingCaret; // whether caret is hidden forcibly.
friend bool NSCanUnload(nsISupports* serviceMgr); friend bool NSCanUnload(nsISupports* serviceMgr);
friend class mozilla::AutoRules;
friend class mozilla::AutoTransactionsConserveSelection; friend class mozilla::AutoTransactionsConserveSelection;
friend class nsAutoSelectionReset; friend class nsAutoSelectionReset;
friend class nsAutoRules;
friend class nsRangeUpdater; friend class nsRangeUpdater;
}; };

View File

@ -57,10 +57,10 @@ NS_IMETHODIMP
nsHTMLEditor::AbsolutePositionSelection(bool aEnabled) nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, AutoRules beginRulesSniffing(this,
aEnabled ? EditAction::setAbsolutePosition : aEnabled ? EditAction::setAbsolutePosition :
EditAction::removeAbsolutePosition, EditAction::removeAbsolutePosition,
nsIEditor::eNext); nsIEditor::eNext);
// the line below does not match the code; should it be removed? // the line below does not match the code; should it be removed?
// Find out if the selection is collapsed: // Find out if the selection is collapsed:
@ -162,10 +162,10 @@ NS_IMETHODIMP
nsHTMLEditor::RelativeChangeZIndex(int32_t aChange) nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, AutoRules beginRulesSniffing(this,
(aChange < 0) ? EditAction::decreaseZIndex : (aChange < 0) ? EditAction::decreaseZIndex :
EditAction::increaseZIndex, EditAction::increaseZIndex,
nsIEditor::eNext); nsIEditor::eNext);
// brade: can we get rid of this comment? // brade: can we get rid of this comment?
// Find out if the selection is collapsed: // Find out if the selection is collapsed:

View File

@ -110,7 +110,7 @@ nsHTMLEditor::LoadHTML(const nsAString & aInputString)
// force IME commit; set up rules sniffing and batching // force IME commit; set up rules sniffing and batching
ForceCompositionEnd(); ForceCompositionEnd();
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext);
// Get selection // Get selection
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -211,7 +211,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
// force IME commit; set up rules sniffing and batching // force IME commit; set up rules sniffing and batching
ForceCompositionEnd(); ForceCompositionEnd();
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::htmlPaste, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::htmlPaste, nsIEditor::eNext);
// Get selection // Get selection
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -1657,7 +1657,8 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
int32_t aSelectionType) int32_t aSelectionType)
{ {
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertQuotation, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// get selection // get selection
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -1849,7 +1850,8 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertQuotation, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// give rules a chance to handle or cancel // give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement); nsTextRulesInfo ruleInfo(EditAction::insertElement);
@ -1938,7 +1940,8 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertQuotation, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
nsIEditor::eNext);
// give rules a chance to handle or cancel // give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement); nsTextRulesInfo ruleInfo(EditAction::insertElement);

View File

@ -1185,13 +1185,13 @@ NS_IMETHODIMP
nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert) nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
{ {
// don't do any post processing, rules get confused // don't do any post processing, rules get confused
nsAutoRules beginRulesSniffing(this, EditAction::ignore, nsIEditor::eNone); AutoRules beginRulesSniffing(this, EditAction::ignore, nsIEditor::eNone);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
ForceCompositionEnd(); ForceCompositionEnd();
// Do not use nsAutoRules -- rules code won't let us insert in <head>. Use // Do not use AutoRules -- rules code won't let us insert in <head>. Use
// the head node as a parent and delete/insert directly. // the head node as a parent and delete/insert directly.
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak); nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
@ -1496,7 +1496,8 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
ForceCompositionEnd(); ForceCompositionEnd();
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertElement, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
if (!selection) { if (!selection) {
@ -1933,7 +1934,7 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
bool cancel, handled; bool cancel, handled;
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::makeList, nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -2006,7 +2007,7 @@ nsHTMLEditor::RemoveList(const nsAString& aListType)
bool cancel, handled; bool cancel, handled;
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::removeList, nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -2037,7 +2038,8 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
bool cancel, handled; bool cancel, handled;
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::makeDefListItem, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::makeDefListItem,
nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -2068,7 +2070,8 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
bool cancel, handled; bool cancel, handled;
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::makeBasicBlock, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::makeBasicBlock,
nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -2141,7 +2144,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
opID = EditAction::outdent; opID = EditAction::outdent;
} }
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -2213,7 +2216,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules); nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
bool cancel, handled; bool cancel, handled;
@ -4529,8 +4532,8 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
bool isCollapsed = selection->Collapsed(); bool isCollapsed = selection->Collapsed();
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertElement, AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext); nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this); nsAutoSelectionReset selectionResetter(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this); AutoTransactionsConserveSelection dontSpazMySelection(this);

View File

@ -125,7 +125,8 @@ nsHTMLEditor::SetInlineProperty(nsIAtom* aProperty,
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertElement, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertElement,
nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this); nsAutoSelectionReset selectionResetter(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this); AutoTransactionsConserveSelection dontSpazMySelection(this);
@ -1169,7 +1170,8 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties() NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
{ {
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, EditAction::resetTextProperties, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::resetTextProperties,
nsIEditor::eNext);
nsresult res = RemoveInlinePropertyImpl(nullptr, nullptr); nsresult res = RemoveInlinePropertyImpl(nullptr, nullptr);
NS_ENSURE_SUCCESS(res, res); NS_ENSURE_SUCCESS(res, res);
@ -1210,8 +1212,8 @@ nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
} }
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, EditAction::removeTextProperty, AutoRules beginRulesSniffing(this, EditAction::removeTextProperty,
nsIEditor::eNext); nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this); nsAutoSelectionReset selectionResetter(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this); AutoTransactionsConserveSelection dontSpazMySelection(this);
@ -1359,8 +1361,8 @@ nsHTMLEditor::RelativeFontChange(FontSize aDir)
// Wrap with txn batching, rules sniffing, and selection preservation code // Wrap with txn batching, rules sniffing, and selection preservation code
nsAutoEditBatch batchIt(this); nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, EditAction::setTextProperty, AutoRules beginRulesSniffing(this, EditAction::setTextProperty,
nsIEditor::eNext); nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this); nsAutoSelectionReset selectionResetter(selection, this);
AutoTransactionsConserveSelection dontSpazMySelection(this); AutoTransactionsConserveSelection dontSpazMySelection(this);

View File

@ -5,7 +5,7 @@
#include "nsPlaintextEditor.h" #include "nsPlaintextEditor.h"
#include "EditorUtils.h" // nsAutoEditBatch, nsAutoRules #include "EditorUtils.h" // nsAutoEditBatch, AutoRules
#include "gfxFontUtils.h" #include "gfxFontUtils.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
@ -540,7 +540,7 @@ nsPlaintextEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
*outBRNode = nullptr; *outBRNode = nullptr;
// calling it text insertion to trigger moz br treatment by rules // calling it text insertion to trigger moz br treatment by rules
nsAutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection); NS_ENSURE_STATE(selection);
@ -660,7 +660,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
// delete placeholder txns merge. // delete placeholder txns merge.
nsAutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName); nsAutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName);
nsAutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction); AutoRules beginRulesSniffing(this, EditAction::deleteSelection, aAction);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -717,7 +717,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
opID = EditAction::insertIMEText; opID = EditAction::insertIMEText;
} }
nsAutoPlaceHolderBatch batch(this, nullptr); nsAutoPlaceHolderBatch batch(this, nullptr);
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); AutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -754,7 +754,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules); nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext);
// pre-process // pre-process
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -1100,7 +1100,7 @@ nsPlaintextEditor::Undo(uint32_t aCount)
NotifyEditorObservers(eNotifyEditorObserversOfBefore); NotifyEditorObservers(eNotifyEditorObserversOfBefore);
nsAutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone); AutoRules beginRulesSniffing(this, EditAction::undo, nsIEditor::eNone);
nsTextRulesInfo ruleInfo(EditAction::undo); nsTextRulesInfo ruleInfo(EditAction::undo);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -1129,7 +1129,7 @@ nsPlaintextEditor::Redo(uint32_t aCount)
NotifyEditorObservers(eNotifyEditorObserversOfBefore); NotifyEditorObservers(eNotifyEditorObserversOfBefore);
nsAutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone); AutoRules beginRulesSniffing(this, EditAction::redo, nsIEditor::eNone);
nsTextRulesInfo ruleInfo(EditAction::redo); nsTextRulesInfo ruleInfo(EditAction::redo);
RefPtr<Selection> selection = GetSelection(); RefPtr<Selection> selection = GetSelection();
@ -1427,7 +1427,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
// give rules a chance to handle or cancel // give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(EditAction::insertElement); nsTextRulesInfo ruleInfo(EditAction::insertElement);

View File

@ -400,7 +400,7 @@ nsHTMLEditor::InsertTableColumn(int32_t aNumber, bool aAfter)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done // Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// Use column after current cell if requested // Use column after current cell if requested
if (aAfter) if (aAfter)
@ -532,7 +532,7 @@ nsHTMLEditor::InsertTableRow(int32_t aNumber, bool aAfter)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done // Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
if (aAfter) if (aAfter)
{ {
@ -733,7 +733,7 @@ nsHTMLEditor::DeleteTableCell(int32_t aNumber)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell; nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range; nsCOMPtr<nsIDOMRange> range;
@ -926,7 +926,7 @@ nsHTMLEditor::DeleteTableCellContents()
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
//Don't let Rules System change the selection //Don't let Rules System change the selection
AutoTransactionsConserveSelection dontChangeSelection(this); AutoTransactionsConserveSelection dontChangeSelection(this);
@ -967,7 +967,7 @@ nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell)
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> child; nsCOMPtr<nsIDOMNode> child;
bool hasChild; bool hasChild;
@ -1011,7 +1011,7 @@ nsHTMLEditor::DeleteTableColumn(int32_t aNumber)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
// Test if deletion is controlled by selected cells // Test if deletion is controlled by selected cells
nsCOMPtr<nsIDOMElement> firstCell; nsCOMPtr<nsIDOMElement> firstCell;
@ -1185,7 +1185,7 @@ nsHTMLEditor::DeleteTableRow(int32_t aNumber)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell; nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range; nsCOMPtr<nsIDOMRange> range;
@ -1272,7 +1272,7 @@ nsHTMLEditor::DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex)
nsresult res = NS_OK; nsresult res = NS_OK;
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
// The list of cells we will change rowspan in // The list of cells we will change rowspan in
// and the new rowspan values for each // and the new rowspan values for each
@ -1701,7 +1701,7 @@ nsHTMLEditor::SplitTableCell()
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done // Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// We reset selection // We reset selection
nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false); nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
@ -1920,7 +1920,7 @@ nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElemen
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell created by ReplaceContainer // Prevent auto insertion of BR in new cell created by ReplaceContainer
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
// Save current selection to restore when done // Save current selection to restore when done
// This is needed so ReplaceContainer can monitor selection // This is needed so ReplaceContainer can monitor selection
@ -2176,7 +2176,8 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
// All cell contents are merged. Delete the empty cells we accumulated // All cell contents are merged. Delete the empty cells we accumulated
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode,
nsIEditor::eNext);
for (uint32_t i = 0, n = deleteList.Length(); i < n; i++) for (uint32_t i = 0, n = deleteList.Length(); i < n; i++)
{ {
@ -2299,7 +2300,7 @@ nsHTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER); NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done // Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
// Don't need to merge if cell is empty // Don't need to merge if cell is empty
if (!IsEmptyCell(cellToMerge)) { if (!IsEmptyCell(cellToMerge)) {
@ -2477,7 +2478,7 @@ nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable)
nsAutoEditBatch beginBatching(this); nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done // Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> cell; nsCOMPtr<nsIDOMElement> cell;
int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan; int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;

View File

@ -1171,7 +1171,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(Selection* aSelection)
} }
// tell rules system to not do any post-processing // tell rules system to not do any post-processing
nsAutoRules beginRulesSniffing(mEditor, EditAction::ignore, nsIEditor::eNone); AutoRules beginRulesSniffing(mEditor, EditAction::ignore, nsIEditor::eNone);
nsCOMPtr<dom::Element> body = mEditor->GetRoot(); nsCOMPtr<dom::Element> body = mEditor->GetRoot();
if (!body) { if (!body) {