Bug 1156062 part 4 - Clean up ns*EditRules::WillInsert; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Sat, 23 Apr 2016 18:30:17 +0900
changeset 332501 12b3e9577b3cf35f8a8008af93adaff7dcb7f896
parent 332500 a13c98a579250bce726f25bcbffc37e35bd0379e
child 332502 42af5753ad68b7d06f0a8ba85d5b361f9ce37f6d
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1156062
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1156062 part 4 - Clean up ns*EditRules::WillInsert; r=ehsan
editor/libeditor/nsHTMLEditRules.cpp
editor/libeditor/nsHTMLEditRules.h
editor/libeditor/nsTextEditRules.cpp
editor/libeditor/nsTextEditRules.h
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -655,17 +655,18 @@ nsHTMLEditRules::WillDoAction(Selection*
     case EditAction::makeBasicBlock:
       return WillMakeBasicBlock(aSelection, info->blockType, aCancel, aHandled);
     case EditAction::removeList:
       return WillRemoveList(aSelection, info->bOrdered, aCancel, aHandled);
     case EditAction::makeDefListItem:
       return WillMakeDefListItem(aSelection, info->blockType, info->entireList,
                                  aCancel, aHandled);
     case EditAction::insertElement:
-      return WillInsert(aSelection, aCancel);
+      WillInsert(*aSelection, aCancel);
+      return NS_OK;
     case EditAction::decreaseZIndex:
       return WillRelativeChangeZIndex(aSelection, -1, aCancel, aHandled);
     case EditAction::increaseZIndex:
       return WillRelativeChangeZIndex(aSelection, 1, aCancel, aHandled);
     default:
       return nsTextEditRules::WillDoAction(aSelection, aInfo,
                                            aCancel, aHandled);
   }
@@ -1201,81 +1202,71 @@ nsHTMLEditRules::GetFormatString(nsIDOMN
 
   return NS_OK;
 }
 
 /********************************************************
  *  Protected rules methods
  ********************************************************/
 
-nsresult
-nsHTMLEditRules::WillInsert(Selection* aSelection, bool* aCancel)
-{
-  nsresult res = nsTextEditRules::WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
-
-  // Adjust selection to prevent insertion after a moz-BR.
-  // this next only works for collapsed selections right now,
-  // because selection is a pain to work with when not collapsed.
-  // (no good way to extend start or end of selection), so we ignore
-  // those types of selections.
-  if (!aSelection->Collapsed()) {
-    return NS_OK;
-  }
-
-  // if we are after a mozBR in the same block, then move selection
-  // to be before it
-  nsCOMPtr<nsIDOMNode> selNode, priorNode;
-  int32_t selOffset;
-  // get the (collapsed) selection location
-  NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode),
-                                           &selOffset);
-  NS_ENSURE_SUCCESS(res, res);
-  // get prior node
-  NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->GetPriorHTMLNode(selNode, selOffset,
-                                      address_of(priorNode));
-  if (NS_SUCCEEDED(res) && priorNode && nsTextEditUtils::IsMozBR(priorNode))
-  {
-    nsCOMPtr<nsIDOMNode> block1, block2;
-    if (IsBlockNode(selNode)) {
-      block1 = selNode;
-    }
-    else {
-      NS_ENSURE_STATE(mHTMLEditor);
-      block1 = mHTMLEditor->GetBlockNodeParent(selNode);
-    }
-    NS_ENSURE_STATE(mHTMLEditor);
-    block2 = mHTMLEditor->GetBlockNodeParent(priorNode);
+void
+nsHTMLEditRules::WillInsert(Selection& aSelection, bool* aCancel)
+{
+  MOZ_ASSERT(aCancel);
+
+  nsTextEditRules::WillInsert(aSelection, aCancel);
+
+  NS_ENSURE_TRUE_VOID(mHTMLEditor);
+  nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
+
+  // Adjust selection to prevent insertion after a moz-BR.  This next only
+  // works for collapsed selections right now, because selection is a pain to
+  // work with when not collapsed.  (no good way to extend start or end of
+  // selection), so we ignore those types of selections.
+  if (!aSelection.Collapsed()) {
+    return;
+  }
+
+  // If we are after a mozBR in the same block, then move selection to be
+  // before it
+  NS_ENSURE_TRUE_VOID(aSelection.GetRangeAt(0) &&
+                      aSelection.GetRangeAt(0)->GetStartParent());
+  OwningNonNull<nsINode> selNode = *aSelection.GetRangeAt(0)->GetStartParent();
+  int32_t selOffset = aSelection.GetRangeAt(0)->StartOffset();
+
+  // Get prior node
+  nsCOMPtr<nsIContent> priorNode = mHTMLEditor->GetPriorHTMLNode(selNode,
+                                                                 selOffset);
+  if (priorNode && nsTextEditUtils::IsMozBR(priorNode)) {
+    nsCOMPtr<Element> block1 = mHTMLEditor->GetBlock(selNode);
+    nsCOMPtr<Element> block2 = mHTMLEditor->GetBlockNodeParent(priorNode);
 
     if (block1 && block1 == block2) {
-      // if we are here then the selection is right after a mozBR
-      // that is in the same block as the selection.  We need to move
-      // the selection start to be before the mozBR.
-      selNode = nsEditor::GetNodeLocation(priorNode, &selOffset);
-      res = aSelection->Collapse(selNode,selOffset);
-      NS_ENSURE_SUCCESS(res, res);
+      // If we are here then the selection is right after a mozBR that is in
+      // the same block as the selection.  We need to move the selection start
+      // to be before the mozBR.
+      selNode = priorNode->GetParentNode();
+      selOffset = selNode->IndexOf(priorNode);
+      nsresult res = aSelection.Collapse(selNode, selOffset);
+      NS_ENSURE_SUCCESS_VOID(res);
     }
   }
 
   if (mDidDeleteSelection &&
       (mTheAction == EditAction::insertText ||
        mTheAction == EditAction::insertIMEText ||
        mTheAction == EditAction::deleteSelection)) {
-    res = ReapplyCachedStyles();
-    NS_ENSURE_SUCCESS(res, res);
+    nsresult res = ReapplyCachedStyles();
+    NS_ENSURE_SUCCESS_VOID(res);
   }
   // For most actions we want to clear the cached styles, but there are
   // exceptions
   if (!IsStyleCachePreservingAction(mTheAction)) {
     ClearCachedStyles();
   }
-
-  return NS_OK;
 }
 
 nsresult
 nsHTMLEditRules::WillInsertText(EditAction aAction,
                                 Selection*       aSelection,
                                 bool            *aCancel,
                                 bool            *aHandled,
                                 const nsAString *inString,
@@ -1302,18 +1293,17 @@ nsHTMLEditRules::WillInsertText(EditActi
   // If the selection isn't collapsed, delete it.  Don't delete existing inline
   // tags, because we're hopefully going to insert text (bug 787432).
   if (!aSelection->Collapsed()) {
     NS_ENSURE_STATE(mHTMLEditor);
     res = mHTMLEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eNoStrip);
     NS_ENSURE_SUCCESS(res, res);
   }
 
-  res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
 
   // we need to get the doc
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIDocument> doc = mHTMLEditor->GetDocument();
   nsCOMPtr<nsIDOMDocument> domDoc = mHTMLEditor->GetDOMDocument();
@@ -1538,18 +1528,17 @@ nsHTMLEditRules::WillInsertBreak(Selecti
   // if the selection isn't collapsed, delete it.
   nsresult res = NS_OK;
   if (!aSelection->Collapsed()) {
     NS_ENSURE_STATE(mHTMLEditor);
     res = mHTMLEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
     NS_ENSURE_SUCCESS(res, res);
   }
 
-  res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
 
   // split any mailcites in the way.
   // should we abort this if we encounter table cell boundaries?
   if (IsMailEditor()) {
@@ -3058,18 +3047,17 @@ nsHTMLEditRules::WillMakeList(Selection*
                               bool* aHandled,
                               const nsAString* aItemType)
 {
   if (!aSelection || !aListType || !aCancel || !aHandled) {
     return NS_ERROR_NULL_POINTER;
   }
   OwningNonNull<nsIAtom> listType = NS_Atomize(*aListType);
 
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = false;
 
   // deduce what tag to use for list items
   nsCOMPtr<nsIAtom> itemType;
@@ -3084,17 +3072,17 @@ nsHTMLEditRules::WillMakeList(Selection*
 
   // convert the selection ranges into "promoted" selection ranges:
   // 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
 
   *aHandled = true;
 
-  res = NormalizeSelection(aSelection);
+  nsresult res = NormalizeSelection(aSelection);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
   res = GetListActionNodes(arrayOfNodes,
                            aEntireList ? EntireList::yes : EntireList::no);
   NS_ENSURE_SUCCESS(res, res);
@@ -3438,22 +3426,21 @@ nsHTMLEditRules::WillMakeBasicBlock(Sele
                                     bool *aHandled)
 {
   OwningNonNull<nsIAtom> blockType = NS_Atomize(*aBlockType);
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
   // initialize out param
   *aCancel = false;
   *aHandled = false;
 
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
-  res = NormalizeSelection(aSelection);
+  nsresult res = NormalizeSelection(aSelection);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor);
   *aHandled = true;
   nsString tString(*aBlockType);
 
@@ -3617,25 +3604,24 @@ nsHTMLEditRules::WillIndent(Selection* a
 }
 
 nsresult
 nsHTMLEditRules::WillCSSIndent(Selection* aSelection,
                                bool* aCancel, bool* aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
-  res = NormalizeSelection(aSelection);
+  nsresult res = NormalizeSelection(aSelection);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
   nsTArray<OwningNonNull<nsRange>> arrayOfRanges;
   nsTArray<OwningNonNull<nsINode>> arrayOfNodes;
 
   // short circuit: detect case of collapsed selection inside an <li>.
   // just sublist that <li>.  This prevents bug 97797.
@@ -3821,25 +3807,24 @@ nsHTMLEditRules::WillCSSIndent(Selection
   return res;
 }
 
 nsresult
 nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
                                 bool* aCancel, bool* aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
-  res = NormalizeSelection(aSelection);
+  nsresult res = NormalizeSelection(aSelection);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
   // convert the selection ranges into "promoted" selection ranges:
   // 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
@@ -4658,25 +4643,24 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode
 nsresult
 nsHTMLEditRules::WillAlign(Selection* aSelection,
                            const nsAString *alignType,
                            bool *aCancel,
                            bool *aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = false;
 
-  res = NormalizeSelection(aSelection);
+  nsresult res = NormalizeSelection(aSelection);
   NS_ENSURE_SUCCESS(res, res);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
   // convert the selection ranges into "promoted" selection ranges:
   // 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
   *aHandled = true;
@@ -8814,27 +8798,27 @@ nsHTMLEditRules::RelativeChangeIndentati
 // Support for Absolute Positioning
 //
 
 nsresult
 nsHTMLEditRules::WillAbsolutePosition(Selection* aSelection,
                                       bool* aCancel, bool* aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement> focusElement;
   NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->GetSelectionContainer(getter_AddRefs(focusElement));
+  nsresult res =
+    mHTMLEditor->GetSelectionContainer(getter_AddRefs(focusElement));
   if (focusElement) {
     nsCOMPtr<nsIDOMNode> node = do_QueryInterface(focusElement);
     if (nsHTMLEditUtils::IsImage(node)) {
       mNewBlock = node;
       return NS_OK;
     }
   }
 
@@ -9043,27 +9027,27 @@ nsHTMLEditRules::DidAbsolutePosition()
   nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(mNewBlock);
   return absPosHTMLEditor->AbsolutelyPositionElement(elt, true);
 }
 
 nsresult
 nsHTMLEditRules::WillRemoveAbsolutePosition(Selection* aSelection,
                                             bool* aCancel, bool* aHandled) {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore aCancel from WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement>  elt;
   NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
+  nsresult res =
+    mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
   NS_ENSURE_SUCCESS(res, res);
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIHTMLAbsPosEditor> absPosHTMLEditor = mHTMLEditor;
   return absPosHTMLEditor->AbsolutelyPositionElement(elt, false);
@@ -9071,27 +9055,27 @@ nsHTMLEditRules::WillRemoveAbsolutePosit
 
 nsresult
 nsHTMLEditRules::WillRelativeChangeZIndex(Selection* aSelection,
                                           int32_t aChange,
                                           bool *aCancel,
                                           bool * aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  nsresult res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
 
   // initialize out param
   // we want to ignore aCancel from WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement>  elt;
   NS_ENSURE_STATE(mHTMLEditor);
-  res = mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
+  nsresult res =
+    mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
   NS_ENSURE_SUCCESS(res, res);
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor);
 
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsIHTMLAbsPosEditor> absPosHTMLEditor = mHTMLEditor;
   int32_t zIndex;
--- a/editor/libeditor/nsHTMLEditRules.h
+++ b/editor/libeditor/nsHTMLEditRules.h
@@ -121,17 +121,17 @@ protected:
   {
     kBeforeBlock,
     kBlockEnd
   };
 
   void InitFields();
 
   // nsHTMLEditRules implementation methods
-  nsresult WillInsert(mozilla::dom::Selection* aSelection, bool* aCancel);
+  void WillInsert(mozilla::dom::Selection& aSelection, bool* aCancel);
   nsresult WillInsertText(  EditAction aAction,
                             mozilla::dom::Selection* aSelection,
                             bool            *aCancel,
                             bool            *aHandled,
                             const nsAString *inString,
                             nsAString       *outString,
                             int32_t          aMaxLength);
   nsresult WillLoadHTML(mozilla::dom::Selection* aSelection, bool* aCancel);
--- a/editor/libeditor/nsTextEditRules.cpp
+++ b/editor/libeditor/nsTextEditRules.cpp
@@ -280,17 +280,18 @@ nsTextEditRules::WillDoAction(Selection*
     case EditAction::removeTextProperty:
       return WillRemoveTextProperty(aSelection, aCancel, aHandled);
     case EditAction::outputText:
       return WillOutputText(aSelection, info->outputFormat, info->outString,
                             aCancel, aHandled);
     case EditAction::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);
+      WillInsert(*aSelection, aCancel);
+      return NS_OK;
     default:
       return NS_ERROR_FAILURE;
   }
 }
 
 NS_IMETHODIMP
 nsTextEditRules::DidDoAction(Selection* aSelection,
                              nsRulesInfo *aInfo, nsresult aResult)
@@ -340,35 +341,35 @@ nsTextEditRules::DocumentIsEmpty(bool *a
   return NS_OK;
 }
 
 /********************************************************
  *  Protected methods
  ********************************************************/
 
 
-nsresult
-nsTextEditRules::WillInsert(Selection* aSelection, bool* aCancel)
+void
+nsTextEditRules::WillInsert(Selection& aSelection, bool* aCancel)
 {
-  NS_ENSURE_TRUE(aSelection && aCancel, NS_ERROR_NULL_POINTER);
+  MOZ_ASSERT(aCancel);
 
-  CANCEL_OPERATION_IF_READONLY_OR_DISABLED
+  if (IsReadonly() || IsDisabled()) {
+    *aCancel = true;
+    return;
+  }
 
   // initialize out param
   *aCancel = false;
 
   // check for the magic content node and delete it if it exists
-  if (mBogusNode)
-  {
-    NS_ENSURE_STATE(mEditor);
+  if (mBogusNode) {
+    NS_ENSURE_TRUE_VOID(mEditor);
     mEditor->DeleteNode(mBogusNode);
     mBogusNode = nullptr;
   }
-
-  return NS_OK;
 }
 
 nsresult
 nsTextEditRules::DidInsert(Selection* aSelection, nsresult aResult)
 {
   return NS_OK;
 }
 
@@ -407,18 +408,17 @@ nsTextEditRules::WillInsertBreak(Selecti
     NS_ENSURE_SUCCESS(res, res);
     if (!bCollapsed)
     {
       NS_ENSURE_STATE(mEditor);
       res = mEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
       NS_ENSURE_SUCCESS(res, res);
     }
 
-    res = WillInsert(aSelection, aCancel);
-    NS_ENSURE_SUCCESS(res, res);
+    WillInsert(*aSelection, aCancel);
     // initialize out param
     // we want to ignore result of WillInsert()
     *aCancel = false;
 
   }
   return NS_OK;
 }
 
@@ -646,18 +646,17 @@ nsTextEditRules::WillInsertText(EditActi
   NS_ENSURE_SUCCESS(res, res);
   if (!bCollapsed)
   {
     NS_ENSURE_STATE(mEditor);
     res = mEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
     NS_ENSURE_SUCCESS(res, res);
   }
 
-  res = WillInsert(aSelection, aCancel);
-  NS_ENSURE_SUCCESS(res, res);
+  WillInsert(*aSelection, aCancel);
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
 
   // handle password field data
   // this has the side effect of changing all the characters in aOutString
   // to the replacement character
   if (IsPasswordEditor())
--- a/editor/libeditor/nsTextEditRules.h
+++ b/editor/libeditor/nsTextEditRules.h
@@ -118,17 +118,17 @@ protected:
                          nsresult aResult);
   nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode);
 
   nsresult WillInsertBreak(mozilla::dom::Selection* aSelection, bool* aCancel,
                            bool *aHandled, int32_t aMaxLength);
   nsresult DidInsertBreak(mozilla::dom::Selection* aSelection,
                           nsresult aResult);
 
-  nsresult WillInsert(mozilla::dom::Selection* aSelection, bool* aCancel);
+  void WillInsert(mozilla::dom::Selection& aSelection, bool* aCancel);
   nsresult DidInsert(mozilla::dom::Selection* aSelection, nsresult aResult);
 
   nsresult WillDeleteSelection(mozilla::dom::Selection* aSelection,
                                nsIEditor::EDirection aCollapsedAction,
                                bool *aCancel,
                                bool *aHandled);
   nsresult DidDeleteSelection(mozilla::dom::Selection* aSelection,
                               nsIEditor::EDirection aCollapsedAction,