diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp index 8e09c149841..245026058cc 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.cpp @@ -473,17 +473,16 @@ nsTypeAheadFind::Observe(nsISupports *aSubject, const char *aTopic, nsresult -nsTypeAheadFind::UseInWindow(nsIDOMWindow *aDOMWin, nsIDOMWindow **aStartWindow) +nsTypeAheadFind::UseInWindow(nsIDOMWindow *aDOMWin) { NS_ENSURE_ARG_POINTER(aDOMWin); - NS_ENSURE_ARG_POINTER(aStartWindow); // Set member variables and listeners up for new window and doc mFindNextBuffer.Truncate(); CancelFind(); - GetStartWindow(aDOMWin, aStartWindow); + GetStartWindow(aDOMWin, getter_AddRefs(mFocusedWindow)); nsCOMPtr domDoc; aDOMWin->GetDocument(getter_AddRefs(domDoc)); @@ -513,7 +512,6 @@ nsTypeAheadFind::UseInWindow(nsIDOMWindow *aDOMWin, nsIDOMWindow **aStartWindow) RemoveDocListeners(); mIsFindAllowedInWindow = PR_TRUE; - mFocusedWindow = aDOMWin; mFocusedWeakShell = do_GetWeakReference(presShell); // Add scroll position and selection listeners, so we can cancel @@ -1801,17 +1799,16 @@ nsTypeAheadFind::StartNewFind(nsIDOMWindow *aWindow, PRBool aLinksOnly) // This routine will set up the doc listeners // Do it first, it does a CancelFind() - nsCOMPtr startWindow; - UseInWindow(aWindow, getter_AddRefs(startWindow)); + UseInWindow(aWindow); mLinksOnly = aLinksOnly; mLinksOnlyManuallySet = PR_TRUE; mRepeatingMode = eRepeatingNone; PRBool isAutoStartWin; - GetAutoStart(startWindow, &isAutoStartWin); + GetAutoStart(mFocusedWindow, &isAutoStartWin); if (!isAutoStartWin) { - AttachWindowListeners(startWindow); + AttachWindowListeners(mFocusedWindow); } if (mFocusedDocSelection) { @@ -2420,18 +2417,6 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, nsCOMPtr topContentWin; GetStartWindow(domWin, getter_AddRefs(topContentWin)); - if (topContentWin != mFocusedWindow) { - mFocusedWindow = topContentWin; - GetAutoStart(topContentWin, &mIsFindAllowedInWindow); - if (mIsFindAllowedInWindow) { - UseInWindow(topContentWin, getter_AddRefs(mFocusedWindow)); - } - } - if (!mIsFindAllowedInWindow) { - return NS_OK; - } - - // ---------- Get presshell ----------- nsCOMPtr presShell; @@ -2442,6 +2427,16 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, nsCOMPtr lastShell(do_QueryReferent(mFocusedWeakShell)); + if (lastShell != presShell || topContentWin != mFocusedWindow) { + GetAutoStart(topContentWin, &mIsFindAllowedInWindow); + if (mIsFindAllowedInWindow) { + UseInWindow(topContentWin); + } + } + if (!mIsFindAllowedInWindow) { + return NS_OK; + } + nsCOMPtr presContext; presShell->GetPresContext(getter_AddRefs(presContext)); nsCOMPtr printPreview(do_QueryInterface(presContext)); @@ -2456,11 +2451,6 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent, return NS_OK; } - if (lastShell != presShell) { - // Same window, but a new document, so start fresh - UseInWindow(domWin, getter_AddRefs(mFocusedWindow)); - } - NS_ADDREF(*aTargetPresShell = presShell); return NS_OK; } diff --git a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.h b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.h index a12042bcf3a..979fc4920d5 100644 --- a/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.h +++ b/mozilla/extensions/typeaheadfind/src/nsTypeAheadFind.h @@ -146,7 +146,7 @@ protected: void StartTimeout(); nsresult Init(); void Shutdown(); - nsresult UseInWindow(nsIDOMWindow *aDomWin, nsIDOMWindow **aStartWin); + nsresult UseInWindow(nsIDOMWindow *aDomWin); void SetSelectionLook(nsIPresShell *aPresShell, PRBool aChangeColor, PRBool aEnabled); void ResetGlobalAutoStart(PRBool aAutoStart);