mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 374862 Port xpfe/components/search/src to frozen linkage. Original patch by Mook, one minor fixup by me,r=Neil,sr=biesi
This commit is contained in:
parent
bf7810b7de
commit
7a32f6e43f
@ -52,14 +52,14 @@ interface nsILocalSearchService : nsISupports
|
||||
{
|
||||
};
|
||||
|
||||
[scriptable, uuid(6bd1d803-1c67-11d3-9820-ed1b357eb3c4)]
|
||||
[scriptable, uuid(a0d28a88-702e-49bd-bee2-929562688ae1)]
|
||||
interface nsIInternetSearchService : nsISupports
|
||||
{
|
||||
// constants set in the whichButtons out param of GetInternetSearchURL()
|
||||
const unsigned short kHaveNext = 1;
|
||||
const unsigned short kHavePrev = 2;
|
||||
|
||||
string GetInternetSearchURL(in string searchEngineURI, in wstring searchStr, in short direction, in unsigned short pageNumber, out unsigned short whichButtons);
|
||||
wstring GetInternetSearchURL(in string searchEngineURI, in wstring searchStr, in short direction, in unsigned short pageNumber, out unsigned short whichButtons);
|
||||
void RememberLastSearchText(in wstring escapedSearchStr);
|
||||
boolean FindInternetSearchResults(in string url);
|
||||
void Stop();
|
||||
|
@ -46,9 +46,8 @@ MODULE = appcomps
|
||||
LIBRARY_NAME = searchservice
|
||||
SHORT_LIBNAME = srchsvc
|
||||
IS_COMPONENT = 1
|
||||
EXPORT_LIBRARY = 1
|
||||
MODULE_NAME = SearchServiceModule
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
@ -73,6 +72,7 @@ endif
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@
|
||||
#define nsinternetsearchdatasource__h____
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringAPI.h"
|
||||
#include "nsISearchService.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIStreamListener.h"
|
||||
@ -143,7 +143,6 @@ protected:
|
||||
PRBool isSearchURI(nsIRDFResource* aResource);
|
||||
PRBool isSearchCategoryURI(nsIRDFResource* aResource);
|
||||
PRBool isSearchCategoryEngineURI(nsIRDFResource* aResource);
|
||||
PRBool isSearchCategoryEngineBasenameURI(nsIRDFNode *aResource);
|
||||
PRBool isSearchCommand(nsIRDFResource* aResource);
|
||||
nsresult resolveSearchCategoryEngineURI(nsIRDFResource *source, nsIRDFResource **trueEngine);
|
||||
nsresult BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest);
|
||||
|
@ -44,10 +44,11 @@
|
||||
#include "nsLocalSearchService.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
@ -59,7 +60,7 @@
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "rdf.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCRTGlue.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kTextToSubURICID, NS_TEXTTOSUBURI_CID);
|
||||
@ -166,7 +167,8 @@ LocalSearchDataSource::GetURI(char **uri)
|
||||
if (! uri)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if ((*uri = nsCRT::strdup("rdf:localsearch")) == nsnull)
|
||||
*uri = ToNewCString(NS_LITERAL_CSTRING("rdf:localsearch"));
|
||||
if (! *uri)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
@ -305,7 +307,8 @@ LocalSearchDataSource::parseResourceIntoFindTokens(nsIRDFResource *u, findTokenP
|
||||
return(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
/* parse ID, build up token list */
|
||||
if ((token = nsCRT::strtok(id, "&", &newstr)) != NULL)
|
||||
newstr = id;
|
||||
if ((token = NS_strtok("&", &newstr)) != NULL)
|
||||
{
|
||||
while (token != NULL)
|
||||
{
|
||||
@ -332,12 +335,12 @@ LocalSearchDataSource::parseResourceIntoFindTokens(nsIRDFResource *u, findTokenP
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyASCIItoUTF16(value, tokens[loop].value);
|
||||
CopyASCIItoUTF16(nsDependentCString(value), tokens[loop].value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
token = nsCRT::strtok(newstr, "&", &newstr);
|
||||
token = NS_strtok("&", &newstr);
|
||||
}
|
||||
}
|
||||
PL_strfree(id);
|
||||
@ -365,50 +368,32 @@ LocalSearchDataSource::doMatch(nsIRDFLiteral *literal,
|
||||
|
||||
if (matchMethod.EqualsLiteral("contains"))
|
||||
{
|
||||
if (FindInReadable(matchText, value,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
if (-1 != value.Find(matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.EqualsLiteral("startswith"))
|
||||
{
|
||||
nsAString::const_iterator start, realstart, end;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
realstart = start;
|
||||
|
||||
if (FindInReadable(matchText, start, end,
|
||||
nsCaseInsensitiveStringComparator()) &&
|
||||
start == realstart)
|
||||
|
||||
if (StringBeginsWith(value, matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.EqualsLiteral("endswith"))
|
||||
{
|
||||
nsAString::const_iterator start, end, realend;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
realend = end;
|
||||
|
||||
if (RFindInReadable(matchText, start, end,
|
||||
nsCaseInsensitiveStringComparator()) &&
|
||||
end == realend)
|
||||
|
||||
if (StringEndsWith(value, matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.EqualsLiteral("is"))
|
||||
{
|
||||
if (value.Equals(matchText, nsCaseInsensitiveStringComparator()))
|
||||
if (value.Equals(matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.EqualsLiteral("isnot"))
|
||||
{
|
||||
if (!value.Equals(matchText, nsCaseInsensitiveStringComparator()))
|
||||
if (!value.Equals(matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
else if (matchMethod.EqualsLiteral("doesntcontain"))
|
||||
{
|
||||
if (!FindInReadable(matchText, value,
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
if (-1 == value.Find(matchText, CaseInsensitiveCompare))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
return(found);
|
||||
@ -445,9 +430,8 @@ LocalSearchDataSource::doIntMatch(nsIRDFInt *aInt,
|
||||
rv = aInt->GetValue(&val);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
PRInt32 error=0;
|
||||
PRInt32 matchVal = matchText.ToInteger(&error);
|
||||
if (error != 0) return PR_FALSE;
|
||||
PRInt32 matchVal = matchText.ToInteger(&rv);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
if (matchMethod.EqualsLiteral("is"))
|
||||
found = (val == matchVal);
|
||||
@ -499,7 +483,7 @@ LocalSearchDataSource::dateMatches(nsIRDFDate *aDate,
|
||||
|
||||
|
||||
NS_METHOD
|
||||
LocalSearchDataSource::parseFindURL(nsIRDFResource *u, nsISupportsArray *array)
|
||||
LocalSearchDataSource::parseFindURL(nsIRDFResource *u, nsIMutableArray *array)
|
||||
{
|
||||
findTokenStruct tokens[5];
|
||||
nsresult rv;
|
||||
@ -590,7 +574,7 @@ LocalSearchDataSource::parseFindURL(nsIRDFResource *u, nsISupportsArray *array)
|
||||
found = matchNode(value, tokens[2].value, tokens[3].value);
|
||||
|
||||
if (found)
|
||||
array->AppendElement(source);
|
||||
array->AppendElement(source, PR_FALSE);
|
||||
}
|
||||
|
||||
if (rv == NS_RDF_CURSOR_EMPTY)
|
||||
@ -626,8 +610,8 @@ NS_METHOD
|
||||
LocalSearchDataSource::getFindResults(nsIRDFResource *source, nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> nameArray;
|
||||
rv = NS_NewISupportsArray( getter_AddRefs(nameArray) );
|
||||
nsCOMPtr<nsIMutableArray> nameArray;
|
||||
nameArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = parseFindURL(source, nameArray);
|
||||
@ -854,12 +838,12 @@ LocalSearchDataSource::ArcLabelsOut(nsIRDFResource *source,
|
||||
|
||||
if (isFindURI(source))
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
rv = NS_NewISupportsArray( getter_AddRefs(array) );
|
||||
nsCOMPtr<nsIMutableArray> array;
|
||||
array = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
array->AppendElement(kNC_Child);
|
||||
array->AppendElement(kNC_pulse);
|
||||
array->AppendElement(kNC_Child, PR_FALSE);
|
||||
array->AppendElement(kNC_pulse, PR_FALSE);
|
||||
|
||||
return NS_NewArrayEnumerator(labels, array);
|
||||
}
|
||||
|
@ -38,10 +38,10 @@
|
||||
#ifndef localsearchdb___h_____
|
||||
#define localsearchdb___h_____
|
||||
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringAPI.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsISearchService.h"
|
||||
@ -94,7 +94,7 @@ protected:
|
||||
|
||||
NS_METHOD parseDate(const nsAString& aDate, PRInt64* aResult);
|
||||
|
||||
NS_METHOD parseFindURL(nsIRDFResource *u, nsISupportsArray *array);
|
||||
NS_METHOD parseFindURL(nsIRDFResource *u, nsIMutableArray *array);
|
||||
|
||||
public:
|
||||
LocalSearchDataSource(void);
|
||||
|
Loading…
Reference in New Issue
Block a user