зеркало из https://github.com/mozilla/gecko-dev.git
backout changeset e1eac54b1ed3 (bug 655337 pt 2) for causing a leak.
This commit is contained in:
Родитель
7c4480f429
Коммит
ebe169a362
|
@ -606,6 +606,16 @@ abstract public class GeckoApp
|
|||
unpackFile(zip, buf, entry, entry.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// copy any hyphenation dictionaries file into a hyphenation/ directory
|
||||
Enumeration<? extends ZipEntry> hyphenEntries = zip.entries();
|
||||
while (hyphenEntries.hasMoreElements()) {
|
||||
ZipEntry entry = hyphenEntries.nextElement();
|
||||
if (entry.getName().startsWith("hyphenation/")) {
|
||||
Log.i("GeckoAppJava", "installing hyphenation : " + entry.getName());
|
||||
unpackFile(zip, buf, entry, entry.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeFiles() throws IOException {
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "mozilla/Omnijar.h"
|
||||
|
||||
class nsHyphenator;
|
||||
class nsIAtom;
|
||||
|
@ -63,7 +62,6 @@ private:
|
|||
|
||||
protected:
|
||||
void LoadPatternList();
|
||||
void LoadPatternListFromOmnijar(mozilla::Omnijar::Type aType);
|
||||
void LoadPatternListFromDir(nsIFile *aDir);
|
||||
void LoadAliases();
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsZipArchive.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -143,17 +142,15 @@ nsHyphenationManager::LoadPatternList()
|
|||
{
|
||||
mPatternFiles.Clear();
|
||||
mHyphenators.Clear();
|
||||
|
||||
LoadPatternListFromOmnijar(Omnijar::GRE);
|
||||
LoadPatternListFromOmnijar(Omnijar::APP);
|
||||
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIProperties> dirSvc =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
||||
if (!dirSvc) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> greDir;
|
||||
rv = dirSvc->Get(NS_GRE_DIR,
|
||||
NS_GET_IID(nsIFile), getter_AddRefs(greDir));
|
||||
|
@ -161,7 +158,7 @@ nsHyphenationManager::LoadPatternList()
|
|||
greDir->AppendNative(NS_LITERAL_CSTRING("hyphenation"));
|
||||
LoadPatternListFromDir(greDir);
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIFile> appDir;
|
||||
rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile), getter_AddRefs(appDir));
|
||||
|
@ -174,70 +171,17 @@ nsHyphenationManager::LoadPatternList()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHyphenationManager::LoadPatternListFromOmnijar(Omnijar::Type aType)
|
||||
{
|
||||
nsZipArchive *zip = Omnijar::GetReader(aType);
|
||||
if (!zip) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsZipFind *find;
|
||||
zip->FindInit("hyphenation/hyph_*.dic", &find);
|
||||
if (!find) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString base;
|
||||
nsresult rv = Omnijar::GetURIString(aType, base);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char *result;
|
||||
PRUint16 len;
|
||||
while (NS_SUCCEEDED(find->FindNext(&result, &len))) {
|
||||
nsCString uriString(base);
|
||||
uriString.Append(result, len);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), uriString);
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
nsCString locale;
|
||||
rv = uri->GetPath(locale);
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
ToLowerCase(locale);
|
||||
locale.SetLength(locale.Length() - 4); // strip ".dic"
|
||||
locale.Cut(0, locale.RFindChar('/') + 1); // strip directory
|
||||
if (StringBeginsWith(locale, NS_LITERAL_CSTRING("hyph_"))) {
|
||||
locale.Cut(0, 5);
|
||||
}
|
||||
for (PRUint32 i = 0; i < locale.Length(); ++i) {
|
||||
if (locale[i] == '_') {
|
||||
locale.Replace(i, 1, '-');
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIAtom> localeAtom = do_GetAtom(locale);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mPatternFiles.Put(localeAtom, uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHyphenationManager::LoadPatternListFromDir(nsIFile *aDir)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
bool check = false;
|
||||
rv = aDir->Exists(&check);
|
||||
if (NS_FAILED(rv) || !check) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
rv = aDir->IsDirectory(&check);
|
||||
if (NS_FAILED(rv) || !check) {
|
||||
return;
|
||||
|
@ -248,12 +192,12 @@ nsHyphenationManager::LoadPatternListFromDir(nsIFile *aDir)
|
|||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file){
|
||||
nsAutoString dictName;
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsZipArchive;
|
||||
class nsIURI;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче