backout changeset e1eac54b1ed3 (bug 655337 pt 2) for causing a leak.
authorJonathan Kew <jfkthame@gmail.com>
Thu, 06 Oct 2011 17:29:39 +0100
changeset 78895 e6b75c79c6180f865030c153d4fbe081e390ce44
parent 78894 26f668dc53fb3e57d278f151cc5c6dc625c1f31b
child 78896 59d91dcef5f4e064d3f5f86e818bd0f9d0178c2a
push idunknown
push userunknown
push dateunknown
bugs655337
milestone10.0a1
backs oute1eac54b1ed3849d8ca2bea4002f04936d8bb344
backout changeset e1eac54b1ed3 (bug 655337 pt 2) for causing a leak.
embedding/android/GeckoApp.java
intl/hyphenation/public/nsHyphenationManager.h
intl/hyphenation/src/nsHyphenationManager.cpp
xpcom/build/Omnijar.h
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -601,16 +601,26 @@ abstract public class GeckoApp
         Enumeration<? extends ZipEntry> zipEntries = zip.entries();
         while (zipEntries.hasMoreElements()) {
             ZipEntry entry = zipEntries.nextElement();
             if (entry.getName().startsWith("extensions/") && entry.getName().endsWith(".xpi")) {
                 Log.i("GeckoAppJava", "installing extension : " + entry.getName());
                 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 {
         BufferedReader reader = new BufferedReader(
             new FileReader(new File(sGREDir, "removed-files")));
         try {
             for (String removedFileName = reader.readLine(); 
                  removedFileName != null; removedFileName = reader.readLine()) {
--- a/intl/hyphenation/public/nsHyphenationManager.h
+++ b/intl/hyphenation/public/nsHyphenationManager.h
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsHyphenationManager_h__
 #define nsHyphenationManager_h__
 
 #include "nsInterfaceHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsHashKeys.h"
-#include "mozilla/Omnijar.h"
 
 class nsHyphenator;
 class nsIAtom;
 class nsIURI;
 
 class nsHyphenationManager
 {
 public:
@@ -58,17 +57,16 @@ public:
 
   static void Shutdown();
 
 private:
   ~nsHyphenationManager();
 
 protected:
   void LoadPatternList();
-  void LoadPatternListFromOmnijar(mozilla::Omnijar::Type aType);
   void LoadPatternListFromDir(nsIFile *aDir);
   void LoadAliases();
 
   nsInterfaceHashtable<nsISupportsHashKey,nsIAtom> mHyphAliases;
   nsInterfaceHashtable<nsISupportsHashKey,nsIURI> mPatternFiles;
   nsRefPtrHashtable<nsISupportsHashKey,nsHyphenator> mHyphenators;
 
   static nsHyphenationManager *sInstance;
--- a/intl/hyphenation/src/nsHyphenationManager.cpp
+++ b/intl/hyphenation/src/nsHyphenationManager.cpp
@@ -42,17 +42,16 @@
 #include "nsIURI.h"
 #include "nsIProperties.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "mozilla/Preferences.h"
-#include "nsZipArchive.h"
 
 using namespace mozilla;
 
 #define INTL_HYPHENATIONALIAS_PREFIX "intl.hyphenation-alias."
 
 nsHyphenationManager *nsHyphenationManager::sInstance = nsnull;
 
 nsHyphenationManager*
@@ -138,127 +137,72 @@ nsHyphenationManager::GetHyphenator(nsIA
   return nsnull;
 }
 
 void
 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));
   if (NS_SUCCEEDED(rv)) {
     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));
   if (NS_SUCCEEDED(rv)) {
     appDir->AppendNative(NS_LITERAL_CSTRING("hyphenation"));
     bool equals;
     if (NS_SUCCEEDED(appDir->Equals(greDir, &equals)) && !equals) {
       LoadPatternListFromDir(appDir);
     }
   }
 }
 
 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;
   }
 
   nsCOMPtr<nsISimpleEnumerator> e;
   rv = aDir->GetDirectoryEntries(getter_AddRefs(e));
   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;
     file->GetLeafName(dictName);
     NS_ConvertUTF16toUTF8 locale(dictName);
     ToLowerCase(locale);
     if (!StringEndsWith(locale, NS_LITERAL_CSTRING(".dic"))) {
       continue;
--- a/xpcom/build/Omnijar.h
+++ b/xpcom/build/Omnijar.h
@@ -38,18 +38,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_Omnijar_h
 #define mozilla_Omnijar_h
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
-#include "nsIFile.h"
 
+class nsIFile;
 class nsZipArchive;
 class nsIURI;
 
 namespace mozilla {
 
 class Omnijar {
 private:
 /**