Bug 751554 part 4 - Make nsEditor::OperationID an enum class; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-08-01 15:22:07 +03:00
parent 13b54b385e
commit 07e11d5e7d
16 changed files with 295 additions and 289 deletions

View File

@ -24,10 +24,10 @@ class nsRulesInfo
{
public:
nsRulesInfo(nsEditor::OperationID aAction) : action(aAction) {}
nsRulesInfo(OperationID aAction) : action(aAction) {}
virtual ~nsRulesInfo() {}
nsEditor::OperationID action;
OperationID action;
};
/***************************************************************************
@ -44,9 +44,9 @@ public:
NS_IMETHOD Init(nsPlaintextEditor *aEditor)=0;
NS_IMETHOD DetachEditor()=0;
NS_IMETHOD BeforeEdit(nsEditor::OperationID action,
NS_IMETHOD BeforeEdit(OperationID action,
nsIEditor::EDirection aDirection) = 0;
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
NS_IMETHOD AfterEdit(OperationID action,
nsIEditor::EDirection aDirection) = 0;
NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo,
bool* aCancel, bool* aHandled) = 0;

View File

@ -143,7 +143,7 @@ nsEditor::nsEditor()
, mFlags(0)
, mUpdateCount(0)
, mPlaceHolderBatch(0)
, mAction(kOpNone)
, mAction(OperationID::none)
, mHandlingActionCount(0)
, mIMETextOffset(0)
, mIMEBufferLength(0)
@ -785,7 +785,7 @@ nsEditor::Undo(PRUint32 aCount)
CanUndo(&hasTxnMgr, &hasTransaction);
NS_ENSURE_TRUE(hasTransaction, NS_OK);
nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone);
nsAutoRules beginRulesSniffing(this, OperationID::undo, nsIEditor::eNone);
if (!mTxnMgr) {
return NS_OK;
@ -828,7 +828,7 @@ nsEditor::Redo(PRUint32 aCount)
CanRedo(&hasTxnMgr, &hasTransaction);
NS_ENSURE_TRUE(hasTransaction, NS_OK);
nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone);
nsAutoRules beginRulesSniffing(this, OperationID::redo, nsIEditor::eNone);
if (!mTxnMgr) {
return NS_OK;
@ -1347,7 +1347,7 @@ NS_IMETHODIMP nsEditor::CreateNode(const nsAString& aTag,
{
PRInt32 i;
nsAutoRules beginRulesSniffing(this, kOpCreateNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::createNode, nsIEditor::eNext);
for (i = 0; i < mActionListeners.Count(); i++)
mActionListeners[i]->WillCreateNode(aTag, aParent, aPosition);
@ -1379,7 +1379,7 @@ NS_IMETHODIMP nsEditor::InsertNode(nsIDOMNode * aNode,
PRInt32 aPosition)
{
PRInt32 i;
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
for (i = 0; i < mActionListeners.Count(); i++)
mActionListeners[i]->WillInsertNode(aNode, aParent, aPosition);
@ -1406,7 +1406,7 @@ nsEditor::SplitNode(nsIDOMNode * aNode,
nsIDOMNode **aNewLeftNode)
{
PRInt32 i;
nsAutoRules beginRulesSniffing(this, kOpSplitNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::splitNode, nsIEditor::eNext);
for (i = 0; i < mActionListeners.Count(); i++)
mActionListeners[i]->WillSplitNode(aNode, aOffset);
@ -1455,7 +1455,7 @@ nsEditor::JoinNodes(nsIDOMNode * aLeftNode,
nsIDOMNode * aParent)
{
PRInt32 i;
nsAutoRules beginRulesSniffing(this, kOpJoinNode, nsIEditor::ePrevious);
nsAutoRules beginRulesSniffing(this, OperationID::joinNode, nsIEditor::ePrevious);
// remember some values; later used for saved selection updating.
// find the offset between the nodes to be joined.
@ -1494,7 +1494,7 @@ nsEditor::DeleteNode(nsIDOMNode* aNode)
nsresult
nsEditor::DeleteNode(nsINode* aNode)
{
nsAutoRules beginRulesSniffing(this, kOpCreateNode, nsIEditor::ePrevious);
nsAutoRules beginRulesSniffing(this, OperationID::createNode, nsIEditor::ePrevious);
// save node location for selection updating code.
for (PRInt32 i = 0; i < mActionListeners.Count(); i++) {
@ -2195,7 +2195,7 @@ nsEditor::StartOperation(OperationID opID, nsIEditor::EDirection aDirection)
NS_IMETHODIMP
nsEditor::EndOperation()
{
mAction = kOpNone;
mAction = OperationID::none;
mDirection = eNone;
return NS_OK;
}
@ -2705,7 +2705,7 @@ NS_IMETHODIMP nsEditor::DeleteText(nsIDOMCharacterData *aElement,
nsRefPtr<DeleteTextTxn> txn;
nsresult result = CreateTxnForDeleteText(aElement, aOffset, aLength,
getter_AddRefs(txn));
nsAutoRules beginRulesSniffing(this, kOpDeleteText, nsIEditor::ePrevious);
nsAutoRules beginRulesSniffing(this, OperationID::deleteText, nsIEditor::ePrevious);
if (NS_SUCCEEDED(result))
{
// let listeners know what's up
@ -4311,7 +4311,7 @@ nsEditor::DeleteSelectionImpl(EDirection aAction,
if (NS_SUCCEEDED(res))
{
nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);
nsAutoRules beginRulesSniffing(this, OperationID::deleteSelection, aAction);
PRInt32 i;
// Notify nsIEditActionListener::WillDelete[Selection|Text|Node]
if (!deleteNode)

View File

@ -85,6 +85,53 @@ struct IMEState;
#define kMOZEditorBogusNodeAttrAtom nsEditProperty::mozEditorBogusNode
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
// This is PRInt32 instead of PRInt16 because nsIInlineSpellChecker.idl's
// spellCheckAfterEditorChange is defined to take it as a long.
MOZ_BEGIN_ENUM_CLASS(OperationID, PRInt32)
ignore = -1,
none = 0,
undo,
redo,
insertNode,
createNode,
deleteNode,
splitNode,
joinNode,
deleteText = 1003,
// text commands
insertText = 2000,
insertIMEText = 2001,
deleteSelection = 2002,
setTextProperty = 2003,
removeTextProperty = 2004,
outputText = 2005,
// html only action
insertBreak = 3000,
makeList = 3001,
indent = 3002,
outdent = 3003,
align = 3004,
makeBasicBlock = 3005,
removeList = 3006,
makeDefListItem = 3007,
insertElement = 3008,
insertQuotation = 3009,
htmlPaste = 3012,
loadHTML = 3013,
resetTextProperties = 3014,
setAbsolutePosition = 3015,
removeAbsolutePosition = 3016,
decreaseZIndex = 3017,
increaseZIndex = 3018
MOZ_END_ENUM_CLASS(OperationID)
inline bool operator!(const OperationID& aOp)
{
return aOp == OperationID::none;
}
/** implementation of an editor object. it will be the controller/focal point
* for the main editor services. i.e. the GUIManager, publishing, transaction
* manager, event interfaces. the idea for the event interfaces is to have them
@ -104,47 +151,6 @@ public:
kIterBackward
};
enum OperationID
{
kOpIgnore = -1,
kOpNone = 0,
kOpUndo,
kOpRedo,
kOpInsertNode,
kOpCreateNode,
kOpDeleteNode,
kOpSplitNode,
kOpJoinNode,
kOpDeleteText = 1003,
// text commands
kOpInsertText = 2000,
kOpInsertIMEText = 2001,
kOpDeleteSelection = 2002,
kOpSetTextProperty = 2003,
kOpRemoveTextProperty = 2004,
kOpOutputText = 2005,
// html only action
kOpInsertBreak = 3000,
kOpMakeList = 3001,
kOpIndent = 3002,
kOpOutdent = 3003,
kOpAlign = 3004,
kOpMakeBasicBlock = 3005,
kOpRemoveList = 3006,
kOpMakeDefListItem = 3007,
kOpInsertElement = 3008,
kOpInsertQuotation = 3009,
kOpHTMLPaste = 3012,
kOpLoadHTML = 3013,
kOpResetTextProperties = 3014,
kOpSetAbsolutePosition = 3015,
kOpRemoveAbsolutePosition = 3016,
kOpDecreaseZIndex = 3017,
kOpIncreaseZIndex = 3018
};
/** The default constructor. This should suffice. the setting of the interfaces is done
* after the construction of the editor class.
*/

View File

@ -78,7 +78,7 @@ class NS_STACK_CLASS nsAutoRules
{
public:
nsAutoRules(nsEditor *ed, nsEditor::OperationID action,
nsAutoRules(nsEditor *ed, OperationID action,
nsIEditor::EDirection aDirection) :
mEd(ed), mDoNothing(false)
{

View File

@ -61,8 +61,8 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
{
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this,
aEnabled ? kOpSetAbsolutePosition :
kOpRemoveAbsolutePosition,
aEnabled ? OperationID::setAbsolutePosition :
OperationID::removeAbsolutePosition,
nsIEditor::eNext);
// the line below does not match the code; should it be removed?
@ -70,8 +70,8 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(aEnabled ? kOpSetAbsolutePosition :
kOpRemoveAbsolutePosition);
nsTextRulesInfo ruleInfo(aEnabled ? OperationID::setAbsolutePosition :
OperationID::removeAbsolutePosition);
bool cancel, handled;
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (NS_FAILED(res) || cancel)
@ -174,16 +174,16 @@ nsHTMLEditor::RelativeChangeZIndex(PRInt32 aChange)
{
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this,
(aChange < 0) ? kOpDecreaseZIndex :
kOpIncreaseZIndex,
(aChange < 0) ? OperationID::decreaseZIndex :
OperationID::increaseZIndex,
nsIEditor::eNext);
// brade: can we get rid of this comment?
// Find out if the selection is collapsed:
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(aChange < 0 ? kOpDecreaseZIndex :
kOpIncreaseZIndex);
nsTextRulesInfo ruleInfo(aChange < 0 ? OperationID::decreaseZIndex :
OperationID::increaseZIndex);
bool cancel, handled;
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || NS_FAILED(res))

View File

@ -155,13 +155,13 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
// force IME commit; set up rules sniffing and batching
ForceCompositionEnd();
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpLoadHTML, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::loadHTML, nsIEditor::eNext);
// Get selection
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_STATE(selection);
nsTextRulesInfo ruleInfo(kOpLoadHTML);
nsTextRulesInfo ruleInfo(OperationID::loadHTML);
bool cancel, handled;
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
@ -252,7 +252,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
// force IME commit; set up rules sniffing and batching
ForceCompositionEnd();
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpHTMLPaste, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::htmlPaste, nsIEditor::eNext);
// Get selection
nsRefPtr<Selection> selection = GetSelection();
@ -391,7 +391,7 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
}
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
bool cancel, handled;
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
@ -1746,14 +1746,14 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
PRInt32 aSelectionType)
{
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertQuotation, nsIEditor::eNext);
// get selection
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
bool cancel, handled;
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
@ -1954,10 +1954,10 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertQuotation, nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
bool cancel, handled;
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);
@ -2047,10 +2047,10 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertQuotation, nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
bool cancel, handled;
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -89,19 +89,19 @@ static bool IsInlineNode(nsIDOMNode* node)
}
static bool
IsStyleCachePreservingAction(nsEditor::OperationID action)
IsStyleCachePreservingAction(OperationID action)
{
return action == nsEditor::kOpDeleteSelection ||
action == nsEditor::kOpInsertBreak ||
action == nsEditor::kOpMakeList ||
action == nsEditor::kOpIndent ||
action == nsEditor::kOpOutdent ||
action == nsEditor::kOpAlign ||
action == nsEditor::kOpMakeBasicBlock ||
action == nsEditor::kOpRemoveList ||
action == nsEditor::kOpMakeDefListItem ||
action == nsEditor::kOpInsertElement ||
action == nsEditor::kOpInsertQuotation;
return action == OperationID::deleteSelection ||
action == OperationID::insertBreak ||
action == OperationID::makeList ||
action == OperationID::indent ||
action == OperationID::outdent ||
action == OperationID::align ||
action == OperationID::makeBasicBlock ||
action == OperationID::removeList ||
action == OperationID::makeDefListItem ||
action == OperationID::insertElement ||
action == OperationID::insertQuotation;
}
class nsTableCellAndListItemFunctor : public nsBoolDomIterFunctor
@ -277,7 +277,7 @@ nsHTMLEditRules::DetachEditor()
}
NS_IMETHODIMP
nsHTMLEditRules::BeforeEdit(nsEditor::OperationID action,
nsHTMLEditRules::BeforeEdit(OperationID action,
nsIEditor::EDirection aDirection)
{
if (mLockRulesSniffing) return NS_OK;
@ -330,9 +330,9 @@ nsHTMLEditRules::BeforeEdit(nsEditor::OperationID action,
}
// remember current inline styles for deletion and normal insertion operations
if (action == nsEditor::kOpInsertText ||
action == nsEditor::kOpInsertIMEText ||
action == nsEditor::kOpDeleteSelection ||
if (action == OperationID::insertText ||
action == OperationID::insertIMEText ||
action == OperationID::deleteSelection ||
IsStyleCachePreservingAction(action)) {
nsCOMPtr<nsIDOMNode> selNode = selStartNode;
if (aDirection == nsIEditor::eNext)
@ -361,7 +361,7 @@ nsHTMLEditRules::BeforeEdit(nsEditor::OperationID action,
NS_IMETHODIMP
nsHTMLEditRules::AfterEdit(nsEditor::OperationID action,
nsHTMLEditRules::AfterEdit(OperationID action,
nsIEditor::EDirection aDirection)
{
if (mLockRulesSniffing) return NS_OK;
@ -396,11 +396,11 @@ nsHTMLEditRules::AfterEdit(nsEditor::OperationID action,
nsresult
nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
nsHTMLEditRules::AfterEditInner(OperationID action,
nsIEditor::EDirection aDirection)
{
ConfirmSelectionInBody();
if (action == nsEditor::kOpIgnore) return NS_OK;
if (action == OperationID::ignore) return NS_OK;
nsCOMPtr<nsISelection>selection;
nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
@ -420,7 +420,7 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
bDamagedRange = true;
}
if (bDamagedRange && !((action == nsEditor::kOpUndo) || (action == nsEditor::kOpRedo)))
if (bDamagedRange && !((action == OperationID::undo) || (action == OperationID::redo)))
{
// don't let any txns in here move the selection around behind our back.
// Note that this won't prevent explicit selection setting from working.
@ -432,9 +432,9 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
// if we did a ranged deletion, make sure we have a place to put caret.
// Note we only want to do this if the overall operation was deletion,
// not if deletion was done along the way for kOpLoadHTML, kOpInsertText, etc.
// not if deletion was done along the way for OperationID::loadHTML, OperationID::insertText, etc.
// That's why this is here rather than DidDeleteSelection().
if ((action == nsEditor::kOpDeleteSelection) && mDidRangedDelete)
if ((action == OperationID::deleteSelection) && mDidRangedDelete)
{
res = InsertBRIfNeeded(selection);
NS_ENSURE_SUCCESS(res, res);
@ -445,8 +445,8 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
NS_ENSURE_SUCCESS(res, res);
// merge any adjacent text nodes
if ( (action != nsEditor::kOpInsertText &&
action != nsEditor::kOpInsertIMEText) )
if ( (action != OperationID::insertText &&
action != OperationID::insertIMEText) )
{
res = mHTMLEditor->CollapseAdjacentTextNodes(mDocChangeRange);
NS_ENSURE_SUCCESS(res, res);
@ -457,12 +457,12 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
NS_ENSURE_SUCCESS(res, res);
// attempt to transform any unneeded nbsp's into spaces after doing various operations
if ((action == nsEditor::kOpInsertText) ||
(action == nsEditor::kOpInsertIMEText) ||
(action == nsEditor::kOpDeleteSelection) ||
(action == nsEditor::kOpInsertBreak) ||
(action == nsHTMLEditor::kOpHTMLPaste ||
(action == nsHTMLEditor::kOpLoadHTML)))
if ((action == OperationID::insertText) ||
(action == OperationID::insertIMEText) ||
(action == OperationID::deleteSelection) ||
(action == OperationID::insertBreak) ||
(action == OperationID::htmlPaste ||
(action == OperationID::loadHTML)))
{
res = AdjustWhitespace(selection);
NS_ENSURE_SUCCESS(res, res);
@ -486,21 +486,21 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
}
// adjust selection for insert text, html paste, and delete actions
if ((action == nsEditor::kOpInsertText) ||
(action == nsEditor::kOpInsertIMEText) ||
(action == nsEditor::kOpDeleteSelection) ||
(action == nsEditor::kOpInsertBreak) ||
(action == nsHTMLEditor::kOpHTMLPaste ||
(action == nsHTMLEditor::kOpLoadHTML)))
if ((action == OperationID::insertText) ||
(action == OperationID::insertIMEText) ||
(action == OperationID::deleteSelection) ||
(action == OperationID::insertBreak) ||
(action == OperationID::htmlPaste ||
(action == OperationID::loadHTML)))
{
res = AdjustSelection(selection, aDirection);
NS_ENSURE_SUCCESS(res, res);
}
// check for any styles which were removed inappropriately
if (action == nsEditor::kOpInsertText ||
action == nsEditor::kOpInsertIMEText ||
action == nsEditor::kOpDeleteSelection ||
if (action == OperationID::insertText ||
action == OperationID::insertIMEText ||
action == OperationID::deleteSelection ||
IsStyleCachePreservingAction(action)) {
mHTMLEditor->mTypeInState->UpdateSelState(selection);
res = ReapplyCachedStyles();
@ -548,9 +548,9 @@ nsHTMLEditRules::WillDoAction(Selection* aSelection,
// Deal with actions for which we don't need to check whether the selection is
// editable.
if (info->action == nsEditor::kOpOutputText ||
info->action == nsEditor::kOpUndo ||
info->action == nsEditor::kOpRedo) {
if (info->action == OperationID::outputText ||
info->action == OperationID::undo ||
info->action == OperationID::redo) {
return nsTextEditRules::WillDoAction(aSelection, aInfo, aCancel, aHandled);
}
@ -583,42 +583,42 @@ nsHTMLEditRules::WillDoAction(Selection* aSelection,
}
switch (info->action) {
case nsEditor::kOpInsertText:
case nsEditor::kOpInsertIMEText:
case OperationID::insertText:
case OperationID::insertIMEText:
return WillInsertText(info->action, aSelection, aCancel, aHandled,
info->inString, info->outString, info->maxLength);
case nsEditor::kOpLoadHTML:
case OperationID::loadHTML:
return WillLoadHTML(aSelection, aCancel);
case nsEditor::kOpInsertBreak:
case OperationID::insertBreak:
return WillInsertBreak(aSelection, aCancel, aHandled);
case nsEditor::kOpDeleteSelection:
case OperationID::deleteSelection:
return WillDeleteSelection(aSelection, info->collapsedAction,
info->stripWrappers, aCancel, aHandled);
case nsEditor::kOpMakeList:
case OperationID::makeList:
return WillMakeList(aSelection, info->blockType, info->entireList,
info->bulletType, aCancel, aHandled);
case nsEditor::kOpIndent:
case OperationID::indent:
return WillIndent(aSelection, aCancel, aHandled);
case nsEditor::kOpOutdent:
case OperationID::outdent:
return WillOutdent(aSelection, aCancel, aHandled);
case nsEditor::kOpSetAbsolutePosition:
case OperationID::setAbsolutePosition:
return WillAbsolutePosition(aSelection, aCancel, aHandled);
case nsEditor::kOpRemoveAbsolutePosition:
case OperationID::removeAbsolutePosition:
return WillRemoveAbsolutePosition(aSelection, aCancel, aHandled);
case nsEditor::kOpAlign:
case OperationID::align:
return WillAlign(aSelection, info->alignType, aCancel, aHandled);
case nsEditor::kOpMakeBasicBlock:
case OperationID::makeBasicBlock:
return WillMakeBasicBlock(aSelection, info->blockType, aCancel, aHandled);
case nsEditor::kOpRemoveList:
case OperationID::removeList:
return WillRemoveList(aSelection, info->bOrdered, aCancel, aHandled);
case nsEditor::kOpMakeDefListItem:
case OperationID::makeDefListItem:
return WillMakeDefListItem(aSelection, info->blockType, info->entireList,
aCancel, aHandled);
case nsEditor::kOpInsertElement:
case OperationID::insertElement:
return WillInsert(aSelection, aCancel);
case nsEditor::kOpDecreaseZIndex:
case OperationID::decreaseZIndex:
return WillRelativeChangeZIndex(aSelection, -1, aCancel, aHandled);
case nsEditor::kOpIncreaseZIndex:
case OperationID::increaseZIndex:
return WillRelativeChangeZIndex(aSelection, 1, aCancel, aHandled);
default:
return nsTextEditRules::WillDoAction(aSelection, aInfo,
@ -634,16 +634,16 @@ nsHTMLEditRules::DidDoAction(nsISelection *aSelection,
nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo);
switch (info->action)
{
case nsEditor::kOpInsertBreak:
case OperationID::insertBreak:
return DidInsertBreak(aSelection, aResult);
case nsEditor::kOpDeleteSelection:
case OperationID::deleteSelection:
return DidDeleteSelection(aSelection, info->collapsedAction, aResult);
case nsEditor::kOpMakeBasicBlock:
case nsEditor::kOpIndent:
case nsEditor::kOpOutdent:
case nsEditor::kOpAlign:
case OperationID::makeBasicBlock:
case OperationID::indent:
case OperationID::outdent:
case OperationID::align:
return DidMakeBasicBlock(aSelection, aInfo, aResult);
case nsEditor::kOpSetAbsolutePosition: {
case OperationID::setAbsolutePosition: {
nsresult rv = DidMakeBasicBlock(aSelection, aInfo, aResult);
NS_ENSURE_SUCCESS(rv, rv);
return DidAbsolutePosition();
@ -802,13 +802,13 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
else
{
nsCOMArray<nsIDOMRange> arrayOfRanges;
res = GetPromotedRanges(selection, arrayOfRanges, nsEditor::kOpAlign);
res = GetPromotedRanges(selection, arrayOfRanges, OperationID::align);
NS_ENSURE_SUCCESS(res, res);
// use these ranges to construct a list of nodes to act on.
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesForOperation(arrayOfRanges, arrayOfNodes,
nsEditor::kOpAlign, true);
OperationID::align, true);
NS_ENSURE_SUCCESS(res, res);
nodeToExamine = arrayOfNodes.SafeObjectAt(0);
}
@ -927,7 +927,7 @@ nsHTMLEditRules::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
// contruct a list of nodes to act on.
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesFromSelection(selection, nsEditor::kOpIndent,
res = GetNodesFromSelection(selection, OperationID::indent,
arrayOfNodes, true);
NS_ENSURE_SUCCESS(res, res);
@ -1226,9 +1226,9 @@ nsHTMLEditRules::WillInsert(nsISelection *aSelection, bool *aCancel)
}
if (mDidDeleteSelection &&
(mTheAction == nsEditor::kOpInsertText ||
mTheAction == nsEditor::kOpInsertIMEText ||
mTheAction == nsEditor::kOpDeleteSelection)) {
(mTheAction == OperationID::insertText ||
mTheAction == OperationID::insertIMEText ||
mTheAction == OperationID::deleteSelection)) {
res = ReapplyCachedStyles();
NS_ENSURE_SUCCESS(res, res);
}
@ -1243,7 +1243,7 @@ nsHTMLEditRules::WillInsert(nsISelection *aSelection, bool *aCancel)
}
nsresult
nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction,
nsHTMLEditRules::WillInsertText(OperationID aAction,
Selection* aSelection,
bool *aCancel,
bool *aHandled,
@ -1253,7 +1253,7 @@ nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction,
{
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
if (inString->IsEmpty() && aAction != nsEditor::kOpInsertIMEText) {
if (inString->IsEmpty() && aAction != OperationID::insertIMEText) {
// HACK: this is a fix for bug 19395
// I can't outlaw all empty insertions
// because IME transaction depend on them
@ -1301,7 +1301,7 @@ nsHTMLEditRules::WillInsertText(nsEditor::OperationID aAction,
return NS_ERROR_FAILURE;
}
if (aAction == nsEditor::kOpInsertIMEText) {
if (aAction == OperationID::insertIMEText) {
// Right now the nsWSRunObject code bails on empty strings, but IME needs
// the InsertTextImpl() call to still happen since empty strings are meaningful there.
if (inString->IsEmpty())
@ -2721,7 +2721,7 @@ nsHTMLEditRules::MoveBlock(nsIDOMNode *aLeftBlock, nsIDOMNode *aRightBlock, PRIn
nsCOMPtr<nsISupports> isupports;
// GetNodesFromPoint is the workhorse that figures out what we wnat to move.
nsresult res = GetNodesFromPoint(DOMPoint(aRightBlock,aRightOffset),
nsEditor::kOpMakeList, arrayOfNodes, true);
OperationID::makeList, arrayOfNodes, true);
NS_ENSURE_SUCCESS(res, res);
PRInt32 listCount = arrayOfNodes.Count();
PRInt32 i;
@ -3165,7 +3165,7 @@ nsHTMLEditRules::WillRemoveList(Selection* aSelection,
nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
nsCOMArray<nsIDOMRange> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges, nsEditor::kOpMakeList);
res = GetPromotedRanges(aSelection, arrayOfRanges, OperationID::makeList);
NS_ENSURE_SUCCESS(res, res);
// use these ranges to contruct a list of nodes to act on.
@ -3253,7 +3253,7 @@ nsHTMLEditRules::WillMakeBasicBlock(Selection* aSelection,
// contruct a list of nodes to act on.
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesFromSelection(aSelection, nsEditor::kOpMakeBasicBlock,
res = GetNodesFromSelection(aSelection, OperationID::makeBasicBlock,
arrayOfNodes);
NS_ENSURE_SUCCESS(res, res);
@ -3445,7 +3445,7 @@ nsHTMLEditRules::WillCSSIndent(Selection* aSelection,
// this basically just expands the range to include the immediate
// block parent, and then further expands to include any ancestors
// whose children are all in the range
res = GetNodesFromSelection(aSelection, nsEditor::kOpIndent, arrayOfNodes);
res = GetNodesFromSelection(aSelection, OperationID::indent, arrayOfNodes);
NS_ENSURE_SUCCESS(res, res);
}
@ -3627,12 +3627,12 @@ nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
// whose children are all in the range
nsCOMArray<nsIDOMRange> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges, nsEditor::kOpIndent);
res = GetPromotedRanges(aSelection, arrayOfRanges, OperationID::indent);
NS_ENSURE_SUCCESS(res, res);
// use these ranges to contruct a list of nodes to act on.
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesForOperation(arrayOfRanges, arrayOfNodes, nsEditor::kOpIndent);
res = GetNodesForOperation(arrayOfRanges, arrayOfNodes, OperationID::indent);
NS_ENSURE_SUCCESS(res, res);
NS_NAMED_LITERAL_STRING(quoteType, "blockquote");
@ -3850,7 +3850,7 @@ nsHTMLEditRules::WillOutdent(Selection* aSelection,
// block parent, and then further expands to include any ancestors
// whose children are all in the range
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesFromSelection(aSelection, nsEditor::kOpOutdent,
res = GetNodesFromSelection(aSelection, OperationID::outdent,
arrayOfNodes);
NS_ENSURE_SUCCESS(res, res);
@ -4424,7 +4424,7 @@ nsHTMLEditRules::WillAlign(Selection* aSelection,
// whose children are all in the range
*aHandled = true;
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesFromSelection(aSelection, nsEditor::kOpAlign, arrayOfNodes);
res = GetNodesFromSelection(aSelection, OperationID::align, arrayOfNodes);
NS_ENSURE_SUCCESS(res, res);
// if we don't have any nodes, or we have only a single br, then we are
@ -5209,7 +5209,7 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection)
void
nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
PRInt32 aOffset,
nsEditor::OperationID actionID,
OperationID actionID,
nsCOMPtr<nsIDOMNode>* outNode,
PRInt32* outOffset)
{
@ -5222,10 +5222,10 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
// we do one thing for text actions, something else entirely for other
// actions
if (actionID == nsEditor::kOpInsertText ||
actionID == nsEditor::kOpInsertIMEText ||
actionID == nsEditor::kOpInsertBreak ||
actionID == nsEditor::kOpDeleteText) {
if (actionID == OperationID::insertText ||
actionID == OperationID::insertIMEText ||
actionID == OperationID::insertBreak ||
actionID == OperationID::deleteText) {
bool isSpace, isNBSP;
nsCOMPtr<nsIContent> content = do_QueryInterface(node), temp;
// for text actions, we want to look backwards (or forwards, as
@ -5294,7 +5294,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
// aWhere == kEnd case. as long as they are in one or the other it will
// work. special case for outdent: don't keep looking up if we have
// found a blockquote element to act on
if (actionID == nsHTMLEditor::kOpOutdent &&
if (actionID == OperationID::outdent &&
node->Tag() == nsGkAtoms::blockquote) {
break;
}
@ -5306,10 +5306,10 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
// before walking up to a parent because we need to return the parent
// object, so the parent itself might not be in the editable area, but
// it's OK if we're not performing a block-level action.
bool blockLevelAction = actionID == nsHTMLEditor::kOpIndent ||
actionID == nsHTMLEditor::kOpOutdent ||
actionID == nsHTMLEditor::kOpAlign ||
actionID == nsHTMLEditor::kOpMakeBasicBlock;
bool blockLevelAction = actionID == OperationID::indent ||
actionID == OperationID::outdent ||
actionID == OperationID::align ||
actionID == OperationID::makeBasicBlock;
if (!mHTMLEditor->IsDescendantOfEditorRoot(parent) &&
(blockLevelAction || !mHTMLEditor->IsDescendantOfEditorRoot(node))) {
break;
@ -5386,7 +5386,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
nsresult
nsHTMLEditRules::GetPromotedRanges(nsISelection *inSelection,
nsCOMArray<nsIDOMRange> &outArrayOfRanges,
nsEditor::OperationID inOperationType)
OperationID inOperationType)
{
NS_ENSURE_TRUE(inSelection, NS_ERROR_NULL_POINTER);
@ -5427,7 +5427,7 @@ nsHTMLEditRules::GetPromotedRanges(nsISelection *inSelection,
//
nsresult
nsHTMLEditRules::PromoteRange(nsIDOMRange *inRange,
nsEditor::OperationID inOperationType)
OperationID inOperationType)
{
NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
nsresult res;
@ -5527,7 +5527,7 @@ private:
nsresult
nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
nsCOMArray<nsIDOMNode>& outArrayOfNodes,
nsEditor::OperationID inOperationType,
OperationID inOperationType,
bool aDontTouchContent)
{
PRInt32 rangeCount = inArrayOfRanges.Count();
@ -5610,7 +5610,7 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
// certain operations should not act on li's and td's, but rather inside
// them. alter the list as needed
if (inOperationType == nsEditor::kOpMakeBasicBlock) {
if (inOperationType == OperationID::makeBasicBlock) {
PRInt32 listCount = outArrayOfNodes.Count();
for (i=listCount-1; i>=0; i--)
{
@ -5626,9 +5626,9 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
}
// indent/outdent already do something special for list items, but
// we still need to make sure we don't act on table elements
else if (inOperationType == nsEditor::kOpOutdent ||
inOperationType == nsEditor::kOpIndent ||
inOperationType == nsEditor::kOpSetAbsolutePosition) {
else if (inOperationType == OperationID::outdent ||
inOperationType == OperationID::indent ||
inOperationType == OperationID::setAbsolutePosition) {
PRInt32 listCount = outArrayOfNodes.Count();
for (i=listCount-1; i>=0; i--)
{
@ -5643,7 +5643,7 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
}
}
// outdent should look inside of divs.
if (inOperationType == nsEditor::kOpOutdent &&
if (inOperationType == OperationID::outdent &&
!mHTMLEditor->IsCSSEnabled()) {
PRInt32 listCount = outArrayOfNodes.Count();
for (i=listCount-1; i>=0; i--)
@ -5662,12 +5662,12 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
// post process the list to break up inline containers that contain br's.
// but only for operations that might care, like making lists or para's...
if (inOperationType == nsEditor::kOpMakeBasicBlock ||
inOperationType == nsEditor::kOpMakeList ||
inOperationType == nsEditor::kOpAlign ||
inOperationType == nsEditor::kOpSetAbsolutePosition ||
inOperationType == nsEditor::kOpIndent ||
inOperationType == nsEditor::kOpOutdent) {
if (inOperationType == OperationID::makeBasicBlock ||
inOperationType == OperationID::makeList ||
inOperationType == OperationID::align ||
inOperationType == OperationID::setAbsolutePosition ||
inOperationType == OperationID::indent ||
inOperationType == OperationID::outdent) {
PRInt32 listCount = outArrayOfNodes.Count();
for (i=listCount-1; i>=0; i--)
{
@ -5771,7 +5771,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMArray<nsIDOMNode> &outArrayOfNodes,
nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
// contruct a list of nodes to act on.
res = GetNodesFromSelection(selection, nsEditor::kOpMakeList,
res = GetNodesFromSelection(selection, OperationID::makeList,
outArrayOfNodes, aDontTouchContent);
NS_ENSURE_SUCCESS(res, res);
}
@ -5901,7 +5901,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsCOMArray<nsIDOMNode>& outArrayOfNodes
NS_ENSURE_SUCCESS(res, res);
// contruct a list of nodes to act on.
res = GetNodesFromSelection(selection, nsEditor::kOpMakeBasicBlock,
res = GetNodesFromSelection(selection, OperationID::makeBasicBlock,
outArrayOfNodes, aDontTouchContent);
NS_ENSURE_SUCCESS(res, res);
@ -6074,7 +6074,7 @@ nsHTMLEditRules::GetHighestInlineParent(nsIDOMNode* aNode)
//
nsresult
nsHTMLEditRules::GetNodesFromPoint(DOMPoint point,
nsEditor::OperationID operation,
OperationID operation,
nsCOMArray<nsIDOMNode> &arrayOfNodes,
bool dontTouchContent)
{
@ -6115,7 +6115,7 @@ nsHTMLEditRules::GetNodesFromPoint(DOMPoint point,
//
nsresult
nsHTMLEditRules::GetNodesFromSelection(nsISelection *selection,
nsEditor::OperationID operation,
OperationID operation,
nsCOMArray<nsIDOMNode>& arrayOfNodes,
bool dontTouchContent)
{
@ -8583,13 +8583,13 @@ nsHTMLEditRules::WillAbsolutePosition(Selection* aSelection,
nsCOMArray<nsIDOMRange> arrayOfRanges;
res = GetPromotedRanges(aSelection, arrayOfRanges,
nsEditor::kOpSetAbsolutePosition);
OperationID::setAbsolutePosition);
NS_ENSURE_SUCCESS(res, res);
// use these ranges to contruct a list of nodes to act on.
nsCOMArray<nsIDOMNode> arrayOfNodes;
res = GetNodesForOperation(arrayOfRanges, arrayOfNodes,
nsEditor::kOpSetAbsolutePosition);
OperationID::setAbsolutePosition);
NS_ENSURE_SUCCESS(res, res);
NS_NAMED_LITERAL_STRING(divType, "div");

View File

@ -77,9 +77,9 @@ public:
// nsIEditRules methods
NS_IMETHOD Init(nsPlaintextEditor *aEditor);
NS_IMETHOD DetachEditor();
NS_IMETHOD BeforeEdit(nsEditor::OperationID action,
NS_IMETHOD BeforeEdit(OperationID action,
nsIEditor::EDirection aDirection);
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
NS_IMETHOD AfterEdit(OperationID action,
nsIEditor::EDirection aDirection);
NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo,
bool* aCancel, bool* aHandled);
@ -128,7 +128,7 @@ protected:
// nsHTMLEditRules implementation methods
nsresult WillInsert(nsISelection *aSelection, bool *aCancel);
nsresult WillInsertText( nsEditor::OperationID aAction,
nsresult WillInsertText( OperationID aAction,
mozilla::Selection* aSelection,
bool *aCancel,
bool *aHandled,
@ -208,7 +208,7 @@ protected:
nsCOMPtr<nsIDOMNode> *aSelNode,
PRInt32 *aOffset);
nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset);
nsresult AfterEditInner(nsEditor::OperationID action,
nsresult AfterEditInner(OperationID action,
nsIEditor::EDirection aDirection);
nsresult RemovePartOfBlock(nsIDOMNode *aBlock,
nsIDOMNode *aStartChild,
@ -253,25 +253,25 @@ protected:
bool IsLastNode(nsIDOMNode *aNode);
nsresult NormalizeSelection(nsISelection *inSelection);
void GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode* aNode,
PRInt32 aOffset, nsEditor::OperationID actionID,
PRInt32 aOffset, OperationID actionID,
nsCOMPtr<nsIDOMNode>* outNode, PRInt32* outOffset);
nsresult GetPromotedRanges(nsISelection *inSelection,
nsCOMArray<nsIDOMRange> &outArrayOfRanges,
nsEditor::OperationID inOperationType);
OperationID inOperationType);
nsresult PromoteRange(nsIDOMRange *inRange,
nsEditor::OperationID inOperationType);
OperationID inOperationType);
nsresult GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
nsCOMArray<nsIDOMNode>& outArrayOfNodes,
nsEditor::OperationID inOperationType,
OperationID inOperationType,
bool aDontTouchContent=false);
nsresult GetChildNodesForOperation(nsIDOMNode *inNode,
nsCOMArray<nsIDOMNode>& outArrayOfNodes);
nsresult GetNodesFromPoint(DOMPoint point,
nsEditor::OperationID operation,
OperationID operation,
nsCOMArray<nsIDOMNode>& arrayOfNodes,
bool dontTouchContent);
nsresult GetNodesFromSelection(nsISelection *selection,
nsEditor::OperationID operation,
OperationID operation,
nsCOMArray<nsIDOMNode>& arrayOfNodes,
bool aDontTouchContent=false);
nsresult GetListActionNodes(nsCOMArray<nsIDOMNode> &outArrayOfNodes, bool aEntireList, bool aDontTouchContent=false);

View File

@ -1168,7 +1168,7 @@ nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelect
NS_IMETHODIMP
nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
{
nsAutoRules beginRulesSniffing(this, kOpIgnore, nsIEditor::eNone); // don't do any post processing, rules get confused
nsAutoRules beginRulesSniffing(this, OperationID::ignore, nsIEditor::eNone); // don't do any post processing, rules get confused
nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
@ -1490,7 +1490,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
ForceCompositionEnd();
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertElement, nsIEditor::eNext);
nsRefPtr<Selection> selection = GetSelection();
if (!selection) {
@ -1499,7 +1499,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
// hand off to the rules system, see if it has anything to say about this
bool cancel, handled;
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
ruleInfo.insertElement = aElement;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -1951,13 +1951,13 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
bool cancel, handled;
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpMakeList, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::makeList, nsIEditor::eNext);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(kOpMakeList);
nsTextRulesInfo ruleInfo(OperationID::makeList);
ruleInfo.blockType = &aListType;
ruleInfo.entireList = entireList;
ruleInfo.bulletType = &aBulletType;
@ -2027,13 +2027,13 @@ nsHTMLEditor::RemoveList(const nsAString& aListType)
bool cancel, handled;
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpRemoveList, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::removeList, nsIEditor::eNext);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(kOpRemoveList);
nsTextRulesInfo ruleInfo(OperationID::removeList);
if (aListType.LowerCaseEqualsLiteral("ol"))
ruleInfo.bOrdered = true;
else ruleInfo.bOrdered = false;
@ -2058,12 +2058,12 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
bool cancel, handled;
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpMakeDefListItem, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::makeDefListItem, nsIEditor::eNext);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(kOpMakeDefListItem);
nsTextRulesInfo ruleInfo(OperationID::makeDefListItem);
ruleInfo.blockType = &aItemType;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2089,12 +2089,12 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
bool cancel, handled;
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpMakeBasicBlock, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::makeBasicBlock, nsIEditor::eNext);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(kOpMakeBasicBlock);
nsTextRulesInfo ruleInfo(OperationID::makeBasicBlock);
ruleInfo.blockType = &aBlockType;
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || (NS_FAILED(res))) return res;
@ -2157,10 +2157,10 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
bool cancel, handled;
OperationID opID = kOpIndent;
OperationID opID = OperationID::indent;
if (aIndent.LowerCaseEqualsLiteral("outdent"))
{
opID = kOpOutdent;
opID = OperationID::outdent;
}
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
@ -2237,7 +2237,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpAlign, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::align, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> node;
bool cancel, handled;
@ -2245,7 +2245,7 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
// Find out if the selection is collapsed:
nsRefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsTextRulesInfo ruleInfo(kOpAlign);
nsTextRulesInfo ruleInfo(OperationID::align);
ruleInfo.alignType = &aAlignType;
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
if (cancel || NS_FAILED(res))
@ -4668,12 +4668,12 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
bool isCollapsed = selection->Collapsed();
nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertElement, nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this);
nsAutoTxnsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(kOpSetTextProperty);
nsTextRulesInfo ruleInfo(OperationID::setTextProperty);
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled)

View File

@ -127,12 +127,12 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
}
nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertElement, nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this);
nsAutoTxnsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(kOpSetTextProperty);
nsTextRulesInfo ruleInfo(OperationID::setTextProperty);
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled) {
@ -1332,7 +1332,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
{
nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, kOpResetTextProperties, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::resetTextProperties, nsIEditor::eNext);
nsresult res = RemoveInlinePropertyImpl(nullptr, nullptr);
NS_ENSURE_SUCCESS(res, res);
@ -1372,12 +1372,12 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
}
nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, kOpRemoveTextProperty, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::removeTextProperty, nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this);
nsAutoTxnsConserveSelection dontSpazMySelection(this);
bool cancel, handled;
nsTextRulesInfo ruleInfo(kOpRemoveTextProperty);
nsTextRulesInfo ruleInfo(OperationID::removeTextProperty);
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(res, res);
if (!cancel && !handled)
@ -1566,7 +1566,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange)
// wrap with txn batching, rules sniffing, and selection preservation code
nsAutoEditBatch batchIt(this);
nsAutoRules beginRulesSniffing(this, kOpSetTextProperty, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::setTextProperty, nsIEditor::eNext);
nsAutoSelectionReset selectionResetter(selection, this);
nsAutoTxnsConserveSelection dontSpazMySelection(this);

View File

@ -424,7 +424,7 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, bool aAfter)
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
// Use column after current cell if requested
if (aAfter)
@ -561,7 +561,7 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, bool aAfter)
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
if (aAfter)
{
@ -761,7 +761,7 @@ nsHTMLEditor::DeleteTableCell(PRInt32 aNumber)
nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
@ -954,7 +954,7 @@ nsHTMLEditor::DeleteTableCellContents()
nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
//Don't let Rules System change the selection
nsAutoTxnsConserveSelection dontChangeSelection(this);
@ -995,7 +995,7 @@ nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell)
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> child;
bool hasChild;
@ -1039,7 +1039,7 @@ nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber)
nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
// Test if deletion is controlled by selected cells
nsCOMPtr<nsIDOMElement> firstCell;
@ -1215,7 +1215,7 @@ nsHTMLEditor::DeleteTableRow(PRInt32 aNumber)
nsAutoEditBatch beginBatching(this);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> firstCell;
nsCOMPtr<nsIDOMRange> range;
@ -1302,7 +1302,7 @@ nsHTMLEditor::DeleteRow(nsIDOMElement *aTable, PRInt32 aRowIndex)
nsresult res = NS_OK;
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
// The list of cells we will change rowspan in
// and the new rowspan values for each
@ -1727,7 +1727,7 @@ nsHTMLEditor::SplitTableCell()
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
// We reset selection
nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
@ -1945,7 +1945,7 @@ nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElemen
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell created by ReplaceContainer
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> newNode;
@ -2204,7 +2204,7 @@ nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
// All cell contents are merged. Delete the empty cells we accumulated
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
for (PRUint32 i = 0, n = deleteList.Length(); i < n; i++)
{
@ -2330,7 +2330,7 @@ nsHTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done
nsAutoRules beginRulesSniffing(this, kOpDeleteNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::deleteNode, nsIEditor::eNext);
// Don't need to merge if cell is empty
if (!IsEmptyCell(cellToMerge)) {
@ -2508,7 +2508,7 @@ nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable)
nsAutoEditBatch beginBatching(this);
// Prevent auto insertion of BR in new cell until we're done
nsAutoRules beginRulesSniffing(this, kOpInsertNode, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMElement> cell;
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;

View File

@ -520,7 +520,7 @@ nsPlaintextEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
*outBRNode = nullptr;
// calling it text insertion to trigger moz br treatment by rules
nsAutoRules beginRulesSniffing(this, kOpInsertText, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertText, nsIEditor::eNext);
nsCOMPtr<nsISelection> selection;
nsresult res = GetSelection(getter_AddRefs(selection));
@ -640,7 +640,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
// delete placeholder txns merge.
nsAutoPlaceHolderBatch batch(this, nsGkAtoms::DeleteTxnName);
nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);
nsAutoRules beginRulesSniffing(this, OperationID::deleteSelection, aAction);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
@ -666,7 +666,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
}
}
nsTextRulesInfo ruleInfo(kOpDeleteSelection);
nsTextRulesInfo ruleInfo(OperationID::deleteSelection);
ruleInfo.collapsedAction = aAction;
ruleInfo.stripWrappers = aStripWrappers;
bool cancel, handled;
@ -692,10 +692,10 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
OperationID opID = kOpInsertText;
OperationID opID = OperationID::insertText;
if (mInIMEMode)
{
opID = kOpInsertIMEText;
opID = OperationID::insertIMEText;
}
nsAutoPlaceHolderBatch batch(this, nullptr);
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
@ -735,7 +735,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertBreak, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertBreak, nsIEditor::eNext);
// pre-process
nsRefPtr<Selection> selection = GetSelection();
@ -747,7 +747,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
NS_ENSURE_TRUE(shell, NS_ERROR_NOT_INITIALIZED);
shell->MaybeInvalidateCaretPosition();
nsTextRulesInfo ruleInfo(kOpInsertBreak);
nsTextRulesInfo ruleInfo(OperationID::insertBreak);
ruleInfo.maxLength = mMaxTextLength;
bool cancel, handled;
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
@ -1082,9 +1082,9 @@ nsPlaintextEditor::Undo(PRUint32 aCount)
ForceCompositionEnd();
nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone);
nsAutoRules beginRulesSniffing(this, OperationID::undo, nsIEditor::eNone);
nsTextRulesInfo ruleInfo(kOpUndo);
nsTextRulesInfo ruleInfo(OperationID::undo);
nsRefPtr<Selection> selection = GetSelection();
bool cancel, handled;
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
@ -1111,9 +1111,9 @@ nsPlaintextEditor::Redo(PRUint32 aCount)
ForceCompositionEnd();
nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone);
nsAutoRules beginRulesSniffing(this, OperationID::redo, nsIEditor::eNone);
nsTextRulesInfo ruleInfo(kOpRedo);
nsTextRulesInfo ruleInfo(OperationID::redo);
nsRefPtr<Selection> selection = GetSelection();
bool cancel, handled;
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
@ -1256,7 +1256,7 @@ nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
nsString resultString;
nsTextRulesInfo ruleInfo(kOpOutputText);
nsTextRulesInfo ruleInfo(OperationID::outputText);
ruleInfo.outString = &resultString;
// XXX Struct should store a nsAReadable*
nsAutoString str(aFormatType);
@ -1392,10 +1392,10 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsAutoEditBatch beginBatching(this);
nsAutoRules beginRulesSniffing(this, kOpInsertText, nsIEditor::eNext);
nsAutoRules beginRulesSniffing(this, OperationID::insertText, nsIEditor::eNext);
// give rules a chance to handle or cancel
nsTextRulesInfo ruleInfo(kOpInsertElement);
nsTextRulesInfo ruleInfo(OperationID::insertElement);
bool cancel, handled;
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -63,7 +63,7 @@ nsTextEditRules::nsTextEditRules()
, mActionNesting(0)
, mLockRulesSniffing(false)
, mDidExplicitlySetInterline(false)
, mTheAction(nsEditor::kOpNone)
, mTheAction(OperationID::none)
, mLastStart(0)
, mLastLength(0)
{
@ -145,7 +145,7 @@ nsTextEditRules::DetachEditor()
}
NS_IMETHODIMP
nsTextEditRules::BeforeEdit(nsEditor::OperationID action,
nsTextEditRules::BeforeEdit(OperationID action,
nsIEditor::EDirection aDirection)
{
if (mLockRulesSniffing) return NS_OK;
@ -172,7 +172,7 @@ nsTextEditRules::BeforeEdit(nsEditor::OperationID action,
NS_IMETHODIMP
nsTextEditRules::AfterEdit(nsEditor::OperationID action,
nsTextEditRules::AfterEdit(OperationID action,
nsIEditor::EDirection aDirection)
{
if (mLockRulesSniffing) return NS_OK;
@ -228,27 +228,27 @@ nsTextEditRules::WillDoAction(Selection* aSelection,
nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo);
switch (info->action) {
case nsEditor::kOpInsertBreak:
case OperationID::insertBreak:
return WillInsertBreak(aSelection, aCancel, aHandled, info->maxLength);
case nsEditor::kOpInsertText:
case nsEditor::kOpInsertIMEText:
case OperationID::insertText:
case OperationID::insertIMEText:
return WillInsertText(info->action, aSelection, aCancel, aHandled,
info->inString, info->outString, info->maxLength);
case nsEditor::kOpDeleteSelection:
case OperationID::deleteSelection:
return WillDeleteSelection(aSelection, info->collapsedAction,
aCancel, aHandled);
case nsEditor::kOpUndo:
case OperationID::undo:
return WillUndo(aSelection, aCancel, aHandled);
case nsEditor::kOpRedo:
case OperationID::redo:
return WillRedo(aSelection, aCancel, aHandled);
case nsEditor::kOpSetTextProperty:
case OperationID::setTextProperty:
return WillSetTextProperty(aSelection, aCancel, aHandled);
case nsEditor::kOpRemoveTextProperty:
case OperationID::removeTextProperty:
return WillRemoveTextProperty(aSelection, aCancel, aHandled);
case nsEditor::kOpOutputText:
case OperationID::outputText:
return WillOutputText(aSelection, info->outputFormat, info->outString,
aCancel, aHandled);
case nsEditor::kOpInsertElement:
case OperationID::insertElement:
// i had thought this would be html rules only. but we put pre elements
// into plaintext mail when doing quoting for reply! doh!
return WillInsert(aSelection, aCancel);
@ -272,22 +272,22 @@ nsTextEditRules::DidDoAction(nsISelection *aSelection,
switch (info->action)
{
case nsEditor::kOpInsertBreak:
case OperationID::insertBreak:
return DidInsertBreak(aSelection, aResult);
case nsEditor::kOpInsertText:
case nsEditor::kOpInsertIMEText:
case OperationID::insertText:
case OperationID::insertIMEText:
return DidInsertText(aSelection, aResult);
case nsEditor::kOpDeleteSelection:
case OperationID::deleteSelection:
return DidDeleteSelection(aSelection, info->collapsedAction, aResult);
case nsEditor::kOpUndo:
case OperationID::undo:
return DidUndo(aSelection, aResult);
case nsEditor::kOpRedo:
case OperationID::redo:
return DidRedo(aSelection, aResult);
case nsEditor::kOpSetTextProperty:
case OperationID::setTextProperty:
return DidSetTextProperty(aSelection, aResult);
case nsEditor::kOpRemoveTextProperty:
case OperationID::removeTextProperty:
return DidRemoveTextProperty(aSelection, aResult);
case nsEditor::kOpOutputText:
case OperationID::outputText:
return DidOutputText(aSelection, aResult);
default:
// Don't fail on transactions we don't handle here!
@ -540,7 +540,7 @@ nsTextEditRules::HandleNewLines(nsString &aString,
}
nsresult
nsTextEditRules::WillInsertText(nsEditor::OperationID aAction,
nsTextEditRules::WillInsertText(OperationID aAction,
Selection* aSelection,
bool *aCancel,
bool *aHandled,
@ -550,7 +550,7 @@ nsTextEditRules::WillInsertText(nsEditor::OperationID aAction,
{
if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
if (inString->IsEmpty() && aAction != nsEditor::kOpInsertIMEText) {
if (inString->IsEmpty() && aAction != OperationID::insertIMEText) {
// HACK: this is a fix for bug 19395
// I can't outlaw all empty insertions
// because IME transaction depend on them
@ -574,7 +574,7 @@ nsTextEditRules::WillInsertText(nsEditor::OperationID aAction,
// If we're exceeding the maxlength when composing IME, we need to clean up
// the composing text, so we shouldn't return early.
if (truncated && outString->IsEmpty() &&
aAction != nsEditor::kOpInsertIMEText) {
aAction != OperationID::insertIMEText) {
*aCancel = true;
return NS_OK;
}
@ -609,7 +609,7 @@ nsTextEditRules::WillInsertText(nsEditor::OperationID aAction,
// to the replacement character
if (IsPasswordEditor())
{
if (aAction == nsEditor::kOpInsertIMEText) {
if (aAction == OperationID::insertIMEText) {
RemoveIMETextFromPWBuf(start, outString);
}
}
@ -676,11 +676,11 @@ nsTextEditRules::WillInsertText(nsEditor::OperationID aAction,
nsCOMPtr<nsIDOMDocument> doc = mEditor->GetDOMDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
if (aAction == nsEditor::kOpInsertIMEText) {
if (aAction == OperationID::insertIMEText) {
res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);
NS_ENSURE_SUCCESS(res, res);
} else {
// aAction == nsEditor::kOpInsertText; find where we are
// aAction == OperationID::insertText; find where we are
nsCOMPtr<nsIDOMNode> curNode = selNode;
PRInt32 curOffset = selOffset;
@ -1087,7 +1087,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection)
}
// tell rules system to not do any post-processing
nsAutoRules beginRulesSniffing(mEditor, nsEditor::kOpIgnore, nsIEditor::eNone);
nsAutoRules beginRulesSniffing(mEditor, OperationID::ignore, nsIEditor::eNone);
nsCOMPtr<dom::Element> body = mEditor->GetRoot();
if (!body) {

View File

@ -49,9 +49,9 @@ public:
// nsIEditRules methods
NS_IMETHOD Init(nsPlaintextEditor *aEditor);
NS_IMETHOD DetachEditor();
NS_IMETHOD BeforeEdit(nsEditor::OperationID action,
NS_IMETHOD BeforeEdit(OperationID action,
nsIEditor::EDirection aDirection);
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
NS_IMETHOD AfterEdit(OperationID action,
nsIEditor::EDirection aDirection);
NS_IMETHOD WillDoAction(mozilla::Selection* aSelection, nsRulesInfo* aInfo,
bool* aCancel, bool* aHandled);
@ -101,7 +101,7 @@ public:
protected:
// nsTextEditRules implementation methods
nsresult WillInsertText( nsEditor::OperationID aAction,
nsresult WillInsertText( OperationID aAction,
mozilla::Selection* aSelection,
bool *aCancel,
bool *aHandled,
@ -233,7 +233,7 @@ protected:
// characters not visually
// adjacent to the caret without
// moving the caret first.
nsEditor::OperationID mTheAction; // the top level editor action
OperationID mTheAction; // the top level editor action
nsCOMPtr<nsITimer> mTimer;
PRUint32 mLastStart, mLastLength;
@ -248,7 +248,7 @@ class nsTextRulesInfo : public nsRulesInfo
{
public:
nsTextRulesInfo(nsEditor::OperationID aAction) :
nsTextRulesInfo(OperationID aAction) :
nsRulesInfo(aAction),
inString(0),
outString(0),

View File

@ -103,7 +103,7 @@ mozInlineSpellStatus::mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker)
nsresult
mozInlineSpellStatus::InitForEditorChange(
nsEditor::OperationID aAction,
OperationID aAction,
nsIDOMNode* aAnchorNode, PRInt32 aAnchorOffset,
nsIDOMNode* aPreviousNode, PRInt32 aPreviousOffset,
nsIDOMNode* aStartNode, PRInt32 aStartOffset,
@ -120,7 +120,7 @@ mozInlineSpellStatus::InitForEditorChange(
getter_AddRefs(mAnchorRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aAction == nsEditor::kOpDeleteSelection) {
if (aAction == OperationID::deleteSelection) {
// Deletes are easy, the range is just the current anchor. We set the range
// to check to be empty, FinishInitOnEvent will fill in the range to be
// the current word.
@ -153,7 +153,7 @@ mozInlineSpellStatus::InitForEditorChange(
// On insert save this range: DoSpellCheck optimizes things in this range.
// Otherwise, just leave this NULL.
if (aAction == nsEditor::kOpInsertText)
if (aAction == OperationID::insertText)
mCreatedRange = mRange;
// if we were given a range, we need to expand our range to encompass it
@ -731,7 +731,7 @@ mozInlineSpellChecker::SpellCheckAfterEditorChange(
NS_ENSURE_SUCCESS(rv, rv);
mozInlineSpellStatus status(this);
rv = status.InitForEditorChange((nsEditor::OperationID)aAction,
rv = status.InitForEditorChange((OperationID)aAction,
anchorNode, anchorOffset,
aPreviousSelectedNode, aPreviousSelectedOffset,
aStartNode, aStartOffset,

View File

@ -35,7 +35,7 @@ class mozInlineSpellStatus
public:
mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker);
nsresult InitForEditorChange(nsEditor::OperationID aAction,
nsresult InitForEditorChange(OperationID aAction,
nsIDOMNode* aAnchorNode, PRInt32 aAnchorOffset,
nsIDOMNode* aPreviousNode, PRInt32 aPreviousOffset,
nsIDOMNode* aStartNode, PRInt32 aStartOffset,
@ -62,8 +62,8 @@ public:
PRInt32 mWordCount;
// what happened?
enum Operation { eOpChange, // for SpellCheckAfterChange except kOpDeleteSelection
eOpChangeDelete, // for SpellCheckAfterChange kOpDeleteSelection
enum Operation { eOpChange, // for SpellCheckAfterChange except deleteSelection
eOpChangeDelete, // for SpellCheckAfterChange deleteSelection
eOpNavigation, // for HandleNavigationEvent
eOpSelection, // re-check all misspelled words
eOpResume }; // for resuming a previously started check