Bug 1156062 - Back out for now, requested by Masayuki at bug 1191356 comment 23
authorAryeh Gregor <ayg@aryeh.name>
Wed, 20 Apr 2016 20:45:21 +0300
changeset 294154 aa95332a325b11d8a0466289fe5c89faa018ed06
parent 294153 a5967250fc9645b575f00f4527e98522109fbed6
child 294155 22d56f931cb6f762f97557927d56c0bd11968cfa
push id18864
push userkwierso@gmail.com
push dateThu, 21 Apr 2016 22:03:23 +0000
treeherderfx-team@467bd00c72db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1156062, 1191356
milestone48.0a1
Bug 1156062 - Back out for now, requested by Masayuki at bug 1191356 comment 23
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,18 +655,17 @@ 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:
-      WillInsert(*aSelection, aCancel);
-      return NS_OK;
+      return WillInsert(aSelection, aCancel);
     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);
   }
@@ -1202,71 +1201,81 @@ nsHTMLEditRules::GetFormatString(nsIDOMN
 
   return NS_OK;
 }
 
 /********************************************************
  *  Protected rules methods
  ********************************************************/
 
-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);
+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);
 
     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 = priorNode->GetParentNode();
-      selOffset = selNode->IndexOf(priorNode);
-      nsresult res = aSelection.Collapse(selNode, selOffset);
-      NS_ENSURE_SUCCESS_VOID(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 = nsEditor::GetNodeLocation(priorNode, &selOffset);
+      res = aSelection->Collapse(selNode,selOffset);
+      NS_ENSURE_SUCCESS(res, res);
     }
   }
 
   if (mDidDeleteSelection &&
       (mTheAction == EditAction::insertText ||
        mTheAction == EditAction::insertIMEText ||
        mTheAction == EditAction::deleteSelection)) {
-    nsresult res = ReapplyCachedStyles();
-    NS_ENSURE_SUCCESS_VOID(res);
+    res = ReapplyCachedStyles();
+    NS_ENSURE_SUCCESS(res, 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,
@@ -1293,17 +1302,18 @@ 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);
   }
 
-  WillInsert(*aSelection, aCancel);
+  res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
   // 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();
@@ -1528,17 +1538,18 @@ 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);
   }
 
-  WillInsert(*aSelection, aCancel);
+  res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // 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()) {
@@ -3010,17 +3021,18 @@ nsHTMLEditRules::WillMakeList(Selection*
                               bool* aHandled,
                               const nsAString* aItemType)
 {
   if (!aSelection || !aListType || !aCancel || !aHandled) {
     return NS_ERROR_NULL_POINTER;
   }
   OwningNonNull<nsIAtom> listType = NS_Atomize(*aListType);
 
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // 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;
@@ -3035,17 +3047,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;
 
-  nsresult res = NormalizeSelection(aSelection);
+  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);
@@ -3389,21 +3401,22 @@ 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;
 
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
-  nsresult res = NormalizeSelection(aSelection);
+  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);
 
@@ -3567,24 +3580,25 @@ nsHTMLEditRules::WillIndent(Selection* a
 }
 
 nsresult
 nsHTMLEditRules::WillCSSIndent(Selection* aSelection,
                                bool* aCancel, bool* aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
-  nsresult res = NormalizeSelection(aSelection);
+  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.
@@ -3770,24 +3784,25 @@ nsHTMLEditRules::WillCSSIndent(Selection
   return res;
 }
 
 nsresult
 nsHTMLEditRules::WillHTMLIndent(Selection* aSelection,
                                 bool* aCancel, bool* aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
-  nsresult res = NormalizeSelection(aSelection);
+  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
@@ -4606,24 +4621,25 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode
 nsresult
 nsHTMLEditRules::WillAlign(Selection* aSelection,
                            const nsAString *alignType,
                            bool *aCancel,
                            bool *aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
 
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = false;
 
-  nsresult res = NormalizeSelection(aSelection);
+  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;
@@ -8761,27 +8777,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; }
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement> focusElement;
   NS_ENSURE_STATE(mHTMLEditor);
-  nsresult res =
-    mHTMLEditor->GetSelectionContainer(getter_AddRefs(focusElement));
+  res = mHTMLEditor->GetSelectionContainer(getter_AddRefs(focusElement));
   if (focusElement) {
     nsCOMPtr<nsIDOMNode> node = do_QueryInterface(focusElement);
     if (nsHTMLEditUtils::IsImage(node)) {
       mNewBlock = node;
       return NS_OK;
     }
   }
 
@@ -8990,27 +9006,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; }
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore aCancel from WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement>  elt;
   NS_ENSURE_STATE(mHTMLEditor);
-  nsresult res =
-    mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
+  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);
@@ -9018,27 +9034,27 @@ nsHTMLEditRules::WillRemoveAbsolutePosit
 
 nsresult
 nsHTMLEditRules::WillRelativeChangeZIndex(Selection* aSelection,
                                           int32_t aChange,
                                           bool *aCancel,
                                           bool * aHandled)
 {
   if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; }
-  WillInsert(*aSelection, aCancel);
+  nsresult res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
 
   // initialize out param
   // we want to ignore aCancel from WillInsert()
   *aCancel = false;
   *aHandled = true;
 
   nsCOMPtr<nsIDOMElement>  elt;
   NS_ENSURE_STATE(mHTMLEditor);
-  nsresult res =
-    mHTMLEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
+  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
@@ -120,17 +120,17 @@ protected:
   {
     kBeforeBlock,
     kBlockEnd
   };
 
   void InitFields();
 
   // nsHTMLEditRules implementation methods
-  void WillInsert(mozilla::dom::Selection& aSelection, bool* aCancel);
+  nsresult 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,18 +280,17 @@ 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!
-      WillInsert(*aSelection, aCancel);
-      return NS_OK;
+      return WillInsert(aSelection, aCancel);
     default:
       return NS_ERROR_FAILURE;
   }
 }
 
 NS_IMETHODIMP
 nsTextEditRules::DidDoAction(Selection* aSelection,
                              nsRulesInfo *aInfo, nsresult aResult)
@@ -341,35 +340,35 @@ nsTextEditRules::DocumentIsEmpty(bool *a
   return NS_OK;
 }
 
 /********************************************************
  *  Protected methods
  ********************************************************/
 
 
-void
-nsTextEditRules::WillInsert(Selection& aSelection, bool* aCancel)
+nsresult
+nsTextEditRules::WillInsert(Selection* aSelection, bool* aCancel)
 {
-  MOZ_ASSERT(aCancel);
+  NS_ENSURE_TRUE(aSelection && aCancel, NS_ERROR_NULL_POINTER);
 
-  if (IsReadonly() || IsDisabled()) {
-    *aCancel = true;
-    return;
-  }
+  CANCEL_OPERATION_IF_READONLY_OR_DISABLED
 
   // initialize out param
   *aCancel = false;
 
   // check for the magic content node and delete it if it exists
-  if (mBogusNode) {
-    NS_ENSURE_TRUE_VOID(mEditor);
+  if (mBogusNode)
+  {
+    NS_ENSURE_STATE(mEditor);
     mEditor->DeleteNode(mBogusNode);
     mBogusNode = nullptr;
   }
+
+  return NS_OK;
 }
 
 nsresult
 nsTextEditRules::DidInsert(Selection* aSelection, nsresult aResult)
 {
   return NS_OK;
 }
 
@@ -408,17 +407,18 @@ 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);
     }
 
-    WillInsert(*aSelection, aCancel);
+    res = WillInsert(aSelection, aCancel);
+    NS_ENSURE_SUCCESS(res, res);
     // initialize out param
     // we want to ignore result of WillInsert()
     *aCancel = false;
 
   }
   return NS_OK;
 }
 
@@ -646,17 +646,18 @@ 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);
   }
 
-  WillInsert(*aSelection, aCancel);
+  res = WillInsert(aSelection, aCancel);
+  NS_ENSURE_SUCCESS(res, res);
   // 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);
 
-  void WillInsert(mozilla::dom::Selection& aSelection, bool* aCancel);
+  nsresult 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,