From 22455d555532a46dc0943602c75df17d19cca301 Mon Sep 17 00:00:00 2001 From: "aaronl%netscape.com" Date: Thu, 31 Oct 2002 02:38:40 +0000 Subject: [PATCH] Bug 175242. Typeaheadfind shouldn't be active in print preview. r=kyle, sr=alecf, a=roc+moz --- .../typeaheadfind/src/nsTypeAheadFind.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index af73e39f30cc..7bbbb4a63eab 100644 --- a/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -97,6 +97,7 @@ #include "nsIWindowWatcher.h" #include "nsIObserverService.h" #include "nsLayoutAtoms.h" +#include "nsIPrintPreviewContext.h" #include "nsIPrivateTextEvent.h" #include "nsIPrivateCompositionEvent.h" @@ -2117,7 +2118,7 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, NS_ADDREF(*aTargetContent = targetContent); - // ---------- Is the keytroke in a new window? ------------------- + // ---------- Is the keystroke in a new window? ------------------- nsCOMPtr doc; if (NS_FAILED(targetContent->GetDocument(*getter_AddRefs(doc))) || !doc) { @@ -2147,7 +2148,23 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, if (!presShell) { return NS_OK; } + nsCOMPtr lastShell(do_QueryReferent(mFocusedWeakShell)); + + nsCOMPtr presContext; + presShell->GetPresContext(getter_AddRefs(presContext)); + nsCOMPtr printPreview(do_QueryInterface(presContext)); + if (printPreview) { + // Typeaheadfind is not designed to work in print preview. + // You can't navigate through the links there. + if (lastShell != presShell) { + mFocusedWeakShell = do_GetWeakReference(presShell); + CancelFind(); + DisplayStatus(PR_FALSE, nsnull, PR_TRUE, NS_LITERAL_STRING("").get()); // Clear status + } + return NS_OK; + } + if (lastShell != presShell) { // Same window, but a new document, so start fresh UseInWindow(domWin);