aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--embed/mozilla/EphyBrowser.cpp7
-rw-r--r--embed/mozilla/EventContext.cpp106
-rw-r--r--embed/mozilla/nsUnicharUtils.cpp344
-rw-r--r--embed/mozilla/nsUnicharUtils.h100
5 files changed, 57 insertions, 511 deletions
diff --git a/ChangeLog b/ChangeLog
index f7d19d9de..84de34dfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2004-02-20 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/mozilla/EventContext.cpp:
+ * embed/mozilla/EphyBrowser.cpp:
+ R embed/mozilla/nsUnicharUtils.h:
+ R embed/mozilla/nsUnicharUtils.cpp:
+
+ Adapt to changed mozilla string APIs by getting rid of
+ nsUnicharUtils, and using EqualsIgnoreCase instead of
+ Equal with nsCaseInsensitiveStringComparator().
+
2004-02-20 Marco Pesenti Gritti <marco@gnome.org>
* src/ephy-completion-model.c: (is_base_address),
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 6f1cf7599..1fea9d6fc 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -81,7 +81,6 @@
#include "nsIDocumentCharsetInfo.h"
#include "nsPromiseFlatString.h"
#include "nsString.h"
-#include "nsUnicharUtils.h"
#include "ContentHandler.h"
EphyEventListener::EphyEventListener(void)
@@ -116,10 +115,8 @@ EphyFaviconEventListener::HandleFaviconLink (nsIDOMNode *node)
result = linkElement->GetAttribute (attr_rel, value);
if (NS_FAILED (result)) return NS_ERROR_FAILURE;
- if (value.Equals(NS_LITERAL_STRING("SHORTCUT ICON"),
- nsCaseInsensitiveStringComparator()) ||
- value.Equals(NS_LITERAL_STRING("ICON"),
- nsCaseInsensitiveStringComparator()))
+ if (value.EqualsIgnoreCase("SHORTCUT ICON") ||
+ value.EqualsIgnoreCase("ICON"))
{
NS_NAMED_LITERAL_STRING(attr_href, "href");
nsAutoString value;
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index d9b24943c..881652d8b 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2000-2003 Marco Pesenti Gritti
- *
+ * Copyright (C) 2000-2004 Marco Pesenti Gritti
+ * Copyright (C) 2003, 2004 Christian Persch
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -35,7 +35,6 @@
#include "nsNetUtil.h"
#include "nsIDOMNSDocument.h"
#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
#include "nsGUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMCharacterData.h"
@@ -235,8 +234,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
rv = element->GetTagName(tag);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
- if (tag.Equals(NS_LITERAL_STRING("img"),
- nsCaseInsensitiveStringComparator()))
+ if (tag.EqualsIgnoreCase("img"))
{
info->context |= EMBED_CONTEXT_IMAGE;
@@ -278,8 +276,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
img);
}
}
- else if (tag.Equals(NS_LITERAL_STRING("input"),
- nsCaseInsensitiveStringComparator()))
+ else if (tag.EqualsIgnoreCase("input"))
{
nsCOMPtr<nsIDOMElement> element;
element = do_QueryInterface (node);
@@ -289,8 +286,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
nsAutoString value;
element->GetAttribute (attr, value);
- if (value.Equals(NS_LITERAL_STRING("image"),
- nsCaseInsensitiveStringComparator()))
+ if (value.EqualsIgnoreCase("image"))
{
info->context |= EMBED_CONTEXT_IMAGE;
nsCOMPtr<nsIDOMHTMLInputElement> input;
@@ -307,29 +303,21 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
SetStringProperty ("image",
NS_ConvertUTF8toUCS2(cImg));
}
- else if (!value.Equals(NS_LITERAL_STRING("radio"),
- nsCaseInsensitiveStringComparator()) &&
- !value.Equals(NS_LITERAL_STRING("submit"),
- nsCaseInsensitiveStringComparator()) &&
- !value.Equals(NS_LITERAL_STRING("reset"),
- nsCaseInsensitiveStringComparator()) &&
- !value.Equals(NS_LITERAL_STRING("hidden"),
- nsCaseInsensitiveStringComparator()) &&
- !value.Equals(NS_LITERAL_STRING("button"),
- nsCaseInsensitiveStringComparator()) &&
- !value.Equals(NS_LITERAL_STRING("checkbox"),
- nsCaseInsensitiveStringComparator()))
+ else if (!value.EqualsIgnoreCase("radio") &&
+ !value.EqualsIgnoreCase("submit") &&
+ !value.EqualsIgnoreCase("reset") &&
+ !value.EqualsIgnoreCase("hidden") &&
+ !value.EqualsIgnoreCase("button") &&
+ !value.EqualsIgnoreCase("checkbox"))
{
info->context |= EMBED_CONTEXT_INPUT;
}
}
- else if (tag.Equals(NS_LITERAL_STRING("textarea"),
- nsCaseInsensitiveStringComparator()))
+ else if (tag.EqualsIgnoreCase("textarea"))
{
info->context |= EMBED_CONTEXT_INPUT;
}
- else if (tag.Equals(NS_LITERAL_STRING("object"),
- nsCaseInsensitiveStringComparator()))
+ else if (tag.EqualsIgnoreCase("object"))
{
nsCOMPtr<nsIDOMHTMLObjectElement> object;
object = do_QueryInterface (node);
@@ -338,11 +326,8 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
nsAutoString value;
object->GetType(value);
- //Forming a substring and confirming it's contents
- //is quicker than doing a Find on the full string
- //and then checking that "image/" is at the beginning
- if (Substring(value, 0, 6).Equals(NS_LITERAL_STRING("image/"),
- nsCaseInsensitiveStringComparator()))
+ // MIME types are always lower case
+ if (Substring (value, 0, 6).Equals(NS_LITERAL_STRING("image/")))
{
info->context |= EMBED_CONTEXT_IMAGE;
@@ -382,8 +367,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
nsAutoString value;
dom_elem->GetAttributeNS (nspace, localname_type, value);
- if (value.Equals(NS_LITERAL_STRING("simple"),
- nsCaseInsensitiveStringComparator()))
+ if (value.EqualsIgnoreCase("simple"))
{
info->context |= EMBED_CONTEXT_LINK;
NS_NAMED_LITERAL_STRING (localname_href, "href");
@@ -406,8 +390,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
/* Link */
- if (tag.Equals(NS_LITERAL_STRING("a"),
- nsCaseInsensitiveStringComparator()))
+ if (tag.EqualsIgnoreCase("a"))
{
nsAutoString tmp;
@@ -421,8 +404,16 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
- if (Substring(tmp, 0, 7).Equals(NS_LITERAL_STRING("mailto:"),
- nsCaseInsensitiveStringComparator()))
+ nsCOMPtr<nsIURI> uri;
+ NS_NewURI (getter_AddRefs (uri), tmp);
+ if (!uri) return NS_ERROR_FAILURE;
+
+ nsresult rv;
+ nsCAutoString scheme;
+ rv = uri->GetScheme (scheme);
+ if (NS_FAILED (rv)) return NS_ERROR_FAILURE;
+
+ if (scheme.EqualsIgnoreCase("mailto"))
{
info->context |= EMBED_CONTEXT_EMAIL_LINK;
const nsAString &address = Substring(tmp, 7, tmp.Length()-7);
@@ -454,8 +445,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
if (NS_SUCCEEDED(rv))
SetStringProperty ("link_type", tmp);
- if (tmp.Equals(NS_LITERAL_STRING("text/smartbookmark"),
- nsCaseInsensitiveStringComparator()))
+ if (tmp.EqualsIgnoreCase("text/smartbookmark"))
{
SetIntProperty ("link_is_smart", TRUE);
@@ -484,14 +474,12 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
}
}
- else if (tag.Equals(NS_LITERAL_STRING("option"),
- nsCaseInsensitiveStringComparator()))
+ else if (tag.EqualsIgnoreCase("option"))
{
info->context = EMBED_CONTEXT_NONE;
return NS_OK;
}
- if (tag.Equals(NS_LITERAL_STRING("area"),
- nsCaseInsensitiveStringComparator()))
+ if (tag.EqualsIgnoreCase("area"))
{
info->context |= EMBED_CONTEXT_LINK;
nsCOMPtr <nsIDOMHTMLAreaElement> area =
@@ -507,10 +495,8 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
CheckLinkScheme (href);
}
}
- else if (tag.Equals(NS_LITERAL_STRING("textarea"),
- nsCaseInsensitiveStringComparator()) ||
- tag.Equals(NS_LITERAL_STRING("input"),
- nsCaseInsensitiveStringComparator()))
+ else if (tag.EqualsIgnoreCase("textarea") ||
+ tag.EqualsIgnoreCase("input"))
{
info->context |= EMBED_CONTEXT_INPUT;
}
@@ -674,16 +660,11 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, Mozilla
nsAutoString nodename;
OriginalNode->GetNodeName(nodename);
- if (nodename.Equals(NS_LITERAL_STRING("xul:scrollbarbutton"),
- nsCaseInsensitiveStringComparator()) ||
- nodename.Equals(NS_LITERAL_STRING("xul:thumb"),
- nsCaseInsensitiveStringComparator()) ||
- nodename.Equals(NS_LITERAL_STRING("xul:vbox"),
- nsCaseInsensitiveStringComparator()) ||
- nodename.Equals(NS_LITERAL_STRING("xul:spacer"),
- nsCaseInsensitiveStringComparator()) ||
- nodename.Equals(NS_LITERAL_STRING("xul:slider"),
- nsCaseInsensitiveStringComparator()))
+ if (nodename.EqualsIgnoreCase("xul:scrollbarbutton") ||
+ nodename.EqualsIgnoreCase("xul:thumb") ||
+ nodename.EqualsIgnoreCase("xul:vbox") ||
+ nodename.EqualsIgnoreCase("xul:spacer") ||
+ nodename.EqualsIgnoreCase("xul:slider"))
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMEventTarget> EventTarget;
@@ -813,12 +794,13 @@ nsresult EventContext::CheckLinkScheme (const nsAString &link)
rv = uri->GetScheme (scheme);
if (NS_FAILED (rv)) return NS_ERROR_FAILURE;
- if (scheme.EqualsIgnoreCase ("http") ||
- scheme.EqualsIgnoreCase ("https") ||
- scheme.EqualsIgnoreCase ("ftp") ||
- scheme.EqualsIgnoreCase ("file") ||
- scheme.EqualsIgnoreCase ("data") ||
- scheme.EqualsIgnoreCase ("about") ||
+ if (scheme.EqualsIgnoreCase ("http") ||
+ scheme.EqualsIgnoreCase ("https") ||
+ scheme.EqualsIgnoreCase ("ftp") ||
+ scheme.EqualsIgnoreCase ("file") ||
+ scheme.EqualsIgnoreCase ("data") ||
+ scheme.EqualsIgnoreCase ("resource") ||
+ scheme.EqualsIgnoreCase ("about") ||
scheme.EqualsIgnoreCase ("gopher"))
{
SetIntProperty ("link-has-web-scheme", TRUE);
diff --git a/embed/mozilla/nsUnicharUtils.cpp b/embed/mozilla/nsUnicharUtils.cpp
deleted file mode 100644
index ce469250a..000000000
--- a/embed/mozilla/nsUnicharUtils.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * 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 Unicode case conversion helpers.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corp..
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Alec Flett <alecf@netscape.com>
- *
- * 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 MPL, 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 MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsString.h"
-#include "nsUnicharUtils.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtilCIID.h"
-#include "nsICaseConversion.h"
-#include "nsIServiceManager.h"
-#include "nsCRT.h"
-
-#include "nsIObserver.h"
-#include "nsIObserverService.h"
-
-// global cache of the case conversion service
-static nsICaseConversion *gCaseConv = nsnull;
-
-class nsShutdownObserver : public nsIObserver
-{
-public:
- nsShutdownObserver() { }
- virtual ~nsShutdownObserver() {}
- NS_DECL_ISUPPORTS
-
- NS_IMETHOD Observe(nsISupports *aSubject, const char *aTopic,
- const PRUnichar *aData)
- {
- if (nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)==0) {
- NS_IF_RELEASE(gCaseConv);
- }
-
- return NS_OK;
- }
-
-};
-
-NS_IMPL_ISUPPORTS1(nsShutdownObserver, nsIObserver)
-
-static nsresult NS_InitCaseConversion() {
- if (gCaseConv) return NS_OK;
-
- nsresult rv;
-
- rv = CallGetService(NS_UNICHARUTIL_CONTRACTID, &gCaseConv);
-
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsIObserverService> obs =
- do_GetService("@mozilla.org/observer-service;1", &rv);
- if (NS_SUCCEEDED(rv)) {
- nsShutdownObserver *observer = new nsShutdownObserver();
- if (observer)
- obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
- }
- }
-
- return NS_OK;
-}
-
-class ConvertToLowerCase
-{
-public:
- typedef PRUnichar value_type;
-
- ConvertToLowerCase()
- {
- NS_InitCaseConversion();
- }
-
- PRUint32 write( const PRUnichar* aSource, PRUint32 aSourceLength)
- {
- if (gCaseConv)
- gCaseConv->ToLower(aSource, NS_CONST_CAST(PRUnichar*,aSource), aSourceLength);
- else
- NS_WARNING("No case converter: no conversion done");
-
- return aSourceLength;
- }
-};
-
-void
-ToLowerCase( nsAString& aString )
- {
- nsAString::iterator fromBegin, fromEnd;
- ConvertToLowerCase converter;
- copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
- }
-
-void
-ToLowerCase( nsASingleFragmentString& aString )
- {
- ConvertToLowerCase converter;
- PRUnichar* start;
- converter.write(aString.BeginWriting(start), aString.Length());
- }
-
-void
-ToLowerCase( nsString& aString )
- {
- ConvertToLowerCase converter;
- converter.write(aString.mUStr, aString.mLength);
- }
-
-class CopyToLowerCase
- {
- public:
- typedef PRUnichar value_type;
-
- CopyToLowerCase( nsAString::iterator& aDestIter )
- : mIter(aDestIter)
- {
- NS_InitCaseConversion();
- }
-
- PRUint32 write( const PRUnichar* aSource, PRUint32 aSourceLength )
- {
- PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength);
- PRUnichar* dest = NS_CONST_CAST(PRUnichar*, mIter.get());
- if (gCaseConv)
- gCaseConv->ToLower(aSource, dest, len);
- else {
- NS_WARNING("No case converter: only copying");
- memcpy((void*)aSource, (void*)dest, len * sizeof(*aSource));
- }
- mIter.advance(len);
- return len;
- }
-
- protected:
- nsAString::iterator& mIter;
- };
-
-void
-ToLowerCase( const nsAString& aSource, nsAString& aDest )
- {
- nsAString::const_iterator fromBegin, fromEnd;
- nsAString::iterator toBegin;
- aDest.SetLength(aSource.Length());
- CopyToLowerCase converter(aDest.BeginWriting(toBegin));
- copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
- }
-
-class ConvertToUpperCase
-{
-public:
- typedef PRUnichar value_type;
-
- ConvertToUpperCase()
- {
- NS_InitCaseConversion();
- }
-
- PRUint32 write( const PRUnichar* aSource, PRUint32 aSourceLength)
- {
- if (gCaseConv)
- gCaseConv->ToUpper(aSource, NS_CONST_CAST(PRUnichar*,aSource), aSourceLength);
- else
- NS_WARNING("No case converter: no conversion done");
-
- return aSourceLength;
- }
-};
-
-void
-ToUpperCase( nsAString& aString )
- {
- nsAString::iterator fromBegin, fromEnd;
- ConvertToUpperCase converter;
- copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
- }
-
-void
-ToUpperCase( nsASingleFragmentString& aString )
- {
- ConvertToUpperCase converter;
- PRUnichar* start;
- converter.write(aString.BeginWriting(start), aString.Length());
- }
-
-void
-ToUpperCase( nsString& aString )
- {
- ConvertToUpperCase converter;
- converter.write(aString.mUStr, aString.mLength);
- }
-
-class CopyToUpperCase
- {
- public:
- typedef PRUnichar value_type;
-
- CopyToUpperCase( nsAString::iterator& aDestIter )
- : mIter(aDestIter)
- {
- NS_InitCaseConversion();
- }
-
- PRUint32 write( const PRUnichar* aSource, PRUint32 aSourceLength )
- {
- PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength);
- PRUnichar* dest = NS_CONST_CAST(PRUnichar*, mIter.get());
- if (gCaseConv)
- gCaseConv->ToUpper(aSource, dest, len);
- else {
- NS_WARNING("No case converter: only copying");
- memcpy((void*)aSource, (void*)dest, len * sizeof(*aSource));
- }
- mIter.advance(len);
- return len;
- }
-
- protected:
- nsAString::iterator& mIter;
- };
-
-void
-ToUpperCase( const nsAString& aSource, nsAString& aDest )
- {
- nsAString::const_iterator fromBegin, fromEnd;
- nsAString::iterator toBegin;
- aDest.SetLength(aSource.Length());
- CopyToUpperCase converter(aDest.BeginWriting(toBegin));
- copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
- }
-
-PRBool
-CaseInsensitiveFindInReadable( const nsAString& aPattern, nsAString::const_iterator& aSearchStart, nsAString::const_iterator& aSearchEnd )
-{
- return FindInReadable(aPattern, aSearchStart, aSearchEnd, nsCaseInsensitiveStringComparator());
-}
-
-
-int
-nsCaseInsensitiveStringComparator::operator()( const PRUnichar* lhs, const PRUnichar* rhs, PRUint32 aLength ) const
- {
- NS_InitCaseConversion();
- PRInt32 result;
- if (gCaseConv) {
- gCaseConv->CaseInsensitiveCompare(lhs, rhs, aLength, &result);
- }
- else {
- NS_WARNING("No case converter: using default");
- nsDefaultStringComparator comparator;
- result = comparator(lhs, rhs, aLength);
- }
- return result;
- }
-
-int
-nsCaseInsensitiveStringComparator::operator()( PRUnichar lhs, PRUnichar rhs ) const
- {
- // see if they're an exact match first
- if (lhs == rhs) return 0;
-
- NS_InitCaseConversion();
-
- if (gCaseConv) {
- gCaseConv->ToLower(lhs, &lhs);
- gCaseConv->ToLower(rhs, &rhs);
- } else {
- if (lhs < 256)
- lhs = tolower(char(lhs));
- if (rhs < 256)
- rhs = tolower(char(rhs));
- NS_WARNING("No case converter: no conversion done");
- }
-
- if (lhs == rhs) return 0;
- if (lhs < rhs) return -1;
- return 1;
- }
-
-PRUnichar
-ToLowerCase(PRUnichar aChar)
-{
- PRUnichar result;
- if (NS_FAILED(NS_InitCaseConversion()))
- return aChar;
-
- if (gCaseConv)
- gCaseConv->ToLower(aChar, &result);
- else {
- NS_WARNING("No case converter: no conversion done");
- if (aChar < 256)
- result = tolower(char(aChar));
- else
- result = aChar;
- }
- return result;
-}
-
-PRUnichar
-ToUpperCase(PRUnichar aChar)
-{
- PRUnichar result;
- if (NS_FAILED(NS_InitCaseConversion()))
- return aChar;
-
- if (gCaseConv)
- gCaseConv->ToUpper(aChar, &result);
- else {
- NS_WARNING("No case converter: no conversion done");
- if (aChar < 256)
- result = toupper(char(aChar));
- else
- result = aChar;
- }
- return result;
-}
-
diff --git a/embed/mozilla/nsUnicharUtils.h b/embed/mozilla/nsUnicharUtils.h
deleted file mode 100644
index 17b3f4666..000000000
--- a/embed/mozilla/nsUnicharUtils.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * 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 Unicode case conversion helpers.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corp..
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Alec Flett <alecf@netscape.com>
- *
- * 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 MPL, 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 MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsUnicharUtils_h__
-#define nsUnicharUtils_h__
-#ifndef nsAString_h___
-#include "nsAString.h"
-#endif
-
-class nsASingleFragmentString;
-class nsString;
-
-void ToLowerCase( nsAString& );
-void ToUpperCase( nsAString& );
-
-void ToLowerCase( nsASingleFragmentString& );
-void ToUpperCase( nsASingleFragmentString& );
-
-void ToLowerCase( nsString& );
-void ToUpperCase( nsString& );
-
-void ToLowerCase( const nsAString& aSource, nsAString& aDest );
-void ToUpperCase( const nsAString& aSource, nsAString& aDest );
-
-PRBool CaseInsensitiveFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator& );
-
-class nsCaseInsensitiveStringComparator
- : public nsStringComparator
- {
- public:
- virtual int operator()( const PRUnichar*, const PRUnichar*, PRUint32 aLength ) const;
- virtual int operator()( PRUnichar, PRUnichar ) const;
- };
-
-
-PRUnichar ToUpperCase(PRUnichar);
-PRUnichar ToLowerCase(PRUnichar);
-
-inline PRBool IsUpperCase(PRUnichar c) {
- return ToLowerCase(c) != c;
-}
-
-inline PRBool IsLowerCase(PRUnichar c) {
- return ToUpperCase(c) != c;
-}
-
-#define IS_HIGH_SURROGATE(u) ((PRUnichar)(u) >= (PRUnichar)0xd800 && (PRUnichar)(u) <= (PRUnichar)0xdbff)
-#define IS_LOW_SURROGATE(u) ((PRUnichar)(u) >= (PRUnichar)0xdc00 && (PRUnichar)(u) <= (PRUnichar)0xdfff)
-
-#define SURROGATE_TO_UCS4(h, l) ((((PRUint32)(h)-(PRUint32)0xd800) << 10) + \
- (PRUint32)(l) - (PRUint32)(0xdc00) + 0x10000)
-
-#define H_SURROGATE(s) ((PRUnichar)(((PRUint32)s - (PRUint32)0x10000) >> 10) + (PRUnichar)0xd800)
-#define L_SURROGATE(s) ((PRUnichar)(((PRUint32)s - (PRUint32)0x10000) & 0x3ff) + (PRUnichar)0xdc00)
-#define IS_IN_BMP(ucs) ((PRUint32)ucs < 0x10000)
-
-/* (0x3131u <= (u) && (u) <= 0x318eu) => Hangul Compatibility Jamo */
-/* (0xac00u <= (u) && (u) <= 0xd7a3u) => Hangul Syllables */
-#define IS_CJ_CHAR(u) \
- ((0x2e80u <= (u) && (u) <= 0x312fu) || \
- (0x3190u <= (u) && (u) <= 0xabffu) || \
- (0xf900u <= (u) && (u) <= 0xfaffu) || \
- (0xff00u <= (u) && (u) <= 0xffefu) )
-
-#endif /* nsUnicharUtils_h__ */