Bug 30088. Type ahead find feature (extension). See bug for the prefs that need to be set for it to work. Not part of build

This commit is contained in:
aaronl%netscape.com 2002-07-09 00:13:13 +00:00
Родитель aa123cc99c
Коммит 0ea947c109
9 изменённых файлов: 1725 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,79 @@
# 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 Initial Developer of the Original Code is Aaron Leventhal.
# Portions created by Aaron Leventhal are Copyright (C) 2001
# Aaron Leventhal. All Rights Reserved.
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above. If you
# wish to allow use of your version of this file only under the terms of
# the GPL and not to allow others to use your version of this file under
# the MPL, indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by the
# GPL. If you do not delete the provisions above, a recipient may use
# your version of this file under either the MPL or the GPL.
# Contributor(s):
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = typeaheadfind
LIBRARY_NAME = typeaheadfind
ifneq ($(OS_ARCH),WINNT)
SHORT_LIBNAME = typahead
endif
REQUIRES = appcomps \
embedcomponents \
content \
docshell \
dom \
find \
intl \
gfx \
layout \
locale \
mozcomps \
necko \
pref \
string \
unicharutil \
uriloader \
view \
webBrowser_core \
webshell \
widget \
xpcom \
webbrwsr \
$(NULL)
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsTypeAheadFind
XPIDLSRCS= ./nsITypeAheadFind.idl \
$(NULL)
CPPSRCS = \
nsTypeAheadFind.cpp \
nsTypeAheadFindRegistration.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)

Просмотреть файл

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributors:
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gVersion = "0.1";
var err = initInstall("Type Ahead Find", "/Netscape/Type Ahead Find", gVersion);
logComment("initInstall: " + err);
var fProgram = getFolder("Program");
var fComponents = getFolder("Components");
// var fChrome = getFolder("Chrome");
// addDirectory: blank, archive_dir, install_dir, subdir
err = addDirectory("", "bin", fProgram, "");
if (err != SUCCESS)
cancelInstall(err);
err = addDirectory("", "components", fComponents, "");
if (err != SUCCESS)
cancelInstall(err);
err = addDirectory("", "chrome", fChrome, "");
if (err != SUCCESS)
cancelInstall(err);
// Register chrome
registerChrome(PACKAGE | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "content/typeaheadfind/");
registerChrome(SKIN | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "skin/modern/typeaheadfind/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder("Chrome","typeaheadfind.jar"), "locale/en-US/typeaheadfind/");
if (getLastError() == SUCCESS) {
err = performInstall();
logComment("performInstall: " + err);
} else {
cancelInstall(err);
}

Просмотреть файл

@ -0,0 +1,9 @@
en-win.jar:
locale/en-US/global-platform/typeaheadfind.properties
en-unix.jar:
locale/en-US/global-platform/typeaheadfind.properties
en-mac.jar:
locale/en-US/global-platform/typeaheadfind.properties

Просмотреть файл

@ -0,0 +1,82 @@
#!gmake
# 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 Initial Developer of the Original Code is Aaron Leventhal.
# Portions created by Aaron Leventhal are Copyright (C) 2001
# Aaron Leventhal. All Rights Reserved.
# Alternatively, the contents of this file may be used under the terms
# of the GNU General Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above. If you
# wish to allow use of your version of this file only under the terms of
# the GPL and not to allow others to use your version of this file under
# the MPL, indicate your decision by deleting the provisions above and
# replace them with the notice and other provisions required by the
# GPL. If you do not delete the provisions above, a recipient may use
# your version of this file under either the MPL or the GPL.
# Contributor(s):
DEPTH=..\..
MODULE = typeaheadfind
XPIDL_MODULE = typeaheadfind
LIBRARY_NAME = typeaheadfind
MODULE_NAME = nsTypeAheadFind
REQUIRES = appcomps \
appstartup \
content \
docshell \
dom \
find \
intl \
gfx \
layout \
locale \
mozcomps \
necko \
pref \
string \
unicharutil \
uriloader \
view \
webBrowser_core \
webshell \
widget \
xpcom \
$(NULL)
XPIDLSRCS= .\nsITypeAheadFind.idl \
$(NULL)
CPP_OBJS=\
.\$(OBJDIR)\nsTypeAheadFind.obj \
.\$(OBJDIR)\nsTypeAheadFindRegistration.obj \
$(NULL)
LLIBS=\
$(DIST)\lib\xpcom.lib \
$(LIBPLC) \
$(LIBNSPR) \
$(DIST)\lib\gkgfx.lib \
$(DIST)\lib\unicharutil_s.lib \
$(DIST)\lib\contentshared_s.lib \
$(DIST)\lib\raptorwidget_s.lib \
$(NULL)
LINCS=\
-I$(PUBLIC)\typeaheadfind \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributors:
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "domstubs.idl"
%{ C++
#include "nsIDOMEvent.h"
#define NS_TYPEAHEADFIND_CID \
{ 0x46590685, 0xbc00, 0x4aac, { 0xab, 0xed, 0x2c, 0x10, 0xa5, 0xb9, 0x45, 0xa4 } }
#define NS_TYPEAHEADFIND_CONTRACTID "@mozilla.org/typeaheadfind;1"
%}
interface nsIDOMEvent;
[uuid(AD1C62CC-72F4-4c5b-BE78-503854F9E0D8)]
interface nsITypeAheadFind : nsISupports
{
void handleEvent(in nsIDOMEvent event);
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,167 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributors:
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMEventListener.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIWebProgressListener.h"
#include "nsIScrollPositionListener.h"
#include "nsISelectionListener.h"
#include "nsITimerCallback.h"
#include "nsITimer.h"
#include "nsUnicharUtils.h"
#include "nsIFindService.h"
#include "nsIFind.h"
#include "nsWeakReference.h"
#include "nsIAppStartupNotifier.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
#include "nsISelection.h"
#include "nsIDOMRange.h"
#include "nsIDOMWindow.h"
#include "nsITypeAheadFind.h"
#include "nsIStringBundle.h"
#define TYPEAHEADFIND_BUNDLE_URL "chrome://global-platform/locale/typeaheadfind.properties"
class nsTypeAheadFind : public nsIDOMFocusListener,
public nsIDOMKeyListener,
public nsIDOMLoadListener,
public nsIWebProgressListener,
public nsIScrollPositionListener,
public nsISelectionListener,
public nsITimerCallback,
public nsSupportsWeakReference
{
public:
nsTypeAheadFind();
virtual ~nsTypeAheadFind();
NS_DEFINE_STATIC_CID_ACCESSOR(NS_TYPEAHEADFIND_CID);
NS_DECL_ISUPPORTS // This macro expands into declaration of nsISupports interface
NS_DECL_NSIWEBPROGRESSLISTENER
// ----- nsIDOMEventListener --------------------------
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
// ----- nsIDOMFocusListener --------------------------
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
// ----- nsIDOMKeyListener ----------------------------
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
// ----- nsIDOMLoadListener ----------------------------
NS_IMETHOD Load(nsIDOMEvent* aEvent);
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
NS_IMETHOD Error(nsIDOMEvent* aEvent);
// ----- nsIScrollPositionListener --------------------
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
// ----- nsISelectionListener -------------------------
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason);
// ----- nsITimerCallback ------------------------------------
NS_IMETHOD_(void) Notify(nsITimer *timer);
static nsTypeAheadFind *GetInstance();
static void ReleaseInstance(void);
protected:
static int PR_CALLBACK TypeAheadFindPrefCallback(const char* aPrefName, void* instance_data);
// Helper methods
void AttachNewSelectionListener();
void RemoveCurrentSelectionListener();
void AttachNewScrollPositionListener(nsIPresShell *aPresShell);
void RemoveCurrentScrollPositionListener();
void AttachNewKeypressListener(nsIDOMEventTarget *aTarget);
void RemoveCurrentKeypressListener();
void AttachNewWindowFocusListener(nsIDOMEventTarget *aTarget);
void RemoveCurrentWindowFocusListener();
void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell,
PRBool *aIsInsideLink, PRBool *aIsStartingLink);
void GetSelection(nsIPresShell *aPresShell, // If aCurrentNode is nsnull, gets selection for document
nsIDOMNode *aCurrentNode, nsISelection **aDomSel);
void CancelFind();
PRBool IsRangeVisible(nsIPresShell *aPresShell, nsIPresContext *aPresContext,
nsIDOMRange *aRange, PRBool aMustBeVisible, nsIDOMRange **aNewRange);
void FindItNow(PRBool aIsLinksOnly, PRBool aIsFirstVisiblePreferred, PRBool aIsBackspace);
void DisplayStatus(PRBool aSuccess, PRBool aClearStatus);
nsresult GetTranslatedString(const nsAString& aKey, nsAString& aStringOut);
// Used by GetInstance and ReleaseInstance
static nsTypeAheadFind *mInstance;
// Current find state
nsString mTypeAheadBuffer;
PRBool mLinksOnlyPref, mLinksOnly, mErrorBeepsPref, mIsTypeAheadOn;
PRBool mCaretBrowsingOn;
PRBool mIsRepeatingSameChar;
PRBool mKeepSelectionOnCancel;
PRInt32 mTimeoutLength; // Amount of time before find is automatically cancelled
static PRBool gIsFindingText; // this flag prevents side effects from listener callbacks while selecting/focusing found text
nsCOMPtr<nsIDOMRange> mStartFindRange; // where selection was when user started the find
#ifdef RESTORE_SEARCH
// Old nsIFindService state
nsString mOldSearchString;
PRBool mOldWrapSetting, mOldCaseSetting, mOldWordSetting, mOldDirectionSetting;
#endif
// Cached useful interfaces
nsCOMPtr<nsIFind> mFind;
nsCOMPtr<nsIFindService> mFindService;
nsCOMPtr<nsIStringBundle> mStringBundle;
nsCOMPtr<nsITimer> mTimer;
// The current content window that we're listening to and it's cached objects
nsCOMPtr<nsISelection> mDocSelection;
nsCOMPtr<nsIDOMWindow> mCurrentWindow;
nsCOMPtr<nsIWeakReference> mWeakShell;
};

Просмотреть файл

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.com)
* Contributors:
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsTypeAheadFind.h"
#include "nsIServiceManager.h"
#include "nsIRegistry.h"
#include "prprf.h"
#include "nsCRT.h"
#include "nsICategoryManager.h"
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
// information like the function to create an instance, contractid, and
// class name.
//
// The Registration and Unregistration proc are optional in the structure.
//
// This function is called at component registration time
static NS_METHOD nsTypeAheadFindRegistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath, const char *registryLocation, const char *componentType,
const nsModuleComponentInfo *info)
{
// This function performs the extra step of installing us as
// an application component. This makes sure that we're
// initialized on application startup.
return NS_OK;
/*
// We used to be called on app startup via nsIObserver::Observe interface
// Now we use a pref callback to initialize ourselves
nsresult rv;
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "Type Ahead Find",
"service," NS_TYPEAHEADFIND_CONTRACTID, PR_TRUE, PR_TRUE, nsnull);
return rv;
*/
}
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsTypeAheadFind,nsTypeAheadFind::GetInstance);
static void PR_CALLBACK TypeAheadFindModuleDtor(nsIModule* self)
{
nsTypeAheadFind::ReleaseInstance();
}
static const nsModuleComponentInfo components[] =
{
{ "TypeAheadFind Component", NS_TYPEAHEADFIND_CID, NS_TYPEAHEADFIND_CONTRACTID,
nsTypeAheadFindConstructor, nsTypeAheadFindRegistrationProc,
nsnull // Unregistration proc
}
};
NS_IMPL_NSGETMODULE_WITH_DTOR(nsTypeAheadFind, components, TypeAheadFindModuleDtor)

Просмотреть файл

@ -0,0 +1,6 @@
textfound = Text found: "
textnotfound = Text not found: "
linkfound = Link found: "
linknotfound = Link not found: "
closequote = "
stopfind = Type ahead find stopped.