From aeafc6d1a7cc4bb179698e4e5bd8040ea1d0d9db Mon Sep 17 00:00:00 2001 From: Theppitak KaroonboonyananTheppitak Karoonboonyanan Date: Thu, 4 Dec 2008 14:17:48 +0100 Subject: [PATCH] Bug 461816 - pressing Ctrl-U in password dialog asserts and then crashes; r+sr=peterv --- editor/libeditor/text/nsTextEditRules.cpp | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp index 365f887e309a..ea5c3bc4cef6 100644 --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -888,6 +888,9 @@ nsTextEditRules::WillDeleteSelection(nsISelection *aSelection, 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); @@ -918,25 +921,22 @@ nsTextEditRules::WillDeleteSelection(nsISelection *aSelection, 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