Commit ff64eb0d authored by Aryeh Gregor's avatar Aryeh Gregor
Browse files

Bug 751547 - Unify action enums in editor/; r=ehsan

parent 2eab8f88
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -54,10 +54,10 @@ class nsRulesInfo
{
  public:
  
  nsRulesInfo(int aAction) : action(aAction) {}
  nsRulesInfo(nsEditor::OperationID aAction) : action(aAction) {}
  virtual ~nsRulesInfo() {}
  
  int action;
  nsEditor::OperationID action;
};

/***************************************************************************
@@ -74,8 +74,10 @@ public:

  NS_IMETHOD Init(nsPlaintextEditor *aEditor)=0;
  NS_IMETHOD DetachEditor()=0;
  NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0;
  NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0;
  NS_IMETHOD BeforeEdit(nsEditor::OperationID action,
                        nsIEditor::EDirection aDirection) = 0;
  NS_IMETHOD AfterEdit(nsEditor::OperationID action,
                       nsIEditor::EDirection aDirection) = 0;
  NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, bool *aCancel, bool *aHandled)=0;
  NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0;
  NS_IMETHOD DocumentIsEmpty(bool *aDocumentIsEmpty)=0;
+4 −4
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ nsEditor::nsEditor()
,  mFlags(0)
,  mUpdateCount(0)
,  mPlaceHolderBatch(0)
,  mAction(nsnull)
,  mAction(kOpNone)
,  mHandlingActionCount(0)
,  mIMETextOffset(0)
,  mIMEBufferLength(0)
@@ -2157,7 +2157,7 @@ nsEditor::GetRootElement(nsIDOMElement **aRootElement)
/** All editor operations which alter the doc should be prefaced
 *  with a call to StartOperation, naming the action and direction */
NS_IMETHODIMP
nsEditor::StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection)
nsEditor::StartOperation(OperationID opID, nsIEditor::EDirection aDirection)
{
  mAction = opID;
  mDirection = aDirection;
@@ -2170,7 +2170,7 @@ nsEditor::StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection)
NS_IMETHODIMP
nsEditor::EndOperation()
{
  mAction = nsnull;
  mAction = kOpNone;
  mDirection = eNone;
  return NS_OK;
}
@@ -5129,7 +5129,7 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
}

nsresult
nsEditor::HandleInlineSpellCheck(PRInt32 action,
nsEditor::HandleInlineSpellCheck(OperationID action,
                                   nsISelection *aSelection,
                                   nsIDOMNode *previousSelectedNode,
                                   PRInt32 previousSelectedOffset,
+31 −8
Original line number Diff line number Diff line
@@ -129,12 +129,34 @@ public:
    kOpDeleteNode,
    kOpSplitNode,
    kOpJoinNode,
    kOpDeleteSelection,
    kOpDeleteText = 1003,

    // text commands
    kOpInsertBreak    = 1000,
    kOpInsertText     = 1001,
    kOpInsertIMEText  = 1002,
    kOpDeleteText     = 1003
    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
@@ -384,7 +406,8 @@ public:

  /** All editor operations which alter the doc should be prefaced
   *  with a call to StartOperation, naming the action and direction */
  NS_IMETHOD StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection);
  NS_IMETHOD StartOperation(OperationID opID,
                            nsIEditor::EDirection aDirection);

  /** All editor operations which alter the doc should be followed
   *  with a call to EndOperation */
@@ -635,7 +658,7 @@ public:

  virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent);

  nsresult HandleInlineSpellCheck(PRInt32 action,
  nsresult HandleInlineSpellCheck(OperationID action,
                                    nsISelection *aSelection,
                                    nsIDOMNode *previousSelectedNode,
                                    PRInt32 previousSelectedOffset,
@@ -846,7 +869,7 @@ protected:
  PRInt32           mUpdateCount;

  PRInt32           mPlaceHolderBatch;   // nesting count for batching
  PRInt32           mAction;             // the current editor action
  OperationID       mAction;             // the current editor action
  PRUint32          mHandlingActionCount;

  PRUint32          mIMETextOffset;    // offset in text node where IME comp string begins
+2 −1
Original line number Diff line number Diff line
@@ -106,7 +106,8 @@ class NS_STACK_CLASS nsAutoRules
{
  public:
  
  nsAutoRules(nsEditor *ed, PRInt32 action, nsIEditor::EDirection aDirection) : 
  nsAutoRules(nsEditor *ed, nsEditor::OperationID action,
              nsIEditor::EDirection aDirection) :
         mEd(ed), mDoNothing(false)
  { 
    if (mEd && !mEd->mAction) // mAction will already be set if this is nested call
+4 −5
Original line number Diff line number Diff line
@@ -84,9 +84,8 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
  NS_ENSURE_SUCCESS(res, res);
  NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);

  nsTextRulesInfo ruleInfo(aEnabled ?
                           nsTextEditRules::kSetAbsolutePosition :
                           nsTextEditRules::kRemoveAbsolutePosition);
  nsTextRulesInfo ruleInfo(aEnabled ? kOpSetAbsolutePosition :
                                      kOpRemoveAbsolutePosition);
  bool cancel, handled;
  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
  if (NS_FAILED(res) || cancel)
@@ -199,8 +198,8 @@ nsHTMLEditor::RelativeChangeZIndex(PRInt32 aChange)
  nsresult res = GetSelection(getter_AddRefs(selection));
  NS_ENSURE_SUCCESS(res, res);
  NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
  nsTextRulesInfo ruleInfo((aChange < 0) ? nsTextEditRules::kDecreaseZIndex:
                                           nsTextEditRules::kIncreaseZIndex);
  nsTextRulesInfo ruleInfo(aChange < 0 ? kOpDecreaseZIndex :
                                         kOpIncreaseZIndex);
  bool cancel, handled;
  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
  if (cancel || NS_FAILED(res))
Loading