Browse files

Fix for 76758, 63241 and 68307. Make Find search through all frames, …

…bring the Find dialog up from JS, and make a docShell enumerator. r=adamlock, sr=kin
  • Loading branch information...
1 parent 259fce8 commit 44cbfd57f874c01785d34226b3a2fb95189c9d28 sfraser%netscape.com committed Apr 27, 2001
Showing with 299 additions and 568 deletions.
  1. +1 −0 build/mac/build_scripts/MozillaBuildList.pm
  2. +2 −1 content/base/src/nsDocumentViewer.cpp
  3. +1 −0 docshell/base/Makefile.in
  4. +2 −1 docshell/base/makefile.win
  5. +86 −0 docshell/base/nsDocShell.cpp
  6. +3 −0 docshell/base/nsDocShell.h
  7. +14 −1 docshell/base/nsIDocShell.idl
  8. +2 −0 docshell/base/nsIDocShellTreeItem.idl
  9. +5 −3 docshell/build/nsDocShellModule.cpp
  10. BIN docshell/macbuild/docshell.mcp
  11. BIN docshell/macbuild/docshellIDL.mcp
  12. +1 −1 editor/ui/composer/content/ComposerCommands.js
  13. BIN embedding/browser/macbuild/browserIDL.mcp
  14. BIN embedding/browser/macbuild/webBrowser.mcp
  15. +0 −1 embedding/browser/webBrowser/MANIFEST_IDL
  16. +0 −2 embedding/browser/webBrowser/Makefile.in
  17. +0 −2 embedding/browser/webBrowser/makefile.win
  18. +0 −54 embedding/browser/webBrowser/nsIWebBrowserFind.idl
  19. +1 −136 embedding/browser/webBrowser/nsWebBrowser.cpp
  20. +1 −6 embedding/browser/webBrowser/nsWebBrowser.h
  21. +0 −140 embedding/browser/webBrowser/nsWebBrowserFind.cpp
  22. +0 −82 embedding/browser/webBrowser/nsWebBrowserFind.h
  23. +1 −1 embedding/components/Makefile.in
  24. +4 −1 embedding/components/build/Makefile.in
  25. BIN embedding/components/build/macbuild/EmbedComponents.mcp
  26. BIN embedding/components/build/macbuild/EmbedComponentsIDL.mcp
  27. +2 −0 embedding/components/build/makefile.win
  28. +5 −2 embedding/components/build/nsModule.cpp
  29. +8 −2 embedding/components/find/src/nsWebBrowserFind.cpp
  30. +2 −1 embedding/components/find/src/nsWebBrowserFind.h
  31. +1 −0 embedding/components/makefile.win
  32. +2 −1 layout/base/nsDocumentViewer.cpp
  33. +1 −1 layout/base/nsPresShell.cpp
  34. +1 −1 layout/html/base/src/nsPresShell.cpp
  35. +0 −3 xpfe/browser/public/nsIBrowserInstance.idl
  36. +51 −5 xpfe/browser/resources/content/navigator.js
  37. +0 −73 xpfe/browser/src/nsBrowserInstance.cpp
  38. +0 −2 xpfe/browser/src/nsBrowserInstance.h
  39. BIN xpfe/components/find/macbuild/FindComponent.mcp
  40. +1 −0 xpfe/components/find/public/MANIFEST_IDL
  41. +1 −0 xpfe/components/find/public/Makefile.in
  42. +1 −0 xpfe/components/find/public/makefile.win
  43. +37 −31 xpfe/components/find/resources/finddialog.js
  44. +5 −1 xpfe/components/find/src/Makefile.in
  45. +2 −0 xpfe/components/find/src/makefile.win
  46. +33 −13 xpfe/components/find/src/nsFindComponent.cpp
  47. +15 −0 xpfe/components/find/src/nsFindComponent.h
  48. +4 −0 xpfe/global/resources/content/browserBindings.xml
  49. +3 −0 xpfe/global/resources/content/xulBindings.xml
View
1 build/mac/build_scripts/MozillaBuildList.pm
@@ -724,6 +724,7 @@ sub BuildClientDist()
InstallFromManifest(":mozilla:embedding:browser:webbrowser:MANIFEST_IDL", "$distdirectory:idl:");
InstallFromManifest(":mozilla:embedding:components:windowwatcher:public:MANIFEST_IDL", "$distdirectory:idl:");
InstallFromManifest(":mozilla:embedding:components:appstartup:src:MANIFEST", "$distdirectory:embedding:components:");
+ InstallFromManifest(":mozilla:embedding:components:find:public:MANIFEST_IDL", "$distdirectory:idl:");
#WIDGET
InstallFromManifest(":mozilla:widget:public:MANIFEST", "$distdirectory:widget:");
View
3 content/base/src/nsDocumentViewer.cpp
@@ -5162,7 +5162,8 @@ nsDocViewerFocusListener::Focus(nsIDOMEvent* aEvent)
//if selection was nsISelectionController::SELECTION_OFF, do nothing
//otherwise re-enable it.
- if(selectionStatus == nsISelectionController::SELECTION_DISABLED)
+ if(selectionStatus == nsISelectionController::SELECTION_DISABLED ||
+ selectionStatus == nsISelectionController::SELECTION_HIDDEN)
{
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
View
1 docshell/base/Makefile.in
@@ -51,6 +51,7 @@ CPPSRCS = \
nsDocShell.cpp \
nsWebShell.cpp \
nsDocShellLoadInfo.cpp \
+ nsDocShellEnumerator.cpp \
nsDSURIContentListener.cpp \
nsDefaultURIFixup.cpp \
# nsDSWebProgressListener.cpp \
View
3 docshell/base/makefile.win
@@ -45,7 +45,8 @@ XPIDLSRCS= \
CPP_OBJS= \
.\$(OBJDIR)\nsDocShell.obj \
- .\$(OBJDIR)\nsWebShell.obj \
+ .\$(OBJDIR)\nsWebShell.obj \
+ .\$(OBJDIR)\nsDocShellEnumerator.obj \
.\$(OBJDIR)\nsDocShellLoadInfo.obj \
.\$(OBJDIR)\nsDSURIContentListener.obj \
.\$(OBJDIR)\nsDefaultURIFixup.obj \
View
86 docshell/base/nsDocShell.cpp
@@ -22,6 +22,7 @@
* Peter Annema <disttsc@bart.nl>
* Dan Rosen <dr@netscape.com>
*/
+
#include "nsIComponentManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
@@ -54,6 +55,7 @@
#include "nsDocShell.h"
#include "nsDocShellLoadInfo.h"
#include "nsCDefaultURIFixup.h"
+#include "nsDocShellEnumerator.h"
// Helper Classes
#include "nsDOMError.h"
@@ -292,6 +294,14 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
}
return NS_NOINTERFACE;
}
+ else if (aIID.Equals(NS_GET_IID(nsIWebBrowserFind))) {
+ nsresult rv = EnsureFind();
+ if (NS_FAILED(rv)) return rv;
+
+ *aSink = mFind;
+ NS_ADDREF((nsISupports*)*aSink);
+ return NS_OK;
+ }
else {
return QueryInterface(aIID, aSink);
}
@@ -799,6 +809,35 @@ NS_IMETHODIMP nsDocShell::SetAllowSubframes(PRBool aAllowSubframes)
}
NS_IMETHODIMP
+nsDocShell::GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimpleEnumerator **outEnum)
+{
+ NS_ENSURE_ARG_POINTER(outEnum);
+ *outEnum = nsnull;
+
+ nsDocShellEnumerator* docShellEnum;
+ if (aDirection == ENUMERATE_FORWARDS)
+ docShellEnum = new nsDocShellForwardsEnumerator;
+ else
+ docShellEnum = new nsDocShellBackwardsEnumerator;
+
+ if (!docShellEnum) return NS_ERROR_OUT_OF_MEMORY;
+
+ nsresult rv = docShellEnum->SetEnumDocShellType(aItemType);
+ if (NS_FAILED(rv)) return rv;
+
+ rv = docShellEnum->SetEnumerationRootItem((nsIDocShellTreeItem *)this);
+ if (NS_FAILED(rv)) return rv;
+
+ rv = docShellEnum->First();
+ if (NS_FAILED(rv)) return rv;
+
+ docShellEnum->AddRef(); // ensure we don't lose the last ref inside the QueryInterface
+ rv = docShellEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)outEnum);
+ docShellEnum->Release();
+ return rv;
+}
+
+NS_IMETHODIMP
nsDocShell::GetAppType(PRUint32 * aAppType)
{
*aAppType = mAppType;
@@ -4794,6 +4833,53 @@ nsDocShell::EnsureScriptEnvironment()
return NS_OK;
}
+NS_IMETHODIMP nsDocShell::EnsureFind()
+{
+ nsresult rv;
+ if (!mFind)
+ {
+ mFind = do_CreateInstance("@mozilla.org/embedcomp/find;1", &rv);
+ if (NS_FAILED(rv)) return rv;
+ }
+
+ // we promise that the nsIWebBrowserFind that we return has been set
+ // up to point to the focussed, or content window, so we have to
+ // set that up each time.
+ nsCOMPtr<nsIScriptGlobalObject> scriptGO;
+ rv = GetScriptGlobalObject(getter_AddRefs(scriptGO));
+ if (NS_FAILED(rv)) return rv;
+
+ // default to our window
+ nsCOMPtr<nsIDOMWindow> rootWindow = do_QueryInterface(scriptGO);
+ nsCOMPtr<nsIDOMWindow> windowToSearch = rootWindow;
+
+ // if we can, search the focussed window
+ nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(scriptGO);
+ nsCOMPtr<nsIFocusController> focusController;
+ if (ourWindow)
+ ourWindow->GetRootFocusController(getter_AddRefs(focusController));
+ if (focusController)
+ {
+ nsCOMPtr<nsIDOMWindowInternal> focussedWindow;
+ focusController->GetFocusedWindow(getter_AddRefs(focussedWindow));
+ if (focussedWindow)
+ {
+ rootWindow = focussedWindow; // constrain to the focussed window.
+ windowToSearch = focussedWindow;
+ }
+ }
+
+ nsCOMPtr<nsIWebBrowserFindInFrames> findInFrames = do_QueryInterface(mFind);
+ if (!findInFrames) return NS_ERROR_NO_INTERFACE;
+
+ rv = findInFrames->SetRootSearchFrame(rootWindow);
+ if (NS_FAILED(rv)) return rv;
+ rv = findInFrames->SetCurrentSearchFrame(windowToSearch);
+ if (NS_FAILED(rv)) return rv;
+
+ return NS_OK;
+}
+
PRBool
nsDocShell::IsFrame()
{
View
3 docshell/base/nsDocShell.h
@@ -72,6 +72,7 @@
#include "nsIDocShellLoadInfo.h"
#include "nsIDocShellHistory.h"
#include "nsIURIFixup.h"
+#include "nsIWebBrowserFind.h"
#define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
@@ -252,6 +253,7 @@ friend class nsDSURIContentListener;
NS_IMETHOD GetRootScrollableView(nsIScrollableView ** aOutScrollView);
NS_IMETHOD EnsureContentListener();
NS_IMETHOD EnsureScriptEnvironment();
+ NS_IMETHOD EnsureFind();
PRBool IsFrame();
@@ -285,6 +287,7 @@ friend class nsDSURIContentListener;
nsCOMPtr<nsIGlobalHistory> mGlobalHistory;
nsCOMPtr<nsISupports> mLoadCookie; // the load cookie associated with the window context.
nsCOMPtr<nsIURIFixup> mURIFixup;
+ nsCOMPtr<nsIWebBrowserFind> mFind;
PRInt32 mMarginWidth;
PRInt32 mMarginHeight;
PRInt32 mItemType;
View
15 docshell/base/nsIDocShell.idl
@@ -45,6 +45,7 @@ interface nsIDocumentLoaderObserver;
interface nsIDocShellLoadInfo;
interface nsIDocumentCharsetInfo;
interface nsIWebNavigation;
+interface nsISimpleEnumerator;
[scriptable, uuid(69E5DE00-7B8B-11d3-AF61-00A024FFC08C)]
interface nsIDocShell : nsISupports
@@ -158,7 +159,19 @@ interface nsIDocShell : nsISupports
*/
attribute boolean allowSubframes;
-
+ /*
+ Get an enumerator over this docShell and its children.
+
+ @param aItemType - Only include docShells of this type, or if typeAll, include
+ all child shells. Uses types from nsIDocShellTreeItem.
+ @param aDirection - Whether to enumerate forwards or backwards.
+ */
+
+ const long ENUMERATE_FORWARDS = 0;
+ const long ENUMERATE_BACKWARDS = 1;
+
+ nsISimpleEnumerator getDocShellEnumerator(in long aItemType, in long aDirection);
+
/*
The type of application that created this window
*/
View
2 docshell/base/nsIDocShellTreeItem.idl
@@ -47,6 +47,8 @@ interface nsIDocShellTreeItem : nsISupports
const long typeContentWrapper=2;
const long typeChromeWrapper=3;
+ const long typeAll=0x7FFFFFFF;
+
/*
The type this item is.
*/
View
8 docshell/build/nsDocShellModule.cpp
@@ -28,7 +28,7 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebShell);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup);
-// Currently no-one is instanciating docshell's directly because
+// Currently no-one is instantiating docshell's directly because
// nsWebShell is still our main "shell" class. nsWebShell is a subclass
// of nsDocShell. Once migration is complete, docshells will be the main
// "shell" class and this module will need to register the docshell as
@@ -39,11 +39,13 @@ static nsModuleComponentInfo gDocShellModuleInfo[] = {
{ "WebShell",
NS_WEB_SHELL_CID,
"@mozilla.org/webshell;1",
- nsWebShellConstructor },
+ nsWebShellConstructor
+ },
{ "Default keyword fixup",
NS_DEFAULTURIFIXUP_CID,
NS_URIFIXUP_CONTRACTID,
- nsDefaultURIFixupConstructor }
+ nsDefaultURIFixupConstructor
+ }
};
// "docshell provider" to illustrate that this thing really *should*
View
BIN docshell/macbuild/docshell.mcp
Binary file not shown.
View
BIN docshell/macbuild/docshellIDL.mcp
Binary file not shown.
View
2 editor/ui/composer/content/ComposerCommands.js
@@ -543,7 +543,7 @@ var nsFindCommand =
doCommand: function(aCommand)
{
- window.editorShell.Find();
+ window.editorShell.Replace();
}
};
View
BIN embedding/browser/macbuild/browserIDL.mcp
Binary file not shown.
View
BIN embedding/browser/macbuild/webBrowser.mcp
Binary file not shown.
View
1 embedding/browser/webBrowser/MANIFEST_IDL
@@ -28,5 +28,4 @@ nsIWebBrowserSetup.idl
nsIEmbeddingSiteWindow.idl
nsIWebBrowserPersist.idl
nsIWebBrowserFocus.idl
-nsIWebBrowserFind.idl
nsIWebBrowserPrint.idl
View
2 embedding/browser/webBrowser/Makefile.in
@@ -42,7 +42,6 @@ XPIDLSRCS = \
nsITooltipListener.idl \
nsIWebBrowserPersist.idl \
nsIWebBrowserFocus.idl \
- nsIWebBrowserFind.idl \
nsIWebBrowserPrint.idl \
$(NULL)
@@ -52,7 +51,6 @@ CPPSRCS = \
nsCommandHandler.cpp \
nsWebBrowserPersist.cpp \
nsDOMWalker.cpp \
- nsWebBrowserFind.cpp \
nsNonPersistAuthPrompt.cpp \
$(NULL)
View
2 embedding/browser/webBrowser/makefile.win
@@ -34,7 +34,6 @@ XPIDLSRCS= \
.\nsIWebBrowserPersist.idl \
.\nsIEmbeddingSiteWindow.idl \
.\nsIWebBrowserFocus.idl \
- .\nsIWebBrowserFind.idl \
.\nsIWebBrowserPrint.idl \
$(NULL)
@@ -46,7 +45,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsCommandHandler.obj \
.\$(OBJDIR)\nsWebBrowserPersist.obj \
.\$(OBJDIR)\nsDOMWalker.obj \
- .\$(OBJDIR)\nsWebBrowserFind.obj \
.\$(OBJDIR)\nsNonPersistAuthPrompt.obj \
$(NULL)
View
54 embedding/browser/webBrowser/nsIWebBrowserFind.idl
@@ -1,54 +0,0 @@
-/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * The contents of this file are subject to the Netscape Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 2001 Netscape Communications Corporation. All
- * Rights Reserved.
- *
- * Author:
- * Conrad Carlen <ccarlen@netscape.com>
- *
- * Contributor(s):
- */
-
-#include "nsISupports.idl"
-
-
-//
-// nsIWebBrowserFind interface
-//
-// Searches for text in a web browser.
-//
-
-[scriptable, uuid(2f977d44-5485-11d4-87e2-0010a4e75ef2)]
-interface nsIWebBrowserFind : nsISupports
-{
- /**
- Finds the next occurance of the string using the
- current attributes. At least the searchString
- attribute must have been set before calling this
- or NS_ERROR_NOT_INITIALIZED will be returned.
- All other attributes can be defaults.
- */
-
- boolean findNext();
-
- attribute wstring searchString;
-
- attribute boolean findBackwards;
- attribute boolean wrapFind;
- attribute boolean entireWord;
- attribute boolean matchCase;
-};
View
137 embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -23,7 +23,6 @@
// Local Includes
#include "nsWebBrowser.h"
#include "nsWebBrowserPersist.h"
-#include "nsWebBrowserFind.h"
// Helper Classes
#include "nsGfxCIID.h"
@@ -67,7 +66,7 @@ static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
nsWebBrowser::nsWebBrowser() : mDocShellTreeOwner(nsnull),
mInitInfo(nsnull), mContentType(typeContentWrapper),
mParentNativeWindow(nsnull), mParentWidget(nsnull), mParent(nsnull),
- mProgressListener(nsnull), mListenerArray(nsnull), mFindImpl(nsnull),
+ mProgressListener(nsnull), mListenerArray(nsnull),
mBackgroundColor(0)
{
NS_INIT_REFCNT();
@@ -111,10 +110,6 @@ NS_IMETHODIMP nsWebBrowser::InternalDestroy()
delete mListenerArray;
mListenerArray = nsnull;
}
- if (mFindImpl) {
- delete mFindImpl;
- mFindImpl = nsnull;
- }
return NS_OK;
}
@@ -139,7 +134,6 @@ NS_INTERFACE_MAP_BEGIN(nsWebBrowser)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserSetup)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersist)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserFocus)
- NS_INTERFACE_MAP_ENTRY(nsIWebBrowserFind)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPrint)
NS_INTERFACE_MAP_END
@@ -724,125 +718,6 @@ NS_IMETHODIMP nsWebBrowser::SaveDocument(nsIDOMDocument *aDocument, const char *
}
//*****************************************************************************
-// nsWebBrowser::nsIWebBrowserFind
-//*****************************************************************************
-
-/* boolean findNext (); */
-NS_IMETHODIMP nsWebBrowser::FindNext(PRBool *didFind)
-{
- NS_ENSURE_ARG_POINTER(didFind);
- *didFind = PR_FALSE;
-
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
-
- NS_ENSURE_TRUE(mFindImpl->CanFindNext(), NS_ERROR_NOT_INITIALIZED);
-
- nsCOMPtr<nsIDOMWindow> windowToSearch;
- rv = GetFocusedWindow(getter_AddRefs(windowToSearch));
- if (!windowToSearch) {
- nsCOMPtr<nsIDOMWindowInternal> contentDomWindow;
- rv = GetPrimaryContentWindow(getter_AddRefs(contentDomWindow));
- windowToSearch = contentDomWindow;
- }
-
- NS_ENSURE_TRUE(windowToSearch, NS_ERROR_FAILURE);
- rv = mFindImpl->DoFind(windowToSearch, didFind);
-
- return rv;
-}
-
-/* attribute wstring searchString; */
-NS_IMETHODIMP nsWebBrowser::GetSearchString(PRUnichar * *aSearchString)
-{
- NS_ENSURE_ARG_POINTER(aSearchString);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- return mFindImpl->GetSearchString(aSearchString);
-}
-
-NS_IMETHODIMP nsWebBrowser::SetSearchString(const PRUnichar * aSearchString)
-{
- NS_ENSURE_ARG(aSearchString);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- return mFindImpl->SetSearchString(aSearchString);
-}
-
-/* attribute boolean findBackwards; */
-NS_IMETHODIMP nsWebBrowser::GetFindBackwards(PRBool *aFindBackwards)
-{
- NS_ENSURE_ARG_POINTER(aFindBackwards);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- *aFindBackwards = mFindImpl->GetFindBackwards();
- return NS_OK;
-}
-
-NS_IMETHODIMP nsWebBrowser::SetFindBackwards(PRBool aFindBackwards)
-{
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- mFindImpl->SetFindBackwards(aFindBackwards);
- return NS_OK;
-}
-
-/* attribute boolean wrapFind; */
-NS_IMETHODIMP nsWebBrowser::GetWrapFind(PRBool *aWrapFind)
-{
- NS_ENSURE_ARG_POINTER(aWrapFind);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- *aWrapFind = mFindImpl->GetWrapFind();
- return NS_OK;
-}
-
-NS_IMETHODIMP nsWebBrowser::SetWrapFind(PRBool aWrapFind)
-{
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- mFindImpl->SetWrapFind(aWrapFind);
- return NS_OK;
-}
-
-/* attribute boolean entireWord; */
-NS_IMETHODIMP nsWebBrowser::GetEntireWord(PRBool *aEntireWord)
-{
- NS_ENSURE_ARG_POINTER(aEntireWord);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- *aEntireWord = mFindImpl->GetEntireWord();
- return NS_OK;
-}
-
-NS_IMETHODIMP nsWebBrowser::SetEntireWord(PRBool aEntireWord)
-{
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- mFindImpl->SetEntireWord(aEntireWord);
- return NS_OK;
-}
-
-/* attribute boolean matchCase; */
-NS_IMETHODIMP nsWebBrowser::GetMatchCase(PRBool *aMatchCase)
-{
- NS_ENSURE_ARG_POINTER(aMatchCase);
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- *aMatchCase = mFindImpl->GetMatchCase();
- return NS_OK;
-}
-
-NS_IMETHODIMP nsWebBrowser::SetMatchCase(PRBool aMatchCase)
-{
- nsresult rv = EnsureFindImpl();
- if (NS_FAILED(rv)) return rv;
- mFindImpl->SetMatchCase(aMatchCase);
- return NS_OK;
-}
-
-
-//*****************************************************************************
// nsWebBrowser::nsIBaseWindow
//*****************************************************************************
@@ -1432,16 +1307,6 @@ NS_IMETHODIMP nsWebBrowser::EnsureDocShellTreeOwner()
return NS_OK;
}
-NS_IMETHODIMP nsWebBrowser::EnsureFindImpl()
-{
- if (mFindImpl)
- return NS_OK;
-
- mFindImpl = new nsWebBrowserFindImpl;
- NS_ENSURE_TRUE(mFindImpl, NS_ERROR_OUT_OF_MEMORY);
- return mFindImpl->Init();
-}
-
NS_IMETHODIMP nsWebBrowser::FillBackground(const nsRect &aRect)
{
mRC->FillRect(aRect);
View
7 embedding/browser/webBrowser/nsWebBrowser.h
@@ -46,7 +46,6 @@
#include "nsIWebBrowserSetup.h"
#include "nsIWebBrowserPersist.h"
#include "nsIWebBrowserFocus.h"
-#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserPrint.h"
#include "nsIWindowWatcher.h"
@@ -94,7 +93,6 @@ class nsWebBrowser : public nsIWebBrowser,
public nsIInterfaceRequestor,
public nsIWebBrowserPersist,
public nsIWebBrowserFocus,
- public nsIWebBrowserFind,
public nsIWebBrowserPrint
{
friend class nsDocShellTreeOwner;
@@ -113,7 +111,6 @@ friend class nsDocShellTreeOwner;
NS_DECL_NSIWEBBROWSERSETUP
NS_DECL_NSIWEBBROWSERPERSIST
NS_DECL_NSIWEBBROWSERFOCUS
- NS_DECL_NSIWEBBROWSERFIND
NS_DECL_NSIWEBBROWSERPRINT
protected:
@@ -125,7 +122,6 @@ friend class nsDocShellTreeOwner;
NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindowInternal **aDomWindow);
NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
- NS_IMETHOD EnsureFindImpl();
NS_IMETHOD FillBackground(const nsRect &aRect);
@@ -146,8 +142,7 @@ friend class nsDocShellTreeOwner;
PRUint32 mContentType;
nativeWindow mParentNativeWindow;
nsIWebBrowserPersistProgress *mProgressListener;
- nsCOMPtr<nsIWebProgress> mWebProgress;
- nsWebBrowserFindImpl* mFindImpl;
+ nsCOMPtr<nsIWebProgress> mWebProgress;
// so that we can draw when we get expose events
nsCOMPtr<nsIRenderingContext> mRC;
View
140 embedding/browser/webBrowser/nsWebBrowserFind.cpp
@@ -1,140 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is the Mozilla browser.
- *
- * The Initial Developer of the Original Code is Netscape
- * Communications, Inc. Portions created by Netscape are
- * Copyright (C) 1999, Mozilla. All Rights Reserved.
- *
- * Author:
- * Conrad Carlen <ccarlen@netscape.com>
- */
-
-#include "nsWebBrowserFind.h"
-
-#include "nsCOMPtr.h"
-#include "nsIComponentManager.h"
-#include "nsITextServicesDocument.h"
-#include "nsTextServicesCID.h"
-#include "nsIScriptGlobalObject.h"
-#include "nsIDOMWindow.h"
-#include "nsIDocShell.h"
-#include "nsIPresShell.h"
-#include "nsIDocument.h"
-#include "nsIDOMDocument.h"
-
-
-static NS_DEFINE_CID(kCTextServicesDocumentCID, NS_TEXTSERVICESDOCUMENT_CID);
-
-//*****************************************************************************
-// nsWebBrowserFindImpl
-//*****************************************************************************
-
-
-nsWebBrowserFindImpl::nsWebBrowserFindImpl() :
- mFindBackwards(PR_FALSE), mWrapFind(PR_FALSE),
- mEntireWord(PR_FALSE), mMatchCase(PR_FALSE)
-{
-}
-
-nsWebBrowserFindImpl::~nsWebBrowserFindImpl()
-{
-}
-
-nsresult nsWebBrowserFindImpl::Init()
-{
- nsresult rv;
- mTSFind = do_CreateInstance(NS_FINDANDREPLACE_CONTRACTID, &rv);
- return rv;
-}
-
-nsresult nsWebBrowserFindImpl::SetSearchString(const PRUnichar* aString)
-{
- mSearchString = aString;
- return NS_OK;
-}
-
-nsresult nsWebBrowserFindImpl::GetSearchString(PRUnichar** aString)
-{
- NS_ENSURE_ARG_POINTER(aString);
- *aString = mSearchString.ToNewUnicode();
- return *aString ? NS_OK : NS_ERROR_FAILURE;
-}
-
-nsresult nsWebBrowserFindImpl::DoFind(nsIDOMWindow* aWindow, PRBool* aDidFind)
-{
- NS_ENSURE_TRUE(mTSFind, NS_ERROR_NOT_INITIALIZED);
-
- nsresult rv;
- nsCOMPtr<nsITextServicesDocument> txtDoc;
- rv = MakeTSDocument(aWindow, getter_AddRefs(txtDoc));
- if (NS_FAILED(rv) || !txtDoc)
- return rv;
-
- (void) mTSFind->SetCaseSensitive(mMatchCase);
- (void) mTSFind->SetFindBackwards(mFindBackwards);
- (void) mTSFind->SetWrapFind(mWrapFind);
- (void) mTSFind->SetEntireWord(mEntireWord);
-
- rv = mTSFind->SetTsDoc(txtDoc);
- if (NS_FAILED(rv))
- return rv;
-
- rv = mTSFind->Find(mSearchString.GetUnicode(), aDidFind);
-
- mTSFind->SetTsDoc(nsnull);
-
- return rv;
-}
-
-nsresult nsWebBrowserFindImpl::MakeTSDocument(nsIDOMWindow* aWindow, nsITextServicesDocument** aDoc)
-{
- NS_ENSURE_ARG(aWindow);
- NS_ENSURE_ARG_POINTER(aDoc);
-
- nsresult rv;
- *aDoc = NULL;
-
- nsCOMPtr<nsITextServicesDocument> tempDoc(do_CreateInstance(kCTextServicesDocumentCID, &rv));
- if (NS_FAILED(rv) || !tempDoc)
- return rv;
-
- nsCOMPtr<nsIScriptGlobalObject> globalObj = do_QueryInterface(aWindow, &rv);
- if (NS_FAILED(rv) || !globalObj)
- return NS_ERROR_FAILURE;
-
- nsCOMPtr<nsIDocShell> docShell;
- globalObj->GetDocShell(getter_AddRefs(docShell));
- if (!docShell)
- return NS_ERROR_FAILURE;
-
- nsCOMPtr<nsIPresShell> presShell;
- docShell->GetPresShell(getter_AddRefs(presShell));
- if (!presShell)
- return NS_ERROR_FAILURE;
-
- nsCOMPtr<nsIDOMDocument> domDoc;
- rv = aWindow->GetDocument(getter_AddRefs(domDoc));
- if (!domDoc)
- return NS_ERROR_FAILURE;
-
- rv = tempDoc->InitWithDocument(domDoc, presShell);
- if (NS_FAILED(rv))
- return rv;
-
- // Return the resulting text services document.
- *aDoc = tempDoc;
- NS_IF_ADDREF(*aDoc);
-
- return rv;
-}
View
82 embedding/browser/webBrowser/nsWebBrowserFind.h
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * The contents of this file are subject to the Mozilla Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is the Mozilla browser.
- *
- * The Initial Developer of the Original Code is Netscape
- * Communications, Inc. Portions created by Netscape are
- * Copyright (C) 1999, Mozilla. All Rights Reserved.
- *
- * Author:
- * Conrad Carlen <ccarlen@netscape.com>
- */
-
-#ifndef nsWebBrowserFindImpl_h__
-#define nsWebBrowserFindImpl_h__
-
-#include "nsString.h"
-#include "nsCOMPtr.h"
-#include "nsIFindAndReplace.h"
-
-class nsIDOMWindow;
-class nsITextServicesDocument;
-
-//*****************************************************************************
-// class nsWebBrowserFindImpl
-//*****************************************************************************
-
-class nsWebBrowserFindImpl
-{
-public:
- nsWebBrowserFindImpl();
- ~nsWebBrowserFindImpl();
-
- nsresult Init(); // Must be called after constructor
-
- nsresult SetSearchString(const PRUnichar* aString);
- nsresult GetSearchString(PRUnichar** aString);
-
- PRBool GetFindBackwards()
- { return mFindBackwards; }
- void SetFindBackwards(PRBool aFindBackwards)
- { mFindBackwards = aFindBackwards; }
-
- PRBool GetWrapFind()
- { return mWrapFind; }
- void SetWrapFind(PRBool aWrapFind)
- { mWrapFind = aWrapFind; }
-
- PRBool GetEntireWord()
- { return mEntireWord; }
- void SetEntireWord(PRBool aEntireWord)
- { mEntireWord = aEntireWord; }
-
- PRBool GetMatchCase()
- { return mMatchCase; }
- void SetMatchCase(PRBool aMatchCase)
- { mMatchCase = aMatchCase; }
-
- PRBool CanFindNext()
- { return mSearchString.Length() != 0; }
-
- nsresult DoFind(nsIDOMWindow* aWindow, PRBool* didFind);
-
-private:
- nsresult MakeTSDocument(nsIDOMWindow* aWindow, nsITextServicesDocument** aDoc);
-
- nsString mSearchString;
- PRBool mFindBackwards, mWrapFind, mEntireWord, mMatchCase;
-
- nsCOMPtr<nsIFindAndReplace> mTSFind;
-};
-
-#endif
View
2 embedding/components/Makefile.in
@@ -24,6 +24,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
-DIRS = windowwatcher appstartup build
+DIRS = windowwatcher appstartup find build
include $(topsrcdir)/config/rules.mk
View
5 embedding/components/build/Makefile.in
@@ -27,14 +27,15 @@ MODULE = embedcomponents
LIBRARY_NAME = embedcomponents
SHORT_LIBNAME = embedcmp
IS_COMPONENT = 1
-REQUIRES = js xpcom string windowwatcher embed_base
+REQUIRES = js xpcom string windowwatcher find embed_base
CPPSRCS = nsModule.cpp
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
EXTRA_DSO_LIBS = \
windowwatcher_s \
appstartupnotifier_s \
+ find_s \
$(NULL)
@@ -47,6 +48,7 @@ else
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/libwindowwatcher_s.$(LIB_SUFFIX) \
$(DIST)/lib/libappstartupnotifier_s.$(LIB_SUFFIX) \
+ $(DIST)/lib/libfind_s.$(LIB_SUFFIX) \
$(NULL)
ifdef MOZ_PERF_METRICS
@@ -58,6 +60,7 @@ endif
LOCAL_INCLUDES = \
-I$(srcdir)/../windowwatcher/src \
-I$(srcdir)/../appstartup/src \
+ -I$(srcdir)/../find/src \
$(NULL)
EXTRA_DSO_LDOPTS = \
View
BIN embedding/components/build/macbuild/EmbedComponents.mcp
Binary file not shown.
View
BIN embedding/components/build/macbuild/EmbedComponentsIDL.mcp
Binary file not shown.
View
2 embedding/components/build/makefile.win
@@ -37,11 +37,13 @@ LLIBS = \
$(DIST)\lib\xpcom.lib \
$(DIST)\lib\windowwatcher_s.lib \
$(DIST)\lib\appstartupnotifier_s.lib \
+ $(DIST)\lib\find_s.lib \
$(NULL)
INCS = $(INCS) \
-I$(DEPTH)\embedding\components\windowwatcher\src \
-I$(DEPTH)\embedding\components\appstartup\src \
+ -I$(DEPTH)\embedding\components\find\src \
$(NULL)
include <$(DEPTH)\config\rules.mak>
View
7 embedding/components/build/nsModule.cpp
@@ -25,18 +25,21 @@
#include "nsPromptService.h"
#include "nsWindowWatcher.h"
#include "nsAppStartupNotifier.h"
+#include "nsWebBrowserFind.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPromptService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowWatcher, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppStartupNotifier)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserFind)
-static nsModuleComponentInfo components[] = {
+static nsModuleComponentInfo gComponents[] = {
{ "Dialog ParamBlock", NS_DIALOGPARAMBLOCK_CID, NS_DIALOGPARAMBLOCK_CONTRACTID, nsDialogParamBlockConstructor },
{ "Prompt Service", NS_PROMPTSERVICE_CID, NS_PROMPTSERVICE_CONTRACTID, nsPromptServiceConstructor },
{ "Window Watcher", NS_WINDOWWATCHER_CID, NS_WINDOWWATCHER_CONTRACTID, nsWindowWatcherConstructor },
+ { "Find", NS_WEB_BROWSER_FIND_CID, NS_WEB_BROWSER_FIND_CONTRACTID, nsWebBrowserFindConstructor },
{ NS_APPSTARTUPNOTIFIER_CLASSNAME, NS_APPSTARTUPNOTIFIER_CID, NS_APPSTARTUPNOTIFIER_CONTRACTID, nsAppStartupNotifierConstructor }
};
-NS_IMPL_NSGETMODULE("embedcomponents", components)
+NS_IMPL_NSGETMODULE("embedcomponents", gComponents)
View
10 embedding/components/find/src/nsWebBrowserFind.cpp
@@ -16,8 +16,9 @@
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
- * Author:
+ * Contributors:
* Conrad Carlen <ccarlen@netscape.com>
+ * Simon Fraser <sfraser@netscape.com>
*/
#include "nsWebBrowserFind.h"
@@ -86,6 +87,10 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(PRBool *outDidFind)
if (*outDidFind)
return OnFind(searchFrame); // we are done
+ // if we are not searching other frames, return
+ if (!mSearchSubFrames && !mSearchParentFrames)
+ return NS_OK;
+
nsCOMPtr<nsIDOMWindow> rootFrame = do_QueryReferent(mRootSearchFrame);
NS_ENSURE_TRUE(searchFrame, NS_ERROR_NOT_INITIALIZED);
@@ -108,7 +113,8 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(PRBool *outDidFind)
nsCOMPtr<nsIDocShellTreeItem> curItem;
- // XXX We should avoid searching in frameset documents here.
+ // XXX We should avoid searching in frameset documents here.
+ // We also need to honour mSearchSubFrames and mSearchParentFrames.
PRBool hasMore, doFind = PR_FALSE;
while (NS_SUCCEEDED(docShellEnumerator->HasMoreElements(&hasMore)) && hasMore)
{
View
3 embedding/components/find/src/nsWebBrowserFind.h
@@ -16,8 +16,9 @@
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
- * Author:
+ * Contributors:
* Conrad Carlen <ccarlen@netscape.com>
+ * Simon Fraser <sfraser@netscape.com>
*/
#ifndef nsWebBrowserFindImpl_h__
View
1 embedding/components/makefile.win
@@ -23,6 +23,7 @@ DEPTH=..\..
DIRS= \
windowwatcher \
appstartup \
+ find \
build \
$(NULL)
View
3 layout/base/nsDocumentViewer.cpp
@@ -5162,7 +5162,8 @@ nsDocViewerFocusListener::Focus(nsIDOMEvent* aEvent)
//if selection was nsISelectionController::SELECTION_OFF, do nothing
//otherwise re-enable it.
- if(selectionStatus == nsISelectionController::SELECTION_DISABLED)
+ if(selectionStatus == nsISelectionController::SELECTION_DISABLED ||
+ selectionStatus == nsISelectionController::SELECTION_HIDDEN)
{
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
View
2 layout/base/nsPresShell.cpp
@@ -1570,7 +1570,7 @@ PresShell::Init(nsIDocument* aDocument,
result = docShell->GetItemType(&docShellType);
if (NS_SUCCEEDED(result)){
if (nsIDocShellTreeItem::typeContent == docShellType){
- SetDisplaySelection(nsISelectionController::SELECTION_ON);
+ SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
}
}
}
View
2 layout/html/base/src/nsPresShell.cpp
@@ -1570,7 +1570,7 @@ PresShell::Init(nsIDocument* aDocument,
result = docShell->GetItemType(&docShellType);
if (NS_SUCCEEDED(result)){
if (nsIDocShellTreeItem::typeContent == docShellType){
- SetDisplaySelection(nsISelectionController::SELECTION_ON);
+ SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
}
}
}
View
3 xpfe/browser/public/nsIBrowserInstance.idl
@@ -51,9 +51,6 @@ interface nsIBrowserInstance : nsISupports {
// Edit.
void copy();
- // Search.
- void find();
- void findNext();
};
%{C++
View
56 xpfe/browser/resources/content/navigator.js
@@ -758,13 +758,59 @@ function BrowserClose()
window.close();
}
- function BrowserFind() {
- appCore.find();
- }
+function BrowserFind()
+{
+ var focusedWindow = document.commandDispatcher.focusedWindow;
+ if (!focusedWindow || focusedWindow == window)
+ focusedWindow = window._content;
+
+ var findInst = getBrowser().webBrowserFind;
+ // set up the find to search the focussedWindow, bounded by the content window.
+ var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
+ findInFrames.rootSearchFrame = window._content;
+ findInFrames.currentSearchFrame = focusedWindow;
+
+ // always search in frames for now. We could add a checkbox to the dialog for this.
+ findInst.searchFrames = true;
+
+ // is the dialog up already?
+ if (window.findDialog)
+ window.findDialog.focus();
+ else
+ window.findDialog = window.openDialog("chrome://global/content/finddialog.xul", "Find on Page", "chrome,resizable=no,dependent=yes", findInst);
+}
+
+function BrowserFindAgain()
+{
+ if (window.findDialog)
+ window.findDialog.focus();
+ else
+ {
+ // since the page may have been reloaded, reset stuff
+ var focusedWindow = document.commandDispatcher.focusedWindow;
+ if (!focusedWindow || focusedWindow == window)
+ focusedWindow = window._content;
+
+ var findInst = getBrowser().webBrowserFind;
+ // set up the find to search the focussedWindow, bounded by the content window.
+ var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
+ findInFrames.rootSearchFrame = window._content;
+ findInFrames.currentSearchFrame = focusedWindow;
+
+ // always search in frames for now. We could add a checkbox to the dialog for this.
+ findInst.searchFrames = true;
- function BrowserFindAgain() {
- appCore.findNext();
+ var found = findInst.findNext();
}
+}
+
+function BrowserCanFindAgain()
+{
+ var findInst = getBrowser().webBrowserFind;
+ var findString = findInst.searchString;
+
+ return (findString.length > 0);
+}
function loadURI(uri)
{
View
73 xpfe/browser/src/nsBrowserInstance.cpp
@@ -809,60 +809,6 @@ nsBrowserInstance::Copy()
return NS_OK;
}
-NS_IMETHODIMP
-nsBrowserInstance::Find()
-{
- nsresult rv = NS_OK;
- PRBool found = PR_FALSE;
-
- // Get find component.
- nsCOMPtr <nsIFindComponent> finder = do_GetService(NS_IFINDCOMPONENT_CONTRACTID, &rv);
- if (NS_FAILED(rv)) return rv;
- if (!finder) return NS_ERROR_FAILURE;
-
- // get the window to search
- nsCOMPtr<nsIDOMWindowInternal> windowToSearch;
- GetFocussedContentWindow(getter_AddRefs(windowToSearch));
-
- // Make sure we've initialized searching for this document.
- rv = InitializeSearch(windowToSearch, finder);
- if (NS_FAILED(rv)) return rv;
-
- // Perform find via find component.
- if (mSearchContext) {
- rv = finder->Find( mSearchContext, &found );
- }
-
- return rv;
-}
-
-NS_IMETHODIMP
-nsBrowserInstance::FindNext()
-{
- nsresult rv = NS_OK;
- PRBool found = PR_FALSE;
-
- // Get find component.
- nsCOMPtr <nsIFindComponent> finder = do_GetService(NS_IFINDCOMPONENT_CONTRACTID, &rv);
- if (NS_FAILED(rv)) return rv;
- if (!finder) return NS_ERROR_FAILURE;
-
- // get the window to search
- nsCOMPtr<nsIDOMWindowInternal> windowToSearch;
- GetFocussedContentWindow(getter_AddRefs(windowToSearch));
-
- // Make sure we've initialized searching for this document.
- rv = InitializeSearch(windowToSearch, finder);
- if (NS_FAILED(rv)) return rv;
-
- // Perform find via find component.
- if (mSearchContext) {
- rv = finder->FindNext(mSearchContext, &found );
- }
-
- return rv;
-}
-
//*****************************************************************************
// nsBrowserInstance: nsIURIContentListener
//*****************************************************************************
@@ -993,25 +939,6 @@ nsBrowserInstance::SetLoadCookie(nsISupports * aLoadCookie)
return NS_OK;
}
-//*****************************************************************************
-// nsBrowserInstance: Helpers
-//*****************************************************************************
-
-nsresult
-nsBrowserInstance::InitializeSearch(nsIDOMWindowInternal* windowToSearch, nsIFindComponent *finder)
-{
- nsresult rv = NS_OK;
-
- if (!finder) return NS_ERROR_NULL_POINTER;
- if (!windowToSearch) return NS_ERROR_NULL_POINTER;
-
- if (!mSearchContext )
- rv = finder->CreateContext(windowToSearch, nsnull, getter_AddRefs(mSearchContext));
- else
- rv = finder->ResetContext(mSearchContext, windowToSearch, nsnull);
-
- return rv;
-}
////////////////////////////////////////////////////////////////////////
// browserCntHandler is a content handler component that registers
View
2 xpfe/browser/src/nsBrowserInstance.h
@@ -82,8 +82,6 @@ class nsBrowserInstance : public nsIBrowserInstance,
nsresult GetFocussedContentWindow(nsIDOMWindowInternal** outFocussedWindow);
void ReinitializeContentVariables();
-
- nsresult InitializeSearch(nsIDOMWindowInternal* windowToSearch, nsIFindComponent *finder );
PRBool mIsClosed;
static PRBool sCmdLineURLUsed;
View
BIN xpfe/components/find/macbuild/FindComponent.mcp
Binary file not shown.
View
1 xpfe/components/find/public/MANIFEST_IDL
@@ -1,2 +1,3 @@
nsIFindComponent.idl
nsISearchContext.idl
+nsIFindService.idl
View
1 xpfe/components/find/public/Makefile.in
@@ -32,6 +32,7 @@ XPIDL_MODULE = mozfind
XPIDLSRCS = \
nsIFindComponent.idl \
nsISearchContext.idl \
+ nsIFindService.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk
View
1 xpfe/components/find/public/makefile.win
@@ -30,6 +30,7 @@ XPIDL_MODULE=mozfind
XPIDLSRCS=\
.\nsIFindComponent.idl \
.\nsISearchContext.idl \
+ .\nsIFindService.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
View
68 xpfe/components/find/resources/finddialog.js
@@ -26,9 +26,8 @@
* Stuart Parmenter <pavlov@netscape.com>
*/
-var finder; // Find component.
-var data; // Search context (passed as argument).
-var dialog; // Quick access to document/form elements.
+var dialog; // Quick access to document/form elements.
+var gFindInst; // nsIWebBrowserFind that we're going to use
function initDialogObject()
{
@@ -52,45 +51,44 @@ function initDialogObject()
function fillDialog()
{
+ // get the find service, which stores global find state
+ var findService = Components.classes["@mozilla.org/find/find_service;1"]
+ .getService(Components.interfaces.nsIFindService);
+
// Set initial dialog field contents.
- dialog.findKey.value = data.searchString;
-
- dialog.caseSensitive.checked = data.caseSensitive;
- dialog.wrap.checked = data.wrapSearch;
- dialog.searchBackwards.checked = data.searchBackwards;
+ dialog.findKey.value = findService.searchString;
+ dialog.caseSensitive.checked = findService.matchCase;
+ dialog.wrap.checked = findService.wrapFind;
+ dialog.searchBackwards.checked = findService.findBackwards;
}
-function loadData()
+function saveFindData()
{
+ // get the find service, which stores global find state
+ var findService = Components.classes["@mozilla.org/find/find_service;1"]
+ .getService(Components.interfaces.nsIFindService);
+
// Set data attributes per user input.
- data.searchString = dialog.findKey.value;
- data.caseSensitive = dialog.caseSensitive.checked;
- data.wrapSearch = dialog.wrap.checked;
- data.searchBackwards = dialog.searchBackwards.checked;
+ findService.searchString = dialog.findKey.value;
+ findService.matchCase = dialog.caseSensitive.checked;
+ findService.wrapFind = dialog.wrap.checked;
+ findService.findBackwards = dialog.searchBackwards.checked;
}
function onLoad()
{
initDialogObject();
- // Get find component.
- finder = Components.classes["@mozilla.org/appshell/component/find;1"].getService();
- finder = finder.QueryInterface(Components.interfaces.nsIFindComponent);
-
// Change "OK" to "Find".
dialog.find.label = document.getElementById("fBLT").getAttribute("label");
// Setup the dialogOverlay.xul button handlers.
doSetOKCancel(onOK, onCancel);
- // Save search context.
- data = window.arguments[0];
-
- // Tell search context about this dialog.
- data.findDialog = window;
+ // get the find instance
+ gFindInst = window.arguments[0];
fillDialog();
-
doEnabling();
if (dialog.findKey.value)
@@ -99,19 +97,27 @@ function onLoad()
dialog.findKey.focus();
}
-function onUnload() {
- // Disconnect context from this dialog.
- data.findDialog = null;
+function onUnload()
+{
+ window.opener.findDialog = 0;
}
function onOK()
{
- // Transfer dialog contents to data elements.
- loadData();
-
+ // Transfer dialog contents to the find service.
+ saveFindData();
+
+ // set up the find instance
+ gFindInst.searchString = dialog.findKey.value;
+ gFindInst.matchCase = dialog.caseSensitive.checked;
+ gFindInst.wrapFind = dialog.wrap.checked;
+ gFindInst.findBackwards = dialog.searchBackwards.checked;
+
// Search.
- var result = finder.findNext(data);
- if (!result) {
+ var result = gFindInst.findNext();
+
+ if (!result)
+ {
if (!dialog.bundle)
dialog.bundle = document.getElementById("findBundle");
window.alert(dialog.bundle.getString("notFoundWarning"));
View
6 xpfe/components/find/src/Makefile.in
@@ -32,7 +32,11 @@ LIBRARY_NAME = mozfind
IS_COMPONENT = 1
REQUIRES = xpcom string dom js layout widget appshell editor necko txtsvc docshell locale uriloader txmgr gfx2 mozcomps
-CPPSRCS = nsFindComponent.cpp
+CPPSRCS = \
+ nsFindComponent.cpp \
+ nsFindService.cpp \
+ nsFindModule.cpp \
+ $(NULL)
EXTRA_DSO_LDOPTS = \
-L$(DIST)/bin \
View
2 xpfe/components/find/src/makefile.win
@@ -68,6 +68,8 @@ LLIBS = \
#//------------------------------------------------------------------------
OBJS = \
.\$(OBJDIR)\nsFindComponent.obj \
+ .\$(OBJDIR)\nsFindService.obj \
+ .\$(OBJDIR)\nsFindModule.obj \
$(NULL)
#//------------------------------------------------------------------------
View
46 xpfe/components/find/src/nsFindComponent.cpp
@@ -60,6 +60,20 @@
#endif
+/*
+
+ Warning: this code is soon to become obsolete. The Find code has moved
+ into mozilla/embedding/components/find, and is now shared between
+ embedding apps and mozilla.
+
+ This code remains because editor needs its find and replace functionality,
+ for now.
+
+ Simon Fraser sfraser@netscape.com
+
+*/
+
+
nsFindComponent::Context::Context()
{
NS_INIT_REFCNT();
@@ -86,6 +100,9 @@ nsFindComponent::Context::~Context()
}
}
+// nsFindComponent::Context implementation...
+NS_IMPL_ISUPPORTS1( nsFindComponent::Context, nsISearchContext)
+
NS_IMETHODIMP
nsFindComponent::Context::Init( nsIDOMWindowInternal *aWindow,
nsIEditorShell* aEditorShell,
@@ -413,6 +430,22 @@ nsFindComponent::Context::SetReplaceDialog( nsIDOMWindowInternal *aDialog )
#pragma mark -
#endif
+
+/*
+
+ Warning: this code is soon to become obsolete. The Find code has moved
+ into mozilla/embedding/components/find, and is now shared between
+ embedding apps and mozilla.
+
+ This code remains because editor needs its find and replace functionality,
+ for now.
+
+ Simon Fraser sfraser@netscape.com
+
+*/
+
+
+
// ctor
nsFindComponent::nsFindComponent()
: mLastSearchString(),
@@ -703,16 +736,3 @@ nsFindComponent::ResetContext( nsISupports *aContext,
return NS_OK;
}
-// nsFindComponent::Context implementation...
-NS_IMPL_ISUPPORTS1( nsFindComponent::Context, nsISearchContext)
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsFindComponent)
-
-static nsModuleComponentInfo components[] = {
- { NS_IFINDCOMPONENT_CLASSNAME,
- NS_FINDCOMPONENT_CID,
- NS_IFINDCOMPONENT_CONTRACTID,
- nsFindComponentConstructor}
-};
-
-NS_IMPL_NSGETMODULE("nsFindComponent", components)
View
15 xpfe/components/find/src/nsFindComponent.h
@@ -24,6 +24,21 @@
#include "nsCOMPtr.h"
#include "nsIFindAndReplace.h"
+
+/*
+
+ Warning: this code is soon to become obsolete. The Find code has moved
+ into mozilla/embedding/components/find, and is now shared between
+ embedding apps and mozilla.
+
+ This code remains because editor needs its find and replace functionality,
+ for now.
+
+ Simon Fraser sfraser@netscape.com
+
+*/
+
+
class nsITextServicesDocument;
// {4AA267A0-F81D-11d2-8067-00600811A9C3}
View
4 xpfe/global/resources/content/browserBindings.xml
@@ -181,6 +181,10 @@
onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
readonly="true"/>
+ <property name="webBrowserFind"
+ readonly="true"
+ onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);"/>
+
<property name="sessionHistory"
onget="return this.webNavigation.sessionHistory;"
readonly="true"/>
View
3 xpfe/global/resources/content/xulBindings.xml
@@ -574,6 +574,9 @@
<property name="webNavigation"
readonly="true"
onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"/>
+ <property name="webBrowserFind"
+ readonly="true"
+ onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);"/>
<property name="markupDocumentViewer"
readonly="true"
onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"/>

0 comments on commit 44cbfd5

Please sign in to comment.