From 1805338f9ab1b98ca2034ed6d668bdc6c691d5a4 Mon Sep 17 00:00:00 2001 From: "aaronl%netscape.com" Date: Tue, 8 Oct 2002 17:53:18 +0000 Subject: [PATCH] Bug 172956. Backspace should go back in page. r=dean, sr=alecf --- extensions/typeaheadfind/src/nsTypeAheadFind.cpp | 16 ++++++++++------ extensions/typeaheadfind/src/nsTypeAheadFind.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 681fb8e80e1..2a3d0852940 100644 --- a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -544,8 +544,10 @@ nsTypeAheadFind::KeyPress(nsIDOMEvent* aEvent) // ----------- Back space ------------------------- if (keyCode == nsIDOMKeyEvent::DOM_VK_BACK_SPACE) { - aEvent->PreventDefault(); // Prevent normal processing of this keystroke - HandleBackspace(); + if (HandleBackspace()) { + aEvent->PreventDefault(); // Prevent normal processing of this keystroke + } + return NS_OK; } @@ -563,7 +565,7 @@ nsTypeAheadFind::KeyPress(nsIDOMEvent* aEvent) } -void +PRBool nsTypeAheadFind::HandleBackspace() { // In normal type ahead find, remove a printable char from @@ -579,7 +581,7 @@ nsTypeAheadFind::HandleBackspace() mFocusedDocSelection->GetRangeAt(0, getter_AddRefs(mStartFindRange)); } else { - return; // No find string to backspace in! + return PR_FALSE; // No find string to backspace in! } } @@ -594,7 +596,7 @@ nsTypeAheadFind::HandleBackspace() mFocusedDocSelection->CollapseToStart(); CancelFind(); - return; + return PR_TRUE; } // ---------- Multiple chars in string ---------- @@ -632,7 +634,7 @@ nsTypeAheadFind::HandleBackspace() } } if (!presShell) { - return; + return PR_FALSE; } // Set the selection to the where the first character was found // so that find starts from there @@ -654,6 +656,8 @@ nsTypeAheadFind::HandleBackspace() mIsFindingText = PR_FALSE; SaveFind(); + + return PR_TRUE; // Backspace handled } diff --git a/extensions/typeaheadfind/src/nsTypeAheadFind.h b/extensions/typeaheadfind/src/nsTypeAheadFind.h index b8aae6100e7..a15aa1f21e4 100644 --- a/extensions/typeaheadfind/src/nsTypeAheadFind.h +++ b/extensions/typeaheadfind/src/nsTypeAheadFind.h @@ -128,7 +128,7 @@ protected: // Helper methods nsresult HandleChar(PRUnichar aChar); - void HandleBackspace(); + PRBool HandleBackspace(); void SaveFind(); nsresult GetWebBrowserFind(nsIWebBrowserFind **aWebBrowserFind); void StartTimeout();