diff --git a/content/base/public/nsISelectionController.idl b/content/base/public/nsISelectionController.idl index b28f4cdd0a6..0144db0e2af 100644 --- a/content/base/public/nsISelectionController.idl +++ b/content/base/public/nsISelectionController.idl @@ -51,7 +51,7 @@ interface nsIDOMNode; interface nsISelection; interface nsISelectionDisplay; -[scriptable, uuid(39429306-4c81-4d8b-9421-eb7d9f43bfd0)] +[scriptable, uuid(80d2e85a-4ad2-45be-88e7-8c1fe943ac4d)] interface nsISelectionController : nsISelectionDisplay { const short SELECTION_NONE=0; @@ -154,6 +154,12 @@ interface nsISelectionController : nsISelectionDisplay */ void characterMove(in boolean forward, in boolean extend); + /** CharacterExtendForDelete will extend the selection one character cell + * forward in the document. + * this method is used internally for handling del key. + */ + [noscript] void characterExtendForDelete(); + /** WordMove will move the selection one word forward/backward in the document. * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE * the "point" of selection that is extended is considered the "focus" point. diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index c0c5ef81be0..05e56d81a04 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -662,6 +662,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction) if (NS_FAILED(result)) return result; if (!bCollapsed && (aAction == eNextWord || aAction == ePreviousWord || + aAction == eNext || aAction == eToBeginningOfLine || aAction == eToEndOfLine)) if (mCaretStyle == 1) { @@ -678,6 +679,7 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction) // This needs to happen inside selection batching, // otherwise the deleted text is autocopied to the clipboard. if (aAction == eNextWord || aAction == ePreviousWord + || aAction == eNext || aAction == eToBeginningOfLine || aAction == eToEndOfLine) { nsCOMPtr selCont (do_QueryReferent(mSelConWeak)); @@ -696,6 +698,10 @@ NS_IMETHODIMP nsPlaintextEditor::DeleteSelection(nsIEditor::EDirection aAction) result = selCont->WordExtendForDelete(PR_FALSE); aAction = eNone; break; + case eNext: + result = selCont->CharacterExtendForDelete(); + aAction = eNone; + break; case eToBeginningOfLine: selCont->IntraLineMove(PR_TRUE, PR_FALSE); // try to move to end result = selCont->IntraLineMove(PR_FALSE, PR_TRUE); // select to beginning diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 1dbd9341931..765982a99d4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -927,6 +927,7 @@ public: // nsISelectionController NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend); + NS_IMETHOD CharacterExtendForDelete(); NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend); NS_IMETHOD WordExtendForDelete(PRBool aForward); NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend); @@ -2716,6 +2717,12 @@ PresShell::CharacterMove(PRBool aForward, PRBool aExtend) return mSelection->CharacterMove(aForward, aExtend); } +NS_IMETHODIMP +PresShell::CharacterExtendForDelete() +{ + return mSelection->CharacterExtendForDelete(); +} + NS_IMETHODIMP PresShell::WordMove(PRBool aForward, PRBool aExtend) { diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 5c0fb4ea5e4..0820e1da0fe 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -581,6 +581,7 @@ public: NS_IMETHOD GetCaretEnabled(PRBool *_retval); NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend); + NS_IMETHOD CharacterExtendForDelete(); NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend); NS_IMETHOD WordExtendForDelete(PRBool aForward); NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend); @@ -794,6 +795,13 @@ nsTextInputSelectionImpl::CharacterMove(PRBool aForward, PRBool aExtend) return NS_ERROR_NULL_POINTER; } +NS_IMETHODIMP +nsTextInputSelectionImpl::CharacterExtendForDelete() +{ + if (mFrameSelection) + return mFrameSelection->CharacterExtendForDelete(); + return NS_ERROR_NULL_POINTER; +} NS_IMETHODIMP nsTextInputSelectionImpl::WordMove(PRBool aForward, PRBool aExtend) diff --git a/layout/generic/nsFrameSelection.h b/layout/generic/nsFrameSelection.h index 394cfe87203..34972916772 100644 --- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -409,6 +409,12 @@ public: /*unsafe*/ nsresult CharacterMove(PRBool aForward, PRBool aExtend); + /** CharacterExtendForDelete extends the selection forward (logically) to + * the next character cell, so that the selected cell can be deleted. + */ + /*unsafe*/ + nsresult CharacterExtendForDelete(); + /** WordMove will generally be called from the nsiselectioncontroller implementations. * the effect being the selection will move one word left or right. * @param aForward move forward in document. diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index ac3f5865b15..bbf80d5e77a 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -2772,6 +2772,12 @@ nsFrameSelection::CharacterMove(PRBool aForward, PRBool aExtend) return MoveCaret(nsIDOMKeyEvent::DOM_VK_LEFT,aExtend,eSelectCharacter); } +nsresult +nsFrameSelection::CharacterExtendForDelete() +{ + return MoveCaret(nsIDOMKeyEvent::DOM_VK_DELETE, PR_TRUE, eSelectCharacter); +} + nsresult nsFrameSelection::WordMove(PRBool aForward, PRBool aExtend) {