Bug 461816 - pressing Ctrl-U in password dialog asserts and then crashes; r+sr=peterv
authorTheppitak KaroonboonyananTheppitak Karoonboonyanan <thep@linux.thai.net>
Thu, 04 Dec 2008 14:17:48 +0100
changeset 22315 f7e30552f3a7
parent 22314 9396e1f577ad
child 22316 cfc553938038
push id3905
push usersgautherie.bz@free.fr
push date2008-12-04 13:18 +0000
treeherdermozilla-central@f7e30552f3a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs461816
milestone1.9.2a1pre
Bug 461816 - pressing Ctrl-U in password dialog asserts and then crashes; r+sr=peterv
editor/libeditor/text/nsTextEditRules.cpp
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -883,16 +883,19 @@ nsTextEditRules::WillDeleteSelection(nsI
     *aCancel = PR_TRUE;
     return NS_OK;
   }
 
   nsresult res = NS_OK;
 
   if (mFlags & nsIPlaintextEditor::eEditorPasswordMask)
   {
+    res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
+    NS_ENSURE_SUCCESS(res, res);
+
     // manage the password buffer
     PRUint32 start, end;
     mEditor->GetTextSelectionOffsets(aSelection, start, end);
     NS_ENSURE_SUCCESS(res, res);
     if (end == start)
     { // collapsed selection
       if (nsIEditor::ePrevious==aCollapsedAction && 0<start) { // del back
         mPasswordText.Cut(start-1, 1);
@@ -913,35 +916,32 @@ nsTextEditRules::WillDeleteSelection(nsI
     res = mEditor->GetStartNodeAndOffset(aSelection, address_of(startNode), &startOffset);
     if (NS_FAILED(res)) return res;
     if (!startNode) return NS_ERROR_FAILURE;
     
     PRBool bCollapsed;
     res = aSelection->GetIsCollapsed(&bCollapsed);
     if (NS_FAILED(res)) return res;
   
-    if (bCollapsed)
-    {
-      // Test for distance between caret and text that will be deleted
-      res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aCollapsedAction, aCancel);
-      if (NS_FAILED(res)) return res;
-      if (*aCancel) return NS_OK;
+    if (!bCollapsed) return NS_OK;
 
-      res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
-      NS_ENSURE_SUCCESS(res, res);
+    // Test for distance between caret and text that will be deleted
+    res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aCollapsedAction, aCancel);
+    if (NS_FAILED(res)) return res;
+    if (*aCancel) return NS_OK;
 
-      res = mEditor->DeleteSelectionImpl(aCollapsedAction);
-      NS_ENSURE_SUCCESS(res, res);
-
-      *aHandled = PR_TRUE;
-      return NS_OK;
-    }
+    res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
+    NS_ENSURE_SUCCESS(res, res);
   }
 
-  return res;
+  res = mEditor->DeleteSelectionImpl(aCollapsedAction);
+  NS_ENSURE_SUCCESS(res, res);
+
+  *aHandled = PR_TRUE;
+  return NS_OK;
 }
 
 nsresult
 nsTextEditRules::DidDeleteSelection(nsISelection *aSelection, 
                                     nsIEditor::EDirection aCollapsedAction, 
                                     nsresult aResult)
 {
   nsCOMPtr<nsIDOMNode> startNode;