Bug 995730 - Change xpcom/io/ to use 2 space indentation
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 05 May 2014 20:30:43 +0300
changeset 181582 7db230827e21908f2911fd02f894a2f3508c0a10
parent 181581 4e27f466ebbb6578ab008f231f12a00917c2c718
child 181583 81587bb1f916648367d7f208d2be0137f28f36e9
push id6646
push userkwierso@gmail.com
push dateTue, 06 May 2014 04:21:52 +0000
treeherderfx-team@81651ad5e43c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs995730
milestone32.0a1
Bug 995730 - Change xpcom/io/ to use 2 space indentation This also removes trailing whitespace in reindented files.
xpcom/io/Base64.cpp
xpcom/io/Base64.h
xpcom/io/SpecialSystemDirectory.cpp
xpcom/io/SpecialSystemDirectory.h
xpcom/io/nsAnonymousTemporaryFile.cpp
xpcom/io/nsAnonymousTemporaryFile.h
xpcom/io/nsAppDirectoryServiceDefs.h
xpcom/io/nsAppFileLocationProvider.cpp
xpcom/io/nsAppFileLocationProvider.h
xpcom/io/nsBinaryStream.cpp
xpcom/io/nsBinaryStream.h
xpcom/io/nsDirectoryService.cpp
xpcom/io/nsDirectoryService.h
xpcom/io/nsDirectoryServiceAtomList.h
xpcom/io/nsDirectoryServiceDefs.h
xpcom/io/nsDirectoryServiceUtils.h
xpcom/io/nsEscape.cpp
xpcom/io/nsEscape.h
xpcom/io/nsInputStreamTee.cpp
xpcom/io/nsLinebreakConverter.cpp
xpcom/io/nsLinebreakConverter.h
xpcom/io/nsLocalFile.h
xpcom/io/nsLocalFileCommon.cpp
xpcom/io/nsLocalFileUnix.cpp
xpcom/io/nsLocalFileUnix.h
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsLocalFileWin.h
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsMultiplexInputStream.h
xpcom/io/nsNativeCharsetUtils.cpp
xpcom/io/nsNativeCharsetUtils.h
xpcom/io/nsPipe3.cpp
xpcom/io/nsScriptableInputStream.cpp
xpcom/io/nsScriptableInputStream.h
xpcom/io/nsSegmentedBuffer.cpp
xpcom/io/nsSegmentedBuffer.h
xpcom/io/nsStorageStream.cpp
xpcom/io/nsStorageStream.h
xpcom/io/nsStreamUtils.cpp
xpcom/io/nsStreamUtils.h
xpcom/io/nsStringStream.cpp
xpcom/io/nsUnicharInputStream.cpp
xpcom/io/nsUnicharInputStream.h
xpcom/io/nsWildCard.cpp
xpcom/io/nsWildCard.h
--- a/xpcom/io/Base64.cpp
+++ b/xpcom/io/Base64.cpp
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Base64.h"
 
 #include "nsIInputStream.h"
 #include "nsString.h"
@@ -14,77 +15,77 @@ namespace {
 
 // BEGIN base64 encode code copied and modified from NSPR
 const unsigned char *base = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 template <typename T>
 static void
 Encode3to4(const unsigned char *src, T *dest)
 {
-    uint32_t b32 = (uint32_t)0;
-    int i, j = 18;
+  uint32_t b32 = (uint32_t)0;
+  int i, j = 18;
 
-    for( i = 0; i < 3; i++ )
-    {
-        b32 <<= 8;
-        b32 |= (uint32_t)src[i];
-    }
+  for( i = 0; i < 3; i++ )
+  {
+    b32 <<= 8;
+    b32 |= (uint32_t)src[i];
+  }
 
-    for( i = 0; i < 4; i++ )
-    {
-        dest[i] = base[ (uint32_t)((b32>>j) & 0x3F) ];
-        j -= 6;
-    }
+  for( i = 0; i < 4; i++ )
+  {
+    dest[i] = base[ (uint32_t)((b32>>j) & 0x3F) ];
+    j -= 6;
+  }
 }
 
 template <typename T>
 static void
 Encode2to4(const unsigned char *src, T *dest)
 {
-    dest[0] = base[ (uint32_t)((src[0]>>2) & 0x3F) ];
-    dest[1] = base[ (uint32_t)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)) ];
-    dest[2] = base[ (uint32_t)((src[1] & 0x0F) << 2) ];
-    dest[3] = (unsigned char)'=';
+  dest[0] = base[ (uint32_t)((src[0]>>2) & 0x3F) ];
+  dest[1] = base[ (uint32_t)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)) ];
+  dest[2] = base[ (uint32_t)((src[1] & 0x0F) << 2) ];
+  dest[3] = (unsigned char)'=';
 }
 
 template <typename T>
 static void
 Encode1to4(const unsigned char *src, T *dest)
 {
-    dest[0] = base[ (uint32_t)((src[0]>>2) & 0x3F) ];
-    dest[1] = base[ (uint32_t)((src[0] & 0x03) << 4) ];
-    dest[2] = (unsigned char)'=';
-    dest[3] = (unsigned char)'=';
+  dest[0] = base[ (uint32_t)((src[0]>>2) & 0x3F) ];
+  dest[1] = base[ (uint32_t)((src[0] & 0x03) << 4) ];
+  dest[2] = (unsigned char)'=';
+  dest[3] = (unsigned char)'=';
 }
 
 template <typename T>
 static void
 Encode(const unsigned char *src, uint32_t srclen, T *dest)
 {
-    while( srclen >= 3 )
-    {
-        Encode3to4(src, dest);
-        src += 3;
-        dest += 4;
-        srclen -= 3;
-    }
+  while( srclen >= 3 )
+  {
+    Encode3to4(src, dest);
+    src += 3;
+    dest += 4;
+    srclen -= 3;
+  }
 
-    switch( srclen )
-    {
-        case 2:
-            Encode2to4(src, dest);
-            break;
-        case 1:
-            Encode1to4(src, dest);
-            break;
-        case 0:
-            break;
-        default:
-            NS_NOTREACHED("coding error");
-    }
+  switch( srclen )
+  {
+    case 2:
+      Encode2to4(src, dest);
+      break;
+    case 1:
+      Encode1to4(src, dest);
+      break;
+    case 0:
+      break;
+    default:
+      NS_NOTREACHED("coding error");
+  }
 }
 
 // END base64 encode code copied and modified from NSPR.
 
 template <typename T>
 struct EncodeInputStream_State {
   unsigned char c[3];
   uint8_t charsOnStack;
@@ -123,17 +124,17 @@ EncodeInputStream_Encoder(nsIInputStream
     }
     Encode(firstSet, 3, state->buffer);
     state->buffer += 4;
     countRemaining -= (3 - state->charsOnStack);
     src += (3 - state->charsOnStack);
     state->charsOnStack = 0;
   }
 
-  // Encode the bulk of the 
+  // Encode the bulk of the
   uint32_t encodeLength = countRemaining - countRemaining % 3;
   NS_ABORT_IF_FALSE(encodeLength % 3 == 0,
                     "Should have an exact number of triplets!");
   Encode(src, encodeLength, state->buffer);
   state->buffer += (encodeLength / 3) * 4;
   src += encodeLength;
   countRemaining -= encodeLength;
 
@@ -148,17 +149,17 @@ EncodeInputStream_Encoder(nsIInputStream
     state->charsOnStack = countRemaining;
   }
 
   return NS_OK;
 }
 
 template <typename T>
 nsresult
-EncodeInputStream(nsIInputStream *aInputStream, 
+EncodeInputStream(nsIInputStream *aInputStream,
                   T &aDest,
                   uint32_t aCount,
                   uint32_t aOffset)
 {
   nsresult rv;
   uint64_t count64 = aCount;
 
   if (!aCount) {
@@ -217,26 +218,26 @@ EncodeInputStream(nsIInputStream *aInput
   return NS_OK;
 }
 
 } // namespace (anonymous)
 
 namespace mozilla {
 
 nsresult
-Base64EncodeInputStream(nsIInputStream *aInputStream, 
+Base64EncodeInputStream(nsIInputStream *aInputStream,
                         nsACString &aDest,
                         uint32_t aCount,
                         uint32_t aOffset)
 {
   return EncodeInputStream<nsACString>(aInputStream, aDest, aCount, aOffset);
 }
 
 nsresult
-Base64EncodeInputStream(nsIInputStream *aInputStream, 
+Base64EncodeInputStream(nsIInputStream *aInputStream,
                         nsAString &aDest,
                         uint32_t aCount,
                         uint32_t aOffset)
 {
   return EncodeInputStream<nsAString>(aInputStream, aDest, aCount, aOffset);
 }
 
 nsresult
@@ -254,18 +255,18 @@ Base64Encode(const nsACString &aBinaryDa
   }
 
   uint32_t stringLen = ((aBinaryData.Length() + 2) / 3) * 4;
 
   char *buffer;
 
   // Add one byte for null termination.
   if (aString.SetCapacity(stringLen + 1, fallible_t()) &&
-    (buffer = aString.BeginWriting()) &&
-    PL_Base64Encode(aBinaryData.BeginReading(), aBinaryData.Length(), buffer)) {
+      (buffer = aString.BeginWriting()) &&
+      PL_Base64Encode(aBinaryData.BeginReading(), aBinaryData.Length(), buffer)) {
     // PL_Base64Encode doesn't null terminate the buffer for us when we pass
     // the buffer in. Do that manually.
     buffer[stringLen] = '\0';
 
     aString.SetLength(stringLen);
     return NS_OK;
   }
 
@@ -304,18 +305,18 @@ Base64Decode(const nsACString &aString, 
   }
 
   uint32_t binaryDataLen = ((aString.Length() * 3) / 4);
 
   char *buffer;
 
   // Add one byte for null termination.
   if (aBinaryData.SetCapacity(binaryDataLen + 1, fallible_t()) &&
-    (buffer = aBinaryData.BeginWriting()) &&
-    PL_Base64Decode(aString.BeginReading(), aString.Length(), buffer)) {
+      (buffer = aBinaryData.BeginWriting()) &&
+      PL_Base64Decode(aString.BeginReading(), aString.Length(), buffer)) {
     // PL_Base64Decode doesn't null terminate the buffer for us when we pass
     // the buffer in. Do that manually, taking into account the number of '='
     // characters we were passed.
     if (!aString.IsEmpty() && aString[aString.Length() - 1] == '=') {
       if (aString.Length() > 1 && aString[aString.Length() - 2] == '=') {
         binaryDataLen -= 2;
       } else {
         binaryDataLen -= 1;
--- a/xpcom/io/Base64.h
+++ b/xpcom/io/Base64.h
@@ -8,22 +8,22 @@
 
 #include "nsString.h"
 
 class nsIInputStream;
 
 namespace mozilla {
 
 nsresult
-Base64EncodeInputStream(nsIInputStream *aInputStream, 
+Base64EncodeInputStream(nsIInputStream *aInputStream,
                         nsACString &aDest,
                         uint32_t aCount,
                         uint32_t aOffset = 0);
 nsresult
-Base64EncodeInputStream(nsIInputStream *aInputStream, 
+Base64EncodeInputStream(nsIInputStream *aInputStream,
                         nsAString &aDest,
                         uint32_t aCount,
                         uint32_t aOffset = 0);
 
 nsresult
 Base64Encode(const nsACString &aString, nsACString &aBinary);
 nsresult
 Base64Encode(const nsAString &aString, nsAString &aBinaryData);
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SpecialSystemDirectory.h"
 #include "nsString.h"
 #include "nsDependentString.h"
 #include "nsAutoPtr.h"
@@ -58,185 +59,185 @@ typedef HRESULT (WINAPI* nsGetKnownFolde
                                                PWSTR *ppszPath);
 
 static nsGetKnownFolderPath gGetKnownFolderPath = nullptr;
 #endif
 
 void StartupSpecialSystemDirectory()
 {
 #if defined (XP_WIN)
-    // SHGetKnownFolderPath is only available on Windows Vista
-    // so that we need to use GetProcAddress to get the pointer.
-    HMODULE hShell32DLLInst = GetModuleHandleW(L"shell32.dll");
-    if(hShell32DLLInst)
-    {
-        gGetKnownFolderPath = (nsGetKnownFolderPath)
-            GetProcAddress(hShell32DLLInst, "SHGetKnownFolderPath");
-    }
+  // SHGetKnownFolderPath is only available on Windows Vista
+  // so that we need to use GetProcAddress to get the pointer.
+  HMODULE hShell32DLLInst = GetModuleHandleW(L"shell32.dll");
+  if(hShell32DLLInst)
+  {
+    gGetKnownFolderPath = (nsGetKnownFolderPath)
+      GetProcAddress(hShell32DLLInst, "SHGetKnownFolderPath");
+  }
 #endif
 }
 
 #if defined (XP_WIN)
 
 static nsresult GetKnownFolder(GUID* guid, nsIFile** aFile)
 {
-    if (!guid || !gGetKnownFolderPath)
-        return NS_ERROR_FAILURE;
+  if (!guid || !gGetKnownFolderPath)
+    return NS_ERROR_FAILURE;
 
-    PWSTR path = nullptr;
-    gGetKnownFolderPath(*guid, 0, nullptr, &path);
+  PWSTR path = nullptr;
+  gGetKnownFolderPath(*guid, 0, nullptr, &path);
 
-    if (!path)
-        return NS_ERROR_FAILURE;
+  if (!path)
+    return NS_ERROR_FAILURE;
 
-    nsresult rv = NS_NewLocalFile(nsDependentString(path),
-                                  true,
-                                  aFile);
+  nsresult rv = NS_NewLocalFile(nsDependentString(path),
+                                true,
+                                aFile);
 
-    CoTaskMemFree(path);
-    return rv;
+  CoTaskMemFree(path);
+  return rv;
 }
 
 static nsresult
 GetWindowsFolder(int folder, nsIFile** aFile)
 {
-    WCHAR path_orig[MAX_PATH + 3];
-    WCHAR *path = path_orig+1;
-    HRESULT result = SHGetSpecialFolderPathW(nullptr, path, folder, true);
+  WCHAR path_orig[MAX_PATH + 3];
+  WCHAR *path = path_orig+1;
+  HRESULT result = SHGetSpecialFolderPathW(nullptr, path, folder, true);
 
-    if (!SUCCEEDED(result))
-        return NS_ERROR_FAILURE;
+  if (!SUCCEEDED(result))
+    return NS_ERROR_FAILURE;
 
-    // Append the trailing slash
-    int len = wcslen(path);
-    if (len > 1 && path[len - 1] != L'\\')
-    {
-        path[len]   = L'\\';
-        path[++len] = L'\0';
-    }
+  // Append the trailing slash
+  int len = wcslen(path);
+  if (len > 1 && path[len - 1] != L'\\')
+  {
+    path[len]   = L'\\';
+    path[++len] = L'\0';
+  }
 
-    return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
+  return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
 }
 
 __inline HRESULT
 SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode,
                              REFIID riid, void **ppv)
 {
-    *ppv = nullptr;
-    IShellLibrary *plib;
-    HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, nullptr,
-                                  CLSCTX_INPROC_SERVER,
-                                  IID_PPV_ARGS(&plib));
+  *ppv = nullptr;
+  IShellLibrary *plib;
+  HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, nullptr,
+                                CLSCTX_INPROC_SERVER,
+                                IID_PPV_ARGS(&plib));
+  if (SUCCEEDED(hr)) {
+    hr = plib->LoadLibraryFromKnownFolder(aFolderId, aMode);
     if (SUCCEEDED(hr)) {
-        hr = plib->LoadLibraryFromKnownFolder(aFolderId, aMode);
-        if (SUCCEEDED(hr)) {
-            hr = plib->QueryInterface(riid, ppv);
-        }
-        plib->Release();
+      hr = plib->QueryInterface(riid, ppv);
     }
-    return hr;
+    plib->Release();
+  }
+  return hr;
 }
 
 /*
  * Check to see if we're on Win7 and up, and if so, returns the default
  * save-to location for the Windows Library passed in through aFolderId.
  * Otherwise falls back on pre-win7 GetWindowsFolder.
  */
 static nsresult
 GetLibrarySaveToPath(int aFallbackFolderId, REFKNOWNFOLDERID aFolderId,
                      nsIFile** aFile)
 {
-    // Skip off checking for library support if the os is Vista or lower.
-    if (!IsWin7OrLater())
-      return GetWindowsFolder(aFallbackFolderId, aFile);
+  // Skip off checking for library support if the os is Vista or lower.
+  if (!IsWin7OrLater())
+    return GetWindowsFolder(aFallbackFolderId, aFile);
 
-    nsRefPtr<IShellLibrary> shellLib;
-    nsRefPtr<IShellItem> savePath;
-    HRESULT hr =
-        SHLoadLibraryFromKnownFolder(aFolderId, STGM_READ,
-                                     IID_IShellLibrary, getter_AddRefs(shellLib));
+  nsRefPtr<IShellLibrary> shellLib;
+  nsRefPtr<IShellItem> savePath;
+  HRESULT hr =
+    SHLoadLibraryFromKnownFolder(aFolderId, STGM_READ,
+                                 IID_IShellLibrary, getter_AddRefs(shellLib));
 
-    if (shellLib &&
-        SUCCEEDED(shellLib->GetDefaultSaveFolder(DSFT_DETECT, IID_IShellItem,
-                                                 getter_AddRefs(savePath)))) {
-        wchar_t* str = nullptr;
-        if (SUCCEEDED(savePath->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
-            nsAutoString path;
-            path.Assign(str);
-            path.AppendLiteral("\\");
-            nsresult rv =
-                NS_NewLocalFile(path, false, aFile);
-            CoTaskMemFree(str);
-            return rv;
-        }
+  if (shellLib &&
+      SUCCEEDED(shellLib->GetDefaultSaveFolder(DSFT_DETECT, IID_IShellItem,
+                                               getter_AddRefs(savePath)))) {
+    wchar_t* str = nullptr;
+    if (SUCCEEDED(savePath->GetDisplayName(SIGDN_FILESYSPATH, &str))) {
+      nsAutoString path;
+      path.Assign(str);
+      path.AppendLiteral("\\");
+      nsresult rv =
+        NS_NewLocalFile(path, false, aFile);
+      CoTaskMemFree(str);
+      return rv;
     }
+  }
 
-    return GetWindowsFolder(aFallbackFolderId, aFile);
+  return GetWindowsFolder(aFallbackFolderId, aFile);
 }
 
 /**
  * Provides a fallback for getting the path to APPDATA or LOCALAPPDATA by
  * querying the registry when the call to SHGetSpecialFolderPathW is unable to
  * provide these paths (Bug 513958).
  */
 static nsresult GetRegWindowsAppDataFolder(bool aLocal, nsIFile** aFile)
 {
-    HKEY key;
-    NS_NAMED_LITERAL_STRING(keyName,
+  HKEY key;
+  NS_NAMED_LITERAL_STRING(keyName,
     "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
-    DWORD res = ::RegOpenKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, KEY_READ,
-                                &key);
-    if (res != ERROR_SUCCESS)
-        return NS_ERROR_FAILURE;
+  DWORD res = ::RegOpenKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, KEY_READ,
+                              &key);
+  if (res != ERROR_SUCCESS)
+    return NS_ERROR_FAILURE;
 
-    WCHAR path[MAX_PATH + 2];
-    DWORD type, size;
-    res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"),
-                           nullptr, &type, (LPBYTE)&path, &size);
-    ::RegCloseKey(key);
-    // The call to RegQueryValueExW must succeed, the type must be REG_SZ, the
-    // buffer size must not equal 0, and the buffer size be a multiple of 2.
-    if (res != ERROR_SUCCESS || type != REG_SZ || size == 0 || size % 2 != 0)
-        return NS_ERROR_FAILURE;
+  WCHAR path[MAX_PATH + 2];
+  DWORD type, size;
+  res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"),
+                         nullptr, &type, (LPBYTE)&path, &size);
+  ::RegCloseKey(key);
+  // The call to RegQueryValueExW must succeed, the type must be REG_SZ, the
+  // buffer size must not equal 0, and the buffer size be a multiple of 2.
+  if (res != ERROR_SUCCESS || type != REG_SZ || size == 0 || size % 2 != 0)
+    return NS_ERROR_FAILURE;
 
-    // Append the trailing slash
-    int len = wcslen(path);
-    if (len > 1 && path[len - 1] != L'\\')
-    {
-        path[len]   = L'\\';
-        path[++len] = L'\0';
-    }
+  // Append the trailing slash
+  int len = wcslen(path);
+  if (len > 1 && path[len - 1] != L'\\')
+  {
+    path[len]   = L'\\';
+    path[++len] = L'\0';
+  }
 
-    return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
+  return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
 }
 
 #endif // XP_WIN
 
 #if defined(XP_UNIX)
 static nsresult
 GetUnixHomeDir(nsIFile** aFile)
 {
 #ifdef VMS
-    char *pHome;
-    pHome = getenv("HOME");
-    if (*pHome == '/') {
-        return NS_NewNativeLocalFile(nsDependentCString(pHome),
-                                     true,
-                                     aFile);
-    } else {
-        return NS_NewNativeLocalFile(nsDependentCString(decc$translate_vms(pHome)),
-                                     true,
-                                     aFile);
-    }
+  char *pHome;
+  pHome = getenv("HOME");
+  if (*pHome == '/') {
+    return NS_NewNativeLocalFile(nsDependentCString(pHome),
+                                 true,
+                                 aFile);
+  } else {
+    return NS_NewNativeLocalFile(nsDependentCString(decc$translate_vms(pHome)),
+                                 true,
+                                 aFile);
+  }
 #elif defined(ANDROID)
-    // XXX no home dir on android; maybe we should return the sdcard if present?
-    return NS_ERROR_FAILURE;
+  // XXX no home dir on android; maybe we should return the sdcard if present?
+  return NS_ERROR_FAILURE;
 #else
-    return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")),
-                                 true, aFile);
+  return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")),
+                               true, aFile);
 #endif
 }
 
 /*
   The following license applies to the xdg_user_dir_lookup function:
 
   Copyright (c) 2007 Red Hat, Inc.
 
@@ -274,553 +275,553 @@ xdg_user_dir_lookup (const char *type)
 
   home_dir = getenv ("HOME");
 
   if (home_dir == nullptr)
     goto error;
 
   config_home = getenv ("XDG_CONFIG_HOME");
   if (config_home == nullptr || config_home[0] == 0)
-    {
-      config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
-      if (config_file == nullptr)
-        goto error;
+  {
+    config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
+    if (config_file == nullptr)
+      goto error;
 
-      strcpy (config_file, home_dir);
-      strcat (config_file, "/.config/user-dirs.dirs");
-    }
+    strcpy (config_file, home_dir);
+    strcat (config_file, "/.config/user-dirs.dirs");
+  }
   else
-    {
-      config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
-      if (config_file == nullptr)
-        goto error;
+  {
+    config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
+    if (config_file == nullptr)
+      goto error;
 
-      strcpy (config_file, config_home);
-      strcat (config_file, "/user-dirs.dirs");
-    }
+    strcpy (config_file, config_home);
+    strcat (config_file, "/user-dirs.dirs");
+  }
 
   file = fopen (config_file, "r");
   free (config_file);
   if (file == nullptr)
     goto error;
 
   user_dir = nullptr;
   while (fgets (buffer, sizeof (buffer), file))
-    {
-      /* Remove newline at end */
-      len = strlen (buffer);
-      if (len > 0 && buffer[len-1] == '\n')
-	buffer[len-1] = 0;
-
-      p = buffer;
-      while (*p == ' ' || *p == '\t')
-	p++;
+  {
+    /* Remove newline at end */
+    len = strlen (buffer);
+    if (len > 0 && buffer[len-1] == '\n')
+      buffer[len-1] = 0;
 
-      if (strncmp (p, "XDG_", 4) != 0)
-	continue;
-      p += 4;
-      if (strncmp (p, type, strlen (type)) != 0)
-	continue;
-      p += strlen (type);
-      if (strncmp (p, "_DIR", 4) != 0)
-	continue;
-      p += 4;
-
-      while (*p == ' ' || *p == '\t')
-	p++;
-
-      if (*p != '=')
-	continue;
+    p = buffer;
+    while (*p == ' ' || *p == '\t')
       p++;
 
-      while (*p == ' ' || *p == '\t')
-	p++;
+    if (strncmp (p, "XDG_", 4) != 0)
+      continue;
+    p += 4;
+    if (strncmp (p, type, strlen (type)) != 0)
+      continue;
+    p += strlen (type);
+    if (strncmp (p, "_DIR", 4) != 0)
+      continue;
+    p += 4;
 
-      if (*p != '"')
-	continue;
+    while (*p == ' ' || *p == '\t')
+      p++;
+
+    if (*p != '=')
+      continue;
+    p++;
+
+    while (*p == ' ' || *p == '\t')
       p++;
 
-      relative = 0;
-      if (strncmp (p, "$HOME/", 6) == 0)
-	{
-	  p += 6;
-	  relative = 1;
-	}
-      else if (*p != '/')
-	continue;
+    if (*p != '"')
+      continue;
+    p++;
 
-      if (relative)
-	{
-	  user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
-          if (user_dir == nullptr)
-            goto error2;
+    relative = 0;
+    if (strncmp (p, "$HOME/", 6) == 0)
+    {
+      p += 6;
+      relative = 1;
+    }
+    else if (*p != '/')
+      continue;
+
+    if (relative)
+    {
+      user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
+      if (user_dir == nullptr)
+        goto error2;
 
-	  strcpy (user_dir, home_dir);
-	  strcat (user_dir, "/");
-	}
-      else
-	{
-	  user_dir = (char*) malloc (strlen (p) + 1);
-          if (user_dir == nullptr)
-            goto error2;
+      strcpy (user_dir, home_dir);
+      strcat (user_dir, "/");
+    }
+    else
+    {
+      user_dir = (char*) malloc (strlen (p) + 1);
+      if (user_dir == nullptr)
+        goto error2;
 
-	  *user_dir = 0;
-	}
+      *user_dir = 0;
+    }
 
-      d = user_dir + strlen (user_dir);
-      while (*p && *p != '"')
-	{
-	  if ((*p == '\\') && (*(p+1) != 0))
-	    p++;
-	  *d++ = *p++;
-	}
-      *d = 0;
+    d = user_dir + strlen (user_dir);
+    while (*p && *p != '"')
+    {
+      if ((*p == '\\') && (*(p+1) != 0))
+        p++;
+      *d++ = *p++;
     }
+    *d = 0;
+  }
 error2:
   fclose (file);
 
   if (user_dir)
     return user_dir;
 
- error:
+error:
   return nullptr;
 }
 
 static const char xdg_user_dirs[] =
-    "DESKTOP\0"
-    "DOCUMENTS\0"
-    "DOWNLOAD\0"
-    "MUSIC\0"
-    "PICTURES\0"
-    "PUBLICSHARE\0"
-    "TEMPLATES\0"
-    "VIDEOS";
+  "DESKTOP\0"
+  "DOCUMENTS\0"
+  "DOWNLOAD\0"
+  "MUSIC\0"
+  "PICTURES\0"
+  "PUBLICSHARE\0"
+  "TEMPLATES\0"
+  "VIDEOS";
 
 static const uint8_t xdg_user_dir_offsets[] = {
-    0,
-    8,
-    18,
-    27,
-    33,
-    42,
-    54,
-    64
+  0,
+  8,
+  18,
+  27,
+  33,
+  42,
+  54,
+  64
 };
 
 static nsresult
 GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
                         nsIFile** aFile)
 {
-    char *dir = xdg_user_dir_lookup
-                    (xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory -
-                                                         Unix_XDG_Desktop]);
+  char *dir = xdg_user_dir_lookup
+    (xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory -
+                                          Unix_XDG_Desktop]);
 
-    nsresult rv;
-    nsCOMPtr<nsIFile> file;
-    if (dir) {
-        rv = NS_NewNativeLocalFile(nsDependentCString(dir), true,
-                                   getter_AddRefs(file));
-        free(dir);
-    } else if (Unix_XDG_Desktop == aSystemDirectory) {
-        // for the XDG desktop dir, fall back to HOME/Desktop
-        // (for historical compatibility)
-        rv = GetUnixHomeDir(getter_AddRefs(file));
-        if (NS_FAILED(rv))
-            return rv;
+  nsresult rv;
+  nsCOMPtr<nsIFile> file;
+  if (dir) {
+    rv = NS_NewNativeLocalFile(nsDependentCString(dir), true,
+                               getter_AddRefs(file));
+    free(dir);
+  } else if (Unix_XDG_Desktop == aSystemDirectory) {
+    // for the XDG desktop dir, fall back to HOME/Desktop
+    // (for historical compatibility)
+    rv = GetUnixHomeDir(getter_AddRefs(file));
+    if (NS_FAILED(rv))
+      return rv;
 
-        rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop"));
-    }
-    else {
-      // no fallback for the other XDG dirs
-      rv = NS_ERROR_FAILURE;
-    }
+    rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop"));
+  }
+  else {
+    // no fallback for the other XDG dirs
+    rv = NS_ERROR_FAILURE;
+  }
 
-    if (NS_FAILED(rv))
-        return rv;
+  if (NS_FAILED(rv))
+    return rv;
 
-    bool exists;
-    rv = file->Exists(&exists);
+  bool exists;
+  rv = file->Exists(&exists);
+  if (NS_FAILED(rv))
+    return rv;
+  if (!exists) {
+    rv = file->Create(nsIFile::DIRECTORY_TYPE, 0755);
     if (NS_FAILED(rv))
-        return rv;
-    if (!exists) {
-        rv = file->Create(nsIFile::DIRECTORY_TYPE, 0755);
-        if (NS_FAILED(rv))
-            return rv;
-    }
+      return rv;
+  }
 
-    *aFile = nullptr;
-    file.swap(*aFile);
+  *aFile = nullptr;
+  file.swap(*aFile);
 
-    return NS_OK;
+  return NS_OK;
 }
 #endif
 
 nsresult
 GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
                           nsIFile** aFile)
 {
 #if defined(XP_WIN)
-    WCHAR path[MAX_PATH];
+  WCHAR path[MAX_PATH];
 #else
-    char path[MAXPATHLEN];
+  char path[MAXPATHLEN];
 #endif
 
-    switch (aSystemSystemDirectory)
-    {
-        case OS_CurrentWorkingDirectory:
+  switch (aSystemSystemDirectory)
+  {
+    case OS_CurrentWorkingDirectory:
 #if defined(XP_WIN)
-            if (!_wgetcwd(path, MAX_PATH))
-                return NS_ERROR_FAILURE;
-            return NS_NewLocalFile(nsDependentString(path),
-                                   true,
-                                   aFile);
+      if (!_wgetcwd(path, MAX_PATH))
+        return NS_ERROR_FAILURE;
+      return NS_NewLocalFile(nsDependentString(path),
+                             true,
+                             aFile);
 #else
-            if(!getcwd(path, MAXPATHLEN))
-                return NS_ERROR_FAILURE;
+      if(!getcwd(path, MAXPATHLEN))
+        return NS_ERROR_FAILURE;
 #endif
 
 #if !defined(XP_WIN)
-            return NS_NewNativeLocalFile(nsDependentCString(path),
-                                         true,
-                                         aFile);
+      return NS_NewNativeLocalFile(nsDependentCString(path),
+                                   true,
+                                   aFile);
 #endif
 
-        case OS_DriveDirectory:
+    case OS_DriveDirectory:
 #if defined (XP_WIN)
-        {
-            int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH);
-            if (len == 0)
-                break;
-            if (path[1] == char16_t(':') && path[2] == char16_t('\\'))
-                path[3] = 0;
+    {
+      int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH);
+      if (len == 0)
+        break;
+      if (path[1] == char16_t(':') && path[2] == char16_t('\\'))
+        path[3] = 0;
 
-            return NS_NewLocalFile(nsDependentString(path),
-                                   true,
-                                   aFile);
-        }
+      return NS_NewLocalFile(nsDependentString(path),
+                             true,
+                             aFile);
+    }
 #else
-        return NS_NewNativeLocalFile(nsDependentCString("/"),
-                                     true,
-                                     aFile);
+    return NS_NewNativeLocalFile(nsDependentCString("/"),
+                                 true,
+                                 aFile);
 
 #endif
 
-        case OS_TemporaryDirectory:
+    case OS_TemporaryDirectory:
 #if defined (XP_WIN)
-            {
-            DWORD len = ::GetTempPathW(MAX_PATH, path);
-            if (len == 0)
-                break;
-            return NS_NewLocalFile(nsDependentString(path, len),
-                                   true,
-                                   aFile);
-        }
+    {
+      DWORD len = ::GetTempPathW(MAX_PATH, path);
+      if (len == 0)
+        break;
+      return NS_NewLocalFile(nsDependentString(path, len),
+                             true,
+                             aFile);
+    }
 #elif defined(MOZ_WIDGET_COCOA)
-        {
-            return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
-        }
+    {
+      return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
+    }
 
 #elif defined(XP_UNIX)
-        {
-            static const char *tPath = nullptr;
-            if (!tPath) {
-                tPath = PR_GetEnv("TMPDIR");
-                if (!tPath || !*tPath) {
-                    tPath = PR_GetEnv("TMP");
-                    if (!tPath || !*tPath) {
-                        tPath = PR_GetEnv("TEMP");
-                        if (!tPath || !*tPath) {
-                            tPath = "/tmp/";
-                        }
-                    }
-                }
+    {
+      static const char *tPath = nullptr;
+      if (!tPath) {
+        tPath = PR_GetEnv("TMPDIR");
+        if (!tPath || !*tPath) {
+          tPath = PR_GetEnv("TMP");
+          if (!tPath || !*tPath) {
+            tPath = PR_GetEnv("TEMP");
+            if (!tPath || !*tPath) {
+              tPath = "/tmp/";
             }
-            return NS_NewNativeLocalFile(nsDependentCString(tPath),
-                                         true,
-                                         aFile);
+          }
         }
-#else
-        break;
-#endif
-#if defined (XP_WIN)
-        case Win_SystemDirectory:
-        {
-            int32_t len = ::GetSystemDirectoryW(path, MAX_PATH);
-
-            // Need enough space to add the trailing backslash
-            if (!len || len > MAX_PATH - 2)
-                break;
-            path[len]   = L'\\';
-            path[++len] = L'\0';
-
-            return NS_NewLocalFile(nsDependentString(path, len),
-                                   true,
-                                   aFile);
-        }
-
-        case Win_WindowsDirectory:
-        {
-            int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH);
-
-            // Need enough space to add the trailing backslash
-            if (!len || len > MAX_PATH - 2)
-                break;
-
-            path[len]   = L'\\';
-            path[++len] = L'\0';
-
-            return NS_NewLocalFile(nsDependentString(path, len),
+      }
+      return NS_NewNativeLocalFile(nsDependentCString(tPath),
                                    true,
                                    aFile);
-        }
+    }
+#else
+    break;
+#endif
+#if defined (XP_WIN)
+    case Win_SystemDirectory:
+    {
+      int32_t len = ::GetSystemDirectoryW(path, MAX_PATH);
 
-        case Win_ProgramFiles:
-        {
-            return GetWindowsFolder(CSIDL_PROGRAM_FILES, aFile);
-        }
+      // Need enough space to add the trailing backslash
+      if (!len || len > MAX_PATH - 2)
+        break;
+      path[len]   = L'\\';
+      path[++len] = L'\0';
 
-        case Win_HomeDirectory:
-        {
-            nsresult rv = GetWindowsFolder(CSIDL_PROFILE, aFile);
-            if (NS_SUCCEEDED(rv))
-                return rv;
+      return NS_NewLocalFile(nsDependentString(path, len),
+                             true,
+                             aFile);
+    }
+
+    case Win_WindowsDirectory:
+    {
+      int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH);
 
-            int32_t len;
-            if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0)
-            {
-                // Need enough space to add the trailing backslash
-                if (len > MAX_PATH - 2)
-                    break;
+      // Need enough space to add the trailing backslash
+      if (!len || len > MAX_PATH - 2)
+        break;
 
-                path[len]   = L'\\';
-                path[++len] = L'\0';
+      path[len]   = L'\\';
+      path[++len] = L'\0';
+
+      return NS_NewLocalFile(nsDependentString(path, len),
+                             true,
+                             aFile);
+    }
 
-                rv = NS_NewLocalFile(nsDependentString(path, len),
-                                     true,
-                                     aFile);
-                if (NS_SUCCEEDED(rv))
-                    return rv;
-            }
+    case Win_ProgramFiles:
+    {
+      return GetWindowsFolder(CSIDL_PROGRAM_FILES, aFile);
+    }
 
-            len = ::GetEnvironmentVariableW(L"HOMEDRIVE", path, MAX_PATH);
-            if (0 < len && len < MAX_PATH)
-            {
-                WCHAR temp[MAX_PATH];
-                DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH);
-                if (0 < len2 && len + len2 < MAX_PATH)
-                    wcsncat(path, temp, len2);
+    case Win_HomeDirectory:
+    {
+      nsresult rv = GetWindowsFolder(CSIDL_PROFILE, aFile);
+      if (NS_SUCCEEDED(rv))
+        return rv;
+
+      int32_t len;
+      if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0)
+      {
+        // Need enough space to add the trailing backslash
+        if (len > MAX_PATH - 2)
+          break;
 
-                len = wcslen(path);
+        path[len]   = L'\\';
+        path[++len] = L'\0';
+
+        rv = NS_NewLocalFile(nsDependentString(path, len),
+                             true,
+                             aFile);
+        if (NS_SUCCEEDED(rv))
+          return rv;
+      }
 
-                // Need enough space to add the trailing backslash
-                if (len > MAX_PATH - 2)
-                    break;
+      len = ::GetEnvironmentVariableW(L"HOMEDRIVE", path, MAX_PATH);
+      if (0 < len && len < MAX_PATH)
+      {
+        WCHAR temp[MAX_PATH];
+        DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH);
+        if (0 < len2 && len + len2 < MAX_PATH)
+          wcsncat(path, temp, len2);
 
-                path[len]   = L'\\';
-                path[++len] = L'\0';
+        len = wcslen(path);
+
+        // Need enough space to add the trailing backslash
+        if (len > MAX_PATH - 2)
+          break;
+
+        path[len]   = L'\\';
+        path[++len] = L'\0';
 
-                return NS_NewLocalFile(nsDependentString(path, len),
-                                       true,
-                                       aFile);
-            }
-        }
-        case Win_Desktop:
-        {
-            return GetWindowsFolder(CSIDL_DESKTOP, aFile);
-        }
-        case Win_Programs:
-        {
-            return GetWindowsFolder(CSIDL_PROGRAMS, aFile);
-        }
+        return NS_NewLocalFile(nsDependentString(path, len),
+                               true,
+                               aFile);
+      }
+    }
+    case Win_Desktop:
+    {
+      return GetWindowsFolder(CSIDL_DESKTOP, aFile);
+    }
+    case Win_Programs:
+    {
+      return GetWindowsFolder(CSIDL_PROGRAMS, aFile);
+    }
 
-        case Win_Downloads:
-        {
-            // Defined in KnownFolders.h.
-            GUID folderid_downloads = {0x374de290, 0x123f, 0x4565, {0x91, 0x64,
-                                       0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b}};
-            nsresult rv = GetKnownFolder(&folderid_downloads, aFile);
-            // On WinXP, there is no downloads folder, default
-            // to 'Desktop'.
-            if(NS_ERROR_FAILURE == rv)
-            {
-              rv = GetWindowsFolder(CSIDL_DESKTOP, aFile);
-            }
-            return rv;
-        }
+    case Win_Downloads:
+    {
+      // Defined in KnownFolders.h.
+      GUID folderid_downloads = {0x374de290, 0x123f, 0x4565, {0x91, 0x64,
+                                 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b}};
+      nsresult rv = GetKnownFolder(&folderid_downloads, aFile);
+      // On WinXP, there is no downloads folder, default
+      // to 'Desktop'.
+      if(NS_ERROR_FAILURE == rv)
+      {
+        rv = GetWindowsFolder(CSIDL_DESKTOP, aFile);
+      }
+      return rv;
+    }
 
-        case Win_Controls:
-        {
-            return GetWindowsFolder(CSIDL_CONTROLS, aFile);
-        }
-        case Win_Printers:
-        {
-            return GetWindowsFolder(CSIDL_PRINTERS, aFile);
-        }
-        case Win_Personal:
-        {
-            return GetWindowsFolder(CSIDL_PERSONAL, aFile);
-        }
-        case Win_Favorites:
-        {
-            return GetWindowsFolder(CSIDL_FAVORITES, aFile);
-        }
-        case Win_Startup:
-        {
-            return GetWindowsFolder(CSIDL_STARTUP, aFile);
-        }
-        case Win_Recent:
-        {
-            return GetWindowsFolder(CSIDL_RECENT, aFile);
-        }
-        case Win_Sendto:
-        {
-            return GetWindowsFolder(CSIDL_SENDTO, aFile);
-        }
-        case Win_Bitbucket:
-        {
-            return GetWindowsFolder(CSIDL_BITBUCKET, aFile);
-        }
-        case Win_Startmenu:
-        {
-            return GetWindowsFolder(CSIDL_STARTMENU, aFile);
-        }
-        case Win_Desktopdirectory:
-        {
-            return GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, aFile);
-        }
-        case Win_Drives:
-        {
-            return GetWindowsFolder(CSIDL_DRIVES, aFile);
-        }
-        case Win_Network:
-        {
-            return GetWindowsFolder(CSIDL_NETWORK, aFile);
-        }
-        case Win_Nethood:
-        {
-            return GetWindowsFolder(CSIDL_NETHOOD, aFile);
-        }
-        case Win_Fonts:
-        {
-            return GetWindowsFolder(CSIDL_FONTS, aFile);
-        }
-        case Win_Templates:
-        {
-            return GetWindowsFolder(CSIDL_TEMPLATES, aFile);
-        }
-        case Win_Common_Startmenu:
-        {
-            return GetWindowsFolder(CSIDL_COMMON_STARTMENU, aFile);
-        }
-        case Win_Common_Programs:
-        {
-            return GetWindowsFolder(CSIDL_COMMON_PROGRAMS, aFile);
-        }
-        case Win_Common_Startup:
-        {
-            return GetWindowsFolder(CSIDL_COMMON_STARTUP, aFile);
-        }
-        case Win_Common_Desktopdirectory:
-        {
-            return GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, aFile);
-        }
-        case Win_Common_AppData:
-        {
-            return GetWindowsFolder(CSIDL_COMMON_APPDATA, aFile);
-        }
-        case Win_Printhood:
-        {
-            return GetWindowsFolder(CSIDL_PRINTHOOD, aFile);
-        }
-        case Win_Cookies:
-        {
-            return GetWindowsFolder(CSIDL_COOKIES, aFile);
-        }
-        case Win_Appdata:
-        {
-            nsresult rv = GetWindowsFolder(CSIDL_APPDATA, aFile);
-            if (NS_FAILED(rv))
-                rv = GetRegWindowsAppDataFolder(false, aFile);
-            return rv;
-        }
-        case Win_LocalAppdata:
-        {
-            nsresult rv = GetWindowsFolder(CSIDL_LOCAL_APPDATA, aFile);
-            if (NS_FAILED(rv))
-                rv = GetRegWindowsAppDataFolder(true, aFile);
-            return rv;
-        }
-        case Win_Documents:
-        {
-            return GetLibrarySaveToPath(CSIDL_MYDOCUMENTS,
-                                        FOLDERID_DocumentsLibrary,
-                                        aFile);
-        }
-        case Win_Pictures:
-        {
-            return GetLibrarySaveToPath(CSIDL_MYPICTURES,
-                                        FOLDERID_PicturesLibrary,
-                                        aFile);
-        }
-        case Win_Music:
-        {
-            return GetLibrarySaveToPath(CSIDL_MYMUSIC,
-                                        FOLDERID_MusicLibrary,
-                                        aFile);
-        }
-        case Win_Videos:
-        {
-            return GetLibrarySaveToPath(CSIDL_MYVIDEO,
-                                        FOLDERID_VideosLibrary,
-                                        aFile);
-        }
+    case Win_Controls:
+    {
+      return GetWindowsFolder(CSIDL_CONTROLS, aFile);
+    }
+    case Win_Printers:
+    {
+      return GetWindowsFolder(CSIDL_PRINTERS, aFile);
+    }
+    case Win_Personal:
+    {
+      return GetWindowsFolder(CSIDL_PERSONAL, aFile);
+    }
+    case Win_Favorites:
+    {
+      return GetWindowsFolder(CSIDL_FAVORITES, aFile);
+    }
+    case Win_Startup:
+    {
+      return GetWindowsFolder(CSIDL_STARTUP, aFile);
+    }
+    case Win_Recent:
+    {
+      return GetWindowsFolder(CSIDL_RECENT, aFile);
+    }
+    case Win_Sendto:
+    {
+      return GetWindowsFolder(CSIDL_SENDTO, aFile);
+    }
+    case Win_Bitbucket:
+    {
+      return GetWindowsFolder(CSIDL_BITBUCKET, aFile);
+    }
+    case Win_Startmenu:
+    {
+      return GetWindowsFolder(CSIDL_STARTMENU, aFile);
+    }
+    case Win_Desktopdirectory:
+    {
+      return GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, aFile);
+    }
+    case Win_Drives:
+    {
+      return GetWindowsFolder(CSIDL_DRIVES, aFile);
+    }
+    case Win_Network:
+    {
+      return GetWindowsFolder(CSIDL_NETWORK, aFile);
+    }
+    case Win_Nethood:
+    {
+      return GetWindowsFolder(CSIDL_NETHOOD, aFile);
+    }
+    case Win_Fonts:
+    {
+      return GetWindowsFolder(CSIDL_FONTS, aFile);
+    }
+    case Win_Templates:
+    {
+      return GetWindowsFolder(CSIDL_TEMPLATES, aFile);
+    }
+    case Win_Common_Startmenu:
+    {
+      return GetWindowsFolder(CSIDL_COMMON_STARTMENU, aFile);
+    }
+    case Win_Common_Programs:
+    {
+      return GetWindowsFolder(CSIDL_COMMON_PROGRAMS, aFile);
+    }
+    case Win_Common_Startup:
+    {
+      return GetWindowsFolder(CSIDL_COMMON_STARTUP, aFile);
+    }
+    case Win_Common_Desktopdirectory:
+    {
+      return GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, aFile);
+    }
+    case Win_Common_AppData:
+    {
+      return GetWindowsFolder(CSIDL_COMMON_APPDATA, aFile);
+    }
+    case Win_Printhood:
+    {
+      return GetWindowsFolder(CSIDL_PRINTHOOD, aFile);
+    }
+    case Win_Cookies:
+    {
+      return GetWindowsFolder(CSIDL_COOKIES, aFile);
+    }
+    case Win_Appdata:
+    {
+      nsresult rv = GetWindowsFolder(CSIDL_APPDATA, aFile);
+      if (NS_FAILED(rv))
+        rv = GetRegWindowsAppDataFolder(false, aFile);
+      return rv;
+    }
+    case Win_LocalAppdata:
+    {
+      nsresult rv = GetWindowsFolder(CSIDL_LOCAL_APPDATA, aFile);
+      if (NS_FAILED(rv))
+        rv = GetRegWindowsAppDataFolder(true, aFile);
+      return rv;
+    }
+    case Win_Documents:
+    {
+      return GetLibrarySaveToPath(CSIDL_MYDOCUMENTS,
+                                  FOLDERID_DocumentsLibrary,
+                                  aFile);
+    }
+    case Win_Pictures:
+    {
+      return GetLibrarySaveToPath(CSIDL_MYPICTURES,
+                                  FOLDERID_PicturesLibrary,
+                                  aFile);
+    }
+    case Win_Music:
+    {
+      return GetLibrarySaveToPath(CSIDL_MYMUSIC,
+                                  FOLDERID_MusicLibrary,
+                                  aFile);
+    }
+    case Win_Videos:
+    {
+      return GetLibrarySaveToPath(CSIDL_MYVIDEO,
+                                  FOLDERID_VideosLibrary,
+                                  aFile);
+    }
 #endif  // XP_WIN
 
 #if defined(XP_UNIX)
-        case Unix_LocalDirectory:
-            return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"),
-                                         true,
-                                         aFile);
-        case Unix_LibDirectory:
-            return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"),
-                                         true,
-                                         aFile);
+    case Unix_LocalDirectory:
+      return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"),
+                                   true,
+                                   aFile);
+    case Unix_LibDirectory:
+      return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"),
+                                   true,
+                                   aFile);
 
-        case Unix_HomeDirectory:
-            return GetUnixHomeDir(aFile);
+    case Unix_HomeDirectory:
+      return GetUnixHomeDir(aFile);
 
-        case Unix_XDG_Desktop:
-        case Unix_XDG_Documents:
-        case Unix_XDG_Download:
-        case Unix_XDG_Music:
-        case Unix_XDG_Pictures:
-        case Unix_XDG_PublicShare:
-        case Unix_XDG_Templates:
-        case Unix_XDG_Videos:
-            return GetUnixXDGUserDirectory(aSystemSystemDirectory, aFile);
+    case Unix_XDG_Desktop:
+    case Unix_XDG_Documents:
+    case Unix_XDG_Download:
+    case Unix_XDG_Music:
+    case Unix_XDG_Pictures:
+    case Unix_XDG_PublicShare:
+    case Unix_XDG_Templates:
+    case Unix_XDG_Videos:
+      return GetUnixXDGUserDirectory(aSystemSystemDirectory, aFile);
 #endif
 
-        default:
-            break;
-    }
-    return NS_ERROR_NOT_AVAILABLE;
+    default:
+      break;
+  }
+  return NS_ERROR_NOT_AVAILABLE;
 }
 
 #if defined (MOZ_WIDGET_COCOA)
 nsresult
 GetOSXFolderType(short aDomain, OSType aFolderType, nsIFile **localFile)
 {
-    OSErr err;
-    FSRef fsRef;
-    nsresult rv = NS_ERROR_FAILURE;
+  OSErr err;
+  FSRef fsRef;
+  nsresult rv = NS_ERROR_FAILURE;
 
-    err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
-    if (err == noErr)
-    {
-        NS_NewLocalFile(EmptyString(), true, localFile);
-        nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*localFile));
-        if (localMacFile)
-            rv = localMacFile->InitWithFSRef(&fsRef);
-    }
-    return rv;
+  err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
+  if (err == noErr)
+  {
+    NS_NewLocalFile(EmptyString(), true, localFile);
+    nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*localFile));
+    if (localMacFile)
+      rv = localMacFile->InitWithFSRef(&fsRef);
+  }
+  return rv;
 }
 #endif
 
--- a/xpcom/io/SpecialSystemDirectory.h
+++ b/xpcom/io/SpecialSystemDirectory.h
@@ -1,9 +1,10 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _SPECIALSYSTEMDIRECTORY_H_
 #define _SPECIALSYSTEMDIRECTORY_H_
 
 #include "nscore.h"
@@ -14,78 +15,78 @@
 #include "nsILocalFileMac.h"
 #include "prenv.h"
 #endif
 
 extern void StartupSpecialSystemDirectory();
 
 
 enum SystemDirectories {
-  OS_DriveDirectory         =   1,   
-  OS_TemporaryDirectory     =   2,   
-  OS_CurrentProcessDirectory=   3,   
+  OS_DriveDirectory         =   1,
+  OS_TemporaryDirectory     =   2,
+  OS_CurrentProcessDirectory=   3,
   OS_CurrentWorkingDirectory=   4,
-  XPCOM_CurrentProcessComponentDirectory=   5,   
-  XPCOM_CurrentProcessComponentRegistry=   6,   
-  
+  XPCOM_CurrentProcessComponentDirectory=   5,
+  XPCOM_CurrentProcessComponentRegistry=   6,
+
   Moz_BinDirectory          =   100 ,
-  Mac_SystemDirectory       =   101,   
-  Mac_DesktopDirectory      =   102,   
-  Mac_TrashDirectory        =   103,   
-  Mac_StartupDirectory      =   104,   
-  Mac_ShutdownDirectory     =   105,   
-  Mac_AppleMenuDirectory    =   106,   
-  Mac_ControlPanelDirectory =   107,   
-  Mac_ExtensionDirectory    =   108,   
-  Mac_FontsDirectory        =   109,   
-  Mac_ClassicPreferencesDirectory =   110,   
-  Mac_DocumentsDirectory          =   111,   
-  Mac_InternetSearchDirectory     =   112,   
-  Mac_DefaultDownloadDirectory    =   113,   
-  Mac_UserLibDirectory      =   114,   
+  Mac_SystemDirectory       =   101,
+  Mac_DesktopDirectory      =   102,
+  Mac_TrashDirectory        =   103,
+  Mac_StartupDirectory      =   104,
+  Mac_ShutdownDirectory     =   105,
+  Mac_AppleMenuDirectory    =   106,
+  Mac_ControlPanelDirectory =   107,
+  Mac_ExtensionDirectory    =   108,
+  Mac_FontsDirectory        =   109,
+  Mac_ClassicPreferencesDirectory =   110,
+  Mac_DocumentsDirectory          =   111,
+  Mac_InternetSearchDirectory     =   112,
+  Mac_DefaultDownloadDirectory    =   113,
+  Mac_UserLibDirectory      =   114,
   Mac_PreferencesDirectory  =   115,
-   
-  Win_SystemDirectory       =   201,   
+
+  Win_SystemDirectory       =   201,
   Win_WindowsDirectory      =   202,
-  Win_HomeDirectory         =   203,   
-  Win_Desktop               =   204,   
-  Win_Programs              =   205,   
-  Win_Controls              =   206,   
-  Win_Printers              =   207,   
-  Win_Personal              =   208,   
-  Win_Favorites             =   209,   
-  Win_Startup               =   210,   
-  Win_Recent                =   211,   
-  Win_Sendto                =   212,   
-  Win_Bitbucket             =   213,   
-  Win_Startmenu             =   214,   
-  Win_Desktopdirectory      =   215,   
-  Win_Drives                =   216,   
-  Win_Network               =   217,   
-  Win_Nethood               =   218,   
-  Win_Fonts                 =   219,   
-  Win_Templates             =   220,   
-  Win_Common_Startmenu      =   221,   
-  Win_Common_Programs       =   222,   
-  Win_Common_Startup        =   223,   
-  Win_Common_Desktopdirectory = 224,   
-  Win_Appdata               =   225,   
-  Win_Printhood             =   226,   
-  Win_Cookies               =   227, 
+  Win_HomeDirectory         =   203,
+  Win_Desktop               =   204,
+  Win_Programs              =   205,
+  Win_Controls              =   206,
+  Win_Printers              =   207,
+  Win_Personal              =   208,
+  Win_Favorites             =   209,
+  Win_Startup               =   210,
+  Win_Recent                =   211,
+  Win_Sendto                =   212,
+  Win_Bitbucket             =   213,
+  Win_Startmenu             =   214,
+  Win_Desktopdirectory      =   215,
+  Win_Drives                =   216,
+  Win_Network               =   217,
+  Win_Nethood               =   218,
+  Win_Fonts                 =   219,
+  Win_Templates             =   220,
+  Win_Common_Startmenu      =   221,
+  Win_Common_Programs       =   222,
+  Win_Common_Startup        =   223,
+  Win_Common_Desktopdirectory = 224,
+  Win_Appdata               =   225,
+  Win_Printhood             =   226,
+  Win_Cookies               =   227,
   Win_LocalAppdata          =   228,
   Win_ProgramFiles          =   229,
   Win_Downloads             =   230,
   Win_Common_AppData        =   231,
   Win_Documents             =   232,
   Win_Pictures              =   233,
   Win_Music                 =   234,
   Win_Videos                =   235,
 
-  Unix_LocalDirectory       =   301,   
-  Unix_LibDirectory         =   302,   
+  Unix_LocalDirectory       =   301,
+  Unix_LibDirectory         =   302,
   Unix_HomeDirectory        =   303,
   Unix_XDG_Desktop          =   304,
   Unix_XDG_Documents        =   305,
   Unix_XDG_Download         =   306,
   Unix_XDG_Music            =   307,
   Unix_XDG_Pictures         =   308,
   Unix_XDG_PublicShare      =   309,
   Unix_XDG_Templates        =   310,
--- a/xpcom/io/nsAnonymousTemporaryFile.cpp
+++ b/xpcom/io/nsAnonymousTemporaryFile.cpp
@@ -63,17 +63,17 @@ GetTempDir(nsIFile** aTempDir)
   // to ensure it's been cleared.
   rv = tmpFile->AppendNative(nsDependentCString("mozilla-temp-files"));
   if (NS_WARN_IF(NS_FAILED(rv)))
     return rv;
   rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700);
   if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv)))
     return rv;
 #endif
- 
+
   tmpFile.forget(aTempDir);
 
   return NS_OK;
 }
 
 nsresult
 NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
 {
@@ -101,17 +101,17 @@ NS_OpenAnonymousTemporaryFile(PRFileDesc
 
   rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0700);
   if (NS_WARN_IF(NS_FAILED(rv)))
     return rv;
 
   rv = tmpFile->OpenNSPRFileDesc(PR_RDWR | nsIFile::DELETE_ON_CLOSE,
                                  PR_IRWXU, aOutFileDesc);
 
-  return rv;    
+  return rv;
 }
 
 #ifdef XP_WIN
 
 // On Windows we have an idle service observer that runs some time after
 // startup and deletes any stray anonymous temporary files...
 
 // Duration of idle time before we'll get a callback whereupon we attempt to
@@ -152,48 +152,48 @@ public:
     // time to start up before we add the idle observer. If we register the
     // idle observer too early, it will be registered before the fake idle
     // service is installed when running in xpcshell, and this interferes with
     // the fake idle service, causing xpcshell-test failures.
     mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
     if (NS_WARN_IF(!mTimer))
       return NS_ERROR_FAILURE;
     nsresult rv = mTimer->Init(this,
-                         SCHEDULE_TIMEOUT_MS,
-                         nsITimer::TYPE_ONE_SHOT);
+                               SCHEDULE_TIMEOUT_MS,
+                               nsITimer::TYPE_ONE_SHOT);
     if (NS_WARN_IF(NS_FAILED(rv)))
       return rv;
 
     // Register shutdown observer so we can cancel the timer if we shutdown before
     // the timer runs.
     nsCOMPtr<nsIObserverService> obsSrv = services::GetObserverService();
     if (NS_WARN_IF(!obsSrv))
       return NS_ERROR_FAILURE;
     return obsSrv->AddObserver(this, XPCOM_SHUTDOWN_TOPIC, false);
   }
 
   void Cleanup() {
     // Cancel timer.
     if (mTimer) {
       mTimer->Cancel();
       mTimer = nullptr;
-    }    
+    }
     // Remove idle service observer.
     nsCOMPtr<nsIIdleService> idleSvc =
       do_GetService("@mozilla.org/widget/idleservice;1");
     if (idleSvc) {
-      idleSvc->RemoveIdleObserver(this, TEMP_FILE_IDLE_TIME_S);    
+      idleSvc->RemoveIdleObserver(this, TEMP_FILE_IDLE_TIME_S);
     }
     // Remove shutdown observer.
     nsCOMPtr<nsIObserverService> obsSrv = services::GetObserverService();
     if (obsSrv) {
       obsSrv->RemoveObserver(this, XPCOM_SHUTDOWN_TOPIC);
     }
   }
-  
+
   NS_IMETHODIMP Observe(nsISupports *aSubject,
                         const char *aTopic,
                         const char16_t *aData)
   {
     if (nsCRT::strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC) == 0 &&
         NS_FAILED(RegisterIdleObserver())) {
       Cleanup();
     } else if (nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE) == 0) {
@@ -204,17 +204,17 @@ public:
       Cleanup();
     } else if (nsCRT::strcmp(aTopic, XPCOM_SHUTDOWN_TOPIC) == 0) {
       Cleanup();
     }
     return NS_OK;
   }
 
   nsresult RegisterIdleObserver() {
-    // Add this as an idle observer. When we've been idle for 
+    // Add this as an idle observer. When we've been idle for
     // TEMP_FILE_IDLE_TIME_S seconds, we'll get a notification, and we'll then
     // try to delete any stray temp files.
     nsCOMPtr<nsIIdleService> idleSvc =
       do_GetService("@mozilla.org/widget/idleservice;1");
     if (!idleSvc)
       return NS_ERROR_FAILURE;
     return idleSvc->AddIdleObserver(this, TEMP_FILE_IDLE_TIME_S);
   }
--- a/xpcom/io/nsAnonymousTemporaryFile.h
+++ b/xpcom/io/nsAnonymousTemporaryFile.h
@@ -20,12 +20,12 @@
  * The caller is responsible for closing the file when they're finished with it.
  *
  * The file will be deleted when the file handle is closed. On non-Windows
  * platforms the file will be unlinked before this function returns. On Windows
  * the OS supplied delete-on-close mechanism is unreliable if the application
  * crashes or the computer power cycles unexpectedly, so unopened temporary
  * files are purged at some time after application startup.
  *
- */ 
+ */
 nsresult
 NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc);
 
--- a/xpcom/io/nsAppDirectoryServiceDefs.h
+++ b/xpcom/io/nsAppDirectoryServiceDefs.h
@@ -1,13 +1,13 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
+
 #ifndef nsAppDirectoryServiceDefs_h___
 #define nsAppDirectoryServiceDefs_h___
 
 //========================================================================================
 //
 // Defines property names for directories available from standard nsIDirectoryServiceProviders.
 // These keys are not guaranteed to exist because the nsIDirectoryServiceProviders which
 // provide them are optional.
@@ -52,41 +52,41 @@
 // Files and directories which exist on a per-profile basis
 // These locations are typically provided by the profile mgr
 // --------------------------------------------------------------------------------------
 
 // In a shared profile environment, prefixing a profile-relative
 // key with NS_SHARED returns a location that is shared by
 // other users of the profile. Without this prefix, the consumer
 // has exclusive access to this location.
- 
+
 #define NS_SHARED                               "SHARED"
 
 #define NS_APP_PREFS_50_DIR                     "PrefD"         // Directory which contains user prefs       
 #define NS_APP_PREFS_50_FILE                    "PrefF"
 #define NS_METRO_APP_PREFS_50_FILE              "MetroPrefF"    // Metro browser prefs file
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST          "PrefDL"
 #define NS_EXT_PREFS_DEFAULTS_DIR_LIST          "ExtPrefDL"
 #define NS_APP_PREFS_OVERRIDE_DIR               "PrefDOverride" // Directory for per-profile defaults
-        
+
 #define NS_APP_USER_PROFILE_50_DIR              "ProfD"
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR        "ProfLD"
-        
+
 #define NS_APP_USER_CHROME_DIR                  "UChrm"
 #define NS_APP_USER_SEARCH_DIR                  "UsrSrchPlugns"
-         
+
 #define NS_APP_LOCALSTORE_50_FILE               "LclSt"
 #define NS_APP_USER_PANELS_50_FILE              "UPnls"
 #define NS_APP_USER_MIMETYPES_50_FILE           "UMimTyp"
 #define NS_APP_CACHE_PARENT_DIR                 "cachePDir"
 
 #define NS_APP_BOOKMARKS_50_FILE                "BMarks"
 
 #define NS_APP_DOWNLOADS_50_FILE                "DLoads"
-         
+
 #define NS_APP_SEARCH_50_FILE                   "SrchF"
-         
+
 #define NS_APP_INSTALL_CLEANUP_DIR              "XPIClnupD"  //location of xpicleanup.dat xpicleanup.exe 
 
 #define NS_APP_INDEXEDDB_PARENT_DIR             "indexedDBPDir"
 
 #define NS_APP_PERMISSION_PARENT_DIR            "permissionDBPDir"
 #endif
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsAppFileLocationProvider.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIAtom.h"
@@ -78,498 +79,498 @@ NS_IMPL_ISUPPORTS(nsAppFileLocationProvi
 
 //*****************************************************************************
 // nsAppFileLocationProvider::nsIDirectoryServiceProvider
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
 {
-    if (NS_WARN_IF(!prop))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!prop))
+    return NS_ERROR_INVALID_ARG;
 
-    nsCOMPtr<nsIFile>  localFile;
-    nsresult rv = NS_ERROR_FAILURE;
+  nsCOMPtr<nsIFile>  localFile;
+  nsresult rv = NS_ERROR_FAILURE;
 
-    *_retval = nullptr;
-    *persistent = true;
+  *_retval = nullptr;
+  *persistent = true;
 
 #ifdef MOZ_WIDGET_COCOA
-    FSRef fileRef;
-    nsCOMPtr<nsILocalFileMac> macFile;
+  FSRef fileRef;
+  nsCOMPtr<nsILocalFileMac> macFile;
 #endif
-    
-    if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
-    {
-        rv = GetProductDirectory(getter_AddRefs(localFile));
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0)
-    {
-        rv = GetProductDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendNative(APP_REGISTRY_NAME);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv)) {
-            rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
-            if (NS_SUCCEEDED(rv))
-                rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
-        }
+
+  if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
+  {
+    rv = GetProductDirectory(getter_AddRefs(localFile));
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0)
+  {
+    rv = GetProductDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendNative(APP_REGISTRY_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv)) {
+      rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
+      if (NS_SUCCEEDED(rv))
+        rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
     }
-    else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 ||
-             nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv)) {
-            rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
-            if (NS_SUCCEEDED(rv))
-                rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME);
-        }
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
-    {
-        rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_LOCAL_ROOT_DIR) == 0)
-    {
-        rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile), true);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 ||
+           nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv)) {
+      rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
+      if (NS_SUCCEEDED(rv))
+        rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME);
     }
-    else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
-    }
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
+  {
+    rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile));
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_LOCAL_ROOT_DIR) == 0)
+  {
+    rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile), true);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
+  }
 #ifdef MOZ_WIDGET_COCOA
-    else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
-    {
-        if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
-            rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
-            if (NS_SUCCEEDED(rv))
-                localFile = macFile;
-        }
+  else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
+  {
+    if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
+      rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
+      if (NS_SUCCEEDED(rv))
+        localFile = macFile;
     }
-    else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
-    {
-        if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
-            rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
-            if (NS_SUCCEEDED(rv))
-                localFile = macFile;
-        }
+  }
+  else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0)
+  {
+    if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
+      rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
+      if (NS_SUCCEEDED(rv))
+        localFile = macFile;
     }
-    else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0)
-    {
-      static const char *const java2PluginDirPath =
-        "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/";
-      rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true, getter_AddRefs(localFile));
-    }
+  }
+  else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0)
+  {
+    static const char *const java2PluginDirPath =
+      "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/";
+    rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true, getter_AddRefs(localFile));
+  }
 #else
-    else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
-    {
-        NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). "
-                 "Use nsAppFileLocationProvider::GetFiles(...).");
-        const char *pathVar = PR_GetEnv("MOZ_PLUGIN_PATH");
-        if (pathVar && *pathVar)
-            rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), true,
-                                       getter_AddRefs(localFile));
-    }
-    else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0)
-    {
+  else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
+  {
+    NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). "
+             "Use nsAppFileLocationProvider::GetFiles(...).");
+    const char *pathVar = PR_GetEnv("MOZ_PLUGIN_PATH");
+    if (pathVar && *pathVar)
+      rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), true,
+                                 getter_AddRefs(localFile));
+  }
+  else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0)
+  {
 #ifdef ENABLE_SYSTEM_EXTENSION_DIRS
-        rv = GetProductDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
+    rv = GetProductDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
 #else
-        rv = NS_ERROR_FAILURE;
+    rv = NS_ERROR_FAILURE;
 #endif
-    }
+  }
 #ifdef XP_UNIX
-    else if (nsCRT::strcmp(prop, NS_SYSTEM_PLUGINS_DIR) == 0) {
+  else if (nsCRT::strcmp(prop, NS_SYSTEM_PLUGINS_DIR) == 0) {
 #ifdef ENABLE_SYSTEM_EXTENSION_DIRS
-        static const char *const sysLPlgDir =
+    static const char *const sysLPlgDir =
 #if defined(HAVE_USR_LIB64_DIR) && defined(__LP64__)
-          "/usr/lib64/mozilla/plugins";
+      "/usr/lib64/mozilla/plugins";
 #elif defined(__OpenBSD__) || defined (__FreeBSD__)
-          "/usr/local/lib/mozilla/plugins";
+      "/usr/local/lib/mozilla/plugins";
 #else
-          "/usr/lib/mozilla/plugins";
+      "/usr/lib/mozilla/plugins";
 #endif
-        rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir),
-                                   false, getter_AddRefs(localFile));
+    rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir),
+                               false, getter_AddRefs(localFile));
 #else
-        rv = NS_ERROR_FAILURE;
+    rv = NS_ERROR_FAILURE;
 #endif
-    }
+  }
 #endif
 #endif
-    else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
-    {
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-        if (NS_SUCCEEDED(rv))
-            rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_USER_SEARCH_DIR) == 0)
-    {
-        rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, _retval);
-        if (NS_SUCCEEDED(rv))
-            rv = (*_retval)->AppendNative(SEARCH_DIR_NAME);
-    }
-    else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
-    {   
-        // This is cloned so that embeddors will have a hook to override
-        // with their own cleanup dir.  See bugzilla bug #105087 
-        rv = CloneMozBinDirectory(getter_AddRefs(localFile));
-    } 
+  else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
+  {
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+    if (NS_SUCCEEDED(rv))
+      rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_USER_SEARCH_DIR) == 0)
+  {
+    rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, _retval);
+    if (NS_SUCCEEDED(rv))
+      rv = (*_retval)->AppendNative(SEARCH_DIR_NAME);
+  }
+  else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
+  {
+    // This is cloned so that embeddors will have a hook to override
+    // with their own cleanup dir.  See bugzilla bug #105087
+    rv = CloneMozBinDirectory(getter_AddRefs(localFile));
+  }
 
-    if (localFile && NS_SUCCEEDED(rv))
-        return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
-        
-    return rv;
+  if (localFile && NS_SUCCEEDED(rv))
+    return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
+
+  return rv;
 }
 
 
 NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
 {
-    if (NS_WARN_IF(!aLocalFile))
-        return NS_ERROR_INVALID_ARG;
-    nsresult rv;
+  if (NS_WARN_IF(!aLocalFile))
+    return NS_ERROR_INVALID_ARG;
+  nsresult rv;
 
-    if (!mMozBinDirectory)
-    {
-        // Get the mozilla bin directory
-        // 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
-        //    This will be set if a directory was passed to NS_InitXPCOM
-        // 2. If that doesn't work, set it to be the current process directory
-        nsCOMPtr<nsIProperties>
-          directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
-        if (NS_FAILED(rv))
-            return rv;
+  if (!mMozBinDirectory)
+  {
+    // Get the mozilla bin directory
+    // 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR
+    //    This will be set if a directory was passed to NS_InitXPCOM
+    // 2. If that doesn't work, set it to be the current process directory
+    nsCOMPtr<nsIProperties>
+    directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
+    if (NS_FAILED(rv))
+      return rv;
 
-        rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
-        if (NS_FAILED(rv)) {
-            rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
-            if (NS_FAILED(rv))
-                return rv;
-        }
+    rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
+    if (NS_FAILED(rv)) {
+      rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory));
+      if (NS_FAILED(rv))
+        return rv;
     }
+  }
 
-    nsCOMPtr<nsIFile> aFile;
-    rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
-    if (NS_FAILED(rv))
-        return rv;
+  nsCOMPtr<nsIFile> aFile;
+  rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
+  if (NS_FAILED(rv))
+    return rv;
 
-    NS_IF_ADDREF(*aLocalFile = aFile);
-    return NS_OK;
+  NS_IF_ADDREF(*aLocalFile = aFile);
+  return NS_OK;
 }
 
 
 //----------------------------------------------------------------------------------------
 // GetProductDirectory - Gets the directory which contains the application data folder
 //
 // UNIX   : ~/.mozilla/
 // WIN    : <Application Data folder on user's machine>\Mozilla
 // Mac    : :Documents:Mozilla:
 //----------------------------------------------------------------------------------------
 NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile **aLocalFile, bool aLocal)
 {
-    if (NS_WARN_IF(!aLocalFile))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!aLocalFile))
+    return NS_ERROR_INVALID_ARG;
 
-    nsresult rv;
-    bool exists;
-    nsCOMPtr<nsIFile> localDir;
+  nsresult rv;
+  bool exists;
+  nsCOMPtr<nsIFile> localDir;
 
 #if defined(MOZ_WIDGET_COCOA)
-    FSRef fsRef;
-    OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType;
-    OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
-    if (err) return NS_ERROR_FAILURE;
-    NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir));
-    if (!localDir) return NS_ERROR_FAILURE;
-    nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
-    rv = localDirMac->InitWithFSRef(&fsRef);
-    if (NS_FAILED(rv)) return rv;
+  FSRef fsRef;
+  OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType;
+  OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
+  if (err) return NS_ERROR_FAILURE;
+  NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir));
+  if (!localDir) return NS_ERROR_FAILURE;
+  nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
+  rv = localDirMac->InitWithFSRef(&fsRef);
+  if (NS_FAILED(rv)) return rv;
 #elif defined(XP_WIN)
-    nsCOMPtr<nsIProperties> directoryService = 
-             do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
-    if (NS_FAILED(rv)) return rv;
-    const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR;
-    rv = directoryService->Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(localDir));
-    if (NS_FAILED(rv)) return rv;
+  nsCOMPtr<nsIProperties> directoryService =
+    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
+  if (NS_FAILED(rv)) return rv;
+  const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR;
+  rv = directoryService->Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(localDir));
+  if (NS_FAILED(rv)) return rv;
 #elif defined(XP_UNIX)
-    rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, getter_AddRefs(localDir));
-    if (NS_FAILED(rv)) return rv;
+  rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, getter_AddRefs(localDir));
+  if (NS_FAILED(rv)) return rv;
 #else
 #error dont_know_how_to_get_product_dir_on_your_platform
 #endif
 
-    rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
-    if (NS_FAILED(rv)) return rv;
-    rv = localDir->Exists(&exists);
+  rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
+  if (NS_FAILED(rv)) return rv;
+  rv = localDir->Exists(&exists);
 
-    if (NS_SUCCEEDED(rv) && !exists)
-        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
+  if (NS_SUCCEEDED(rv) && !exists)
+    rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
 
-    if (NS_FAILED(rv)) return rv;
+  if (NS_FAILED(rv)) return rv;
 
-    *aLocalFile = localDir;
-    NS_ADDREF(*aLocalFile);
+  *aLocalFile = localDir;
+  NS_ADDREF(*aLocalFile);
 
-   return rv;
+  return rv;
 }
 
 
 //----------------------------------------------------------------------------------------
 // GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir
 //
 // UNIX   : ~/.mozilla/
 // WIN    : <Application Data folder on user's machine>\Mozilla\Profiles
 // Mac    : :Documents:Mozilla:Profiles:
 //----------------------------------------------------------------------------------------
 NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile **aLocalFile, bool aLocal)
 {
-    if (NS_WARN_IF(!aLocalFile))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!aLocalFile))
+    return NS_ERROR_INVALID_ARG;
 
-    nsresult rv;
-    nsCOMPtr<nsIFile> localDir;
+  nsresult rv;
+  nsCOMPtr<nsIFile> localDir;
 
-    rv = GetProductDirectory(getter_AddRefs(localDir), aLocal);
-    if (NS_FAILED(rv)) return rv;
+  rv = GetProductDirectory(getter_AddRefs(localDir), aLocal);
+  if (NS_FAILED(rv)) return rv;
 
 #if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN)
-    // These 3 platforms share this part of the path - do them as one
-    rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
-    if (NS_FAILED(rv)) return rv;
+  // These 3 platforms share this part of the path - do them as one
+  rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
+  if (NS_FAILED(rv)) return rv;
 
-    bool exists;
-    rv = localDir->Exists(&exists);
-    if (NS_SUCCEEDED(rv) && !exists)
-        rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
-    if (NS_FAILED(rv)) return rv;
+  bool exists;
+  rv = localDir->Exists(&exists);
+  if (NS_SUCCEEDED(rv) && !exists)
+    rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
+  if (NS_FAILED(rv)) return rv;
 #endif
 
-    *aLocalFile = localDir;
-    NS_ADDREF(*aLocalFile);
+  *aLocalFile = localDir;
+  NS_ADDREF(*aLocalFile);
 
-   return rv;
+  return rv;
 }
 
 //*****************************************************************************
 // nsAppFileLocationProvider::nsIDirectoryServiceProvider2
 //*****************************************************************************
 
 class nsAppDirectoryEnumerator : public nsISimpleEnumerator
 {
-  public:
-    NS_DECL_ISUPPORTS
+public:
+  NS_DECL_ISUPPORTS
 
-    /**
-     * aKeyList is a null-terminated list of properties which are provided by aProvider
-     * They do not need to be publicly defined keys.
-     */
-    nsAppDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
-                             const char* aKeyList[]) :
-        mProvider(aProvider),
-        mCurrentKey(aKeyList)
-    {
-    }
+  /**
+   * aKeyList is a null-terminated list of properties which are provided by aProvider
+   * They do not need to be publicly defined keys.
+   */
+  nsAppDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
+                           const char* aKeyList[]) :
+    mProvider(aProvider),
+    mCurrentKey(aKeyList)
+  {
+  }
 
-    NS_IMETHOD HasMoreElements(bool *result) 
+  NS_IMETHOD HasMoreElements(bool *result)
+  {
+    while (!mNext && *mCurrentKey)
     {
-        while (!mNext && *mCurrentKey)
-        {
-            bool dontCare;
-            nsCOMPtr<nsIFile> testFile;
-            (void)mProvider->GetFile(*mCurrentKey++, &dontCare, getter_AddRefs(testFile));
-            // Don't return a file which does not exist.
-            bool exists;
-            if (testFile && NS_SUCCEEDED(testFile->Exists(&exists)) && exists)
-                mNext = testFile;
-        }
-        *result = mNext != nullptr;
-        return NS_OK;
+      bool dontCare;
+      nsCOMPtr<nsIFile> testFile;
+      (void)mProvider->GetFile(*mCurrentKey++, &dontCare, getter_AddRefs(testFile));
+      // Don't return a file which does not exist.
+      bool exists;
+      if (testFile && NS_SUCCEEDED(testFile->Exists(&exists)) && exists)
+        mNext = testFile;
     }
+    *result = mNext != nullptr;
+    return NS_OK;
+  }
 
-    NS_IMETHOD GetNext(nsISupports **result) 
-    {
-        if (NS_WARN_IF(!result))
-            return NS_ERROR_INVALID_ARG;
-        *result = nullptr;
+  NS_IMETHOD GetNext(nsISupports **result)
+  {
+    if (NS_WARN_IF(!result))
+      return NS_ERROR_INVALID_ARG;
+    *result = nullptr;
+
+    bool hasMore;
+    HasMoreElements(&hasMore);
+    if (!hasMore)
+      return NS_ERROR_FAILURE;
+
+    *result = mNext;
+    NS_IF_ADDREF(*result);
+    mNext = nullptr;
 
-        bool hasMore;
-        HasMoreElements(&hasMore);
-        if (!hasMore)
-            return NS_ERROR_FAILURE;
-            
-        *result = mNext;
-        NS_IF_ADDREF(*result);
-        mNext = nullptr;
-        
-        return *result ? NS_OK : NS_ERROR_FAILURE;
-    }
+    return *result ? NS_OK : NS_ERROR_FAILURE;
+  }
+
+  // Virtual destructor since subclass nsPathsDirectoryEnumerator
+  // does not re-implement Release()
 
-    // Virtual destructor since subclass nsPathsDirectoryEnumerator
-    // does not re-implement Release()
+  virtual ~nsAppDirectoryEnumerator()
+  {
+  }
 
-    virtual ~nsAppDirectoryEnumerator()
-    {
-    }
-
-  protected:
-    nsIDirectoryServiceProvider *mProvider;
-    const char** mCurrentKey;
-    nsCOMPtr<nsIFile> mNext;
+protected:
+  nsIDirectoryServiceProvider *mProvider;
+  const char** mCurrentKey;
+  nsCOMPtr<nsIFile> mNext;
 };
 
 NS_IMPL_ISUPPORTS(nsAppDirectoryEnumerator, nsISimpleEnumerator)
 
 /* nsPathsDirectoryEnumerator and PATH_SEPARATOR
  * are not used on MacOS/X. */
 
 #if defined(XP_WIN) /* Win32 */
 #define PATH_SEPARATOR ';'
 #else
 #define PATH_SEPARATOR ':'
 #endif
 
 class nsPathsDirectoryEnumerator : public nsAppDirectoryEnumerator
 {
-  public:
-    /**
-     * aKeyList is a null-terminated list.
-     * The first element is a path list.
-     * The remainder are properties provided by aProvider.
-     * They do not need to be publicly defined keys.
-     */
-    nsPathsDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
-                               const char* aKeyList[]) :
+public:
+  /**
+   * aKeyList is a null-terminated list.
+   * The first element is a path list.
+   * The remainder are properties provided by aProvider.
+   * They do not need to be publicly defined keys.
+   */
+  nsPathsDirectoryEnumerator(nsIDirectoryServiceProvider *aProvider,
+                             const char* aKeyList[]) :
     nsAppDirectoryEnumerator(aProvider, aKeyList+1),
     mEndPath(aKeyList[0])
-    {
-    }
+  {
+  }
 
-    NS_IMETHOD HasMoreElements(bool *result) 
-    {
-        if (mEndPath)
-            while (!mNext && *mEndPath)
-            {
-                const char *pathVar = mEndPath;
-           
-                // skip PATH_SEPARATORs at the begining of the mEndPath
-                while (*pathVar == PATH_SEPARATOR) pathVar++;
+  NS_IMETHOD HasMoreElements(bool *result)
+  {
+    if (mEndPath)
+      while (!mNext && *mEndPath)
+      {
+        const char *pathVar = mEndPath;
 
-                do { ++mEndPath; } while (*mEndPath && *mEndPath != PATH_SEPARATOR);
+        // skip PATH_SEPARATORs at the begining of the mEndPath
+        while (*pathVar == PATH_SEPARATOR) pathVar++;
+
+        do { ++mEndPath; } while (*mEndPath && *mEndPath != PATH_SEPARATOR);
 
-                nsCOMPtr<nsIFile> localFile;
-                NS_NewNativeLocalFile(Substring(pathVar, mEndPath),
-                                      true,
-                                      getter_AddRefs(localFile));
-                if (*mEndPath == PATH_SEPARATOR)
-                    ++mEndPath;
-                // Don't return a "file" (directory) which does not exist.
-                bool exists;
-                if (localFile &&
-                    NS_SUCCEEDED(localFile->Exists(&exists)) &&
-                    exists)
-                    mNext = localFile;
-            }
-        if (mNext)
-            *result = true;
-        else
-            nsAppDirectoryEnumerator::HasMoreElements(result);
+        nsCOMPtr<nsIFile> localFile;
+        NS_NewNativeLocalFile(Substring(pathVar, mEndPath),
+                              true,
+                              getter_AddRefs(localFile));
+        if (*mEndPath == PATH_SEPARATOR)
+          ++mEndPath;
+        // Don't return a "file" (directory) which does not exist.
+        bool exists;
+        if (localFile &&
+            NS_SUCCEEDED(localFile->Exists(&exists)) &&
+            exists)
+          mNext = localFile;
+      }
+    if (mNext)
+      *result = true;
+    else
+      nsAppDirectoryEnumerator::HasMoreElements(result);
 
-        return NS_OK;
-    }
+    return NS_OK;
+  }
 
-  protected:
-    const char *mEndPath;
+protected:
+  const char *mEndPath;
 };
 
 NS_IMETHODIMP
 nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
 {
-    if (NS_WARN_IF(!_retval))
-        return NS_ERROR_INVALID_ARG;
-    *_retval = nullptr;
-    nsresult rv = NS_ERROR_FAILURE;
-    
-    if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
-    {
+  if (NS_WARN_IF(!_retval))
+    return NS_ERROR_INVALID_ARG;
+  *_retval = nullptr;
+  nsresult rv = NS_ERROR_FAILURE;
+
+  if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
+  {
 #ifdef MOZ_WIDGET_COCOA
-        // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on
-        // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/.  Java
-        // Plugin2 is still present and usable, but there are no longer any links to it in the
-        // "normal" locations.  So we won't be able to find it unless we look in the "non-normal"
-        // location where it actually is.  Safari can use the WebKit-specific JavaPluginCocoa.bundle,
-        // which (of course) is still fully supported on OS X 10.5.  But we have no alternative to
-        // using Java Plugin2.  For more information see bug 668639.
-        static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR,
-                                      NS_MACOSX_LOCAL_PLUGIN_DIR,
-                                      IsOSXLeopard() ? NS_MACOSX_JAVA2_PLUGIN_DIR : nullptr, nullptr };
-        *_retval = new nsAppDirectoryEnumerator(this, keys);
+    // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on
+    // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/.  Java
+    // Plugin2 is still present and usable, but there are no longer any links to it in the
+    // "normal" locations.  So we won't be able to find it unless we look in the "non-normal"
+    // location where it actually is.  Safari can use the WebKit-specific JavaPluginCocoa.bundle,
+    // which (of course) is still fully supported on OS X 10.5.  But we have no alternative to
+    // using Java Plugin2.  For more information see bug 668639.
+    static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR,
+                                  NS_MACOSX_LOCAL_PLUGIN_DIR,
+                                  IsOSXLeopard() ? NS_MACOSX_JAVA2_PLUGIN_DIR : nullptr, nullptr };
+    *_retval = new nsAppDirectoryEnumerator(this, keys);
 #else
 #ifdef XP_UNIX
-        static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nullptr };
+    static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nullptr };
 #else
-        static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, nullptr };
+    static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, nullptr };
 #endif
-        if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_PLUGIN_PATH"))) {
-            static const char nullstr = 0;
-            keys[0] = &nullstr;
-        }
-        *_retval = new nsPathsDirectoryEnumerator(this, keys);
-#endif
-        NS_IF_ADDREF(*_retval);
-        rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
+    if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_PLUGIN_PATH"))) {
+      static const char nullstr = 0;
+      keys[0] = &nullstr;
     }
-    if (!nsCRT::strcmp(prop, NS_APP_SEARCH_DIR_LIST))
-    {
-        static const char* keys[] = { nullptr, NS_APP_SEARCH_DIR, NS_APP_USER_SEARCH_DIR, nullptr };
-        if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) {
-            static const char nullstr = 0;
-            keys[0] = &nullstr;
-        }
-        *_retval = new nsPathsDirectoryEnumerator(this, keys);
-        NS_IF_ADDREF(*_retval);
-        rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
+    *_retval = new nsPathsDirectoryEnumerator(this, keys);
+#endif
+    NS_IF_ADDREF(*_retval);
+    rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
+  }
+  if (!nsCRT::strcmp(prop, NS_APP_SEARCH_DIR_LIST))
+  {
+    static const char* keys[] = { nullptr, NS_APP_SEARCH_DIR, NS_APP_USER_SEARCH_DIR, nullptr };
+    if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) {
+      static const char nullstr = 0;
+      keys[0] = &nullstr;
     }
-    return rv;
+    *_retval = new nsPathsDirectoryEnumerator(this, keys);
+    NS_IF_ADDREF(*_retval);
+    rv = *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
+  }
+  return rv;
 }
 
 #if defined(MOZ_WIDGET_COCOA)
 bool
 nsAppFileLocationProvider::IsOSXLeopard()
 {
-    static SInt32 version = 0;
+  static SInt32 version = 0;
 
-    if (!version) {
-        OSErr err = ::Gestalt(gestaltSystemVersion, &version);
-        if (err != noErr) {
-            version = 0;
-        } else {
-            version &= 0xFFFF; // The system version is in the low order word
-        }
+  if (!version) {
+    OSErr err = ::Gestalt(gestaltSystemVersion, &version);
+    if (err != noErr) {
+      version = 0;
+    } else {
+      version &= 0xFFFF; // The system version is in the low order word
     }
+  }
 
-    return ((version >= 0x1050) && (version < 0x1060));
+  return ((version >= 0x1050) && (version < 0x1060));
 }
 #endif
--- a/xpcom/io/nsAppFileLocationProvider.h
+++ b/xpcom/io/nsAppFileLocationProvider.h
@@ -1,52 +1,53 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsAppFileLocationProvider_h
 #define nsAppFileLocationProvider_h
 
 #include "nsIDirectoryService.h"
 #include "nsIFile.h"
 #include "mozilla/Attributes.h"
 
 class nsIFile;
 
 //*****************************************************************************
 // class nsAppFileLocationProvider
-//*****************************************************************************   
+//*****************************************************************************
 
 class nsAppFileLocationProvider MOZ_FINAL : public nsIDirectoryServiceProvider2
 {
 public:
-                        nsAppFileLocationProvider();
+  nsAppFileLocationProvider();
 
-   NS_DECL_THREADSAFE_ISUPPORTS
-   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
-   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
+  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_NSIDIRECTORYSERVICEPROVIDER
+  NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
 private:
-                        ~nsAppFileLocationProvider() {}
+  ~nsAppFileLocationProvider() {}
 
 protected:
-   NS_METHOD            CloneMozBinDirectory(nsIFile **aLocalFile);
-   /**
-    * Get the product directory. This is a user-specific directory for storing
-    * application settings (e.g. the Application Data directory on windows
-    * systems).
-    * @param aLocal If true, should try to get a directory that is only stored
-    *               locally (ie not transferred with roaming profiles)
-    */
-   NS_METHOD            GetProductDirectory(nsIFile **aLocalFile,
-                                            bool aLocal = false);
-   NS_METHOD            GetDefaultUserProfileRoot(nsIFile **aLocalFile,
-                                                  bool aLocal = false);
+  NS_METHOD CloneMozBinDirectory(nsIFile **aLocalFile);
+  /**
+  * Get the product directory. This is a user-specific directory for storing
+  * application settings (e.g. the Application Data directory on windows
+  * systems).
+  * @param aLocal If true, should try to get a directory that is only stored
+  *               locally (ie not transferred with roaming profiles)
+  */
+  NS_METHOD GetProductDirectory(nsIFile **aLocalFile,
+                                bool aLocal = false);
+  NS_METHOD GetDefaultUserProfileRoot(nsIFile **aLocalFile,
+                                      bool aLocal = false);
 
 #if defined(MOZ_WIDGET_COCOA)
-   static bool          IsOSXLeopard();
+  static bool IsOSXLeopard();
 #endif
 
-   nsCOMPtr<nsIFile> mMozBinDirectory;
+  nsCOMPtr<nsIFile> mMozBinDirectory;
 };
 
 #endif
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This file contains implementations of the nsIBinaryInputStream and
  * nsIBinaryOutputStream interfaces.  Together, these interfaces allows reading
  * and writing of primitive data types (integers, floating-point values,
  * booleans, etc.) to a stream in a binary, untagged, fixed-endianness format.
@@ -27,574 +28,574 @@
 #include "nsIURI.h" // for NS_IURI_IID
 #include "mozilla/Endian.h"
 
 #include "jsfriendapi.h"
 
 NS_IMPL_ISUPPORTS(nsBinaryOutputStream, nsIObjectOutputStream, nsIBinaryOutputStream, nsIOutputStream)
 
 NS_IMETHODIMP
-nsBinaryOutputStream::Flush() 
-{ 
-    if (NS_WARN_IF(!mOutputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mOutputStream->Flush(); 
+nsBinaryOutputStream::Flush()
+{
+  if (NS_WARN_IF(!mOutputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mOutputStream->Flush();
 }
 
 NS_IMETHODIMP
-nsBinaryOutputStream::Close() 
-{ 
-    if (NS_WARN_IF(!mOutputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mOutputStream->Close(); 
+nsBinaryOutputStream::Close()
+{
+  if (NS_WARN_IF(!mOutputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mOutputStream->Close();
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::Write(const char *aBuf, uint32_t aCount, uint32_t *aActualBytes)
 {
-    if (NS_WARN_IF(!mOutputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mOutputStream->Write(aBuf, aCount, aActualBytes);
+  if (NS_WARN_IF(!mOutputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mOutputStream->Write(aBuf, aCount, aActualBytes);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteFrom(nsIInputStream *inStr, uint32_t count, uint32_t *_retval)
 {
-    NS_NOTREACHED("WriteFrom");
-    return NS_ERROR_NOT_IMPLEMENTED;
+  NS_NOTREACHED("WriteFrom");
+  return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, uint32_t count, uint32_t *_retval)
 {
-    NS_NOTREACHED("WriteSegments");
-    return NS_ERROR_NOT_IMPLEMENTED;
+  NS_NOTREACHED("WriteSegments");
+  return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::IsNonBlocking(bool *aNonBlocking)
 {
-    if (NS_WARN_IF(!mOutputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mOutputStream->IsNonBlocking(aNonBlocking);
+  if (NS_WARN_IF(!mOutputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mOutputStream->IsNonBlocking(aNonBlocking);
 }
 
 nsresult
 nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
 {
-    if (NS_WARN_IF(!mOutputStream))
-        return NS_ERROR_UNEXPECTED;
+  if (NS_WARN_IF(!mOutputStream))
+    return NS_ERROR_UNEXPECTED;
 
-    nsresult rv;
-    uint32_t bytesWritten;
+  nsresult rv;
+  uint32_t bytesWritten;
 
-    rv = mOutputStream->Write(aBuf, aCount, &bytesWritten);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesWritten != aCount)
-        return NS_ERROR_FAILURE;
-    return NS_OK;
+  rv = mOutputStream->Write(aBuf, aCount, &bytesWritten);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesWritten != aCount)
+    return NS_ERROR_FAILURE;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::SetOutputStream(nsIOutputStream *aOutputStream)
 {
-    if (NS_WARN_IF(!aOutputStream))
-        return NS_ERROR_INVALID_ARG;
-    mOutputStream = aOutputStream;
-    mBufferAccess = do_QueryInterface(aOutputStream);
-    return NS_OK;
+  if (NS_WARN_IF(!aOutputStream))
+    return NS_ERROR_INVALID_ARG;
+  mOutputStream = aOutputStream;
+  mBufferAccess = do_QueryInterface(aOutputStream);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteBoolean(bool aBoolean)
 {
-    return Write8(aBoolean);
+  return Write8(aBoolean);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::Write8(uint8_t aByte)
 {
-    return WriteFully((const char*)&aByte, sizeof aByte);
+  return WriteFully((const char*)&aByte, sizeof aByte);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::Write16(uint16_t a16)
 {
-    a16 = mozilla::NativeEndian::swapToBigEndian(a16);
-    return WriteFully((const char*)&a16, sizeof a16);
+  a16 = mozilla::NativeEndian::swapToBigEndian(a16);
+  return WriteFully((const char*)&a16, sizeof a16);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::Write32(uint32_t a32)
 {
-    a32 = mozilla::NativeEndian::swapToBigEndian(a32);
-    return WriteFully((const char*)&a32, sizeof a32);
+  a32 = mozilla::NativeEndian::swapToBigEndian(a32);
+  return WriteFully((const char*)&a32, sizeof a32);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::Write64(uint64_t a64)
 {
-    nsresult rv;
-    uint32_t bytesWritten;
+  nsresult rv;
+  uint32_t bytesWritten;
 
-    a64 = mozilla::NativeEndian::swapToBigEndian(a64);
-    rv = Write(reinterpret_cast<char*>(&a64), sizeof a64, &bytesWritten);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesWritten != sizeof a64)
-        return NS_ERROR_FAILURE;
-    return rv;
+  a64 = mozilla::NativeEndian::swapToBigEndian(a64);
+  rv = Write(reinterpret_cast<char*>(&a64), sizeof a64, &bytesWritten);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesWritten != sizeof a64)
+    return NS_ERROR_FAILURE;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteFloat(float aFloat)
 {
-    NS_ASSERTION(sizeof(float) == sizeof (uint32_t),
-                 "False assumption about sizeof(float)");
-    return Write32(*reinterpret_cast<uint32_t*>(&aFloat));
+  NS_ASSERTION(sizeof(float) == sizeof (uint32_t),
+               "False assumption about sizeof(float)");
+  return Write32(*reinterpret_cast<uint32_t*>(&aFloat));
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteDouble(double aDouble)
 {
-    NS_ASSERTION(sizeof(double) == sizeof(uint64_t),
-                 "False assumption about sizeof(double)");
-    return Write64(*reinterpret_cast<uint64_t*>(&aDouble));
+  NS_ASSERTION(sizeof(double) == sizeof(uint64_t),
+               "False assumption about sizeof(double)");
+  return Write64(*reinterpret_cast<uint64_t*>(&aDouble));
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteStringZ(const char *aString)
 {
-    uint32_t length;
-    nsresult rv;
+  uint32_t length;
+  nsresult rv;
 
-    length = strlen(aString);
-    rv = Write32(length);
-    if (NS_FAILED(rv)) return rv;
-    return WriteFully(aString, length);
+  length = strlen(aString);
+  rv = Write32(length);
+  if (NS_FAILED(rv)) return rv;
+  return WriteFully(aString, length);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteWStringZ(const char16_t* aString)
 {
-    uint32_t length, byteCount;
-    nsresult rv;
+  uint32_t length, byteCount;
+  nsresult rv;
 
-    length = NS_strlen(aString);
-    rv = Write32(length);
-    if (NS_FAILED(rv)) return rv;
+  length = NS_strlen(aString);
+  rv = Write32(length);
+  if (NS_FAILED(rv)) return rv;
 
-    if (length == 0)
-        return NS_OK;
-    byteCount = length * sizeof(char16_t);
+  if (length == 0)
+    return NS_OK;
+  byteCount = length * sizeof(char16_t);
 
 #ifdef IS_BIG_ENDIAN
-    rv = WriteBytes(reinterpret_cast<const char*>(aString), byteCount);
+  rv = WriteBytes(reinterpret_cast<const char*>(aString), byteCount);
 #else
-    // XXX use WriteSegments here to avoid copy!
-    char16_t *copy, temp[64];
-    if (length <= 64) {
-        copy = temp;
-    } else {
-        copy = reinterpret_cast<char16_t*>(moz_malloc(byteCount));
-        if (!copy)
-            return NS_ERROR_OUT_OF_MEMORY;
-    }
-    NS_ASSERTION((uintptr_t(aString) & 0x1) == 0, "aString not properly aligned");
-    mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
-    rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
-    if (copy != temp)
-        moz_free(copy);
+  // XXX use WriteSegments here to avoid copy!
+  char16_t *copy, temp[64];
+  if (length <= 64) {
+    copy = temp;
+  } else {
+    copy = reinterpret_cast<char16_t*>(moz_malloc(byteCount));
+    if (!copy)
+      return NS_ERROR_OUT_OF_MEMORY;
+  }
+  NS_ASSERTION((uintptr_t(aString) & 0x1) == 0, "aString not properly aligned");
+  mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
+  rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
+  if (copy != temp)
+    moz_free(copy);
 #endif
 
-    return rv;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteUtf8Z(const char16_t* aString)
 {
-    return WriteStringZ(NS_ConvertUTF16toUTF8(aString).get());
+  return WriteStringZ(NS_ConvertUTF16toUTF8(aString).get());
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteBytes(const char *aString, uint32_t aLength)
 {
-    nsresult rv;
-    uint32_t bytesWritten;
+  nsresult rv;
+  uint32_t bytesWritten;
 
-    rv = Write(aString, aLength, &bytesWritten);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesWritten != aLength)
-        return NS_ERROR_FAILURE;
-    return rv;
+  rv = Write(aString, aLength, &bytesWritten);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesWritten != aLength)
+    return NS_ERROR_FAILURE;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteByteArray(uint8_t *aBytes, uint32_t aLength)
 {
-    return WriteBytes(reinterpret_cast<char *>(aBytes), aLength);
+  return WriteBytes(reinterpret_cast<char *>(aBytes), aLength);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteObject(nsISupports* aObject, bool aIsStrongRef)
 {
-    return WriteCompoundObject(aObject, NS_GET_IID(nsISupports),
-                               aIsStrongRef);
+  return WriteCompoundObject(aObject, NS_GET_IID(nsISupports),
+                             aIsStrongRef);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteSingleRefObject(nsISupports* aObject)
 {
-    return WriteCompoundObject(aObject, NS_GET_IID(nsISupports),
-                               true);
+  return WriteCompoundObject(aObject, NS_GET_IID(nsISupports),
+                             true);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteCompoundObject(nsISupports* aObject,
                                           const nsIID& aIID,
                                           bool aIsStrongRef)
 {
-    nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
-    nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aObject);
+  nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
+  nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aObject);
 
-    // Can't deal with weak refs
-    if (NS_WARN_IF(!aIsStrongRef))
-        return NS_ERROR_UNEXPECTED;
-    if (NS_WARN_IF(!classInfo) || NS_WARN_IF(!serializable))
-        return NS_ERROR_NOT_AVAILABLE;
+  // Can't deal with weak refs
+  if (NS_WARN_IF(!aIsStrongRef))
+    return NS_ERROR_UNEXPECTED;
+  if (NS_WARN_IF(!classInfo) || NS_WARN_IF(!serializable))
+    return NS_ERROR_NOT_AVAILABLE;
 
-    nsCID cid;
-    nsresult rv = classInfo->GetClassIDNoAlloc(&cid);
-    if (NS_SUCCEEDED(rv)) {
-        rv = WriteID(cid);
-    } else {
-        nsCID *cidptr = nullptr;
-        rv = classInfo->GetClassID(&cidptr);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-            return rv;
-        }
-
-        rv = WriteID(*cidptr);
-
-        NS_Free(cidptr);
+  nsCID cid;
+  nsresult rv = classInfo->GetClassIDNoAlloc(&cid);
+  if (NS_SUCCEEDED(rv)) {
+    rv = WriteID(cid);
+  } else {
+    nsCID *cidptr = nullptr;
+    rv = classInfo->GetClassID(&cidptr);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
     }
 
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+    rv = WriteID(*cidptr);
+
+    NS_Free(cidptr);
+  }
 
-    rv = WriteID(aIID);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    return serializable->Write(this);
+  rv = WriteID(aIID);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
+
+  return serializable->Write(this);
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteID(const nsIID& aIID)
 {
-    nsresult rv = Write32(aIID.m0);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  nsresult rv = Write32(aIID.m0);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    rv = Write16(aIID.m1);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  rv = Write16(aIID.m1);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    rv = Write16(aIID.m2);
+  rv = Write16(aIID.m2);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
+
+  for (int i = 0; i < 8; ++i) {
+    rv = Write8(aIID.m3[i]);
     if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+      return rv;
+  }
 
-    for (int i = 0; i < 8; ++i) {
-        rv = Write8(aIID.m3[i]);
-        if (NS_WARN_IF(NS_FAILED(rv)))
-            return rv;
-    }
-
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP_(char*)
 nsBinaryOutputStream::GetBuffer(uint32_t aLength, uint32_t aAlignMask)
 {
-    if (mBufferAccess)
-        return mBufferAccess->GetBuffer(aLength, aAlignMask);
-    return nullptr;
+  if (mBufferAccess)
+    return mBufferAccess->GetBuffer(aLength, aAlignMask);
+  return nullptr;
 }
 
 NS_IMETHODIMP_(void)
 nsBinaryOutputStream::PutBuffer(char* aBuffer, uint32_t aLength)
 {
-    if (mBufferAccess)
-        mBufferAccess->PutBuffer(aBuffer, aLength);
+  if (mBufferAccess)
+    mBufferAccess->PutBuffer(aBuffer, aLength);
 }
 
 NS_IMPL_ISUPPORTS(nsBinaryInputStream, nsIObjectInputStream, nsIBinaryInputStream, nsIInputStream)
 
 NS_IMETHODIMP
 nsBinaryInputStream::Available(uint64_t* aResult)
 {
-    if (NS_WARN_IF(!mInputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mInputStream->Available(aResult);
+  if (NS_WARN_IF(!mInputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mInputStream->Available(aResult);
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t *aNumRead)
 {
-    if (NS_WARN_IF(!mInputStream))
-        return NS_ERROR_UNEXPECTED;
+  if (NS_WARN_IF(!mInputStream))
+    return NS_ERROR_UNEXPECTED;
 
-    // mInputStream might give us short reads, so deal with that.
-    uint32_t totalRead = 0;
+  // mInputStream might give us short reads, so deal with that.
+  uint32_t totalRead = 0;
 
-    uint32_t bytesRead;
-    do {
-        nsresult rv = mInputStream->Read(aBuffer, aCount, &bytesRead);
-        if (rv == NS_BASE_STREAM_WOULD_BLOCK && totalRead != 0) {
-            // We already read some data.  Return it.
-            break;
-        }
-        
-        if (NS_FAILED(rv)) {
-            return rv;
-        }
+  uint32_t bytesRead;
+  do {
+    nsresult rv = mInputStream->Read(aBuffer, aCount, &bytesRead);
+    if (rv == NS_BASE_STREAM_WOULD_BLOCK && totalRead != 0) {
+      // We already read some data.  Return it.
+      break;
+    }
 
-        totalRead += bytesRead;
-        aBuffer += bytesRead;
-        aCount -= bytesRead;
-    } while (aCount != 0 && bytesRead != 0);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
 
-    *aNumRead = totalRead;
-    
-    return NS_OK;
+    totalRead += bytesRead;
+    aBuffer += bytesRead;
+    aCount -= bytesRead;
+  } while (aCount != 0 && bytesRead != 0);
+
+  *aNumRead = totalRead;
+
+  return NS_OK;
 }
 
 
 // when forwarding ReadSegments to mInputStream, we need to make sure
 // 'this' is being passed to the writer each time. To do this, we need
 // a thunking function which keeps the real input stream around.
 
 // the closure wrapper
 struct ReadSegmentsClosure {
-    nsIInputStream* mRealInputStream;
-    void* mRealClosure;
-    nsWriteSegmentFun mRealWriter;
-    nsresult mRealResult;
-    uint32_t mBytesRead;  // to properly implement aToOffset
+  nsIInputStream* mRealInputStream;
+  void* mRealClosure;
+  nsWriteSegmentFun mRealWriter;
+  nsresult mRealResult;
+  uint32_t mBytesRead;  // to properly implement aToOffset
 };
 
 // the thunking function
 static NS_METHOD
 ReadSegmentForwardingThunk(nsIInputStream* aStream,
                            void *aClosure,
                            const char* aFromSegment,
                            uint32_t aToOffset,
                            uint32_t aCount,
                            uint32_t *aWriteCount)
 {
-    ReadSegmentsClosure* thunkClosure =
-        reinterpret_cast<ReadSegmentsClosure*>(aClosure);
+  ReadSegmentsClosure* thunkClosure =
+    reinterpret_cast<ReadSegmentsClosure*>(aClosure);
 
-    NS_ASSERTION(NS_SUCCEEDED(thunkClosure->mRealResult),
-                 "How did this get to be a failure status?");
+  NS_ASSERTION(NS_SUCCEEDED(thunkClosure->mRealResult),
+               "How did this get to be a failure status?");
 
-    thunkClosure->mRealResult =
-        thunkClosure->mRealWriter(thunkClosure->mRealInputStream,
-                                  thunkClosure->mRealClosure,
-                                  aFromSegment,
-                                  thunkClosure->mBytesRead + aToOffset,
-                                  aCount, aWriteCount);
+  thunkClosure->mRealResult =
+    thunkClosure->mRealWriter(thunkClosure->mRealInputStream,
+                              thunkClosure->mRealClosure,
+                              aFromSegment,
+                              thunkClosure->mBytesRead + aToOffset,
+                              aCount, aWriteCount);
 
-    return thunkClosure->mRealResult;
+  return thunkClosure->mRealResult;
 }
 
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, uint32_t count, uint32_t *_retval)
 {
-    if (NS_WARN_IF(!mInputStream))
-        return NS_ERROR_UNEXPECTED;
+  if (NS_WARN_IF(!mInputStream))
+    return NS_ERROR_UNEXPECTED;
+
+  ReadSegmentsClosure thunkClosure = { this, closure, writer, NS_OK, 0 };
 
-    ReadSegmentsClosure thunkClosure = { this, closure, writer, NS_OK, 0 };
-    
-    // mInputStream might give us short reads, so deal with that.
-    uint32_t bytesRead;
-    do {
-        nsresult rv = mInputStream->ReadSegments(ReadSegmentForwardingThunk,
-                                                 &thunkClosure,
-                                                 count, &bytesRead);
+  // mInputStream might give us short reads, so deal with that.
+  uint32_t bytesRead;
+  do {
+    nsresult rv = mInputStream->ReadSegments(ReadSegmentForwardingThunk,
+                                             &thunkClosure,
+                                             count, &bytesRead);
 
-        if (rv == NS_BASE_STREAM_WOULD_BLOCK && thunkClosure.mBytesRead != 0) {
-            // We already read some data.  Return it.
-            break;
-        }
-        
-        if (NS_FAILED(rv)) {
-            return rv;
-        }
+    if (rv == NS_BASE_STREAM_WOULD_BLOCK && thunkClosure.mBytesRead != 0) {
+      // We already read some data.  Return it.
+      break;
+    }
+
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
 
-        thunkClosure.mBytesRead += bytesRead;
-        count -= bytesRead;
-    } while (count != 0 && bytesRead != 0 &&
-             NS_SUCCEEDED(thunkClosure.mRealResult));
+    thunkClosure.mBytesRead += bytesRead;
+    count -= bytesRead;
+  } while (count != 0 && bytesRead != 0 &&
+           NS_SUCCEEDED(thunkClosure.mRealResult));
 
-    *_retval = thunkClosure.mBytesRead;
+  *_retval = thunkClosure.mBytesRead;
 
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::IsNonBlocking(bool *aNonBlocking)
 {
-    if (NS_WARN_IF(!mInputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mInputStream->IsNonBlocking(aNonBlocking);
+  if (NS_WARN_IF(!mInputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mInputStream->IsNonBlocking(aNonBlocking);
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Close()
 {
-    if (NS_WARN_IF(!mInputStream))
-        return NS_ERROR_UNEXPECTED;
-    return mInputStream->Close();
+  if (NS_WARN_IF(!mInputStream))
+    return NS_ERROR_UNEXPECTED;
+  return mInputStream->Close();
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::SetInputStream(nsIInputStream *aInputStream)
 {
-    if (NS_WARN_IF(!aInputStream))
-        return NS_ERROR_INVALID_ARG;
-    mInputStream = aInputStream;
-    mBufferAccess = do_QueryInterface(aInputStream);
-    return NS_OK;
+  if (NS_WARN_IF(!aInputStream))
+    return NS_ERROR_INVALID_ARG;
+  mInputStream = aInputStream;
+  mBufferAccess = do_QueryInterface(aInputStream);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadBoolean(bool* aBoolean)
 {
-    uint8_t byteResult;
-    nsresult rv = Read8(&byteResult);
-    if (NS_FAILED(rv)) return rv;
-    *aBoolean = !!byteResult;
-    return rv;
+  uint8_t byteResult;
+  nsresult rv = Read8(&byteResult);
+  if (NS_FAILED(rv)) return rv;
+  *aBoolean = !!byteResult;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read8(uint8_t* aByte)
 {
-    nsresult rv;
-    uint32_t bytesRead;
+  nsresult rv;
+  uint32_t bytesRead;
 
-    rv = Read(reinterpret_cast<char*>(aByte), sizeof(*aByte), &bytesRead);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesRead != 1)
-        return NS_ERROR_FAILURE;
-    return rv;
+  rv = Read(reinterpret_cast<char*>(aByte), sizeof(*aByte), &bytesRead);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesRead != 1)
+    return NS_ERROR_FAILURE;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read16(uint16_t* a16)
 {
-    nsresult rv;
-    uint32_t bytesRead;
+  nsresult rv;
+  uint32_t bytesRead;
 
-    rv = Read(reinterpret_cast<char*>(a16), sizeof *a16, &bytesRead);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesRead != sizeof *a16)
-        return NS_ERROR_FAILURE;
-    *a16 = mozilla::NativeEndian::swapFromBigEndian(*a16);
-    return rv;
+  rv = Read(reinterpret_cast<char*>(a16), sizeof *a16, &bytesRead);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesRead != sizeof *a16)
+    return NS_ERROR_FAILURE;
+  *a16 = mozilla::NativeEndian::swapFromBigEndian(*a16);
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read32(uint32_t* a32)
 {
-    nsresult rv;
-    uint32_t bytesRead;
+  nsresult rv;
+  uint32_t bytesRead;
 
-    rv = Read(reinterpret_cast<char*>(a32), sizeof *a32, &bytesRead);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesRead != sizeof *a32)
-        return NS_ERROR_FAILURE;
-    *a32 = mozilla::NativeEndian::swapFromBigEndian(*a32);
-    return rv;
+  rv = Read(reinterpret_cast<char*>(a32), sizeof *a32, &bytesRead);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesRead != sizeof *a32)
+    return NS_ERROR_FAILURE;
+  *a32 = mozilla::NativeEndian::swapFromBigEndian(*a32);
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::Read64(uint64_t* a64)
 {
-    nsresult rv;
-    uint32_t bytesRead;
+  nsresult rv;
+  uint32_t bytesRead;
 
-    rv = Read(reinterpret_cast<char*>(a64), sizeof *a64, &bytesRead);
-    if (NS_FAILED(rv)) return rv;
-    if (bytesRead != sizeof *a64)
-        return NS_ERROR_FAILURE;
-    *a64 = mozilla::NativeEndian::swapFromBigEndian(*a64);
-    return rv;
+  rv = Read(reinterpret_cast<char*>(a64), sizeof *a64, &bytesRead);
+  if (NS_FAILED(rv)) return rv;
+  if (bytesRead != sizeof *a64)
+    return NS_ERROR_FAILURE;
+  *a64 = mozilla::NativeEndian::swapFromBigEndian(*a64);
+  return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadFloat(float* aFloat)
 {
-    NS_ASSERTION(sizeof(float) == sizeof (uint32_t),
-                 "False assumption about sizeof(float)");
-    return Read32(reinterpret_cast<uint32_t*>(aFloat));
+  NS_ASSERTION(sizeof(float) == sizeof (uint32_t),
+               "False assumption about sizeof(float)");
+  return Read32(reinterpret_cast<uint32_t*>(aFloat));
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadDouble(double* aDouble)
 {
-    NS_ASSERTION(sizeof(double) == sizeof(uint64_t),
-                 "False assumption about sizeof(double)");
-    return Read64(reinterpret_cast<uint64_t*>(aDouble));
+  NS_ASSERTION(sizeof(double) == sizeof(uint64_t),
+               "False assumption about sizeof(double)");
+  return Read64(reinterpret_cast<uint64_t*>(aDouble));
 }
 
 static NS_METHOD
 WriteSegmentToCString(nsIInputStream* aStream,
                       void *aClosure,
                       const char* aFromSegment,
                       uint32_t aToOffset,
                       uint32_t aCount,
                       uint32_t *aWriteCount)
 {
-    nsACString* outString = static_cast<nsACString*>(aClosure);
+  nsACString* outString = static_cast<nsACString*>(aClosure);
 
-    outString->Append(aFromSegment, aCount);
+  outString->Append(aFromSegment, aCount);
 
-    *aWriteCount = aCount;
-    
-    return NS_OK;
+  *aWriteCount = aCount;
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadCString(nsACString& aString)
 {
-    nsresult rv;
-    uint32_t length, bytesRead;
+  nsresult rv;
+  uint32_t length, bytesRead;
 
-    rv = Read32(&length);
-    if (NS_FAILED(rv)) return rv;
+  rv = Read32(&length);
+  if (NS_FAILED(rv)) return rv;
 
-    aString.Truncate();
-    rv = ReadSegments(WriteSegmentToCString, &aString, length, &bytesRead);
-    if (NS_FAILED(rv)) return rv;
-    
-    if (bytesRead != length)
-        return NS_ERROR_FAILURE;
+  aString.Truncate();
+  rv = ReadSegments(WriteSegmentToCString, &aString, length, &bytesRead);
+  if (NS_FAILED(rv)) return rv;
 
-    return NS_OK;
+  if (bytesRead != length)
+    return NS_ERROR_FAILURE;
+
+  return NS_OK;
 }
 
 
 // sometimes, WriteSegmentToString will be handed an odd-number of
 // bytes, which means we only have half of the last char16_t
 struct WriteStringClosure {
-    char16_t *mWriteCursor;
-    bool mHasCarryoverByte;
-    char mCarryoverByte;
+  char16_t *mWriteCursor;
+  bool mHasCarryoverByte;
+  char mCarryoverByte;
 };
 
 // there are a few cases we have to account for here:
 // * even length buffer, no carryover - easy, just append
 // * odd length buffer, no carryover - the last byte needs to be saved
 //                                     for carryover
 // * odd length buffer, with carryover - first byte needs to be used
 //                              with the carryover byte, and
@@ -611,251 +612,251 @@ struct WriteStringClosure {
 static NS_METHOD
 WriteSegmentToString(nsIInputStream* aStream,
                      void *aClosure,
                      const char* aFromSegment,
                      uint32_t aToOffset,
                      uint32_t aCount,
                      uint32_t *aWriteCount)
 {
-    NS_PRECONDITION(aCount > 0, "Why are we being told to write 0 bytes?");
-    NS_PRECONDITION(sizeof(char16_t) == 2, "We can't handle other sizes!");
+  NS_PRECONDITION(aCount > 0, "Why are we being told to write 0 bytes?");
+  NS_PRECONDITION(sizeof(char16_t) == 2, "We can't handle other sizes!");
 
-    WriteStringClosure* closure = static_cast<WriteStringClosure*>(aClosure);
-    char16_t *cursor = closure->mWriteCursor;
+  WriteStringClosure* closure = static_cast<WriteStringClosure*>(aClosure);
+  char16_t *cursor = closure->mWriteCursor;
 
-    // we're always going to consume the whole buffer no matter what
-    // happens, so take care of that right now.. that allows us to
-    // tweak aCount later. Do NOT move this!
-    *aWriteCount = aCount;
+  // we're always going to consume the whole buffer no matter what
+  // happens, so take care of that right now.. that allows us to
+  // tweak aCount later. Do NOT move this!
+  *aWriteCount = aCount;
 
-    // if the last Write had an odd-number of bytes read, then 
-    if (closure->mHasCarryoverByte) {
-        // re-create the two-byte sequence we want to work with
-        char bytes[2] = { closure->mCarryoverByte, *aFromSegment };
-        *cursor = *(char16_t*)bytes;
-        // Now the little endianness dance
-        mozilla::NativeEndian::swapToBigEndianInPlace(cursor, 1);
-        ++cursor;
-        
-        // now skip past the first byte of the buffer.. code from here
-        // can assume normal operations, but should not assume aCount
-        // is relative to the ORIGINAL buffer
-        ++aFromSegment;
-        --aCount;
+  // if the last Write had an odd-number of bytes read, then
+  if (closure->mHasCarryoverByte) {
+    // re-create the two-byte sequence we want to work with
+    char bytes[2] = { closure->mCarryoverByte, *aFromSegment };
+    *cursor = *(char16_t*)bytes;
+    // Now the little endianness dance
+    mozilla::NativeEndian::swapToBigEndianInPlace(cursor, 1);
+    ++cursor;
+
+    // now skip past the first byte of the buffer.. code from here
+    // can assume normal operations, but should not assume aCount
+    // is relative to the ORIGINAL buffer
+    ++aFromSegment;
+    --aCount;
 
-        closure->mHasCarryoverByte = false;
-    }
-    
-    // this array is possibly unaligned... be careful how we access it!
-    const char16_t *unicodeSegment =
-        reinterpret_cast<const char16_t*>(aFromSegment);
+    closure->mHasCarryoverByte = false;
+  }
 
-    // calculate number of full characters in segment (aCount could be odd!)
-    uint32_t segmentLength = aCount / sizeof(char16_t);
+  // this array is possibly unaligned... be careful how we access it!
+  const char16_t *unicodeSegment =
+    reinterpret_cast<const char16_t*>(aFromSegment);
+
+  // calculate number of full characters in segment (aCount could be odd!)
+  uint32_t segmentLength = aCount / sizeof(char16_t);
 
-    // copy all data into our aligned buffer.  byte swap if necessary.
-    // cursor may be unaligned, so we cannot use copyAndSwapToBigEndian directly
-    memcpy(cursor, unicodeSegment, segmentLength * sizeof(char16_t));
-    char16_t *end = cursor + segmentLength;
-    mozilla::NativeEndian::swapToBigEndianInPlace(cursor, segmentLength);
-    closure->mWriteCursor = end;
+  // copy all data into our aligned buffer.  byte swap if necessary.
+  // cursor may be unaligned, so we cannot use copyAndSwapToBigEndian directly
+  memcpy(cursor, unicodeSegment, segmentLength * sizeof(char16_t));
+  char16_t *end = cursor + segmentLength;
+  mozilla::NativeEndian::swapToBigEndianInPlace(cursor, segmentLength);
+  closure->mWriteCursor = end;
 
-    // remember this is the modifed aCount and aFromSegment,
-    // so that will take into account the fact that we might have
-    // skipped the first byte in the buffer
-    if (aCount % sizeof(char16_t) != 0) {
-        // we must have had a carryover byte, that we'll need the next
-        // time around
-        closure->mCarryoverByte = aFromSegment[aCount - 1];
-        closure->mHasCarryoverByte = true;
-    }
-    
-    return NS_OK;
+  // remember this is the modifed aCount and aFromSegment,
+  // so that will take into account the fact that we might have
+  // skipped the first byte in the buffer
+  if (aCount % sizeof(char16_t) != 0) {
+    // we must have had a carryover byte, that we'll need the next
+    // time around
+    closure->mCarryoverByte = aFromSegment[aCount - 1];
+    closure->mHasCarryoverByte = true;
+  }
+
+  return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadString(nsAString& aString)
 {
-    nsresult rv;
-    uint32_t length, bytesRead;
+  nsresult rv;
+  uint32_t length, bytesRead;
 
-    rv = Read32(&length);
-    if (NS_FAILED(rv)) return rv;
+  rv = Read32(&length);
+  if (NS_FAILED(rv)) return rv;
 
-    if (length == 0) {
-      aString.Truncate();
-      return NS_OK;
-    }
+  if (length == 0) {
+    aString.Truncate();
+    return NS_OK;
+  }
 
-    // pre-allocate output buffer, and get direct access to buffer...
-    if (!aString.SetLength(length, mozilla::fallible_t()))
-        return NS_ERROR_OUT_OF_MEMORY;
+  // pre-allocate output buffer, and get direct access to buffer...
+  if (!aString.SetLength(length, mozilla::fallible_t()))
+    return NS_ERROR_OUT_OF_MEMORY;
 
-    nsAString::iterator start;
-    aString.BeginWriting(start);
-    
-    WriteStringClosure closure;
-    closure.mWriteCursor = start.get();
-    closure.mHasCarryoverByte = false;
-    
-    rv = ReadSegments(WriteSegmentToString, &closure,
-                      length*sizeof(char16_t), &bytesRead);
-    if (NS_FAILED(rv)) return rv;
+  nsAString::iterator start;
+  aString.BeginWriting(start);
+
+  WriteStringClosure closure;
+  closure.mWriteCursor = start.get();
+  closure.mHasCarryoverByte = false;
 
-    NS_ASSERTION(!closure.mHasCarryoverByte, "some strange stream corruption!");
-    
-    if (bytesRead != length*sizeof(char16_t))
-        return NS_ERROR_FAILURE;
+  rv = ReadSegments(WriteSegmentToString, &closure,
+                    length*sizeof(char16_t), &bytesRead);
+  if (NS_FAILED(rv)) return rv;
 
-    return NS_OK;
+  NS_ASSERTION(!closure.mHasCarryoverByte, "some strange stream corruption!");
+
+  if (bytesRead != length*sizeof(char16_t))
+    return NS_ERROR_FAILURE;
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadBytes(uint32_t aLength, char* *_rval)
 {
-    nsresult rv;
-    uint32_t bytesRead;
-    char* s;
+  nsresult rv;
+  uint32_t bytesRead;
+  char* s;
 
-    s = reinterpret_cast<char*>(moz_malloc(aLength));
-    if (!s)
-        return NS_ERROR_OUT_OF_MEMORY;
+  s = reinterpret_cast<char*>(moz_malloc(aLength));
+  if (!s)
+    return NS_ERROR_OUT_OF_MEMORY;
 
-    rv = Read(s, aLength, &bytesRead);
-    if (NS_FAILED(rv)) {
-        moz_free(s);
-        return rv;
-    }
-    if (bytesRead != aLength) {
-        moz_free(s);
-        return NS_ERROR_FAILURE;
-    }
+  rv = Read(s, aLength, &bytesRead);
+  if (NS_FAILED(rv)) {
+    moz_free(s);
+    return rv;
+  }
+  if (bytesRead != aLength) {
+    moz_free(s);
+    return NS_ERROR_FAILURE;
+  }
 
-    *_rval = s;
-    return NS_OK;
+  *_rval = s;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadByteArray(uint32_t aLength, uint8_t* *_rval)
 {
-    return ReadBytes(aLength, reinterpret_cast<char **>(_rval));
+  return ReadBytes(aLength, reinterpret_cast<char **>(_rval));
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, JS::Handle<JS::Value> aBuffer, JSContext* cx)
 {
-    if (!aBuffer.isObject()) {
-        return NS_ERROR_FAILURE;
-    }
-    JS::RootedObject buffer(cx, &aBuffer.toObject());
-    if (!JS_IsArrayBufferObject(buffer) ||
-        JS_GetArrayBufferByteLength(buffer) < aLength) {
-        return NS_ERROR_FAILURE;
-    }
-    uint8_t* data = JS_GetStableArrayBufferData(cx, buffer);
-    if (!data) {
-        return NS_ERROR_FAILURE;
-    }
+  if (!aBuffer.isObject()) {
+    return NS_ERROR_FAILURE;
+  }
+  JS::RootedObject buffer(cx, &aBuffer.toObject());
+  if (!JS_IsArrayBufferObject(buffer) ||
+      JS_GetArrayBufferByteLength(buffer) < aLength) {
+    return NS_ERROR_FAILURE;
+  }
+  uint8_t* data = JS_GetStableArrayBufferData(cx, buffer);
+  if (!data) {
+    return NS_ERROR_FAILURE;
+  }
 
-    uint32_t bytesRead;
-    nsresult rv = Read(reinterpret_cast<char*>(data), aLength, &bytesRead);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
-    if (bytesRead != aLength) {
-        return NS_ERROR_FAILURE;
-    }
-    return NS_OK;
+  uint32_t bytesRead;
+  nsresult rv = Read(reinterpret_cast<char*>(data), aLength, &bytesRead);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
+  if (bytesRead != aLength) {
+    return NS_ERROR_FAILURE;
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadObject(bool aIsStrongRef, nsISupports* *aObject)
 {
-    nsCID cid;
-    nsIID iid;
-    nsresult rv = ReadID(&cid);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  nsCID cid;
+  nsIID iid;
+  nsresult rv = ReadID(&cid);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    rv = ReadID(&iid);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  rv = ReadID(&iid);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    // HACK: Intercept old (pre-gecko6) nsIURI IID, and replace with
-    // the updated IID, so that we're QI'ing to an actual interface.
-    // (As soon as we drop support for upgrading from pre-gecko6, we can
-    // remove this chunk.)
-    static const nsIID oldURIiid =
-        { 0x7a22cc0, 0xce5, 0x11d3,
-          { 0x93, 0x31, 0x0, 0x10, 0x4b, 0xa0, 0xfd, 0x40 }};
+  // HACK: Intercept old (pre-gecko6) nsIURI IID, and replace with
+  // the updated IID, so that we're QI'ing to an actual interface.
+  // (As soon as we drop support for upgrading from pre-gecko6, we can
+  // remove this chunk.)
+  static const nsIID oldURIiid =
+    { 0x7a22cc0, 0xce5, 0x11d3,
+      { 0x93, 0x31, 0x0, 0x10, 0x4b, 0xa0, 0xfd, 0x40 }};
 
-    // hackaround for bug 670542
-    static const nsIID oldURIiid2 =
-        { 0xd6d04c36, 0x0fa4, 0x4db3,
-          { 0xbe, 0x05, 0x4a, 0x18, 0x39, 0x71, 0x03, 0xe2 }};
+  // hackaround for bug 670542
+  static const nsIID oldURIiid2 =
+    { 0xd6d04c36, 0x0fa4, 0x4db3,
+      { 0xbe, 0x05, 0x4a, 0x18, 0x39, 0x71, 0x03, 0xe2 }};
 
-    // hackaround for bug 682031
-    static const nsIID oldURIiid3 =
-        { 0x12120b20, 0x0929, 0x40e9,
-          { 0x88, 0xcf, 0x6e, 0x08, 0x76, 0x6e, 0x8b, 0x23 }};
+  // hackaround for bug 682031
+  static const nsIID oldURIiid3 =
+    { 0x12120b20, 0x0929, 0x40e9,
+      { 0x88, 0xcf, 0x6e, 0x08, 0x76, 0x6e, 0x8b, 0x23 }};
 
-    if (iid.Equals(oldURIiid) ||
-        iid.Equals(oldURIiid2) ||
-        iid.Equals(oldURIiid3)) {
-        const nsIID newURIiid = NS_IURI_IID;
-        iid = newURIiid;
-    }
-    // END HACK
+  if (iid.Equals(oldURIiid) ||
+      iid.Equals(oldURIiid2) ||
+      iid.Equals(oldURIiid3)) {
+    const nsIID newURIiid = NS_IURI_IID;
+    iid = newURIiid;
+  }
+  // END HACK
 
-    nsCOMPtr<nsISupports> object = do_CreateInstance(cid, &rv);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  nsCOMPtr<nsISupports> object = do_CreateInstance(cid, &rv);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    nsCOMPtr<nsISerializable> serializable = do_QueryInterface(object);
-    if (NS_WARN_IF(!serializable))
-        return NS_ERROR_UNEXPECTED;
+  nsCOMPtr<nsISerializable> serializable = do_QueryInterface(object);
+  if (NS_WARN_IF(!serializable))
+    return NS_ERROR_UNEXPECTED;
 
-    rv = serializable->Read(this);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  rv = serializable->Read(this);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    return object->QueryInterface(iid, reinterpret_cast<void**>(aObject));
+  return object->QueryInterface(iid, reinterpret_cast<void**>(aObject));
 }
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadID(nsID *aResult)
 {
-    nsresult rv = Read32(&aResult->m0);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  nsresult rv = Read32(&aResult->m0);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    rv = Read16(&aResult->m1);
-    if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+  rv = Read16(&aResult->m1);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
 
-    rv = Read16(&aResult->m2);
+  rv = Read16(&aResult->m2);
+  if (NS_WARN_IF(NS_FAILED(rv)))
+    return rv;
+
+  for (int i = 0; i < 8; ++i) {
+    rv = Read8(&aResult->m3[i]);
     if (NS_WARN_IF(NS_FAILED(rv)))
-        return rv;
+      return rv;
+  }
 
-    for (int i = 0; i < 8; ++i) {
-        rv = Read8(&aResult->m3[i]);
-        if (NS_WARN_IF(NS_FAILED(rv)))
-            return rv;
-    }
-
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP_(char*)
 nsBinaryInputStream::GetBuffer(uint32_t aLength, uint32_t aAlignMask)
 {
-    if (mBufferAccess)
-        return mBufferAccess->GetBuffer(aLength, aAlignMask);
-    return nullptr;
+  if (mBufferAccess)
+    return mBufferAccess->GetBuffer(aLength, aAlignMask);
+  return nullptr;
 }
 
 NS_IMETHODIMP_(void)
 nsBinaryInputStream::PutBuffer(char* aBuffer, uint32_t aLength)
 {
-    if (mBufferAccess)
-        mBufferAccess->PutBuffer(aBuffer, aLength);
+  if (mBufferAccess)
+    mBufferAccess->PutBuffer(aBuffer, aLength);
 }
--- a/xpcom/io/nsBinaryStream.h
+++ b/xpcom/io/nsBinaryStream.h
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsBinaryStream_h___
 #define nsBinaryStream_h___
 
 #include "nsCOMPtr.h"
 #include "nsAString.h"
@@ -22,69 +23,69 @@
 
 #define NS_BINARYOUTPUTSTREAM_CONTRACTID "@mozilla.org/binaryoutputstream;1"
 
 // Derive from nsIObjectOutputStream so this class can be used as a superclass
 // by nsObjectOutputStream.
 class nsBinaryOutputStream : public nsIObjectOutputStream
 {
 public:
-    nsBinaryOutputStream() {}
-    // virtual dtor since subclasses call our Release()
-    virtual ~nsBinaryOutputStream() {}
+  nsBinaryOutputStream() {}
+  // virtual dtor since subclasses call our Release()
+  virtual ~nsBinaryOutputStream() {}
 
 protected:
-    // nsISupports methods
-    NS_DECL_ISUPPORTS
+  // nsISupports methods
+  NS_DECL_ISUPPORTS
 
-    // nsIOutputStream methods
-    NS_DECL_NSIOUTPUTSTREAM
+  // nsIOutputStream methods
+  NS_DECL_NSIOUTPUTSTREAM
 
-    // nsIBinaryOutputStream methods
-    NS_DECL_NSIBINARYOUTPUTSTREAM
+  // nsIBinaryOutputStream methods
+  NS_DECL_NSIBINARYOUTPUTSTREAM
 
-    // nsIObjectOutputStream methods
-    NS_DECL_NSIOBJECTOUTPUTSTREAM
+  // nsIObjectOutputStream methods
+  NS_DECL_NSIOBJECTOUTPUTSTREAM
 
-    // Call Write(), ensuring that all proffered data is written
-    nsresult WriteFully(const char *aBuf, uint32_t aCount);
+  // Call Write(), ensuring that all proffered data is written
+  nsresult WriteFully(const char *aBuf, uint32_t aCount);
 
-    nsCOMPtr<nsIOutputStream>       mOutputStream;
-    nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
+  nsCOMPtr<nsIOutputStream>       mOutputStream;
+  nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
 };
 
 #define NS_BINARYINPUTSTREAM_CID        \
-{ /* c521a612-2aad-46db-b6ab-3b821fb150b1 */         \
-     0xc521a612,                                     \
-     0x2aad,                                         \
-     0x46db,                                         \
-    {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
+{ /* c521a612-2aad-46db-b6ab-3b821fb150b1 */       \
+   0xc521a612,                                     \
+   0x2aad,                                         \
+   0x46db,                                         \
+  {0xb6, 0xab, 0x3b, 0x82, 0x1f, 0xb1, 0x50, 0xb1} \
 }
 
 #define NS_BINARYINPUTSTREAM_CONTRACTID "@mozilla.org/binaryinputstream;1"
 
 // Derive from nsIObjectInputStream so this class can be used as a superclass
 // by nsObjectInputStream.
 class nsBinaryInputStream : public nsIObjectInputStream
 {
 public:
-    nsBinaryInputStream() {}
-    // virtual dtor since subclasses call our Release()
-    virtual ~nsBinaryInputStream() {}
+  nsBinaryInputStream() {}
+  // virtual dtor since subclasses call our Release()
+  virtual ~nsBinaryInputStream() {}
 
 protected:
-    // nsISupports methods
-    NS_DECL_ISUPPORTS
+  // nsISupports methods
+  NS_DECL_ISUPPORTS
 
-    // nsIInputStream methods
-    NS_DECL_NSIINPUTSTREAM
+  // nsIInputStream methods
+  NS_DECL_NSIINPUTSTREAM
 
-    // nsIBinaryInputStream methods
-    NS_DECL_NSIBINARYINPUTSTREAM
+  // nsIBinaryInputStream methods
+  NS_DECL_NSIBINARYINPUTSTREAM
 
-    // nsIObjectInputStream methods
-    NS_DECL_NSIOBJECTINPUTSTREAM
+  // nsIObjectInputStream methods
+  NS_DECL_NSIOBJECTINPUTSTREAM
 
-    nsCOMPtr<nsIInputStream>        mInputStream;
-    nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
+  nsCOMPtr<nsIInputStream>        mInputStream;
+  nsCOMPtr<nsIStreamBufferAccess> mBufferAccess;
 };
 
 #endif // nsBinaryStream_h___
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -1,11 +1,11 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 sts=4 et
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsDirectoryService.h"
@@ -46,849 +46,849 @@ using namespace mozilla;
 #define HOME_DIR NS_WIN_APPDATA_DIR
 #elif defined (MOZ_WIDGET_COCOA)
 #define HOME_DIR NS_OSX_HOME_DIR
 #elif defined (XP_UNIX)
 #define HOME_DIR NS_UNIX_HOME_DIR
 #endif
 
 //----------------------------------------------------------------------------------------
-nsresult 
+nsresult
 nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
 //----------------------------------------------------------------------------------------
 {
-    if (NS_WARN_IF(!aFile))
-        return NS_ERROR_INVALID_ARG;
-    *aFile = nullptr;
-    
-   //  Set the component registry location:
-    if (!gService)
-        return NS_ERROR_FAILURE;
+  if (NS_WARN_IF(!aFile))
+    return NS_ERROR_INVALID_ARG;
+  *aFile = nullptr;
+
+  //  Set the component registry location:
+  if (!gService)
+    return NS_ERROR_FAILURE;
 
-    nsresult rv; 
- 
-    nsCOMPtr<nsIProperties> dirService;
-    rv = nsDirectoryService::Create(nullptr, 
-                                    NS_GET_IID(nsIProperties), 
-                                    getter_AddRefs(dirService));  // needs to be around for life of product
-    if (NS_FAILED(rv))
-        return rv;
+  nsresult rv;
+
+  nsCOMPtr<nsIProperties> dirService;
+  rv = nsDirectoryService::Create(nullptr,
+                                  NS_GET_IID(nsIProperties),
+                                  getter_AddRefs(dirService));  // needs to be around for life of product
+  if (NS_FAILED(rv))
+    return rv;
 
-    if (dirService)
+  if (dirService)
+  {
+    nsCOMPtr <nsIFile> aLocalFile;
+    dirService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(aLocalFile));
+    if (aLocalFile)
     {
-      nsCOMPtr <nsIFile> aLocalFile;
-      dirService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(aLocalFile));
-      if (aLocalFile)
-      {
-        *aFile = aLocalFile;
-        NS_ADDREF(*aFile);
-        return NS_OK;
-      }
+      *aFile = aLocalFile;
+      NS_ADDREF(*aFile);
+      return NS_OK;
     }
+  }
 
-    nsLocalFile* localFile = new nsLocalFile;
+  nsLocalFile* localFile = new nsLocalFile;
 
-    if (localFile == nullptr)
-        return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(localFile);
+  if (localFile == nullptr)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(localFile);
 
 
 
 #ifdef XP_WIN
-    wchar_t buf[MAX_PATH + 1];
-    SetLastError(ERROR_SUCCESS);
-    if (GetModuleFileNameW(0, buf, mozilla::ArrayLength(buf)) &&
-        GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
-        // chop off the executable name by finding the rightmost backslash
-        wchar_t* lastSlash = wcsrchr(buf, L'\\');
-        if (lastSlash)
-            *(lastSlash + 1) = L'\0';
+  wchar_t buf[MAX_PATH + 1];
+  SetLastError(ERROR_SUCCESS);
+  if (GetModuleFileNameW(0, buf, mozilla::ArrayLength(buf)) &&
+      GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+    // chop off the executable name by finding the rightmost backslash
+    wchar_t* lastSlash = wcsrchr(buf, L'\\');
+    if (lastSlash)
+      *(lastSlash + 1) = L'\0';
 
-        localFile->InitWithPath(nsDependentString(buf));
-        *aFile = localFile;
-        return NS_OK;
-    }
+    localFile->InitWithPath(nsDependentString(buf));
+    *aFile = localFile;
+    return NS_OK;
+  }
 
 #elif defined(MOZ_WIDGET_COCOA)
-    // Works even if we're not bundled.
-    CFBundleRef appBundle = CFBundleGetMainBundle();
-    if (appBundle != nullptr)
+  // Works even if we're not bundled.
+  CFBundleRef appBundle = CFBundleGetMainBundle();
+  if (appBundle != nullptr)
+  {
+    CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle);
+    if (bundleURL != nullptr)
     {
-        CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle);
-        if (bundleURL != nullptr)
+      CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, bundleURL);
+      if (parentURL)
+      {
+        // Pass true for the "resolveAgainstBase" arg to CFURLGetFileSystemRepresentation.
+        // This will resolve the relative portion of the CFURL against it base, giving a full
+        // path, which CFURLCopyFileSystemPath doesn't do.
+        char buffer[PATH_MAX];
+        if (CFURLGetFileSystemRepresentation(parentURL, true, (UInt8 *)buffer, sizeof(buffer)))
         {
-            CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, bundleURL);
-            if (parentURL)
-            {
-                // Pass true for the "resolveAgainstBase" arg to CFURLGetFileSystemRepresentation.
-                // This will resolve the relative portion of the CFURL against it base, giving a full
-                // path, which CFURLCopyFileSystemPath doesn't do.
-                char buffer[PATH_MAX];
-                if (CFURLGetFileSystemRepresentation(parentURL, true, (UInt8 *)buffer, sizeof(buffer)))
-                {
 #ifdef DEBUG_conrad
-                    printf("nsDirectoryService - CurrentProcessDir is: %s\n", buffer);
+          printf("nsDirectoryService - CurrentProcessDir is: %s\n", buffer);
 #endif
-                    rv = localFile->InitWithNativePath(nsDependentCString(buffer));
-                    if (NS_SUCCEEDED(rv))
-                        *aFile = localFile;
-                }
-                CFRelease(parentURL);
-            }
-            CFRelease(bundleURL);
+          rv = localFile->InitWithNativePath(nsDependentCString(buffer));
+          if (NS_SUCCEEDED(rv))
+            *aFile = localFile;
         }
+        CFRelease(parentURL);
+      }
+      CFRelease(bundleURL);
     }
-    
-    NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n");
-    if (*aFile)
-        return NS_OK;
+  }
+
+  NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n");
+  if (*aFile)
+    return NS_OK;
 
 #elif defined(XP_UNIX)
 
-    // In the absence of a good way to get the executable directory let
-    // us try this for unix:
-    //    - if MOZILLA_FIVE_HOME is defined, that is it
-    //    - else give the current directory
-    char buf[MAXPATHLEN];
+  // In the absence of a good way to get the executable directory let
+  // us try this for unix:
+  //    - if MOZILLA_FIVE_HOME is defined, that is it
+  //    - else give the current directory
+  char buf[MAXPATHLEN];
 
-    // The MOZ_DEFAULT_MOZILLA_FIVE_HOME variable can be set at configure time with
-    // a --with-default-mozilla-five-home=foo autoconf flag.
-    // 
-    // The idea here is to allow for builds that have a default MOZILLA_FIVE_HOME
-    // regardless of the environment.  This makes it easier to write apps that
-    // embed mozilla without having to worry about setting up the environment 
-    //
-    // We do this by putenv()ing the default value into the environment.  Note that
-    // we only do this if it is not already set.
+  // The MOZ_DEFAULT_MOZILLA_FIVE_HOME variable can be set at configure time with
+  // a --with-default-mozilla-five-home=foo autoconf flag.
+  //
+  // The idea here is to allow for builds that have a default MOZILLA_FIVE_HOME
+  // regardless of the environment.  This makes it easier to write apps that
+  // embed mozilla without having to worry about setting up the environment
+  //
+  // We do this by putenv()ing the default value into the environment.  Note that
+  // we only do this if it is not already set.
 #ifdef MOZ_DEFAULT_MOZILLA_FIVE_HOME
-    const char *home = PR_GetEnv("MOZILLA_FIVE_HOME");
-    if (!home || !*home)
-    {
-        putenv("MOZILLA_FIVE_HOME=" MOZ_DEFAULT_MOZILLA_FIVE_HOME);
-    }
+  const char *home = PR_GetEnv("MOZILLA_FIVE_HOME");
+  if (!home || !*home)
+  {
+    putenv("MOZILLA_FIVE_HOME=" MOZ_DEFAULT_MOZILLA_FIVE_HOME);
+  }
 #endif
 
-    char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME");
-    if (moz5 && *moz5)
-    {
-        if (realpath(moz5, buf)) {
-            localFile->InitWithNativePath(nsDependentCString(buf));
-            *aFile = localFile;
-            return NS_OK;
-        }
+  char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME");
+  if (moz5 && *moz5)
+  {
+    if (realpath(moz5, buf)) {
+      localFile->InitWithNativePath(nsDependentCString(buf));
+      *aFile = localFile;
+      return NS_OK;
     }
+  }
 #if defined(DEBUG)
-    static bool firstWarning = true;
+  static bool firstWarning = true;
 
-    if((!moz5 || !*moz5) && firstWarning) {
-        // Warn that MOZILLA_FIVE_HOME not set, once.
-        printf("Warning: MOZILLA_FIVE_HOME not set.\n");
-        firstWarning = false;
-    }
+  if((!moz5 || !*moz5) && firstWarning) {
+    // Warn that MOZILLA_FIVE_HOME not set, once.
+    printf("Warning: MOZILLA_FIVE_HOME not set.\n");
+    firstWarning = false;
+  }
 #endif /* DEBUG */
 
-    // Fall back to current directory.
-    if (getcwd(buf, sizeof(buf)))
-    {
-        localFile->InitWithNativePath(nsDependentCString(buf));
-        *aFile = localFile;
-        return NS_OK;
-    }
+  // Fall back to current directory.
+  if (getcwd(buf, sizeof(buf)))
+  {
+    localFile->InitWithNativePath(nsDependentCString(buf));
+    *aFile = localFile;
+    return NS_OK;
+  }
 
 #endif
-    
-    NS_RELEASE(localFile);
+
+  NS_RELEASE(localFile);
 
-    NS_ERROR("unable to get current process directory");
-    return NS_ERROR_FAILURE;
+  NS_ERROR("unable to get current process directory");
+  return NS_ERROR_FAILURE;
 } // GetCurrentProcessDirectory()
 
 nsDirectoryService* nsDirectoryService::gService = nullptr;
 
 nsDirectoryService::nsDirectoryService()
-    : mHashtable(256)
+  : mHashtable(256)
 {
 }
 
 nsresult
 nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
 {
-    if (NS_WARN_IF(!aResult))
-        return NS_ERROR_INVALID_ARG;
-    if (NS_WARN_IF(outer))
-        return NS_ERROR_NO_AGGREGATION;
+  if (NS_WARN_IF(!aResult))
+    return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(outer))
+    return NS_ERROR_NO_AGGREGATION;
 
-    if (!gService)
-    {
-        return NS_ERROR_NOT_INITIALIZED;
-    }
+  if (!gService)
+  {
+    return NS_ERROR_NOT_INITIALIZED;
+  }
 
-    return gService->QueryInterface(aIID, aResult);
+  return gService->QueryInterface(aIID, aResult);
 }
 
 #define DIR_ATOM(name_, value_) nsIAtom* nsDirectoryService::name_ = nullptr;
 #include "nsDirectoryServiceAtomList.h"
 #undef DIR_ATOM
 
 #define DIR_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
 #include "nsDirectoryServiceAtomList.h"
 #undef DIR_ATOM
 
 static const nsStaticAtom directory_atoms[] = {
 #define DIR_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &nsDirectoryService::name_),
 #include "nsDirectoryServiceAtomList.h"
 #undef DIR_ATOM
-};    
+};
 
 NS_IMETHODIMP
 nsDirectoryService::Init()
 {
-    NS_NOTREACHED("nsDirectoryService::Init() for internal use only!");
-    return NS_OK;
+  NS_NOTREACHED("nsDirectoryService::Init() for internal use only!");
+  return NS_OK;
 }
 
 void
 nsDirectoryService::RealInit()
 {
-    NS_ASSERTION(!gService, 
-                 "nsDirectoryService::RealInit Mustn't initialize twice!");
+  NS_ASSERTION(!gService,
+               "nsDirectoryService::RealInit Mustn't initialize twice!");
 
-    nsRefPtr<nsDirectoryService> self = new nsDirectoryService();
+  nsRefPtr<nsDirectoryService> self = new nsDirectoryService();
 
-    NS_RegisterStaticAtoms(directory_atoms);
-    
-    // Let the list hold the only reference to the provider.
-    nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider;
-    self->mProviders.AppendElement(defaultProvider);
+  NS_RegisterStaticAtoms(directory_atoms);
 
-    self.swap(gService);
+  // Let the list hold the only reference to the provider.
+  nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider;
+  self->mProviders.AppendElement(defaultProvider);
+
+  self.swap(gService);
 }
 
 nsDirectoryService::~nsDirectoryService()
 {
 }
 
 NS_IMPL_ISUPPORTS(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
 
 
 NS_IMETHODIMP
 nsDirectoryService::Undefine(const char* prop)
 {
-    if (NS_WARN_IF(!prop))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!prop))
+    return NS_ERROR_INVALID_ARG;
 
-    nsDependentCString key(prop);
-    if (!mHashtable.Get(key, nullptr))
-        return NS_ERROR_FAILURE;
+  nsDependentCString key(prop);
+  if (!mHashtable.Get(key, nullptr))
+    return NS_ERROR_FAILURE;
 
-    mHashtable.Remove(key);
-    return NS_OK;
- }
+  mHashtable.Remove(key);
+  return NS_OK;
+}
 
 NS_IMETHODIMP
 nsDirectoryService::GetKeys(uint32_t *count, char ***keys)
 {
-    return NS_ERROR_NOT_IMPLEMENTED;
+  return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 struct FileData
 {
   FileData(const char* aProperty,
            const nsIID& aUUID) :
     property(aProperty),
     data(nullptr),
     persistent(true),
     uuid(aUUID) {}
-    
+
   const char*   property;
   nsISupports*  data;
   bool          persistent;
   const nsIID&  uuid;
 };
 
 static bool FindProviderFile(nsIDirectoryServiceProvider* aElement,
                              FileData* aData)
 {
   nsresult rv;
   if (aData->uuid.Equals(NS_GET_IID(nsISimpleEnumerator))) {
-      // Not all providers implement this iface
-      nsCOMPtr<nsIDirectoryServiceProvider2> prov2 = do_QueryInterface(aElement);
-      if (prov2)
-      {
-          nsCOMPtr<nsISimpleEnumerator> newFiles;
-          rv = prov2->GetFiles(aData->property, getter_AddRefs(newFiles));
-          if (NS_SUCCEEDED(rv) && newFiles) {
-              if (aData->data) {
-                  nsCOMPtr<nsISimpleEnumerator> unionFiles;
+    // Not all providers implement this iface
+    nsCOMPtr<nsIDirectoryServiceProvider2> prov2 = do_QueryInterface(aElement);
+    if (prov2)
+    {
+      nsCOMPtr<nsISimpleEnumerator> newFiles;
+      rv = prov2->GetFiles(aData->property, getter_AddRefs(newFiles));
+      if (NS_SUCCEEDED(rv) && newFiles) {
+        if (aData->data) {
+          nsCOMPtr<nsISimpleEnumerator> unionFiles;
 
-                  NS_NewUnionEnumerator(getter_AddRefs(unionFiles),
-                                        (nsISimpleEnumerator*) aData->data, newFiles);
+          NS_NewUnionEnumerator(getter_AddRefs(unionFiles),
+                                (nsISimpleEnumerator*) aData->data, newFiles);
 
-                  if (unionFiles)
-                      unionFiles.swap(* (nsISimpleEnumerator**) &aData->data);
-              }
-              else
-              {
-                  NS_ADDREF(aData->data = newFiles);
-              }
-                  
-              aData->persistent = false; // Enumerators can never be persistent
-              return rv == NS_SUCCESS_AGGREGATE_RESULT;
-          }
+          if (unionFiles)
+            unionFiles.swap(* (nsISimpleEnumerator**) &aData->data);
+        }
+        else
+        {
+          NS_ADDREF(aData->data = newFiles);
+        }
+
+        aData->persistent = false; // Enumerators can never be persistent
+        return rv == NS_SUCCESS_AGGREGATE_RESULT;
       }
+    }
   }
   else
   {
-      rv = aElement->GetFile(aData->property, &aData->persistent,
-                             (nsIFile **)&aData->data);
-      if (NS_SUCCEEDED(rv) && aData->data)
-          return false;
+    rv = aElement->GetFile(aData->property, &aData->persistent,
+                           (nsIFile **)&aData->data);
+    if (NS_SUCCEEDED(rv) && aData->data)
+      return false;
   }
 
   return true;
 }
 
 NS_IMETHODIMP
 nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
 {
-    if (NS_WARN_IF(!prop))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!prop))
+    return NS_ERROR_INVALID_ARG;
 
-    nsDependentCString key(prop);
+  nsDependentCString key(prop);
 
-    nsCOMPtr<nsIFile> cachedFile = mHashtable.Get(key);
+  nsCOMPtr<nsIFile> cachedFile = mHashtable.Get(key);
 
-    if (cachedFile) {
-        nsCOMPtr<nsIFile> cloneFile;
-        cachedFile->Clone(getter_AddRefs(cloneFile));
-        return cloneFile->QueryInterface(uuid, result);
-    }
+  if (cachedFile) {
+    nsCOMPtr<nsIFile> cloneFile;
+    cachedFile->Clone(getter_AddRefs(cloneFile));
+    return cloneFile->QueryInterface(uuid, result);
+  }
+
+  // it is not one of our defaults, lets check any providers
+  FileData fileData(prop, uuid);
 
-    // it is not one of our defaults, lets check any providers
-    FileData fileData(prop, uuid);
-
-    for (int32_t i = mProviders.Length() - 1; i >= 0; i--) {
-        if (!FindProviderFile(mProviders[i], &fileData)) {
-            break;
-        }
+  for (int32_t i = mProviders.Length() - 1; i >= 0; i--) {
+    if (!FindProviderFile(mProviders[i], &fileData)) {
+      break;
     }
-    if (fileData.data)
+  }
+  if (fileData.data)
+  {
+    if (fileData.persistent)
     {
-        if (fileData.persistent)
-        {
-            Set(prop, static_cast<nsIFile*>(fileData.data));
-        }
-        nsresult rv = (fileData.data)->QueryInterface(uuid, result);
-        NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
-        return rv;
+      Set(prop, static_cast<nsIFile*>(fileData.data));
     }
+    nsresult rv = (fileData.data)->QueryInterface(uuid, result);
+    NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
+    return rv;
+  }
 
-    FindProviderFile(static_cast<nsIDirectoryServiceProvider*>(this), &fileData);
-    if (fileData.data)
+  FindProviderFile(static_cast<nsIDirectoryServiceProvider*>(this), &fileData);
+  if (fileData.data)
+  {
+    if (fileData.persistent)
     {
-        if (fileData.persistent)
-        {
-            Set(prop, static_cast<nsIFile*>(fileData.data));
-        }
-        nsresult rv = (fileData.data)->QueryInterface(uuid, result);
-        NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
-        return rv;
+      Set(prop, static_cast<nsIFile*>(fileData.data));
     }
+    nsresult rv = (fileData.data)->QueryInterface(uuid, result);
+    NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
+    return rv;
+  }
 
-    return NS_ERROR_FAILURE;
+  return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsDirectoryService::Set(const char* prop, nsISupports* value)
 {
-    if (NS_WARN_IF(!prop))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!prop))
+    return NS_ERROR_INVALID_ARG;
 
-    nsDependentCString key(prop);
-    if (mHashtable.Get(key, nullptr) || !value) {
-        return NS_ERROR_FAILURE;
-    }
+  nsDependentCString key(prop);
+  if (mHashtable.Get(key, nullptr) || !value) {
+    return NS_ERROR_FAILURE;
+  }
 
-    nsCOMPtr<nsIFile> ourFile = do_QueryInterface(value);
-    if (ourFile) {
-      nsCOMPtr<nsIFile> cloneFile;
-      ourFile->Clone (getter_AddRefs (cloneFile));
-      mHashtable.Put(key, cloneFile);
+  nsCOMPtr<nsIFile> ourFile = do_QueryInterface(value);
+  if (ourFile) {
+    nsCOMPtr<nsIFile> cloneFile;
+    ourFile->Clone (getter_AddRefs (cloneFile));
+    mHashtable.Put(key, cloneFile);
 
-      return NS_OK;
-    }
+    return NS_OK;
+  }
 
-    return NS_ERROR_FAILURE;
+  return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsDirectoryService::Has(const char *prop, bool *_retval)
 {
-    if (NS_WARN_IF(!prop))
-        return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(!prop))
+    return NS_ERROR_INVALID_ARG;
 
-    *_retval = false;
-    nsCOMPtr<nsIFile> value;
-    nsresult rv = Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(value));
-    if (NS_FAILED(rv))
-        return NS_OK;
-    
-    if (value)
-    {
-        *_retval = true;
-    }
-    
-    return rv;
+  *_retval = false;
+  nsCOMPtr<nsIFile> value;
+  nsresult rv = Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(value));
+  if (NS_FAILED(rv))
+    return NS_OK;
+
+  if (value)
+  {
+    *_retval = true;
+  }
+
+  return rv;
 }
 
 NS_IMETHODIMP
 nsDirectoryService::RegisterProvider(nsIDirectoryServiceProvider *prov)
 {
-    if (!prov)
-        return NS_ERROR_FAILURE;
+  if (!prov)
+    return NS_ERROR_FAILURE;
 
-    mProviders.AppendElement(prov);
-    return NS_OK;
+  mProviders.AppendElement(prov);
+  return NS_OK;
 }
 
 void
 nsDirectoryService::RegisterCategoryProviders()
 {
-    nsCOMPtr<nsICategoryManager> catman
-        (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
-    if (!catman)
-        return;
+  nsCOMPtr<nsICategoryManager> catman
+  (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
+  if (!catman)
+    return;
 
-    nsCOMPtr<nsISimpleEnumerator> entries;
-    catman->EnumerateCategory(XPCOM_DIRECTORY_PROVIDER_CATEGORY,
-                              getter_AddRefs(entries));
+  nsCOMPtr<nsISimpleEnumerator> entries;
+  catman->EnumerateCategory(XPCOM_DIRECTORY_PROVIDER_CATEGORY,
+                            getter_AddRefs(entries));
 
-    nsCOMPtr<nsIUTF8StringEnumerator> strings(do_QueryInterface(entries));
-    if (!strings)
-        return;
+  nsCOMPtr<nsIUTF8StringEnumerator> strings(do_QueryInterface(entries));
+  if (!strings)
+    return;
 
-    bool more;
-    while (NS_SUCCEEDED(strings->HasMore(&more)) && more) {
-        nsAutoCString entry;
-        strings->GetNext(entry);
+  bool more;
+  while (NS_SUCCEEDED(strings->HasMore(&more)) && more) {
+    nsAutoCString entry;
+    strings->GetNext(entry);
 
-        nsXPIDLCString contractID;
-        catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));
+    nsXPIDLCString contractID;
+    catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));
 
-        if (contractID) {
-            nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());
-            if (provider)
-                RegisterProvider(provider);
-        }
+    if (contractID) {
+      nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());
+      if (provider)
+        RegisterProvider(provider);
     }
+  }
 }
 
 NS_IMETHODIMP
 nsDirectoryService::UnregisterProvider(nsIDirectoryServiceProvider *prov)
 {
-    if (!prov)
-        return NS_ERROR_FAILURE;
+  if (!prov)
+    return NS_ERROR_FAILURE;
 
-    mProviders.RemoveElement(prov);
-    return NS_OK;
+  mProviders.RemoveElement(prov);
+  return NS_OK;
 }
 
 // DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com.
 // This is meant to be a place of xpcom or system specific file locations, not
 // application specific locations.  If you need the later, register a callback for
-// your application.  
+// your application.
 
 NS_IMETHODIMP
 nsDirectoryService::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
 {
-    nsCOMPtr<nsIFile> localFile;
-    nsresult rv = NS_ERROR_FAILURE;
+  nsCOMPtr<nsIFile> localFile;
+  nsresult rv = NS_ERROR_FAILURE;
+
+  *_retval = nullptr;
+  *persistent = true;
+
+  nsCOMPtr<nsIAtom> inAtom = do_GetAtom(prop);
 
-    *_retval = nullptr;
-    *persistent = true;
+  // check to see if it is one of our defaults
 
-    nsCOMPtr<nsIAtom> inAtom = do_GetAtom(prop);
+  if (inAtom == nsDirectoryService::sCurrentProcess ||
+      inAtom == nsDirectoryService::sOS_CurrentProcessDirectory )
+  {
+    rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
+  }
 
-    // check to see if it is one of our defaults
-        
-    if (inAtom == nsDirectoryService::sCurrentProcess || 
-        inAtom == nsDirectoryService::sOS_CurrentProcessDirectory )
-    {
-        rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
-    }
-    
-    // Unless otherwise set, the core pieces of the GRE exist
-    // in the current process directory.
-    else if (inAtom == nsDirectoryService::sGRE_Directory)
-    {
-        rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_DriveDirectory)
-    {
-        rv = GetSpecialSystemDirectory(OS_DriveDirectory, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_TemporaryDirectory)
-    {
-        rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_CurrentProcessDirectory)
-    {
-        rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory)
-    {
-        rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); 
-    }
-       
+  // Unless otherwise set, the core pieces of the GRE exist
+  // in the current process directory.
+  else if (inAtom == nsDirectoryService::sGRE_Directory)
+  {
+    rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_DriveDirectory)
+  {
+    rv = GetSpecialSystemDirectory(OS_DriveDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_TemporaryDirectory)
+  {
+    rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_CurrentProcessDirectory)
+  {
+    rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory)
+  {
+    rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile));
+  }
+
 #if defined(MOZ_WIDGET_COCOA)
-    else if (inAtom == nsDirectoryService::sDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sTrashDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sStartupDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kStartupFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sShutdownDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kShutdownFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sAppleMenuDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kAppleMenuFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sControlPanelDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kControlPanelFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sExtensionDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kExtensionFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sFontsDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kFontsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sPreferencesDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kPreferencesFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sInternetSearchDirectory)
-    {
-        rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile));
-    }   
-    else if (inAtom == nsDirectoryService::sUserLibDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
-    {
-        // 10.5 and later, we can use kDownloadsFolderType which is defined in
-        // Folders.h as "down".  However, in order to support 10.4 still, we
-        // cannot use the named constant.  We'll use it's value, and if it
-        // fails, fall back to the desktop.
+  else if (inAtom == nsDirectoryService::sDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sTrashDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sStartupDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kStartupFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sShutdownDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kShutdownFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sAppleMenuDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kAppleMenuFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sControlPanelDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kControlPanelFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sExtensionDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kExtensionFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sFontsDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kFontsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPreferencesDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kPreferencesFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sInternetSearchDirectory)
+  {
+    rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserLibDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
+  {
+    // 10.5 and later, we can use kDownloadsFolderType which is defined in
+    // Folders.h as "down".  However, in order to support 10.4 still, we
+    // cannot use the named constant.  We'll use it's value, and if it
+    // fails, fall back to the desktop.
 #ifndef kDownloadsFolderType
 #define kDownloadsFolderType 'down'
 #endif
 
-        rv = GetOSXFolderType(kUserDomain, kDownloadsFolderType,
-                              getter_AddRefs(localFile));
-        if (NS_FAILED(rv)) {
-            rv = GetOSXFolderType(kUserDomain, kDesktopFolderType,
-                                  getter_AddRefs(localFile));
-        }
-    }
-    else if (inAtom == nsDirectoryService::sUserDesktopDirectory ||
-             inAtom == nsDirectoryService::sOS_DesktopDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalDesktopDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kDesktopFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sUserApplicationsDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kApplicationsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalApplicationsDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kApplicationsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sUserDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sUserInternetPlugInDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalInternetPlugInDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sUserFrameworksDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kFrameworksFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalFrameworksDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kFrameworksFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sUserPreferencesDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kPreferencesFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sLocalPreferencesDirectory)
-    {
-        rv = GetOSXFolderType(kLocalDomain, kPreferencesFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sPictureDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kPictureDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sMovieDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kMovieDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sMusicDocumentsDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kMusicDocumentsFolderType, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sInternetSitesDirectory)
-    {
-        rv = GetOSXFolderType(kUserDomain, kInternetSitesFolderType, getter_AddRefs(localFile));
-    }
-#elif defined (XP_WIN)
-    else if (inAtom == nsDirectoryService::sSystemDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sWindowsDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sWindowsProgramFiles)
-    {
-        rv = GetSpecialSystemDirectory(Win_ProgramFiles, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sDesktop)
-    {
-        rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sPrograms)
-    {
-        rv = GetSpecialSystemDirectory(Win_Programs, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sControls)
-    {
-        rv = GetSpecialSystemDirectory(Win_Controls, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sPrinters)
-    {
-        rv = GetSpecialSystemDirectory(Win_Printers, getter_AddRefs(localFile)); 
+    rv = GetOSXFolderType(kUserDomain, kDownloadsFolderType,
+                          getter_AddRefs(localFile));
+    if (NS_FAILED(rv)) {
+      rv = GetOSXFolderType(kUserDomain, kDesktopFolderType,
+                            getter_AddRefs(localFile));
     }
-    else if (inAtom == nsDirectoryService::sPersonal)
-    {
-        rv = GetSpecialSystemDirectory(Win_Personal, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sFavorites)
-    {
-        rv = GetSpecialSystemDirectory(Win_Favorites, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sStartup)
-    {
-        rv = GetSpecialSystemDirectory(Win_Startup, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sRecent)
-    {
-        rv = GetSpecialSystemDirectory(Win_Recent, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sSendto)
-    {
-        rv = GetSpecialSystemDirectory(Win_Sendto, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sBitbucket)
-    {
-        rv = GetSpecialSystemDirectory(Win_Bitbucket, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sStartmenu)
-    {
-        rv = GetSpecialSystemDirectory(Win_Startmenu, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sDesktopdirectory ||
-             inAtom == nsDirectoryService::sOS_DesktopDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_Desktopdirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sDrives)
-    {
-        rv = GetSpecialSystemDirectory(Win_Drives, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sNetwork)
-    {
-        rv = GetSpecialSystemDirectory(Win_Network, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sNethood)
-    {
-        rv = GetSpecialSystemDirectory(Win_Nethood, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sFonts)
-    {
-        rv = GetSpecialSystemDirectory(Win_Fonts, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sTemplates)
-    {
-        rv = GetSpecialSystemDirectory(Win_Templates, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sCommon_Startmenu)
-    {
-        rv = GetSpecialSystemDirectory(Win_Common_Startmenu, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sCommon_Programs)
-    {
-        rv = GetSpecialSystemDirectory(Win_Common_Programs, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sCommon_Startup)
-    {
-        rv = GetSpecialSystemDirectory(Win_Common_Startup, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sCommon_Desktopdirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_Common_Desktopdirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sCommon_AppData)
-    {
-        rv = GetSpecialSystemDirectory(Win_Common_AppData, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sAppdata)
-    {
-        rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sLocalAppdata)
-    {
-        rv = GetSpecialSystemDirectory(Win_LocalAppdata, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sPrinthood)
-    {
-        rv = GetSpecialSystemDirectory(Win_Printhood, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sWinCookiesDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_Cookies, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Win_Downloads, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sDocs)
-    {
-        rv = GetSpecialSystemDirectory(Win_Documents, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sPictures)
-    {
-        rv = GetSpecialSystemDirectory(Win_Pictures, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sMusic)
-    {
-        rv = GetSpecialSystemDirectory(Win_Music, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sVideos)
-    {
-        rv = GetSpecialSystemDirectory(Win_Videos, getter_AddRefs(localFile));
-    }
+  }
+  else if (inAtom == nsDirectoryService::sUserDesktopDirectory ||
+           inAtom == nsDirectoryService::sOS_DesktopDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalDesktopDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kDesktopFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserApplicationsDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kApplicationsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalApplicationsDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kApplicationsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserInternetPlugInDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalInternetPlugInDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserFrameworksDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kFrameworksFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalFrameworksDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kFrameworksFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sUserPreferencesDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kPreferencesFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalPreferencesDirectory)
+  {
+    rv = GetOSXFolderType(kLocalDomain, kPreferencesFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPictureDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kPictureDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sMovieDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kMovieDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sMusicDocumentsDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kMusicDocumentsFolderType, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sInternetSitesDirectory)
+  {
+    rv = GetOSXFolderType(kUserDomain, kInternetSitesFolderType, getter_AddRefs(localFile));
+  }
+#elif defined (XP_WIN)
+  else if (inAtom == nsDirectoryService::sSystemDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sWindowsDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sWindowsProgramFiles)
+  {
+    rv = GetSpecialSystemDirectory(Win_ProgramFiles, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDesktop)
+  {
+    rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPrograms)
+  {
+    rv = GetSpecialSystemDirectory(Win_Programs, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sControls)
+  {
+    rv = GetSpecialSystemDirectory(Win_Controls, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPrinters)
+  {
+    rv = GetSpecialSystemDirectory(Win_Printers, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPersonal)
+  {
+    rv = GetSpecialSystemDirectory(Win_Personal, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sFavorites)
+  {
+    rv = GetSpecialSystemDirectory(Win_Favorites, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sStartup)
+  {
+    rv = GetSpecialSystemDirectory(Win_Startup, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sRecent)
+  {
+    rv = GetSpecialSystemDirectory(Win_Recent, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sSendto)
+  {
+    rv = GetSpecialSystemDirectory(Win_Sendto, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sBitbucket)
+  {
+    rv = GetSpecialSystemDirectory(Win_Bitbucket, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sStartmenu)
+  {
+    rv = GetSpecialSystemDirectory(Win_Startmenu, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDesktopdirectory ||
+           inAtom == nsDirectoryService::sOS_DesktopDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_Desktopdirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDrives)
+  {
+    rv = GetSpecialSystemDirectory(Win_Drives, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sNetwork)
+  {
+    rv = GetSpecialSystemDirectory(Win_Network, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sNethood)
+  {
+    rv = GetSpecialSystemDirectory(Win_Nethood, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sFonts)
+  {
+    rv = GetSpecialSystemDirectory(Win_Fonts, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sTemplates)
+  {
+    rv = GetSpecialSystemDirectory(Win_Templates, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sCommon_Startmenu)
+  {
+    rv = GetSpecialSystemDirectory(Win_Common_Startmenu, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sCommon_Programs)
+  {
+    rv = GetSpecialSystemDirectory(Win_Common_Programs, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sCommon_Startup)
+  {
+    rv = GetSpecialSystemDirectory(Win_Common_Startup, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sCommon_Desktopdirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_Common_Desktopdirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sCommon_AppData)
+  {
+    rv = GetSpecialSystemDirectory(Win_Common_AppData, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sAppdata)
+  {
+    rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLocalAppdata)
+  {
+    rv = GetSpecialSystemDirectory(Win_LocalAppdata, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPrinthood)
+  {
+    rv = GetSpecialSystemDirectory(Win_Printhood, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sWinCookiesDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_Cookies, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Win_Downloads, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sDocs)
+  {
+    rv = GetSpecialSystemDirectory(Win_Documents, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sPictures)
+  {
+    rv = GetSpecialSystemDirectory(Win_Pictures, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sMusic)
+  {
+    rv = GetSpecialSystemDirectory(Win_Music, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sVideos)
+  {
+    rv = GetSpecialSystemDirectory(Win_Videos, getter_AddRefs(localFile));
+  }
 #elif defined (XP_UNIX)
 
-    else if (inAtom == nsDirectoryService::sLocalDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sLibDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Unix_LibDirectory, getter_AddRefs(localFile));
-    }
-    else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile)); 
-    }
-    else if (inAtom == nsDirectoryService::sXDGDesktop ||
-             inAtom == nsDirectoryService::sOS_DesktopDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Desktop, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGDocuments)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Documents, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGDownload ||
-             inAtom == nsDirectoryService::sDefaultDownloadDirectory)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Download, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGMusic)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Music, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGPictures)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Pictures, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGPublicShare)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_PublicShare, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGTemplates)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Templates, getter_AddRefs(localFile));
-        *persistent = false;
-    }
-    else if (inAtom == nsDirectoryService::sXDGVideos)
-    {
-        rv = GetSpecialSystemDirectory(Unix_XDG_Videos, getter_AddRefs(localFile));
-        *persistent = false;
-    }
+  else if (inAtom == nsDirectoryService::sLocalDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sLibDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Unix_LibDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sOS_HomeDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile));
+  }
+  else if (inAtom == nsDirectoryService::sXDGDesktop ||
+           inAtom == nsDirectoryService::sOS_DesktopDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Desktop, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGDocuments)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Documents, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGDownload ||
+           inAtom == nsDirectoryService::sDefaultDownloadDirectory)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Download, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGMusic)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Music, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGPictures)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Pictures, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGPublicShare)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_PublicShare, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGTemplates)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Templates, getter_AddRefs(localFile));
+    *persistent = false;
+  }
+  else if (inAtom == nsDirectoryService::sXDGVideos)
+  {
+    rv = GetSpecialSystemDirectory(Unix_XDG_Videos, getter_AddRefs(localFile));
+    *persistent = false;
+  }
 #endif
 
-    if (NS_FAILED(rv))
-        return rv;
+  if (NS_FAILED(rv))
+    return rv;
 
-    if (!localFile)
-        return NS_ERROR_FAILURE;
+  if (!localFile)
+    return NS_ERROR_FAILURE;
 
-    localFile.forget(_retval);
-    return NS_OK;
+  localFile.forget(_retval);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirectoryService::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
 {
-    if (NS_WARN_IF(!_retval))
-        return NS_ERROR_INVALID_ARG;
-    *_retval = nullptr;
-        
-    return NS_ERROR_FAILURE;
+  if (NS_WARN_IF(!_retval))
+    return NS_ERROR_INVALID_ARG;
+  *_retval = nullptr;
+
+  return NS_ERROR_FAILURE;
 }
--- a/xpcom/io/nsDirectoryService.h
+++ b/xpcom/io/nsDirectoryService.h
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDirectoryService_h___
 #define nsDirectoryService_h___
 
 #include "nsIDirectoryService.h"
@@ -16,45 +17,45 @@
 #define NS_XPCOM_INIT_CURRENT_PROCESS_DIR       "MozBinD"   // Can be used to set NS_XPCOM_CURRENT_PROCESS_DIR
                                                             // CANNOT be used to GET a location
 #define NS_DIRECTORY_SERVICE_CID  {0xf00152d0,0xb40b,0x11d3,{0x8c, 0x9c, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
 
 class nsDirectoryService MOZ_FINAL : public nsIDirectoryService,
                                      public nsIProperties,
                                      public nsIDirectoryServiceProvider2
 {
-  public:
+public:
 
   // nsISupports interface
   NS_DECL_THREADSAFE_ISUPPORTS
 
-  NS_DECL_NSIPROPERTIES  
+  NS_DECL_NSIPROPERTIES
 
   NS_DECL_NSIDIRECTORYSERVICE
 
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
-  
+
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
   nsDirectoryService();
-   ~nsDirectoryService();
+  ~nsDirectoryService();
 
   static void RealInit();
   void RegisterCategoryProviders();
 
   static nsresult
   Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
   static nsDirectoryService* gService;
 
 private:
-    nsresult GetCurrentProcessDirectory(nsIFile** aFile);
-    
-    nsInterfaceHashtable<nsCStringHashKey, nsIFile> mHashtable;
-    nsTArray<nsCOMPtr<nsIDirectoryServiceProvider> > mProviders;
+  nsresult GetCurrentProcessDirectory(nsIFile** aFile);
+
+  nsInterfaceHashtable<nsCStringHashKey, nsIFile> mHashtable;
+  nsTArray<nsCOMPtr<nsIDirectoryServiceProvider> > mProviders;
 
 public:
 
 #define DIR_ATOM(name_, value_) static nsIAtom* name_;
 #include "nsDirectoryServiceAtomList.h"
 #undef DIR_ATOM
 
 };
--- a/xpcom/io/nsDirectoryServiceAtomList.h
+++ b/xpcom/io/nsDirectoryServiceAtomList.h
@@ -37,17 +37,17 @@ DIR_ATOM(sLocalInternetPlugInDirectory, 
 DIR_ATOM(sUserFrameworksDirectory, NS_OSX_USER_FRAMEWORKS_DIR)
 DIR_ATOM(sLocalFrameworksDirectory, NS_OSX_LOCAL_FRAMEWORKS_DIR)
 DIR_ATOM(sUserPreferencesDirectory, NS_OSX_USER_PREFERENCES_DIR)
 DIR_ATOM(sLocalPreferencesDirectory, NS_OSX_LOCAL_PREFERENCES_DIR)
 DIR_ATOM(sPictureDocumentsDirectory, NS_OSX_PICTURE_DOCUMENTS_DIR)
 DIR_ATOM(sMovieDocumentsDirectory, NS_OSX_MOVIE_DOCUMENTS_DIR)
 DIR_ATOM(sMusicDocumentsDirectory, NS_OSX_MUSIC_DOCUMENTS_DIR)
 DIR_ATOM(sInternetSitesDirectory, NS_OSX_INTERNET_SITES_DIR)
-#elif defined (XP_WIN) 
+#elif defined (XP_WIN)
 DIR_ATOM(sSystemDirectory, NS_OS_SYSTEM_DIR)
 DIR_ATOM(sWindowsDirectory, NS_WIN_WINDOWS_DIR)
 DIR_ATOM(sWindowsProgramFiles, NS_WIN_PROGRAM_FILES_DIR)
 DIR_ATOM(sDesktop, NS_WIN_DESKTOP_DIR)
 DIR_ATOM(sPrograms, NS_WIN_PROGRAMS_DIR)
 DIR_ATOM(sControls, NS_WIN_CONTROLS_DIR)
 DIR_ATOM(sPrinters, NS_WIN_PRINTERS_DIR)
 DIR_ATOM(sPersonal, NS_WIN_PERSONAL_DIR)
--- a/xpcom/io/nsDirectoryServiceDefs.h
+++ b/xpcom/io/nsDirectoryServiceDefs.h
@@ -1,20 +1,21 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
- * Defines the property names for directories available from 
- * nsIDirectoryService. These dirs are always available even if no 
- * nsIDirectoryServiceProviders have been registered with the service. 
+ * Defines the property names for directories available from
+ * nsIDirectoryService. These dirs are always available even if no
+ * nsIDirectoryServiceProviders have been registered with the service.
  * Application level keys are defined in nsAppDirectoryServiceDefs.h.
  *
- * Keys whose definition ends in "DIR" or "FILE" return a single nsIFile (or 
+ * Keys whose definition ends in "DIR" or "FILE" return a single nsIFile (or
  * subclass). Keys whose definition ends in "LIST" return an nsISimpleEnumerator
  * which enumerates a list of file objects.
  *
  * Defines listed in this file are FROZEN.  This list may grow.
  */
 
 #ifndef nsDirectoryServiceDefs_h___
 #define nsDirectoryServiceDefs_h___
@@ -24,130 +25,130 @@
 #define NS_OS_HOME_DIR                          "Home"
 #define NS_OS_TEMP_DIR                          "TmpD"
 #define NS_OS_CURRENT_WORKING_DIR               "CurWorkD"
 /* Files stored in this directory will appear on the user's desktop,
  * if there is one, otherwise it's just the same as "Home"
  */
 #define NS_OS_DESKTOP_DIR                       "Desk"
 
-/* Property returns the directory in which the procces was started from.  
- * On Unix this will be the path in the MOZILLA_FIVE_HOME env var and if 
- * unset will be the current working directory. 
+/* Property returns the directory in which the procces was started from.
+ * On Unix this will be the path in the MOZILLA_FIVE_HOME env var and if
+ * unset will be the current working directory.
  */
 #define NS_OS_CURRENT_PROCESS_DIR               "CurProcD"
-                                                                                                                       
-/* This location is similar to NS_OS_CURRENT_PROCESS_DIR, however, 
+
+/* This location is similar to NS_OS_CURRENT_PROCESS_DIR, however,
  * NS_XPCOM_CURRENT_PROCESS_DIR can be overriden by passing a "bin
- * directory" to NS_InitXPCOM2(). 
+ * directory" to NS_InitXPCOM2().
  */
 #define NS_XPCOM_CURRENT_PROCESS_DIR            "XCurProcD"
 
 /* Property will return the location of the the XPCOM Shared Library.
  */
 #define NS_XPCOM_LIBRARY_FILE                   "XpcomLib"
 
-/* Property will return the current location of the the GRE directory.  
- * If no GRE is used, this propery will behave like 
+/* Property will return the current location of the the GRE directory.
+ * If no GRE is used, this propery will behave like
  * NS_XPCOM_CURRENT_PROCESS_DIR.
  */
 #define NS_GRE_DIR                              "GreD"
 
 /* Platform Specific Locations */
 
 #if !defined (XP_UNIX) || defined(MOZ_WIDGET_COCOA)
     #define NS_OS_SYSTEM_DIR                    "SysD"
 #endif
 
 #if defined (MOZ_WIDGET_COCOA)
-    #define NS_MAC_DESKTOP_DIR                  NS_OS_DESKTOP_DIR
-    #define NS_MAC_TRASH_DIR                    "Trsh"
-    #define NS_MAC_STARTUP_DIR                  "Strt"
-    #define NS_MAC_SHUTDOWN_DIR                 "Shdwn"
-    #define NS_MAC_APPLE_MENU_DIR               "ApplMenu"
-    #define NS_MAC_CONTROL_PANELS_DIR           "CntlPnl"
-    #define NS_MAC_EXTENSIONS_DIR               "Exts"
-    #define NS_MAC_FONTS_DIR                    "Fnts"
-    #define NS_MAC_PREFS_DIR                    "Prfs"
-    #define NS_MAC_DOCUMENTS_DIR                "Docs"
-    #define NS_MAC_INTERNET_SEARCH_DIR          "ISrch"
-    #define NS_OSX_HOME_DIR                     NS_OS_HOME_DIR
-    #define NS_MAC_HOME_DIR                     NS_OS_HOME_DIR
-    #define NS_MAC_DEFAULT_DOWNLOAD_DIR         "DfltDwnld"
-    #define NS_MAC_USER_LIB_DIR                 "ULibDir"   // Only available under OS X
-    #define NS_OSX_DEFAULT_DOWNLOAD_DIR         NS_MAC_DEFAULT_DOWNLOAD_DIR
-    #define NS_OSX_USER_DESKTOP_DIR             "UsrDsk"
-    #define NS_OSX_LOCAL_DESKTOP_DIR            "LocDsk"
-    #define NS_OSX_USER_APPLICATIONS_DIR        "UsrApp"
-    #define NS_OSX_LOCAL_APPLICATIONS_DIR       "LocApp"
-    #define NS_OSX_USER_DOCUMENTS_DIR           "UsrDocs"
-    #define NS_OSX_LOCAL_DOCUMENTS_DIR          "LocDocs"
-    #define NS_OSX_USER_INTERNET_PLUGIN_DIR     "UsrIntrntPlgn"
-    #define NS_OSX_LOCAL_INTERNET_PLUGIN_DIR    "LoclIntrntPlgn"
-    #define NS_OSX_USER_FRAMEWORKS_DIR          "UsrFrmwrks"
-    #define NS_OSX_LOCAL_FRAMEWORKS_DIR         "LocFrmwrks"
-    #define NS_OSX_USER_PREFERENCES_DIR         "UsrPrfs"
-    #define NS_OSX_LOCAL_PREFERENCES_DIR        "LocPrfs"
-    #define NS_OSX_PICTURE_DOCUMENTS_DIR        "Pct"
-    #define NS_OSX_MOVIE_DOCUMENTS_DIR          "Mov"
-    #define NS_OSX_MUSIC_DOCUMENTS_DIR          "Music"
-    #define NS_OSX_INTERNET_SITES_DIR           "IntrntSts"
+  #define NS_MAC_DESKTOP_DIR                  NS_OS_DESKTOP_DIR
+  #define NS_MAC_TRASH_DIR                    "Trsh"
+  #define NS_MAC_STARTUP_DIR                  "Strt"
+  #define NS_MAC_SHUTDOWN_DIR                 "Shdwn"
+  #define NS_MAC_APPLE_MENU_DIR               "ApplMenu"
+  #define NS_MAC_CONTROL_PANELS_DIR           "CntlPnl"
+  #define NS_MAC_EXTENSIONS_DIR               "Exts"
+  #define NS_MAC_FONTS_DIR                    "Fnts"
+  #define NS_MAC_PREFS_DIR                    "Prfs"
+  #define NS_MAC_DOCUMENTS_DIR                "Docs"
+  #define NS_MAC_INTERNET_SEARCH_DIR          "ISrch"
+  #define NS_OSX_HOME_DIR                     NS_OS_HOME_DIR
+  #define NS_MAC_HOME_DIR                     NS_OS_HOME_DIR
+  #define NS_MAC_DEFAULT_DOWNLOAD_DIR         "DfltDwnld"
+  #define NS_MAC_USER_LIB_DIR                 "ULibDir"   // Only available under OS X
+  #define NS_OSX_DEFAULT_DOWNLOAD_DIR         NS_MAC_DEFAULT_DOWNLOAD_DIR
+  #define NS_OSX_USER_DESKTOP_DIR             "UsrDsk"
+  #define NS_OSX_LOCAL_DESKTOP_DIR            "LocDsk"
+  #define NS_OSX_USER_APPLICATIONS_DIR        "UsrApp"
+  #define NS_OSX_LOCAL_APPLICATIONS_DIR       "LocApp"
+  #define NS_OSX_USER_DOCUMENTS_DIR           "UsrDocs"
+  #define NS_OSX_LOCAL_DOCUMENTS_DIR          "LocDocs"
+  #define NS_OSX_USER_INTERNET_PLUGIN_DIR     "UsrIntrntPlgn"
+  #define NS_OSX_LOCAL_INTERNET_PLUGIN_DIR    "LoclIntrntPlgn"
+  #define NS_OSX_USER_FRAMEWORKS_DIR          "UsrFrmwrks"
+  #define NS_OSX_LOCAL_FRAMEWORKS_DIR         "LocFrmwrks"
+  #define NS_OSX_USER_PREFERENCES_DIR         "UsrPrfs"
+  #define NS_OSX_LOCAL_PREFERENCES_DIR        "LocPrfs"
+  #define NS_OSX_PICTURE_DOCUMENTS_DIR        "Pct"
+  #define NS_OSX_MOVIE_DOCUMENTS_DIR          "Mov"
+  #define NS_OSX_MUSIC_DOCUMENTS_DIR          "Music"
+  #define NS_OSX_INTERNET_SITES_DIR           "IntrntSts"
 #elif defined (XP_WIN)
-    #define NS_WIN_WINDOWS_DIR                  "WinD"
-    #define NS_WIN_PROGRAM_FILES_DIR            "ProgF"
-    #define NS_WIN_HOME_DIR                     NS_OS_HOME_DIR
-    #define NS_WIN_DESKTOP_DIR                  "DeskV" // virtual folder at the root of the namespace
-    #define NS_WIN_PROGRAMS_DIR                 "Progs" // User start menu programs directory!
-    #define NS_WIN_CONTROLS_DIR                 "Cntls"
-    #define NS_WIN_PRINTERS_DIR                 "Prnts"
-    #define NS_WIN_PERSONAL_DIR                 "Pers"
-    #define NS_WIN_FAVORITES_DIR                "Favs"
-    #define NS_WIN_STARTUP_DIR                  "Strt"
-    #define NS_WIN_RECENT_DIR                   "Rcnt"
-    #define NS_WIN_SEND_TO_DIR                  "SndTo"
-    #define NS_WIN_BITBUCKET_DIR                "Buckt"
-    #define NS_WIN_STARTMENU_DIR                "Strt"
+  #define NS_WIN_WINDOWS_DIR                  "WinD"
+  #define NS_WIN_PROGRAM_FILES_DIR            "ProgF"
+  #define NS_WIN_HOME_DIR                     NS_OS_HOME_DIR
+  #define NS_WIN_DESKTOP_DIR                  "DeskV" // virtual folder at the root of the namespace
+  #define NS_WIN_PROGRAMS_DIR                 "Progs" // User start menu programs directory!
+  #define NS_WIN_CONTROLS_DIR                 "Cntls"
+  #define NS_WIN_PRINTERS_DIR                 "Prnts"
+  #define NS_WIN_PERSONAL_DIR                 "Pers"
+  #define NS_WIN_FAVORITES_DIR                "Favs"
+  #define NS_WIN_STARTUP_DIR                  "Strt"
+  #define NS_WIN_RECENT_DIR                   "Rcnt"
+  #define NS_WIN_SEND_TO_DIR                  "SndTo"
+  #define NS_WIN_BITBUCKET_DIR                "Buckt"
+  #define NS_WIN_STARTMENU_DIR                "Strt"
 // This gives the same thing as NS_OS_DESKTOP_DIR
-    #define NS_WIN_DESKTOP_DIRECTORY            "DeskP" // file sys dir which physically stores objects on desktop
-    #define NS_WIN_DRIVES_DIR                   "Drivs"
-    #define NS_WIN_NETWORK_DIR                  "NetW"
-    #define NS_WIN_NETHOOD_DIR                  "netH"
-    #define NS_WIN_FONTS_DIR                    "Fnts"
-    #define NS_WIN_TEMPLATES_DIR                "Tmpls"
-    #define NS_WIN_COMMON_STARTMENU_DIR         "CmStrt"
-    #define NS_WIN_COMMON_PROGRAMS_DIR          "CmPrgs"
-    #define NS_WIN_COMMON_STARTUP_DIR           "CmStrt"
-    #define NS_WIN_COMMON_DESKTOP_DIRECTORY     "CmDeskP"
-    #define NS_WIN_COMMON_APPDATA_DIR           "CmAppData"
-    #define NS_WIN_APPDATA_DIR                  "AppData"
-    #define NS_WIN_LOCAL_APPDATA_DIR            "LocalAppData"
-    #define NS_WIN_PRINTHOOD                    "PrntHd"
-    #define NS_WIN_COOKIES_DIR                  "CookD"
-    #define NS_WIN_DEFAULT_DOWNLOAD_DIR         "DfltDwnld"
-    // On Win7 and up these ids will return the default save-to location for
-    // Windows Libraries associated with the specific content type. For other
-    // os they return the local user folder. Note these can return network file
-    // paths which can jank the ui thread so be careful how you access them.
-    #define NS_WIN_DOCUMENTS_DIR                "Docs"
-    #define NS_WIN_PICTURES_DIR                 "Pict"
-    #define NS_WIN_MUSIC_DIR                    "Music"
-    #define NS_WIN_VIDEOS_DIR                   "Vids"
+  #define NS_WIN_DESKTOP_DIRECTORY            "DeskP" // file sys dir which physically stores objects on desktop
+  #define NS_WIN_DRIVES_DIR                   "Drivs"
+  #define NS_WIN_NETWORK_DIR                  "NetW"
+  #define NS_WIN_NETHOOD_DIR                  "netH"
+  #define NS_WIN_FONTS_DIR                    "Fnts"
+  #define NS_WIN_TEMPLATES_DIR                "Tmpls"
+  #define NS_WIN_COMMON_STARTMENU_DIR         "CmStrt"
+  #define NS_WIN_COMMON_PROGRAMS_DIR          "CmPrgs"
+  #define NS_WIN_COMMON_STARTUP_DIR           "CmStrt"
+  #define NS_WIN_COMMON_DESKTOP_DIRECTORY     "CmDeskP"
+  #define NS_WIN_COMMON_APPDATA_DIR           "CmAppData"
+  #define NS_WIN_APPDATA_DIR                  "AppData"
+  #define NS_WIN_LOCAL_APPDATA_DIR            "LocalAppData"
+  #define NS_WIN_PRINTHOOD                    "PrntHd"
+  #define NS_WIN_COOKIES_DIR                  "CookD"
+  #define NS_WIN_DEFAULT_DOWNLOAD_DIR         "DfltDwnld"
+  // On Win7 and up these ids will return the default save-to location for
+  // Windows Libraries associated with the specific content type. For other
+  // os they return the local user folder. Note these can return network file
+  // paths which can jank the ui thread so be careful how you access them.
+  #define NS_WIN_DOCUMENTS_DIR                "Docs"
+  #define NS_WIN_PICTURES_DIR                 "Pict"
+  #define NS_WIN_MUSIC_DIR                    "Music"
+  #define NS_WIN_VIDEOS_DIR                   "Vids"
 #elif defined (XP_UNIX)
-    #define NS_UNIX_LOCAL_DIR                   "Locl"
-    #define NS_UNIX_LIB_DIR                     "LibD"
-    #define NS_UNIX_HOME_DIR                    NS_OS_HOME_DIR
-    #define NS_UNIX_XDG_DESKTOP_DIR             "XDGDesk"
-    #define NS_UNIX_XDG_DOCUMENTS_DIR           "XDGDocs"
-    #define NS_UNIX_XDG_DOWNLOAD_DIR            "XDGDwnld"
-    #define NS_UNIX_XDG_MUSIC_DIR               "XDGMusic"
-    #define NS_UNIX_XDG_PICTURES_DIR            "XDGPict"
-    #define NS_UNIX_XDG_PUBLIC_SHARE_DIR        "XDGPubSh"
-    #define NS_UNIX_XDG_TEMPLATES_DIR           "XDGTempl"
-    #define NS_UNIX_XDG_VIDEOS_DIR              "XDGVids"
-    #define NS_UNIX_DEFAULT_DOWNLOAD_DIR        "DfltDwnld"
+  #define NS_UNIX_LOCAL_DIR                   "Locl"
+  #define NS_UNIX_LIB_DIR                     "LibD"
+  #define NS_UNIX_HOME_DIR                    NS_OS_HOME_DIR
+  #define NS_UNIX_XDG_DESKTOP_DIR             "XDGDesk"
+  #define NS_UNIX_XDG_DOCUMENTS_DIR           "XDGDocs"
+  #define NS_UNIX_XDG_DOWNLOAD_DIR            "XDGDwnld"
+  #define NS_UNIX_XDG_MUSIC_DIR               "XDGMusic"
+  #define NS_UNIX_XDG_PICTURES_DIR            "XDGPict"
+  #define NS_UNIX_XDG_PUBLIC_SHARE_DIR        "XDGPubSh"
+  #define NS_UNIX_XDG_TEMPLATES_DIR           "XDGTempl"
+  #define NS_UNIX_XDG_VIDEOS_DIR              "XDGVids"
+  #define NS_UNIX_DEFAULT_DOWNLOAD_DIR        "DfltDwnld"
 #endif
 
 /* Deprecated */
 
 #define NS_OS_DRIVE_DIR                         "DrvD"
 
 
 
--- a/xpcom/io/nsDirectoryServiceUtils.h
+++ b/xpcom/io/nsDirectoryServiceUtils.h
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDirectoryServiceUtils_h___
 #define nsDirectoryServiceUtils_h___
 
 #include "nsIServiceManager.h"
@@ -11,18 +12,18 @@
 #include "nsServiceManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsXPCOMCID.h"
 #include "nsIFile.h"
 
 inline nsresult
 NS_GetSpecialDirectory(const char* specialDirName, nsIFile* *result)
 {
-    nsresult rv;
-    nsCOMPtr<nsIProperties> serv(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
-    if (NS_FAILED(rv))
-        return rv;
+  nsresult rv;
+  nsCOMPtr<nsIProperties> serv(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv))
+    return rv;
 
-    return serv->Get(specialDirName, NS_GET_IID(nsIFile),
-                     reinterpret_cast<void**>(result));
+  return serv->Get(specialDirName, NS_GET_IID(nsIFile),
+                   reinterpret_cast<void**>(result));
 }
 
 #endif
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -1,285 +1,286 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
-//	First checked in on 98/12/03 by John R. McMullen, derived from net.h/mkparse.c.
+
+//  First checked in on 98/12/03 by John R. McMullen, derived from net.h/mkparse.c.
 
 #include "nsEscape.h"
 #include "nsMemory.h"
 #include "nsCRT.h"
 #include "nsReadableUtils.h"
 
 const int netCharType[256] =
-/*	Bit 0		xalpha		-- the alphas
-**	Bit 1		xpalpha		-- as xalpha but 
+/*  Bit 0       xalpha      -- the alphas
+**  Bit 1       xpalpha     -- as xalpha but
 **                             converts spaces to plus and plus to %2B
-**	Bit 3 ...	path		-- as xalphas but doesn't escape '/'
+**  Bit 3 ...   path        -- as xalphas but doesn't escape '/'
 */
-    /*   0 1 2 3 4 5 6 7 8 9 A B C D E F */
-    {    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/* 0x */
-		 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/* 1x */
-		 0,0,0,0,0,0,0,0,0,0,7,4,0,7,7,4,	/* 2x   !"#$%&'()*+,-./	 */
-         7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,	/* 3x  0123456789:;<=>?	 */
-	     0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,	/* 4x  @ABCDEFGHIJKLMNO  */
-	     /* bits for '@' changed from 7 to 0 so '@' can be escaped   */
-	     /* in usernames and passwords in publishing.                */
-	     7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,7,	/* 5X  PQRSTUVWXYZ[\]^_	 */
-	     0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,	/* 6x  `abcdefghijklmno	 */
-	     7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,	/* 7X  pqrstuvwxyz{\}~	DEL */
-		 0, };
+  /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+  {  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,   /* 0x */
+     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,   /* 1x */
+     0,0,0,0,0,0,0,0,0,0,7,4,0,7,7,4,   /* 2x   !"#$%&'()*+,-./  */
+     7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,   /* 3x  0123456789:;<=>?  */
+     0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,   /* 4x  @ABCDEFGHIJKLMNO  */
+     /* bits for '@' changed from 7 to 0 so '@' can be escaped   */
+     /* in usernames and passwords in publishing.                */
+     7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,7,   /* 5X  PQRSTUVWXYZ[\]^_  */
+     0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,   /* 6x  `abcdefghijklmno  */
+     7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,   /* 7X  pqrstuvwxyz{\}~  DEL */
+     0, };
 
 /* decode % escaped hex codes into character values
  */
 #define UNHEX(C) \
     ((C >= '0' && C <= '9') ? C - '0' : \
      ((C >= 'A' && C <= 'F') ? C - 'A' + 10 : \
      ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : 0)))
 
 
 #define IS_OK(C) (netCharType[((unsigned int) (C))] & (flags))
 #define HEX_ESCAPE '%'
 
 //----------------------------------------------------------------------------------------
 static char* nsEscapeCount(
-    const char * str,
-    nsEscapeMask flags,
-    size_t* out_len)
+  const char * str,
+  nsEscapeMask flags,
+  size_t* out_len)
 //----------------------------------------------------------------------------------------
 {
-	if (!str)
-		return 0;
+  if (!str)
+    return 0;
 
-    size_t i, len = 0, charsToEscape = 0;
-    static const char hexChars[] = "0123456789ABCDEF";
+  size_t i, len = 0, charsToEscape = 0;
+  static const char hexChars[] = "0123456789ABCDEF";
 
-	const unsigned char* src = (const unsigned char *) str;
-    while (*src)
-	{
-        len++;
-        if (!IS_OK(*src++))
-            charsToEscape++;
-	}
+  const unsigned char* src = (const unsigned char *) str;
+  while (*src)
+  {
+    len++;
+    if (!IS_OK(*src++))
+      charsToEscape++;
+  }
 
-    // calculate how much memory should be allocated
-    // original length + 2 bytes for each escaped character + terminating '\0'
-    // do the sum in steps to check for overflow
-    size_t dstSize = len + 1 + charsToEscape;
-    if (dstSize <= len)
-	return 0;
-    dstSize += charsToEscape;
-    if (dstSize < len)
-	return 0;
+  // calculate how much memory should be allocated
+  // original length + 2 bytes for each escaped character + terminating '\0'
+  // do the sum in steps to check for overflow
+  size_t dstSize = len + 1 + charsToEscape;
+  if (dstSize <= len)
+    return 0;
+  dstSize += charsToEscape;
+  if (dstSize < len)
+    return 0;
 
-    // fail if we need more than 4GB
-    // size_t is likely to be long unsigned int but nsMemory::Alloc(size_t)
-    // calls NS_Alloc_P(size_t) which calls PR_Malloc(uint32_t), so there is
-    // no chance to allocate more than 4GB using nsMemory::Alloc()
-    if (dstSize > UINT32_MAX)
-        return 0;
+  // fail if we need more than 4GB
+  // size_t is likely to be long unsigned int but nsMemory::Alloc(size_t)
+  // calls NS_Alloc_P(size_t) which calls PR_Malloc(uint32_t), so there is
+  // no chance to allocate more than 4GB using nsMemory::Alloc()
+  if (dstSize > UINT32_MAX)
+    return 0;
 
-	char* result = (char *)nsMemory::Alloc(dstSize);
-    if (!result)
-        return 0;
+  char* result = (char *)nsMemory::Alloc(dstSize);
+  if (!result)
+    return 0;
 
-    unsigned char* dst = (unsigned char *) result;
-	src = (const unsigned char *) str;
-	if (flags == url_XPAlphas)
-	{
-	    for (i = 0; i < len; i++)
-		{
-			unsigned char c = *src++;
-			if (IS_OK(c))
-				*dst++ = c;
-			else if (c == ' ')
-				*dst++ = '+'; /* convert spaces to pluses */
-			else 
-			{
-				*dst++ = HEX_ESCAPE;
-				*dst++ = hexChars[c >> 4];	/* high nibble */
-				*dst++ = hexChars[c & 0x0f];	/* low nibble */
-			}
-		}
-	}
-	else
-	{
-	    for (i = 0; i < len; i++)
-		{
-			unsigned char c = *src++;
-			if (IS_OK(c))
-				*dst++ = c;
-			else 
-			{
-				*dst++ = HEX_ESCAPE;
-				*dst++ = hexChars[c >> 4];	/* high nibble */
-				*dst++ = hexChars[c & 0x0f];	/* low nibble */
-			}
-		}
-	}
+  unsigned char* dst = (unsigned char *) result;
+  src = (const unsigned char *) str;
+  if (flags == url_XPAlphas)
+  {
+    for (i = 0; i < len; i++)
+    {
+      unsigned char c = *src++;
+      if (IS_OK(c))
+        *dst++ = c;
+      else if (c == ' ')
+        *dst++ = '+'; /* convert spaces to pluses */
+      else
+      {
+        *dst++ = HEX_ESCAPE;
+        *dst++ = hexChars[c >> 4];  /* high nibble */
+        *dst++ = hexChars[c & 0x0f];  /* low nibble */
+      }
+    }
+  }
+  else
+  {
+    for (i = 0; i < len; i++)
+    {
+      unsigned char c = *src++;
+      if (IS_OK(c))
+        *dst++ = c;
+      else
+      {
+        *dst++ = HEX_ESCAPE;
+        *dst++ = hexChars[c >> 4];  /* high nibble */
+        *dst++ = hexChars[c & 0x0f];  /* low nibble */
+      }
+    }
+  }
 
-    *dst = '\0';     /* tack on eos */
-	if(out_len)
-		*out_len = dst - (unsigned char *) result;
-    return result;
+  *dst = '\0';     /* tack on eos */
+  if(out_len)
+    *out_len = dst - (unsigned char *) result;
+  return result;
 }
 
 //----------------------------------------------------------------------------------------
 char* nsEscape(const char * str, nsEscapeMask flags)
 //----------------------------------------------------------------------------------------
 {
-    if(!str)
-        return nullptr;
-    return nsEscapeCount(str, flags, nullptr);
+  if(!str)
+    return nullptr;
+  return nsEscapeCount(str, flags, nullptr);
 }
 
 //----------------------------------------------------------------------------------------
 char* nsUnescape(char * str)
 //----------------------------------------------------------------------------------------
 {
-	nsUnescapeCount(str);
-	return str;
+  nsUnescapeCount(str);
+  return str;
 }
 
 //----------------------------------------------------------------------------------------
 int32_t nsUnescapeCount(char * str)
 //----------------------------------------------------------------------------------------
 {
-    char *src = str;
-    char *dst = str;
-    static const char hexChars[] = "0123456789ABCDEFabcdef";
+  char *src = str;
+  char *dst = str;
+  static const char hexChars[] = "0123456789ABCDEFabcdef";
 
-    char c1[] = " ";
-    char c2[] = " ";
-    char* const pc1 = c1;
-    char* const pc2 = c2;
+  char c1[] = " ";
+  char c2[] = " ";
+  char* const pc1 = c1;
+  char* const pc2 = c2;
 
-    if (!*src) {
-      // A null string was passed in.  Nothing to escape.
-      // Returns early as the string might not actually be mutable with
-      // length 0.
-      return 0;
-    }
+  if (!*src) {
+    // A null string was passed in.  Nothing to escape.
+    // Returns early as the string might not actually be mutable with
+    // length 0.
+    return 0;
+  }
 
-    while (*src)
+  while (*src)
+  {
+    c1[0] = *(src+1);
+    if (*(src+1) == '\0')
+      c2[0] = '\0';
+    else
+      c2[0] = *(src+2);
+
+    if (*src != HEX_ESCAPE || PL_strpbrk(pc1, hexChars) == 0 ||
+        PL_strpbrk(pc2, hexChars) == 0 )
+      *dst++ = *src++;
+    else
     {
-        c1[0] = *(src+1);
-        if (*(src+1) == '\0') 
-            c2[0] = '\0';
-        else
-            c2[0] = *(src+2);
+      src++; /* walk over escape */
+      if (*src)
+      {
+        *dst = UNHEX(*src) << 4;
+        src++;
+      }
+      if (*src)
+      {
+        *dst = (*dst + UNHEX(*src));
+        src++;
+      }
+      dst++;
+    }
+  }
 
-        if (*src != HEX_ESCAPE || PL_strpbrk(pc1, hexChars) == 0 || 
-                                  PL_strpbrk(pc2, hexChars) == 0 )
-        	*dst++ = *src++;
-        else 	
-		{
-        	src++; /* walk over escape */
-        	if (*src)
-            {
-            	*dst = UNHEX(*src) << 4;
-            	src++;
-            }
-        	if (*src)
-            {
-            	*dst = (*dst + UNHEX(*src));
-            	src++;
-            }
-        	dst++;
-        }
-    }
-
-    *dst = 0;
-    return (int)(dst - str);
+  *dst = 0;
+  return (int)(dst - str);
 
 } /* NET_UnEscapeCnt */
 
 
 char *
 nsEscapeHTML(const char * string)
 {
-    char *rv = nullptr;
-    /* XXX Hardcoded max entity len. The +1 is for the trailing null. */
-    uint32_t len = strlen(string);
-    if (len >= (UINT32_MAX / 6))
-      return nullptr;
+  char *rv = nullptr;
+  /* XXX Hardcoded max entity len. The +1 is for the trailing null. */
+  uint32_t len = strlen(string);
+  if (len >= (UINT32_MAX / 6))
+    return nullptr;
+
+  rv = (char *)NS_Alloc( (6 * len) + 1 );
+  char *ptr = rv;
 
-    rv = (char *)NS_Alloc( (6 * len) + 1 );
-    char *ptr = rv;
-
-    if(rv)
+  if(rv)
+  {
+    for(; *string != '\0'; string++)
+    {
+      if(*string == '<')
+      {
+        *ptr++ = '&';
+        *ptr++ = 'l';
+        *ptr++ = 't';
+        *ptr++ = ';';
+      }
+      else if(*string == '>')
+      {
+        *ptr++ = '&';
+        *ptr++ = 'g';
+        *ptr++ = 't';
+        *ptr++ = ';';
+      }
+      else if(*string == '&')
       {
-        for(; *string != '\0'; string++)
-          {
-            if(*string == '<')
-              {
-                *ptr++ = '&';
-                *ptr++ = 'l';
-                *ptr++ = 't';
-                *ptr++ = ';';
-              }
-            else if(*string == '>')
-              {
-                *ptr++ = '&';
-                *ptr++ = 'g';
-                *ptr++ = 't';
-                *ptr++ = ';';
-              }
-            else if(*string == '&')
-              {
-                *ptr++ = '&';
-                *ptr++ = 'a';
-                *ptr++ = 'm';
-                *ptr++ = 'p';
-                *ptr++ = ';';
-              }
-            else if (*string == '"')
-              {
-                *ptr++ = '&';
-                *ptr++ = 'q';
-                *ptr++ = 'u';
-                *ptr++ = 'o';
-                *ptr++ = 't';
-                *ptr++ = ';';
-              }
-            else if (*string == '\'')
-              {
-                *ptr++ = '&';
-                *ptr++ = '#';
-                *ptr++ = '3';
-                *ptr++ = '9';
-                *ptr++ = ';';
-              }
-            else
-              {
-                *ptr++ = *string;
-              }
-          }
-        *ptr = '\0';
+        *ptr++ = '&';
+        *ptr++ = 'a';
+        *ptr++ = 'm';
+        *ptr++ = 'p';
+        *ptr++ = ';';
+      }
+      else if (*string == '"')
+      {
+        *ptr++ = '&';
+        *ptr++ = 'q';
+        *ptr++ = 'u';
+        *ptr++ = 'o';
+        *ptr++ = 't';
+        *ptr++ = ';';
       }
+      else if (*string == '\'')
+      {
+        *ptr++ = '&';
+        *ptr++ = '#';
+        *ptr++ = '3';
+        *ptr++ = '9';
+        *ptr++ = ';';
+      }
+      else
+      {
+        *ptr++ = *string;
+      }
+    }
+    *ptr = '\0';
+  }
 
-    return(rv);
+  return(rv);
 }
 
 char16_t *
 nsEscapeHTML2(const char16_t *aSourceBuffer, int32_t aSourceBufferLen)
 {
   // Calculate the length, if the caller didn't.
   if (aSourceBufferLen < 0) {
     aSourceBufferLen = NS_strlen(aSourceBuffer);
   }
 
   /* XXX Hardcoded max entity len. */
   if (uint32_t(aSourceBufferLen) >=
       ((UINT32_MAX - sizeof(char16_t)) / (6 * sizeof(char16_t))) )
     return nullptr;
 
   char16_t *resultBuffer = (char16_t *)nsMemory::Alloc(aSourceBufferLen *
-                            6 * sizeof(char16_t) + sizeof(char16_t('\0')));
+    6 * sizeof(char16_t) + sizeof(char16_t('\0')));
   char16_t *ptr = resultBuffer;
 
   if (resultBuffer) {
     int32_t i;
 
     for(i = 0; i < aSourceBufferLen; i++) {
       if(aSourceBuffer[i] == '<') {
         *ptr++ = '&';
@@ -318,187 +319,187 @@ nsEscapeHTML2(const char16_t *aSourceBuf
   }
 
   return resultBuffer;
 }
 
 //----------------------------------------------------------------------------------------
 
 const int EscapeChars[256] =
-/*      0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F */
+/*   0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F */
 {
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,       /* 0x */
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  	    /* 1x */
-        0,1023,   0, 512,1023,   0,1023,   0,1023,1023,1023,1023,1023,1023, 953, 784,       /* 2x   !"#$%&'()*+,-./	 */
-     1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008,1008,   0,1008,   0, 768,       /* 3x  0123456789:;<=>?	 */
-     1008,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,       /* 4x  @ABCDEFGHIJKLMNO  */
-     1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896, 896, 896, 896,1023,       /* 5x  PQRSTUVWXYZ[\]^_	 */
-        0,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,       /* 6x  `abcdefghijklmno	 */
-     1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896,1012, 896,1023,   0,       /* 7x  pqrstuvwxyz{|}~	 */
-        0    /* 8x  DEL               */
+     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 0x */
+     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  /* 1x */
+     0,1023,   0, 512,1023,   0,1023,   0,1023,1023,1023,1023,1023,1023, 953, 784,  /* 2x   !"#$%&'()*+,-./  */
+  1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008,1008,   0,1008,   0, 768,  /* 3x  0123456789:;<=>?  */
+  1008,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,  /* 4x  @ABCDEFGHIJKLMNO  */
+  1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896, 896, 896, 896,1023,  /* 5x  PQRSTUVWXYZ[\]^_  */
+     0,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,  /* 6x  `abcdefghijklmno  */
+  1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896,1012, 896,1023,   0,  /* 7x  pqrstuvwxyz{|}~   */
+     0    /* 8x  DEL               */
 };
 
 #define NO_NEED_ESC(C) (EscapeChars[((unsigned int) (C))] & (flags))
 
 //----------------------------------------------------------------------------------------
 
 /* returns an escaped string */
 
-/* use the following flags to specify which 
-   part of an URL you want to escape: 
+/* use the following flags to specify which
+   part of an URL you want to escape:
 
    esc_Scheme        =     1
    esc_Username      =     2
    esc_Password      =     4
    esc_Host          =     8
    esc_Directory     =    16
    esc_FileBaseName  =    32
    esc_FileExtension =    64
    esc_Param         =   128
    esc_Query         =   256
    esc_Ref           =   512
 */
 
 /* by default this function will not escape parts of a string
-   that already look escaped, which means it already includes 
+   that already look escaped, which means it already includes
    a valid hexcode. This is done to avoid multiple escapes of
-   a string. Use the following flags to force escaping of a 
+   a string. Use the following flags to force escaping of a
    string:
- 
+
    esc_Forced        =  1024
 */
 
 bool NS_EscapeURL(const char *part,
-                           int32_t partLen,
-                           uint32_t flags,
-                           nsACString &result)
+                  int32_t partLen,
+                  uint32_t flags,
+                  nsACString &result)
 {
-    if (!part) {
-        NS_NOTREACHED("null pointer");
-        return false;
+  if (!part) {
+    NS_NOTREACHED("null pointer");
+    return false;
+  }
+
+  int i = 0;
+  static const char hexChars[] = "0123456789ABCDEF";
+  if (partLen < 0)
+    partLen = strlen(part);
+  bool forced = !!(flags & esc_Forced);
+  bool ignoreNonAscii = !!(flags & esc_OnlyASCII);
+  bool ignoreAscii = !!(flags & esc_OnlyNonASCII);
+  bool writing = !!(flags & esc_AlwaysCopy);
+  bool colon = !!(flags & esc_Colon);
+
+  const unsigned char* src = (const unsigned char *) part;
+
+  char tempBuffer[100];
+  unsigned int tempBufferPos = 0;
+
+  bool previousIsNonASCII = false;
+  for (i = 0; i < partLen; i++)
+  {
+    unsigned char c = *src++;
+
+    // if the char has not to be escaped or whatever follows % is
+    // a valid escaped string, just copy the char.
+    //
+    // Also the % will not be escaped until forced
+    // See bugzilla bug 61269 for details why we changed this
+    //
+    // And, we will not escape non-ascii characters if requested.
+    // On special request we will also escape the colon even when
+    // not covered by the matrix.
+    // ignoreAscii is not honored for control characters (C0 and DEL)
+    //
+    // And, we should escape the '|' character when it occurs after any
+    // non-ASCII character as it may be part of a multi-byte character.
+    //
+    // 0x20..0x7e are the valid ASCII characters. We also escape spaces
+    // (0x20) since they are not legal in URLs.
+    if ((NO_NEED_ESC(c) || (c == HEX_ESCAPE && !forced)
+         || (c > 0x7f && ignoreNonAscii)
+         || (c > 0x20 && c < 0x7f && ignoreAscii))
+        && !(c == ':' && colon)
+        && !(previousIsNonASCII && c == '|' && !ignoreNonAscii))
+    {
+      if (writing)
+        tempBuffer[tempBufferPos++] = c;
+    }
+    else /* do the escape magic */
+    {
+      if (!writing)
+      {
+        result.Append(part, i);
+        writing = true;
+      }
+      tempBuffer[tempBufferPos++] = HEX_ESCAPE;
+      tempBuffer[tempBufferPos++] = hexChars[c >> 4]; /* high nibble */
+      tempBuffer[tempBufferPos++] = hexChars[c & 0x0f]; /* low nibble */
     }
 
-    int i = 0;
-    static const char hexChars[] = "0123456789ABCDEF";
-    if (partLen < 0)
-        partLen = strlen(part);
-    bool forced = !!(flags & esc_Forced);
-    bool ignoreNonAscii = !!(flags & esc_OnlyASCII);
-    bool ignoreAscii = !!(flags & esc_OnlyNonASCII);
-    bool writing = !!(flags & esc_AlwaysCopy);
-    bool colon = !!(flags & esc_Colon);
-
-    const unsigned char* src = (const unsigned char *) part;
-
-    char tempBuffer[100];
-    unsigned int tempBufferPos = 0;
-
-    bool previousIsNonASCII = false;
-    for (i = 0; i < partLen; i++)
+    if (tempBufferPos >= sizeof(tempBuffer) - 4)
     {
-      unsigned char c = *src++;
-
-      // if the char has not to be escaped or whatever follows % is 
-      // a valid escaped string, just copy the char.
-      //
-      // Also the % will not be escaped until forced
-      // See bugzilla bug 61269 for details why we changed this
-      //
-      // And, we will not escape non-ascii characters if requested.
-      // On special request we will also escape the colon even when
-      // not covered by the matrix.
-      // ignoreAscii is not honored for control characters (C0 and DEL)
-      //
-      // And, we should escape the '|' character when it occurs after any
-      // non-ASCII character as it may be part of a multi-byte character.
-      //
-      // 0x20..0x7e are the valid ASCII characters. We also escape spaces
-      // (0x20) since they are not legal in URLs.
-      if ((NO_NEED_ESC(c) || (c == HEX_ESCAPE && !forced)
-                          || (c > 0x7f && ignoreNonAscii)
-                          || (c > 0x20 && c < 0x7f && ignoreAscii))
-          && !(c == ':' && colon)
-          && !(previousIsNonASCII && c == '|' && !ignoreNonAscii))
-      {
-        if (writing)
-          tempBuffer[tempBufferPos++] = c;
-      }
-      else /* do the escape magic */
-      {
-        if (!writing)
-        {
-          result.Append(part, i);
-          writing = true;
-        }
-        tempBuffer[tempBufferPos++] = HEX_ESCAPE;
-        tempBuffer[tempBufferPos++] = hexChars[c >> 4];	/* high nibble */
-        tempBuffer[tempBufferPos++] = hexChars[c & 0x0f]; /* low nibble */
-      }
-
-      if (tempBufferPos >= sizeof(tempBuffer) - 4)
-      {
-        NS_ASSERTION(writing, "should be writing");
-        tempBuffer[tempBufferPos] = '\0';
-        result += tempBuffer;
-        tempBufferPos = 0;
-      }
-
-      previousIsNonASCII = (c > 0x7f);
-    }
-    if (writing) {
+      NS_ASSERTION(writing, "should be writing");
       tempBuffer[tempBufferPos] = '\0';
       result += tempBuffer;
+      tempBufferPos = 0;
     }
-    return writing;
+
+    previousIsNonASCII = (c > 0x7f);
+  }
+  if (writing) {
+    tempBuffer[tempBufferPos] = '\0';
+    result += tempBuffer;
+  }
+  return writing;
 }
 
 #define ISHEX(c) memchr(hexChars, c, sizeof(hexChars)-1)
 
 bool NS_UnescapeURL(const char *str, int32_t len, uint32_t flags, nsACString &result)
 {
-    if (!str) {
-        NS_NOTREACHED("null pointer");
-        return false;
-    }
+  if (!str) {
+    NS_NOTREACHED("null pointer");
+    return false;
+  }
 
-    if (len < 0)
-        len = strlen(str);
+  if (len < 0)
+    len = strlen(str);
 
-    bool ignoreNonAscii = !!(flags & esc_OnlyASCII);
-    bool ignoreAscii = !!(flags & esc_OnlyNonASCII);
-    bool writing = !!(flags & esc_AlwaysCopy);
-    bool skipControl = !!(flags & esc_SkipControl); 
+  bool ignoreNonAscii = !!(flags & esc_OnlyASCII);
+  bool ignoreAscii = !!(flags & esc_OnlyNonASCII);
+  bool writing = !!(flags & esc_AlwaysCopy);
+  bool skipControl = !!(flags & esc_SkipControl);
 
-    static const char hexChars[] = "0123456789ABCDEFabcdef";
+  static const char hexChars[] = "0123456789ABCDEFabcdef";
 
-    const char *last = str;
-    const char *p = str;
+  const char *last = str;
+  const char *p = str;
 
-    for (int i=0; i<len; ++i, ++p) {
-        //printf("%c [i=%d of len=%d]\n", *p, i, len);
-        if (*p == HEX_ESCAPE && i < len-2) {
-            unsigned char *p1 = ((unsigned char *) p) + 1;
-            unsigned char *p2 = ((unsigned char *) p) + 2;
-            if (ISHEX(*p1) && ISHEX(*p2) && 
-                ((*p1 < '8' && !ignoreAscii) || (*p1 >= '8' && !ignoreNonAscii)) &&
-                !(skipControl && 
-                  (*p1 < '2' || (*p1 == '7' && (*p2 == 'f' || *p2 == 'F'))))) {
-                //printf("- p1=%c p2=%c\n", *p1, *p2);
-                writing = true;
-                if (p > last) {
-                    //printf("- p=%p, last=%p\n", p, last);
-                    result.Append(last, p - last);
-                    last = p;
-                }
-                char u = (UNHEX(*p1) << 4) + UNHEX(*p2);
-                //printf("- u=%c\n", u);
-                result.Append(u);
-                i += 2;
-                p += 2;
-                last += 3;
-            }
+  for (int i=0; i<len; ++i, ++p) {
+    //printf("%c [i=%d of len=%d]\n", *p, i, len);
+    if (*p == HEX_ESCAPE && i < len-2) {
+      unsigned char *p1 = ((unsigned char *) p) + 1;
+      unsigned char *p2 = ((unsigned char *) p) + 2;
+      if (ISHEX(*p1) && ISHEX(*p2) &&
+          ((*p1 < '8' && !ignoreAscii) || (*p1 >= '8' && !ignoreNonAscii)) &&
+          !(skipControl &&
+            (*p1 < '2' || (*p1 == '7' && (*p2 == 'f' || *p2 == 'F'))))) {
+        //printf("- p1=%c p2=%c\n", *p1, *p2);
+        writing = true;
+        if (p > last) {
+          //printf("- p=%p, last=%p\n", p, last);
+          result.Append(last, p - last);
+          last = p;
         }
+        char u = (UNHEX(*p1) << 4) + UNHEX(*p2);
+        //printf("- u=%c\n", u);
+        result.Append(u);
+        i += 2;
+        p += 2;
+        last += 3;
+      }
     }
-    if (writing && last < str + len)
-        result.Append(last, str + len - last);
+  }
+  if (writing && last < str + len)
+    result.Append(last, str + len - last);
 
-    return writing;
+  return writing;
 }
--- a/xpcom/io/nsEscape.h
+++ b/xpcom/io/nsEscape.h
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*	First checked in on 98/12/03 by John R. McMullen, derived from net.h/mkparse.c. */
 
 #ifndef _ESCAPE_H_
 #define _ESCAPE_H_
@@ -13,55 +14,55 @@
 #include "nsString.h"
 
 /**
  * Valid mask values for nsEscape
  * Note: these values are copied in nsINetUtil.idl. Any changes should be kept
  * in sync.
  */
 typedef enum {
- 	url_All       = 0       /**< %-escape every byte unconditionally */
-,	url_XAlphas   = 1u << 0 /**< Normal escape - leave alphas intact, escape the rest */
-,	url_XPAlphas  = 1u << 1 /**< As url_XAlphas, but convert spaces (0x20) to '+' and plus to %2B */
-,	url_Path      = 1u << 2 /**< As url_XAlphas, but don't escape slash ('/') */
+  url_All       = 0       /**< %-escape every byte unconditionally */
+, url_XAlphas   = 1u << 0 /**< Normal escape - leave alphas intact, escape the rest */
+, url_XPAlphas  = 1u << 1 /**< As url_XAlphas, but convert spaces (0x20) to '+' and plus to %2B */
+, url_Path      = 1u << 2 /**< As url_XAlphas, but don't escape slash ('/') */
 } nsEscapeMask;
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /**
  * Escape the given string according to mask
  * @param str The string to escape
  * @param mask How to escape the string
  * @return A newly allocated escaped string that must be free'd with
  *         nsCRT::free, or null on failure
  */
 char * nsEscape(const char * str, nsEscapeMask mask);
 
 char * nsUnescape(char * str);
-	/* decode % escaped hex codes into character values,
-	 * modifies the parameter, returns the same buffer
-	 */
+/* decode % escaped hex codes into character values,
+ * modifies the parameter, returns the same buffer
+ */
 
 int32_t nsUnescapeCount (char * str);
-	/* decode % escaped hex codes into character values,
-	 * modifies the parameter buffer, returns the length of the result
-	 * (result may contain \0's).
-	 */
+/* decode % escaped hex codes into character values,
+ * modifies the parameter buffer, returns the length of the result
+ * (result may contain \0's).
+ */
 
 char *
 nsEscapeHTML(const char * string);
 
 char16_t *
 nsEscapeHTML2(const char16_t *aSourceBuffer,
               int32_t aSourceBufferLen = -1);
- /*
-  * Escape problem char's for HTML display 
-  */
+/*
+ * Escape problem char's for HTML display
+ */
 
 
 #ifdef __cplusplus
 }
 #endif
 
 
 /**
@@ -79,20 +80,20 @@ enum EscapeMask {
   esc_Directory      = 1u << 4,
   esc_FileBaseName   = 1u << 5,
   esc_FileExtension  = 1u << 6,
   esc_FilePath       = esc_Directory | esc_FileBaseName | esc_FileExtension,
   esc_Param          = 1u << 7,
   esc_Query          = 1u << 8,
   esc_Ref            = 1u << 9,
   /** special flags **/
-  esc_Minimal        = esc_Scheme | esc_Username | esc_Password | esc_Host | esc_FilePath | esc_Param | esc_Query | esc_Ref, 
+  esc_Minimal        = esc_Scheme | esc_Username | esc_Password | esc_Host | esc_FilePath | esc_Param | esc_Query | esc_Ref,
   esc_Forced         = 1u << 10, /* forces escaping of existing escape sequences */
   esc_OnlyASCII      = 1u << 11, /* causes non-ascii octets to be skipped */
-  esc_OnlyNonASCII   = 1u << 12, /* causes _graphic_ ascii octets (0x20-0x7E) 
+  esc_OnlyNonASCII   = 1u << 12, /* causes _graphic_ ascii octets (0x20-0x7E)
                                     * to be skipped when escaping. causes all
                                     * ascii octets (<= 0x7F) to be skipped when unescaping */
   esc_AlwaysCopy     = 1u << 13, /* copy input to result buf even if escaping is unnecessary */
   esc_Colon          = 1u << 14, /* forces escape of colon */
   esc_SkipControl    = 1u << 15  /* skips C0 and DEL from unescaping */
 };
 
 /**
@@ -105,55 +106,55 @@ enum EscapeMask {
  * @param  str     url segment string
  * @param  len     url segment string length (-1 if unknown)
  * @param  flags   url segment type flag
  * @param  result  result buffer, untouched if part is already escaped
  *
  * @return TRUE if escaping was performed, FALSE otherwise.
  */
 bool NS_EscapeURL(const char *str,
-                           int32_t len,
-                           uint32_t flags,
-                           nsACString &result);
+                  int32_t len,
+                  uint32_t flags,
+                  nsACString &result);
 
 /**
  * Expands URL escape sequences... beware embedded null bytes!
  *
  * @param  str     url string to unescape
  * @param  len     length of |str|
- * @param  flags   only esc_OnlyNonASCII, esc_SkipControl and esc_AlwaysCopy 
+ * @param  flags   only esc_OnlyNonASCII, esc_SkipControl and esc_AlwaysCopy
  *                 are recognized
  * @param  result  result buffer, untouched if |str| is already unescaped
  *
  * @return TRUE if unescaping was performed, FALSE otherwise.
  */
 bool NS_UnescapeURL(const char *str,
-                             int32_t len,
-                             uint32_t flags,
-                             nsACString &result);
+                    int32_t len,
+                    uint32_t flags,
+                    nsACString &result);
 
 /** returns resultant string length **/
 inline int32_t NS_UnescapeURL(char *str) {
-    return nsUnescapeCount(str);
+  return nsUnescapeCount(str);
 }
 
 /**
  * String friendly versions...
  */
 inline const nsCSubstring &
 NS_EscapeURL(const nsCSubstring &str, uint32_t flags, nsCSubstring &result) {
-    if (NS_EscapeURL(str.Data(), str.Length(), flags, result))
-        return result;
-    return str;
+  if (NS_EscapeURL(str.Data(), str.Length(), flags, result))
+    return result;
+  return str;
 }
 inline const nsCSubstring &
 NS_UnescapeURL(const nsCSubstring &str, uint32_t flags, nsCSubstring &result) {
-    if (NS_UnescapeURL(str.Data(), str.Length(), flags, result))
-        return result;
-    return str;
+  if (NS_UnescapeURL(str.Data(), str.Length(), flags, result))
+    return result;
+  return str;
 }
 
 /**
  * CString version of nsEscape. Returns true on success, false
  * on out of memory. To reverse this function, use NS_UnescapeURL.
  */
 inline bool
 NS_Escape(const nsCString& aOriginal, nsCString& aEscaped,
@@ -167,13 +168,13 @@ NS_Escape(const nsCString& aOriginal, ns
 }
 
 /**
  * Inline unescape of mutable string object.
  */
 inline nsCString &
 NS_UnescapeURL(nsCString &str)
 {
-    str.SetLength(nsUnescapeCount(str.BeginWriting()));
-    return str;
+  str.SetLength(nsUnescapeCount(str.BeginWriting()));
+  return str;
 }
 
 #endif //  _ESCAPE_H_
--- a/xpcom/io/nsInputStreamTee.cpp
+++ b/xpcom/io/nsInputStreamTee.cpp
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdlib.h>
 #include "prlog.h"
 
 #include "mozilla/Mutex.h"
@@ -20,337 +21,337 @@ using namespace mozilla;
 
 #ifdef LOG
 #undef LOG
 #endif
 #ifdef PR_LOGGING
 static PRLogModuleInfo*
 GetTeeLog()
 {
-    static PRLogModuleInfo *sLog;
-    if (!sLog)
-        sLog = PR_NewLogModule("nsInputStreamTee");
-    return sLog;
+  static PRLogModuleInfo *sLog;
+  if (!sLog)
+    sLog = PR_NewLogModule("nsInputStreamTee");
+  return sLog;
 }
 #define LOG(args) PR_LOG(GetTeeLog(), PR_LOG_DEBUG, args)
 #else
 #define LOG(args)
 #endif
 
 class nsInputStreamTee MOZ_FINAL : public nsIInputStreamTee
 {
 public:
-    NS_DECL_THREADSAFE_ISUPPORTS
-    NS_DECL_NSIINPUTSTREAM
-    NS_DECL_NSIINPUTSTREAMTEE
+  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_NSIINPUTSTREAM
+  NS_DECL_NSIINPUTSTREAMTEE
 
-    nsInputStreamTee();
-    bool SinkIsValid();
-    void InvalidateSink();
+  nsInputStreamTee();
+  bool SinkIsValid();
+  void InvalidateSink();
 
 private:
-    ~nsInputStreamTee() {}
+  ~nsInputStreamTee() {}
 
-    nsresult TeeSegment(const char *buf, uint32_t count);
-    
-    static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *,
-                                     uint32_t, uint32_t, uint32_t *);
+  nsresult TeeSegment(const char *buf, uint32_t count);
+
+  static NS_METHOD WriteSegmentFun(nsIInputStream *, void *, const char *,
+                                   uint32_t, uint32_t, uint32_t *);
 
 private:
-    nsCOMPtr<nsIInputStream>  mSource;
-    nsCOMPtr<nsIOutputStream> mSink;
-    nsCOMPtr<nsIEventTarget>  mEventTarget;
-    nsWriteSegmentFun         mWriter;  // for implementing ReadSegments
-    void                      *mClosure; // for implementing ReadSegments
-    nsAutoPtr<Mutex>          mLock; // synchronize access to mSinkIsValid
-    bool                      mSinkIsValid; // False if TeeWriteEvent fails 
+  nsCOMPtr<nsIInputStream>  mSource;
+  nsCOMPtr<nsIOutputStream> mSink;
+  nsCOMPtr<nsIEventTarget>  mEventTarget;
+  nsWriteSegmentFun         mWriter;  // for implementing ReadSegments
+  void                      *mClosure; // for implementing ReadSegments
+  nsAutoPtr<Mutex>          mLock; // synchronize access to mSinkIsValid
+  bool                      mSinkIsValid; // False if TeeWriteEvent fails
 };
 
 class nsInputStreamTeeWriteEvent : public nsRunnable {
 public:
-    // aTee's lock is held across construction of this object
-    nsInputStreamTeeWriteEvent(const char *aBuf, uint32_t aCount,
-                               nsIOutputStream  *aSink, 
-                               nsInputStreamTee *aTee)
-    {
-        // copy the buffer - will be free'd by dtor
-        mBuf = (char *)malloc(aCount);
-        if (mBuf) memcpy(mBuf, (char *)aBuf, aCount);
-        mCount = aCount;
-        mSink = aSink;
-        bool isNonBlocking;
-        mSink->IsNonBlocking(&isNonBlocking);
-        NS_ASSERTION(isNonBlocking == false, "mSink is nonblocking");
-        mTee = aTee;
+  // aTee's lock is held across construction of this object
+  nsInputStreamTeeWriteEvent(const char *aBuf, uint32_t aCount,
+                             nsIOutputStream  *aSink,
+                             nsInputStreamTee *aTee)
+  {
+    // copy the buffer - will be free'd by dtor
+    mBuf = (char *)malloc(aCount);
+    if (mBuf) memcpy(mBuf, (char *)aBuf, aCount);
+    mCount = aCount;
+    mSink = aSink;
+    bool isNonBlocking;
+    mSink->IsNonBlocking(&isNonBlocking);
+    NS_ASSERTION(isNonBlocking == false, "mSink is nonblocking");
+    mTee = aTee;
+  }
+
+  NS_IMETHOD Run()
+  {
+    if (!mBuf) {
+      NS_WARNING("nsInputStreamTeeWriteEvent::Run() "
+                 "memory not allocated\n");
+      return NS_OK;
+    }
+    NS_ABORT_IF_FALSE(mSink, "mSink is null!");
+
+    //  The output stream could have been invalidated between when
+    //  this event was dispatched and now, so check before writing.
+    if (!mTee->SinkIsValid()) {
+      return NS_OK;
     }
 
-    NS_IMETHOD Run()
-    {
-        if (!mBuf) {
-            NS_WARNING("nsInputStreamTeeWriteEvent::Run() "
-                       "memory not allocated\n");
-            return NS_OK;
-        }
-        NS_ABORT_IF_FALSE(mSink, "mSink is null!");
-
-        //  The output stream could have been invalidated between when 
-        //  this event was dispatched and now, so check before writing.
-        if (!mTee->SinkIsValid()) {
-            return NS_OK; 
-        }
+    LOG(("nsInputStreamTeeWriteEvent::Run() [%p]"
+         "will write %u bytes to %p\n",
+         this, mCount, mSink.get()));
 
-        LOG(("nsInputStreamTeeWriteEvent::Run() [%p]"
-             "will write %u bytes to %p\n",
-              this, mCount, mSink.get()));
-
-        uint32_t totalBytesWritten = 0;
-        while (mCount) {
-            nsresult rv;
-            uint32_t bytesWritten = 0;
-            rv = mSink->Write(mBuf + totalBytesWritten, mCount, &bytesWritten);
-            if (NS_FAILED(rv)) {
-                LOG(("nsInputStreamTeeWriteEvent::Run[%p] error %x in writing",
-                     this,rv));
-                mTee->InvalidateSink();
-                break;
-            }
-            totalBytesWritten += bytesWritten;
-            NS_ASSERTION(bytesWritten <= mCount, "wrote too much");
-            mCount -= bytesWritten;
-        }
-        return NS_OK;
+    uint32_t totalBytesWritten = 0;
+    while (mCount) {
+      nsresult rv;
+      uint32_t bytesWritten = 0;
+      rv = mSink->Write(mBuf + totalBytesWritten, mCount, &bytesWritten);
+      if (NS_FAILED(rv)) {
+        LOG(("nsInputStreamTeeWriteEvent::Run[%p] error %x in writing",
+             this,rv));
+        mTee->InvalidateSink();
+        break;
+      }
+      totalBytesWritten += bytesWritten;
+      NS_ASSERTION(bytesWritten <= mCount, "wrote too much");
+      mCount -= bytesWritten;
     }
+    return NS_OK;
+  }
 
 protected:
-    virtual ~nsInputStreamTeeWriteEvent()
-    {
-        if (mBuf) free(mBuf);
-        mBuf = nullptr;
-    }
-    
+  virtual ~nsInputStreamTeeWriteEvent()
+  {
+    if (mBuf) free(mBuf);
+    mBuf = nullptr;
+  }
+
 private:
-    char *mBuf;
-    uint32_t mCount;
-    nsCOMPtr<nsIOutputStream> mSink;
-    // back pointer to the tee that created this runnable
-    nsRefPtr<nsInputStreamTee> mTee;
+  char *mBuf;
+  uint32_t mCount;
+  nsCOMPtr<nsIOutputStream> mSink;
+  // back pointer to the tee that created this runnable
+  nsRefPtr<nsInputStreamTee> mTee;
 };
 
 nsInputStreamTee::nsInputStreamTee(): mLock(nullptr)
                                     , mSinkIsValid(true)
 {
 }
 
 bool
 nsInputStreamTee::SinkIsValid()
 {
-    MutexAutoLock lock(*mLock); 
-    return mSinkIsValid; 
+  MutexAutoLock lock(*mLock);
+  return mSinkIsValid;
 }
 
 void
 nsInputStreamTee::InvalidateSink()
 {
-    MutexAutoLock lock(*mLock);
-    mSinkIsValid = false;
+  MutexAutoLock lock(*mLock);
+  mSinkIsValid = false;
 }
 
 nsresult
 nsInputStreamTee::TeeSegment(const char *buf, uint32_t count)
 {
-    if (!mSink) return NS_OK; // nothing to do
-    if (mLock) { // asynchronous case
-        NS_ASSERTION(mEventTarget, "mEventTarget is null, mLock is not null.");
-        if (!SinkIsValid()) {
-            return NS_OK; // nothing to do
-        }
-        nsRefPtr<nsIRunnable> event =
-            new nsInputStreamTeeWriteEvent(buf, count, mSink, this);
-        LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
-              this, count));
-        return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
-    } else { // synchronous case
-        NS_ASSERTION(!mEventTarget, "mEventTarget is not null, mLock is null.");
-        nsresult rv;
-        uint32_t totalBytesWritten = 0;
-        while (count) {
-            uint32_t bytesWritten = 0;
-            rv = mSink->Write(buf + totalBytesWritten, count, &bytesWritten);
-            if (NS_FAILED(rv)) {
-                // ok, this is not a fatal error... just drop our reference to mSink
-                // and continue on as if nothing happened.
-                NS_WARNING("Write failed (non-fatal)");
-                // catch possible misuse of the input stream tee
-                NS_ASSERTION(rv != NS_BASE_STREAM_WOULD_BLOCK, "sink must be a blocking stream");
-                mSink = 0;
-                break;
-            }
-            totalBytesWritten += bytesWritten;
-            NS_ASSERTION(bytesWritten <= count, "wrote too much");
-            count -= bytesWritten;
-        }
-        return NS_OK;
+  if (!mSink) return NS_OK; // nothing to do
+  if (mLock) { // asynchronous case
+    NS_ASSERTION(mEventTarget, "mEventTarget is null, mLock is not null.");
+    if (!SinkIsValid()) {
+      return NS_OK; // nothing to do
     }
+    nsRefPtr<nsIRunnable> event =
+      new nsInputStreamTeeWriteEvent(buf, count, mSink, this);
+    LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
+         this, count));
+    return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
+  } else { // synchronous case
+    NS_ASSERTION(!mEventTarget, "mEventTarget is not null, mLock is null.");
+    nsresult rv;
+    uint32_t totalBytesWritten = 0;
+    while (count) {
+      uint32_t bytesWritten = 0;
+      rv = mSink->Write(buf + totalBytesWritten, count, &bytesWritten);
+      if (NS_FAILED(rv)) {
+        // ok, this is not a fatal error... just drop our reference to mSink
+        // and continue on as if nothing happened.
+        NS_WARNING("Write failed (non-fatal)");
+        // catch possible misuse of the input stream tee
+        NS_ASSERTION(rv != NS_BASE_STREAM_WOULD_BLOCK, "sink must be a blocking stream");
+        mSink = 0;
+        break;
+      }
+      totalBytesWritten += bytesWritten;
+      NS_ASSERTION(bytesWritten <= count, "wrote too much");
+      count -= bytesWritten;
+    }
+    return NS_OK;
+  }
 }
 
 NS_METHOD
 nsInputStreamTee::WriteSegmentFun(nsIInputStream *in, void *closure, const char *fromSegment,
                                   uint32_t offset, uint32_t count, uint32_t *writeCount)
 {
-    nsInputStreamTee *tee = reinterpret_cast<nsInputStreamTee *>(closure);
+  nsInputStreamTee *tee = reinterpret_cast<nsInputStreamTee *>(closure);
 
-    nsresult rv = tee->mWriter(in, tee->mClosure, fromSegment, offset, count, writeCount);
-    if (NS_FAILED(rv) || (*writeCount == 0)) {
-        NS_ASSERTION((NS_FAILED(rv) ? (*writeCount == 0) : true),
-                "writer returned an error with non-zero writeCount");
-        return rv;
-    }
+  nsresult rv = tee->mWriter(in, tee->mClosure, fromSegment, offset, count, writeCount);
+  if (NS_FAILED(rv) || (*writeCount == 0)) {
+    NS_ASSERTION((NS_FAILED(rv) ? (*writeCount == 0) : true),
+                 "writer returned an error with non-zero writeCount");
+    return rv;
+  }
 
-    return tee->TeeSegment(fromSegment, *writeCount);
+  return tee->TeeSegment(fromSegment, *writeCount);
 }
 
 NS_IMPL_ISUPPORTS(nsInputStreamTee,
                   nsIInputStreamTee,
                   nsIInputStream)
 NS_IMETHODIMP
 nsInputStreamTee::Close()
 {
-    if (NS_WARN_IF(!mSource))
-        return NS_ERROR_NOT_INITIALIZED;
-    nsresult rv = mSource->Close();
-    mSource = 0;
-    mSink = 0;
-    return rv;
+  if (NS_WARN_IF(!mSource))
+    return NS_ERROR_NOT_INITIALIZED;
+  nsresult rv = mSource->Close();
+  mSource = 0;
+  mSink = 0;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::Available(uint64_t *avail)
 {
-    if (NS_WARN_IF(!mSource))
-        return NS_ERROR_NOT_INITIALIZED;
-    return mSource->Available(avail);
+  if (NS_WARN_IF(!mSource))
+    return NS_ERROR_NOT_INITIALIZED;
+  return mSource->Available(avail);
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::Read(char *buf, uint32_t count, uint32_t *bytesRead)
 {
-    if (NS_WARN_IF(!mSource))
-        return NS_ERROR_NOT_INITIALIZED;
+  if (NS_WARN_IF(!mSource))
+    return NS_ERROR_NOT_INITIALIZED;
 
-    nsresult rv = mSource->Read(buf, count, bytesRead);
-    if (NS_FAILED(rv) || (*bytesRead == 0))
-        return rv;
+  nsresult rv = mSource->Read(buf, count, bytesRead);
+  if (NS_FAILED(rv) || (*bytesRead == 0))
+    return rv;
 
-    return TeeSegment(buf, *bytesRead);
+  return TeeSegment(buf, *bytesRead);
 }
 
 NS_IMETHODIMP
-nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer, 
+nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
                                void *closure,
                                uint32_t count,
                                uint32_t *bytesRead)
 {
-    if (NS_WARN_IF(!mSource))
-        return NS_ERROR_NOT_INITIALIZED;
+  if (NS_WARN_IF(!mSource))
+    return NS_ERROR_NOT_INITIALIZED;
 
-    mWriter = writer;
-    mClosure = closure;
+  mWriter = writer;
+  mClosure = closure;
 
-    return mSource->ReadSegments(WriteSegmentFun, this, count, bytesRead);
+  return mSource->ReadSegments(WriteSegmentFun, this, count, bytesRead);
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::IsNonBlocking(bool *result)
 {
-    if (NS_WARN_IF(!mSource))
-        return NS_ERROR_NOT_INITIALIZED;
-    return mSource->IsNonBlocking(result);
+  if (NS_WARN_IF(!mSource))
+    return NS_ERROR_NOT_INITIALIZED;
+  return mSource->IsNonBlocking(result);
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::SetSource(nsIInputStream *source)
 {
-    mSource = source;
-    return NS_OK;
+  mSource = source;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::GetSource(nsIInputStream **source)
 {
-    NS_IF_ADDREF(*source = mSource);
-    return NS_OK;
+  NS_IF_ADDREF(*source = mSource);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::SetSink(nsIOutputStream *sink)
 {
 #ifdef DEBUG
-    if (sink) {
-        bool nonBlocking;
-        nsresult rv = sink->IsNonBlocking(&nonBlocking);
-        if (NS_FAILED(rv) || nonBlocking)
-            NS_ERROR("sink should be a blocking stream");
-    }
+  if (sink) {
+    bool nonBlocking;
+    nsresult rv = sink->IsNonBlocking(&nonBlocking);
+    if (NS_FAILED(rv) || nonBlocking)
+      NS_ERROR("sink should be a blocking stream");
+  }
 #endif
-    mSink = sink;
-    return NS_OK;
+  mSink = sink;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::GetSink(nsIOutputStream **sink)
 {
-    NS_IF_ADDREF(*sink = mSink);
-    return NS_OK;
+  NS_IF_ADDREF(*sink = mSink);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::SetEventTarget(nsIEventTarget *anEventTarget)
 {
-    mEventTarget = anEventTarget;
-    if (mEventTarget) {
-        // Only need synchronization if this is an async tee
-        mLock = new Mutex("nsInputStreamTee.mLock");
-    }
-    return NS_OK;
+  mEventTarget = anEventTarget;
+  if (mEventTarget) {
+    // Only need synchronization if this is an async tee
+    mLock = new Mutex("nsInputStreamTee.mLock");
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsInputStreamTee::GetEventTarget(nsIEventTarget **anEventTarget)
 {
-    NS_IF_ADDREF(*anEventTarget = mEventTarget);
-    return NS_OK;
+  NS_IF_ADDREF(*anEventTarget = mEventTarget);
+  return NS_OK;
 }
 
 
 nsresult
 NS_NewInputStreamTeeAsync(nsIInputStream **result,
                           nsIInputStream *source,
                           nsIOutputStream *sink,
                           nsIEventTarget *anEventTarget)
 {
-    nsresult rv;
-    
-    nsCOMPtr<nsIInputStreamTee> tee = new nsInputStreamTee();
-    if (!tee)
-        return NS_ERROR_OUT_OF_MEMORY;
+  nsresult rv;
 
-    rv = tee->SetSource(source);
-    if (NS_FAILED(rv)) return rv;
+  nsCOMPtr<nsIInputStreamTee> tee = new nsInputStreamTee();
+  if (!tee)
+    return NS_ERROR_OUT_OF_MEMORY;
+
+  rv = tee->SetSource(source);
+  if (NS_FAILED(rv)) return rv;
 
-    rv = tee->SetSink(sink);
-    if (NS_FAILED(rv)) return rv;
+  rv = tee->SetSink(sink);
+  if (NS_FAILED(rv)) return rv;
 
-    rv = tee->SetEventTarget(anEventTarget);
-    if (NS_FAILED(rv)) return rv;
+  rv = tee->SetEventTarget(anEventTarget);
+  if (NS_FAILED(rv)) return rv;
 
-    NS_ADDREF(*result = tee);
-    return rv;
+  NS_ADDREF(*result = tee);
+  return rv;
 }
 
 nsresult
 NS_NewInputStreamTee(nsIInputStream **result,
                      nsIInputStream *source,
                      nsIOutputStream *sink)
 {
-    return NS_NewInputStreamTeeAsync(result, source, sink, nullptr);
+  return NS_NewInputStreamTeeAsync(result, source, sink, nullptr);
 }
 
 #undef LOG
--- a/xpcom/io/nsLinebreakConverter.cpp
+++ b/xpcom/io/nsLinebreakConverter.cpp
@@ -5,55 +5,55 @@
 
 #include "nsLinebreakConverter.h"
 
 #include "nsMemory.h"
 #include "nsCRT.h"
 
 
 /*----------------------------------------------------------------------------
-	GetLinebreakString 
-	
+	GetLinebreakString
+
 	Could make this inline
 ----------------------------------------------------------------------------*/
 static const char* GetLinebreakString(nsLinebreakConverter::ELinebreakType aBreakType)
 {
   static const char* const sLinebreaks[] = {
     "",             // any
     NS_LINEBREAK,   // platform
     LFSTR,          // content
     CRLF,           // net
     CRSTR,          // Mac
     LFSTR,          // Unix
     CRLF,           // Windows
     " ",            // space
-    nullptr  
+    nullptr
   };
-  
+
   return sLinebreaks[aBreakType];
 }
 
 
 /*----------------------------------------------------------------------------
-	AppendLinebreak 
-	
+	AppendLinebreak
+
 	Wee inline method to append a line break. Modifies ioDest.
 ----------------------------------------------------------------------------*/
 template<class T>
 void AppendLinebreak(T*& ioDest, const char* lineBreakStr)
 {
   *ioDest++ = *lineBreakStr;
 
   if (lineBreakStr[1])
     *ioDest++ = lineBreakStr[1];
 }
 
 /*----------------------------------------------------------------------------
-	CountChars 
-	
+	CountChars
+
 	Counts occurrences of breakStr in aSrc
 ----------------------------------------------------------------------------*/
 template<class T>
 int32_t CountLinebreaks(const T* aSrc, int32_t inLen, const char* breakStr)
 {
   const T* src = aSrc;
   const T* srcEnd = aSrc + inLen;
   int32_t theCount = 0;
@@ -77,59 +77,59 @@ int32_t CountLinebreaks(const T* aSrc, i
         theCount++;
       }
     }
     else
     {
       src++;
     }
   }
-  
+
   return theCount;
 }
 
 
 /*----------------------------------------------------------------------------
-	ConvertBreaks 
-	
+	ConvertBreaks
+
 	ioLen *includes* a terminating null, if any
 ----------------------------------------------------------------------------*/
 template<class T>
 static T* ConvertBreaks(const T* inSrc, int32_t& ioLen, const char* srcBreak, const char* destBreak)
 {
   NS_ASSERTION(inSrc && srcBreak && destBreak, "Got a null string");
-  
+
   T* resultString = nullptr;
-   
+
   // handle the no conversion case
   if (nsCRT::strcmp(srcBreak, destBreak) == 0)
   {
     resultString = (T *)nsMemory::Alloc(sizeof(T) * ioLen);
     if (!resultString) return nullptr;
     memcpy(resultString, inSrc, sizeof(T) * ioLen); // includes the null, if any
     return resultString;
   }
-    
+
   int32_t srcBreakLen = strlen(srcBreak);
   int32_t destBreakLen = strlen(destBreak);
 
   // handle the easy case, where the string length does not change, and the
   // breaks are only 1 char long, i.e. CR <-> LF
   if (srcBreakLen == destBreakLen && srcBreakLen == 1)
   {
     resultString = (T *)nsMemory::Alloc(sizeof(T) * ioLen);
     if (!resultString) return nullptr;
-    
+
     const T* src = inSrc;
     const T* srcEnd = inSrc + ioLen;		// includes null, if any
     T*       dst = resultString;
-    
+
     char srcBreakChar = *srcBreak;        // we know it's one char long already
     char dstBreakChar = *destBreak;
-    
+
     while (src < srcEnd)
     {
       if (*src == srcBreakChar)
       {
         *dst++ = dstBreakChar;
         src++;
       }
       else
@@ -138,88 +138,88 @@ static T* ConvertBreaks(const T* inSrc, 
       }
     }
 
     // ioLen does not change
   }
   else
   {
     // src and dest termination is different length. Do it a slower way.
-    
+
     // count linebreaks in src. Assumes that chars in 2-char linebreaks are unique.
     int32_t numLinebreaks = CountLinebreaks(inSrc, ioLen, srcBreak);
-    
+
     int32_t newBufLen = ioLen - (numLinebreaks * srcBreakLen) + (numLinebreaks * destBreakLen);
     resultString = (T *)nsMemory::Alloc(sizeof(T) * newBufLen);
     if (!resultString) return nullptr;
-    
+
     const T* src = inSrc;
     const T* srcEnd = inSrc + ioLen;		// includes null, if any
     T*       dst = resultString;
-    
+
     while (src < srcEnd)
     {
       if (*src == *srcBreak)
       {
         *dst++ = *destBreak;
         if (destBreak[1])
           *dst++ = destBreak[1];
-      
+
         src++;
         if (src < srcEnd && srcBreak[1] && *src == srcBreak[1])
           src++;
       }
       else
       {
         *dst++ = *src++;
       }
     }
-    
+
     ioLen = newBufLen;
   }
-  
+
   return resultString;
 }
 
 
 /*----------------------------------------------------------------------------
-  ConvertBreaksInSitu 
-	
+  ConvertBreaksInSitu
+
   Convert breaks in situ. Can only do this if the linebreak length
   does not change.
 ----------------------------------------------------------------------------*/
 template<class T>
 static void ConvertBreaksInSitu(T* inSrc, int32_t inLen, char srcBreak, char destBreak)
 {
   T* src = inSrc;
   T* srcEnd = inSrc + inLen;
 
   while (src < srcEnd)
   {
     if (*src == srcBreak)
       *src = destBreak;
-    
+
     src++;
   }
 }
 
 
 /*----------------------------------------------------------------------------
-  ConvertUnknownBreaks 
-	
+  ConvertUnknownBreaks
+
   Convert unknown line breaks to the specified break.
-	
+
   This will convert CRLF pairs to one break, and single CR or LF to a break.
 ----------------------------------------------------------------------------*/
 template<class T>
 static T* ConvertUnknownBreaks(const T* inSrc, int32_t& ioLen, const char* destBreak)
 {
   const T* src = inSrc;
   const T* srcEnd = inSrc + ioLen;		// includes null, if any
-  
+
   int32_t destBreakLen = strlen(destBreak);
   int32_t finalLen = 0;
 
   while (src < srcEnd)
   {
     if (*src == nsCRT::CR)
     {
       if (src < srcEnd && src[1] == nsCRT::LF)
@@ -240,25 +240,25 @@ static T* ConvertUnknownBreaks(const T* 
       finalLen += destBreakLen;
     }
     else
     {
       finalLen++;
     }
     src++;
   }
-  
+
   T* resultString = (T *)nsMemory::Alloc(sizeof(T) * finalLen);
   if (!resultString) return nullptr;
 
   src = inSrc;
   srcEnd = inSrc + ioLen;		// includes null, if any
 
   T* dst = resultString;
-  
+
   while (src < srcEnd)
   {
     if (*src == nsCRT::CR)
     {
       if (src < srcEnd && src[1] == nsCRT::LF)
       {
         // CRLF
         AppendLinebreak(dst, destBreak);
@@ -283,183 +283,183 @@ static T* ConvertUnknownBreaks(const T* 
   }
 
   ioLen = finalLen;
   return resultString;
 }
 
 
 /*----------------------------------------------------------------------------
-	ConvertLineBreaks 
-	
+	ConvertLineBreaks
+
 ----------------------------------------------------------------------------*/
 char* nsLinebreakConverter::ConvertLineBreaks(const char* aSrc,
-            ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
+    ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
 {
   NS_ASSERTION(aDestBreaks != eLinebreakAny &&
                aSrcBreaks != eLinebreakSpace, "Invalid parameter");
   if (!aSrc) return nullptr;
-  
+
   int32_t sourceLen = (aSrcLen == kIgnoreLen) ? strlen(aSrc) + 1 : aSrcLen;
 
   char* resultString;
   if (aSrcBreaks == eLinebreakAny)
     resultString = ConvertUnknownBreaks(aSrc, sourceLen, GetLinebreakString(aDestBreaks));
   else
     resultString = ConvertBreaks(aSrc, sourceLen, GetLinebreakString(aSrcBreaks), GetLinebreakString(aDestBreaks));
-  
+
   if (outLen)
     *outLen = sourceLen;
   return resultString;
 }
 
 
 /*----------------------------------------------------------------------------
-	ConvertLineBreaksInSitu 
-	
+	ConvertLineBreaksInSitu
+
 ----------------------------------------------------------------------------*/
 nsresult nsLinebreakConverter::ConvertLineBreaksInSitu(char **ioBuffer, ELinebreakType aSrcBreaks,
-            ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
+    ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
 {
   NS_ASSERTION(ioBuffer && *ioBuffer, "Null pointer passed");
   if (!ioBuffer || !*ioBuffer) return NS_ERROR_NULL_POINTER;
-  
+
   NS_ASSERTION(aDestBreaks != eLinebreakAny &&
                aSrcBreaks != eLinebreakSpace, "Invalid parameter");
 
   int32_t sourceLen = (aSrcLen == kIgnoreLen) ? strlen(*ioBuffer) + 1 : aSrcLen;
-  
+
   // can we convert in-place?
   const char* srcBreaks = GetLinebreakString(aSrcBreaks);
   const char* dstBreaks = GetLinebreakString(aDestBreaks);
-  
+
   if ( (aSrcBreaks != eLinebreakAny) &&
        (strlen(srcBreaks) == 1) &&
        (strlen(dstBreaks) == 1) )
   {
     ConvertBreaksInSitu(*ioBuffer, sourceLen, *srcBreaks, *dstBreaks);
     if (outLen)
       *outLen = sourceLen;
   }
   else
   {
     char* destBuffer;
-    
+
     if (aSrcBreaks == eLinebreakAny)
       destBuffer = ConvertUnknownBreaks(*ioBuffer, sourceLen, dstBreaks);
     else
       destBuffer = ConvertBreaks(*ioBuffer, sourceLen, srcBreaks, dstBreaks);
 
     if (!destBuffer) return NS_ERROR_OUT_OF_MEMORY;
     *ioBuffer = destBuffer;
     if (outLen)
       *outLen = sourceLen;
   }
-  
+
   return NS_OK;
 }
 
 
 /*----------------------------------------------------------------------------
-	ConvertUnicharLineBreaks 
-	
+	ConvertUnicharLineBreaks
+
 ----------------------------------------------------------------------------*/
 char16_t* nsLinebreakConverter::ConvertUnicharLineBreaks(const char16_t* aSrc,
-            ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
+    ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
 {
   NS_ASSERTION(aDestBreaks != eLinebreakAny &&
                aSrcBreaks != eLinebreakSpace, "Invalid parameter");
   if (!aSrc) return nullptr;
-  
+
   int32_t bufLen = (aSrcLen == kIgnoreLen) ? NS_strlen(aSrc) + 1 : aSrcLen;
 
   char16_t* resultString;
   if (aSrcBreaks == eLinebreakAny)
     resultString = ConvertUnknownBreaks(aSrc, bufLen, GetLinebreakString(aDestBreaks));
   else
     resultString = ConvertBreaks(aSrc, bufLen, GetLinebreakString(aSrcBreaks), GetLinebreakString(aDestBreaks));
-  
+
   if (outLen)
     *outLen = bufLen;
   return resultString;
 }
 
 
 /*----------------------------------------------------------------------------
-	ConvertStringLineBreaks 
-	
+	ConvertStringLineBreaks
+
 ----------------------------------------------------------------------------*/
 nsresult nsLinebreakConverter::ConvertUnicharLineBreaksInSitu(char16_t **ioBuffer,
-            ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
+    ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks, int32_t aSrcLen, int32_t* outLen)
 {
   NS_ASSERTION(ioBuffer && *ioBuffer, "Null pointer passed");
   if (!ioBuffer || !*ioBuffer) return NS_ERROR_NULL_POINTER;
   NS_ASSERTION(aDestBreaks != eLinebreakAny &&
                aSrcBreaks != eLinebreakSpace, "Invalid parameter");
 
   int32_t sourceLen = (aSrcLen == kIgnoreLen) ? NS_strlen(*ioBuffer) + 1 : aSrcLen;
 
   // can we convert in-place?
   const char* srcBreaks = GetLinebreakString(aSrcBreaks);
   const char* dstBreaks = GetLinebreakString(aDestBreaks);
-  
+
   if ( (aSrcBreaks != eLinebreakAny) &&
        (strlen(srcBreaks) == 1) &&
        (strlen(dstBreaks) == 1) )
   {
     ConvertBreaksInSitu(*ioBuffer, sourceLen, *srcBreaks, *dstBreaks);
     if (outLen)
       *outLen = sourceLen;
   }
   else
   {
     char16_t* destBuffer;
-    
+
     if (aSrcBreaks == eLinebreakAny)
       destBuffer = ConvertUnknownBreaks(*ioBuffer, sourceLen, dstBreaks);
     else
       destBuffer = ConvertBreaks(*ioBuffer, sourceLen, srcBreaks, dstBreaks);
 
     if (!destBuffer) return NS_ERROR_OUT_OF_MEMORY;
     *ioBuffer = destBuffer;
     if (outLen)
       *outLen = sourceLen;
   }
-  
+
   return NS_OK;
 }
 
 /*----------------------------------------------------------------------------
-	ConvertStringLineBreaks 
-	
+	ConvertStringLineBreaks
+
 ----------------------------------------------------------------------------*/
 nsresult nsLinebreakConverter::ConvertStringLineBreaks(nsString& ioString,
-          ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks)
+    ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks)
 {
 
   NS_ASSERTION(aDestBreaks != eLinebreakAny &&
                aSrcBreaks != eLinebreakSpace, "Invalid parameter");
 
   // nothing to do
   if (ioString.IsEmpty()) return NS_OK;
-  
+
   nsresult rv;
-  
+
   // remember the old buffer in case
   // we blow it away later
   nsString::char_iterator stringBuf;
   ioString.BeginWriting(stringBuf);
-  
+
   int32_t    newLen;
-    
+
   rv = ConvertUnicharLineBreaksInSitu(&stringBuf,
                                       aSrcBreaks, aDestBreaks,
                                       ioString.Length() + 1, &newLen);
   if (NS_FAILED(rv)) return rv;
 
   if (stringBuf != ioString.get())
     ioString.Adopt(stringBuf);
-  
+
   return NS_OK;
 }
 
 
 
--- a/xpcom/io/nsLinebreakConverter.h
+++ b/xpcom/io/nsLinebreakConverter.h
@@ -13,66 +13,66 @@
 
 class nsLinebreakConverter
 {
 public:
 
   // Note: enum must match char* array in GetLinebreakString
   typedef enum {
     eLinebreakAny,          // any kind of linebreak (i.e. "don't care" source)
-    
+
     eLinebreakPlatform,     // platform linebreak
     eLinebreakContent,      // Content model linebreak (LF)
     eLinebreakNet,          // Form submission linebreak (CRLF)
-  
+
     eLinebreakMac,          // CR
     eLinebreakUnix,         // LF
     eLinebreakWindows,      // CRLF
 
     eLinebreakSpace         // space characters. Only valid as destination type
-  
+
   } ELinebreakType;
 
   enum {
     kIgnoreLen = -1
   };
-  
+
   /* ConvertLineBreaks
    * Convert line breaks in the supplied string, allocating and returning
    * a new buffer. Returns nullptr on failure.
    * @param aSrc: the source string. if aSrcLen == kIgnoreLen this string is assumed
    *              to be null terminated, otherwise it must be at least aSrcLen long.
    * @param aSrcBreaks: the line breaks in the source. If unknown, pass eLinebreakAny.
    *              If known, pass the known value, as this may be more efficient.
    * @param aDestBreaks: the line breaks you want in the output.
    * @param aSrcLen: length of the source. If -1, the source is assumed to be a null-
    *              terminated string.
    * @param aOutLen: used to return character length of returned buffer, if not null.
    */
   static char* ConvertLineBreaks(const char* aSrc,
-                ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
-                int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
-  
+                                 ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
+                                 int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
+
 
   /* ConvertUnicharLineBreaks
    * Convert line breaks in the supplied string, allocating and returning
    * a new buffer. Returns nullptr on failure.
    * @param aSrc: the source string. if aSrcLen == kIgnoreLen this string is assumed
    *              to be null terminated, otherwise it must be at least aSrcLen long.
    * @param aSrcBreaks: the line breaks in the source. If unknown, pass eLinebreakAny.
    *              If known, pass the known value, as this may be more efficient.
    * @param aDestBreaks: the line breaks you want in the output.
    * @param aSrcLen: length of the source, in characters. If -1, the source is assumed to be a null-
    *              terminated string.
    * @param aOutLen: used to return character length of returned buffer, if not null.
    */
   static char16_t* ConvertUnicharLineBreaks(const char16_t* aSrc,
-                ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
-                int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
-  
+                                            ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
+                                            int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
+
 
   /* ConvertStringLineBreaks
    * Convert line breaks in the supplied string, changing the string buffer (i.e. in-place conversion)
    * @param ioString: the string to be converted.
    * @param aSrcBreaks: the line breaks in the source. If unknown, pass eLinebreakAny.
    *              If known, pass the known value, as this may be more efficient.
    * @param aDestBreaks: the line breaks you want in the output.
    * @param aSrcLen: length of the source, in characters. If -1, the source is assumed to be a null-
@@ -81,42 +81,42 @@ public:
   static nsresult ConvertStringLineBreaks(nsString& ioString, ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks);
 
 
   /* ConvertLineBreaksInSitu
    * Convert line breaks in place if possible. NOTE: THIS MAY REALLOCATE THE BUFFER,
    * BUT IT WON'T FREE THE OLD BUFFER (because it doesn't know how). So be prepared
    * to keep a copy of the old pointer, and free it if this passes back a new pointer.
    * ALSO NOTE: DON'T PASS A STATIC STRING POINTER TO THIS FUNCTION.
-   * 
+   *
    * @param ioBuffer: the source buffer. if aSrcLen == kIgnoreLen this string is assumed
    *              to be null terminated, otherwise it must be at least aSrcLen long.
    * @param aSrcBreaks: the line breaks in the source. If unknown, pass eLinebreakAny.
    *              If known, pass the known value, as this may be more efficient.
    * @param aDestBreaks: the line breaks you want in the output.
    * @param aSrcLen: length of the source. If -1, the source is assumed to be a null-
    *              terminated string.
    * @param aOutLen: used to return character length of returned buffer, if not null.
    */
   static nsresult ConvertLineBreaksInSitu(char **ioBuffer, ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
-                        int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
+                                          int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
 
 
   /* ConvertUnicharLineBreaksInSitu
    * Convert line breaks in place if possible. NOTE: THIS MAY REALLOCATE THE BUFFER,
    * BUT IT WON'T FREE THE OLD BUFFER (because it doesn't know how). So be prepared
    * to keep a copy of the old pointer, and free it if this passes back a new pointer.
-   * 
+   *
    * @param ioBuffer: the source buffer. if aSrcLen == kIgnoreLen this string is assumed
    *              to be null terminated, otherwise it must be at least aSrcLen long.
    * @param aSrcBreaks: the line breaks in the source. If unknown, pass eLinebreakAny.
    *              If known, pass the known value, as this may be more efficient.
    * @param aDestBreaks: the line breaks you want in the output.
    * @param aSrcLen: length of the source in characters. If -1, the source is assumed to be a null-
    *              terminated string.
    * @param aOutLen: used to return character length of returned buffer, if not null.
    */
   static nsresult ConvertUnicharLineBreaksInSitu(char16_t **ioBuffer, ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
-                        int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
-    
+                                                 int32_t aSrcLen = kIgnoreLen, int32_t* aOutLen = nullptr);
+
 };
 
 #endif // nsLinebreakConverter_h_
--- a/xpcom/io/nsLocalFile.h
+++ b/xpcom/io/nsLocalFile.h
@@ -1,39 +1,40 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * This Original Code has been modified by IBM Corporation. Modifications made by IBM 
+ * This Original Code has been modified by IBM Corporation. Modifications made by IBM
  * described herein are Copyright (c) International Business Machines Corporation, 2000.
  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
  *
  * Date             Modified by     Description of modification
  * 04/20/2000       IBM Corp.      OS/2 build.
  */
 
 #ifndef _NS_LOCAL_FILE_H_
 #define _NS_LOCAL_FILE_H_
 
 #include "nscore.h"
 
 #define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
 
 #define NS_DECL_NSLOCALFILE_UNICODE_METHODS                                                      \
-    nsresult AppendUnicode(const char16_t *aNode);                                              \
-    nsresult GetUnicodeLeafName(char16_t **aLeafName);                                          \
-    nsresult SetUnicodeLeafName(const char16_t *aLeafName);                                     \
-    nsresult CopyToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
-    nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \
-    nsresult MoveToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
-    nsresult GetUnicodeTarget(char16_t **aTarget);                                              \
-    nsresult GetUnicodePath(char16_t **aPath);                                                  \
-    nsresult InitWithUnicodePath(const char16_t *aPath);                                        \
-    nsresult AppendRelativeUnicodePath(const char16_t *aRelativePath);
+  nsresult AppendUnicode(const char16_t *aNode);                                              \
+  nsresult GetUnicodeLeafName(char16_t **aLeafName);                                          \
+  nsresult SetUnicodeLeafName(const char16_t *aLeafName);                                     \
+  nsresult CopyToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
+  nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName); \
+  nsresult MoveToUnicode(nsIFile *aNewParentDir, const char16_t *aNewLeafName);               \
+  nsresult GetUnicodeTarget(char16_t **aTarget);                                              \
+  nsresult GetUnicodePath(char16_t **aPath);                                                  \
+  nsresult InitWithUnicodePath(const char16_t *aPath);                                        \
+  nsresult AppendRelativeUnicodePath(const char16_t *aRelativePath);
 
 // nsXPComInit needs to know about how we are implemented,
 // so here we will export it.  Other users should not depend
 // on this.
 
 #include <errno.h>
 #include "nsILocalFile.h"
 
@@ -45,79 +46,79 @@
 #error NOT_IMPLEMENTED
 #endif
 
 #define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
 
 inline nsresult
 nsresultForErrno(int err)
 {
-    switch (err) {
-      case 0:
-        return NS_OK;
+  switch (err) {
+    case 0:
+      return NS_OK;
 #ifdef EDQUOT
-      case EDQUOT: /* Quota exceeded */
-        // FALLTHROUGH to return NS_ERROR_FILE_DISK_FULL
+    case EDQUOT: /* Quota exceeded */
+      // FALLTHROUGH to return NS_ERROR_FILE_DISK_FULL
 #endif
-      case ENOSPC:
-        return NS_ERROR_FILE_DISK_FULL;
+    case ENOSPC:
+      return NS_ERROR_FILE_DISK_FULL;
 #ifdef EISDIR
-      case EISDIR:    /*      Is a directory. */
-        return NS_ERROR_FILE_IS_DIRECTORY;
+    case EISDIR:    /*      Is a directory. */
+      return NS_ERROR_FILE_IS_DIRECTORY;
 #endif
-      case ENAMETOOLONG: 
-        return NS_ERROR_FILE_NAME_TOO_LONG;
-      case ENOEXEC:  /*     Executable file format error. */
-        return NS_ERROR_FILE_EXECUTION_FAILED;
-      case ENOENT:
-        return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
-      case ENOTDIR:
-        return NS_ERROR_FILE_DESTINATION_NOT_DIR;
+    case ENAMETOOLONG:
+      return NS_ERROR_FILE_NAME_TOO_LONG;
+    case ENOEXEC:  /*     Executable file format error. */
+      return NS_ERROR_FILE_EXECUTION_FAILED;
+    case ENOENT:
+      return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
+    case ENOTDIR:
+      return NS_ERROR_FILE_DESTINATION_NOT_DIR;
 #ifdef ELOOP
-      case ELOOP:
-        return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
+    case ELOOP:
+      return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
 #endif /* ELOOP */
 #ifdef ENOLINK
-      case ENOLINK:
-        return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
+    case ENOLINK:
+      return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
 #endif /* ENOLINK */
-      case EEXIST:
-        return NS_ERROR_FILE_ALREADY_EXISTS;
+    case EEXIST:
+      return NS_ERROR_FILE_ALREADY_EXISTS;
 #ifdef EPERM
-      case EPERM:
+    case EPERM:
 #endif /* EPERM */
-      case EACCES:
-        return NS_ERROR_FILE_ACCESS_DENIED;
+    case EACCES:
+      return NS_ERROR_FILE_ACCESS_DENIED;
 #ifdef EROFS
-      case EROFS: /*     Read-only file system. */
-        return NS_ERROR_FILE_READ_ONLY;
+    case EROFS: /*     Read-only file system. */
+      return NS_ERROR_FILE_READ_ONLY;
 #endif
-      /*
-       * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
-       * so there can't be cases for both without
-       * preprocessing.
-       */
+    /*
+     * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
+     * so there can't be cases for both without
+     * preprocessing.
+     */
 #if ENOTEMPTY != EEXIST
-      case ENOTEMPTY:
-        return NS_ERROR_FILE_DIR_NOT_EMPTY;
+    case ENOTEMPTY:
+      return NS_ERROR_FILE_DIR_NOT_EMPTY;
 #endif /* ENOTEMPTY != EEXIST */
-        /* Note that nsIFile.createUnique() returns
-           NS_ERROR_FILE_TOO_BIG when it cannot create a temporary
-           file with a unique filename.
-           See https://developer.mozilla.org/en-US/docs/Table_Of_Errors 
-           Other usages of NS_ERROR_FILE_TOO_BIG in the source tree
-           are in line with the POSIX semantics of EFBIG.
-           So this is a reasonably good approximation.
-        */
-      case EFBIG: /*     File too large. */
-        return NS_ERROR_FILE_TOO_BIG;
+    /* Note that nsIFile.createUnique() returns
+       NS_ERROR_FILE_TOO_BIG when it cannot create a temporary
+       file with a unique filename.
+       See https://developer.mozilla.org/en-US/docs/Table_Of_Errors
+       Other usages of NS_ERROR_FILE_TOO_BIG in the source tree
+       are in line with the POSIX semantics of EFBIG.
+       So this is a reasonably good approximation.
+    */
+    case EFBIG: /*     File too large. */
+      return NS_ERROR_FILE_TOO_BIG;
 
-      default:
-        return NS_ERROR_FAILURE;
-    }
+    default:
+      return NS_ERROR_FAILURE;
+  }
 }
 
 #define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
 
 void NS_StartupLocalFile();
 void NS_ShutdownLocalFile();
 
 #endif
--- a/xpcom/io/nsLocalFileCommon.cpp
+++ b/xpcom/io/nsLocalFileCommon.cpp
@@ -1,12 +1,14 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #include "nsIServiceManager.h"
 
 #include "nsLocalFile.h" // includes platform-specific headers
 
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsPrintfCString.h"
@@ -16,277 +18,277 @@
 
 #ifdef XP_WIN
 #include <string.h>
 #endif
 
 
 void NS_StartupLocalFile()
 {
-    nsLocalFile::GlobalInit();
+  nsLocalFile::GlobalInit();
 }
 
 void NS_ShutdownLocalFile()
 {
-    nsLocalFile::GlobalShutdown();
+  nsLocalFile::GlobalShutdown();
 }
 
 #if !defined(MOZ_WIDGET_COCOA) && !defined(XP_WIN)
 NS_IMETHODIMP
 nsLocalFile::InitWithFile(nsIFile *aFile)
 {
-    if (NS_WARN_IF(!aFile))
-        return NS_ERROR_INVALID_ARG;
-    
-    nsAutoCString path;
-    aFile->GetNativePath(path);
-    if (path.IsEmpty())
-        return NS_ERROR_INVALID_ARG;
-    return InitWithNativePath(path); 
+  if (NS_WARN_IF(!aFile))
+    return NS_ERROR_INVALID_ARG;
+
+  nsAutoCString path;
+  aFile->GetNativePath(path);
+  if (path.IsEmpty())
+    return NS_ERROR_INVALID_ARG;
+  return InitWithNativePath(path);
 }
 #endif
 
 #define kMaxFilenameLength 255
 #define kMaxExtensionLength 100
 #define kMaxSequenceNumberLength 5 // "-9999"
 // requirement: kMaxExtensionLength < kMaxFilenameLength - kMaxSequenceNumberLength
 
 NS_IMETHODIMP
 nsLocalFile::CreateUnique(uint32_t type, uint32_t attributes)
 {
-    nsresult rv;
-    bool longName;
+  nsresult rv;
+  bool longName;
+
+#ifdef XP_WIN
+  nsAutoString pathName, leafName, rootName, suffix;
+  rv = GetPath(pathName);
+#else
+  nsAutoCString pathName, leafName, rootName, suffix;
+  rv = GetNativePath(pathName);
+#endif
+  if (NS_FAILED(rv))
+    return rv;
+
+  longName = (pathName.Length() + kMaxSequenceNumberLength >
+              kMaxFilenameLength);
+  if (!longName)
+  {
+    rv = Create(type, attributes);
+    if (rv != NS_ERROR_FILE_ALREADY_EXISTS)
+      return rv;
+  }
 
 #ifdef XP_WIN
-    nsAutoString pathName, leafName, rootName, suffix;
-    rv = GetPath(pathName);
+  rv = GetLeafName(leafName);
+  if (NS_FAILED(rv))
+    return rv;
+
+  const int32_t lastDot = leafName.RFindChar(char16_t('.'));
 #else
-    nsAutoCString pathName, leafName, rootName, suffix; 
-    rv = GetNativePath(pathName);
+  rv = GetNativeLeafName(leafName);
+  if (NS_FAILED(rv))
+    return rv;
+
+  const int32_t lastDot = leafName.RFindChar('.');
 #endif
-    if (NS_FAILED(rv))
-        return rv;
 
-    longName = (pathName.Length() + kMaxSequenceNumberLength >
-                kMaxFilenameLength);
-    if (!longName)
-    {
-        rv = Create(type, attributes);
-        if (rv != NS_ERROR_FILE_ALREADY_EXISTS)
-            return rv;
-    }
+  if (lastDot == kNotFound)
+  {
+    rootName = leafName;
+  }
+  else
+  {
+    suffix = Substring(leafName, lastDot);      // include '.'
+    rootName = Substring(leafName, 0, lastDot); // strip suffix and dot
+  }
+
+  if (longName)
+  {
+    int32_t maxRootLength = (kMaxFilenameLength -
+                             (pathName.Length() - leafName.Length()) -
+                             suffix.Length() - kMaxSequenceNumberLength);
+
+    // We cannot create an item inside a directory whose name is too long.
+    // Also, ensure that at least one character remains after we truncate
+    // the root name, as we don't want to end up with an empty leaf name.
+    if (maxRootLength < 2)
+      return NS_ERROR_FILE_UNRECOGNIZED_PATH;
 
 #ifdef XP_WIN
-    rv = GetLeafName(leafName);
-    if (NS_FAILED(rv))
-        return rv;
-
-    const int32_t lastDot = leafName.RFindChar(char16_t('.'));
+    // ensure that we don't cut the name in mid-UTF16-character
+    rootName.SetLength(NS_IS_LOW_SURROGATE(rootName[maxRootLength]) ?
+                       maxRootLength - 1 : maxRootLength);
+    SetLeafName(rootName + suffix);
 #else
-    rv = GetNativeLeafName(leafName);
-    if (NS_FAILED(rv))
-        return rv;
+    if (NS_IsNativeUTF8())
+    {
+      // ensure that we don't cut the name in mid-UTF8-character
+      // (assume the name is valid UTF8 to begin with)
+      while (UTF8traits::isInSeq(rootName[maxRootLength]))
+        --maxRootLength;
 
-    const int32_t lastDot = leafName.RFindChar('.');
-#endif
-
-    if (lastDot == kNotFound)
-    {
-        rootName = leafName;
-    } 
-    else
-    {
-        suffix = Substring(leafName, lastDot);      // include '.'
-        rootName = Substring(leafName, 0, lastDot); // strip suffix and dot
+      // Another check to avoid ending up with an empty leaf name.
+      if (maxRootLength == 0 && suffix.IsEmpty())
+        return NS_ERROR_FILE_UNRECOGNIZED_PATH;
     }
 
-    if (longName)
-    {
-        int32_t maxRootLength = (kMaxFilenameLength -
-                                 (pathName.Length() - leafName.Length()) -
-                                 suffix.Length() - kMaxSequenceNumberLength);
-
-        // We cannot create an item inside a directory whose name is too long.
-        // Also, ensure that at least one character remains after we truncate
-        // the root name, as we don't want to end up with an empty leaf name.
-        if (maxRootLength < 2)
-            return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-
-#ifdef XP_WIN
-        // ensure that we don't cut the name in mid-UTF16-character
-        rootName.SetLength(NS_IS_LOW_SURROGATE(rootName[maxRootLength]) ?
-                           maxRootLength - 1 : maxRootLength);
-        SetLeafName(rootName + suffix);
-#else
-        if (NS_IsNativeUTF8())
-        {
-            // ensure that we don't cut the name in mid-UTF8-character
-            // (assume the name is valid UTF8 to begin with)
-            while (UTF8traits::isInSeq(rootName[maxRootLength]))
-                --maxRootLength;
+    rootName.SetLength(maxRootLength);
+    SetNativeLeafName(rootName + suffix);
+#endif
+    nsresult rv = Create(type, attributes);
+    if (rv != NS_ERROR_FILE_ALREADY_EXISTS)
+      return rv;
+  }
 
-            // Another check to avoid ending up with an empty leaf name.
-            if (maxRootLength == 0 && suffix.IsEmpty())
-                return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-        }
-
-        rootName.SetLength(maxRootLength);
-        SetNativeLeafName(rootName + suffix);
+  for (int indx = 1; indx < 10000; indx++)
+  {
+    // start with "Picture-1.jpg" after "Picture.jpg" exists
+#ifdef XP_WIN
+    SetLeafName(rootName +
+                NS_ConvertASCIItoUTF16(nsPrintfCString("-%d", indx)) +
+                suffix);
+#else
+    SetNativeLeafName(rootName + nsPrintfCString("-%d", indx) + suffix);
 #endif
-        nsresult rv = Create(type, attributes);
-        if (rv != NS_ERROR_FILE_ALREADY_EXISTS)
-            return rv;
-    }
+    rv = Create(type, attributes);
+    if (NS_SUCCEEDED(rv) || rv != NS_ERROR_FILE_ALREADY_EXISTS)
+      return rv;
+  }
 
-    for (int indx = 1; indx < 10000; indx++)
-    {
-        // start with "Picture-1.jpg" after "Picture.jpg" exists
-#ifdef XP_WIN
-        SetLeafName(rootName +
-                    NS_ConvertASCIItoUTF16(nsPrintfCString("-%d", indx)) +
-                    suffix);
-#else
-        SetNativeLeafName(rootName + nsPrintfCString("-%d", indx) + suffix);
-#endif
-        rv = Create(type, attributes);
-        if (NS_SUCCEEDED(rv) || rv != NS_ERROR_FILE_ALREADY_EXISTS) 
-            return rv;
-    }
- 
-    // The disk is full, sort of
-    return NS_ERROR_FILE_TOO_BIG;
+  // The disk is full, sort of
+  return NS_ERROR_FILE_TOO_BIG;
 }
 
 #if defined(XP_WIN)
 static const char16_t kPathSeparatorChar       = '\\';
 #elif defined(XP_UNIX)
 static const char16_t kPathSeparatorChar       = '/';
 #else
 #error Need to define file path separator for your platform
 #endif
 
 static int32_t SplitPath(char16_t *path, char16_t **nodeArray, int32_t arrayLen)
 {
-    if (*path == 0)
-      return 0;
+  if (*path == 0)
+    return 0;
+
+  char16_t **nodePtr = nodeArray;
+  if (*path == kPathSeparatorChar)
+    path++;
+  *nodePtr++ = path;
 
-    char16_t **nodePtr = nodeArray;
-    if (*path == kPathSeparatorChar)
-      path++;    
-    *nodePtr++ = path;
-    
-    for (char16_t *cp = path; *cp != 0; cp++) {
-      if (*cp == kPathSeparatorChar) {
-        *cp++ = 0;
-        if (*cp == 0)
-          break;
-        if (nodePtr - nodeArray >= arrayLen)
-          return -1;
-        *nodePtr++ = cp;
-      }
+  for (char16_t *cp = path; *cp != 0; cp++) {
+    if (*cp == kPathSeparatorChar) {
+      *cp++ = 0;
+      if (*cp == 0)
+        break;
+      if (nodePtr - nodeArray >= arrayLen)
+        return -1;
+      *nodePtr++ = cp;
     }
-    return nodePtr - nodeArray;
+  }
+  return nodePtr - nodeArray;
 }
 
- 
+
 NS_IMETHODIMP
 nsLocalFile::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
 {
-    if (NS_WARN_IF(!fromFile))
-        return NS_ERROR_INVALID_ARG;
-    const int32_t kMaxNodesInPath = 32;
+  if (NS_WARN_IF(!fromFile))
+    return NS_ERROR_INVALID_ARG;
+  const int32_t kMaxNodesInPath = 32;
 
-    //
-    // _retval will be UTF-8 encoded
-    // 
-        
-    nsresult rv;
-    _retval.Truncate(0);
+  //
+  // _retval will be UTF-8 encoded
+  //
+
+  nsresult rv;
+  _retval.Truncate(0);
 
-    nsAutoString thisPath, fromPath;
-    char16_t *thisNodes[kMaxNodesInPath], *fromNodes[kMaxNodesInPath];
-    int32_t  thisNodeCnt, fromNodeCnt, nodeIndex;
-    
-    rv = GetPath(thisPath);
-    if (NS_FAILED(rv))
-        return rv;
-    rv = fromFile->GetPath(fromPath);
-    if (NS_FAILED(rv))
-        return rv;
+  nsAutoString thisPath, fromPath;
+  char16_t *thisNodes[kMaxNodesInPath], *fromNodes[kMaxNodesInPath];
+  int32_t  thisNodeCnt, fromNodeCnt, nodeIndex;
+
+  rv = GetPath(thisPath);
+  if (NS_FAILED(rv))
+    return rv;
+  rv = fromFile->GetPath(fromPath);
+  if (NS_FAILED(rv))
+    return rv;
+
+  // get raw pointer to mutable string buffer
+  char16_t *thisPathPtr; thisPath.BeginWriting(thisPathPtr);
+  char16_t *fromPathPtr; fromPath.BeginWriting(fromPathPtr);
 
-    // get raw pointer to mutable string buffer
-    char16_t *thisPathPtr; thisPath.BeginWriting(thisPathPtr);
-    char16_t *fromPathPtr; fromPath.BeginWriting(fromPathPtr);
-    
-    thisNodeCnt = SplitPath(thisPathPtr, thisNodes, kMaxNodesInPath);
-    fromNodeCnt = SplitPath(fromPathPtr, fromNodes, kMaxNodesInPath);
-    if (thisNodeCnt < 0 || fromNodeCnt < 0)
-      return NS_ERROR_FAILURE;
-    
-    for (nodeIndex = 0; nodeIndex < thisNodeCnt && nodeIndex < fromNodeCnt; ++nodeIndex) {
+  thisNodeCnt = SplitPath(thisPathPtr, thisNodes, kMaxNodesInPath);
+  fromNodeCnt = SplitPath(fromPathPtr, fromNodes, kMaxNodesInPath);
+  if (thisNodeCnt < 0 || fromNodeCnt < 0)
+    return NS_ERROR_FAILURE;
+
+  for (nodeIndex = 0; nodeIndex < thisNodeCnt && nodeIndex < fromNodeCnt; ++nodeIndex) {
 #ifdef XP_WIN
-      if (_wcsicmp(char16ptr_t(thisNodes[nodeIndex]), char16ptr_t(fromNodes[nodeIndex])))
-        break;
+    if (_wcsicmp(char16ptr_t(thisNodes[nodeIndex]), char16ptr_t(fromNodes[nodeIndex])))
+      break;
 #else
-      if (nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
-        break;
+    if (nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
+      break;
 #endif
-    }
-    
-    int32_t branchIndex = nodeIndex;
-    for (nodeIndex = branchIndex; nodeIndex < fromNodeCnt; nodeIndex++) 
-      _retval.AppendLiteral("../");
-    for (nodeIndex = branchIndex; nodeIndex < thisNodeCnt; nodeIndex++) {
-      NS_ConvertUTF16toUTF8 nodeStr(thisNodes[nodeIndex]);
-      _retval.Append(nodeStr);
-      if (nodeIndex + 1 < thisNodeCnt)
-        _retval.Append('/');
-    }
-        
-    return NS_OK;
+  }
+
+  int32_t branchIndex = nodeIndex;
+  for (nodeIndex = branchIndex; nodeIndex < fromNodeCnt; nodeIndex++)
+    _retval.AppendLiteral("../");
+  for (nodeIndex = branchIndex; nodeIndex < thisNodeCnt; nodeIndex++) {
+    NS_ConvertUTF16toUTF8 nodeStr(thisNodes[nodeIndex]);
+    _retval.Append(nodeStr);
+    if (nodeIndex + 1 < thisNodeCnt)
+      _retval.Append('/');
+  }
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::SetRelativeDescriptor(nsIFile *fromFile, const nsACString& relativeDesc)
 {
-    NS_NAMED_LITERAL_CSTRING(kParentDirStr, "../");
- 
-    nsCOMPtr<nsIFile> targetFile;
-    nsresult rv = fromFile->Clone(getter_AddRefs(targetFile));
-    if (NS_FAILED(rv))
-        return rv;
+  NS_NAMED_LITERAL_CSTRING(kParentDirStr, "../");
+
+  nsCOMPtr<nsIFile> targetFile;
+  nsresult rv = fromFile->Clone(getter_AddRefs(targetFile));
+  if (NS_FAILED(rv))
+    return rv;
 
-    //
-    // relativeDesc is UTF-8 encoded
-    // 
+  //
+  // relativeDesc is UTF-8 encoded
+  //
+
+  nsCString::const_iterator strBegin, strEnd;
+  relativeDesc.BeginReading(strBegin);
+  relativeDesc.EndReading(strEnd);
+
+  nsCString::const_iterator nodeBegin(strBegin), nodeEnd(strEnd);
+  nsCString::const_iterator pos(strBegin);
 
-    nsCString::const_iterator strBegin, strEnd;
-    relativeDesc.BeginReading(strBegin);
-    relativeDesc.EndReading(strEnd);
-    
-    nsCString::const_iterator nodeBegin(strBegin), nodeEnd(strEnd);
-    nsCString::const_iterator pos(strBegin);
-    
-    nsCOMPtr<nsIFile> parentDir;
-    while (FindInReadable(kParentDirStr, nodeBegin, nodeEnd)) {
-        rv = targetFile->GetParent(getter_AddRefs(parentDir));
-        if (NS_FAILED(rv))
-            return rv;
-        if (!parentDir)
-            return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-        targetFile = parentDir;
+  nsCOMPtr<nsIFile> parentDir;
+  while (FindInReadable(kParentDirStr, nodeBegin, nodeEnd)) {
+    rv = targetFile->GetParent(getter_AddRefs(parentDir));
+    if (NS_FAILED(rv))
+      return rv;
+    if (!parentDir)
+      return NS_ERROR_FILE_UNRECOGNIZED_PATH;
+    targetFile = parentDir;
 
-        nodeBegin = nodeEnd;
-        pos = nodeEnd;
-        nodeEnd = strEnd;
-    }
+    nodeBegin = nodeEnd;
+    pos = nodeEnd;
+    nodeEnd = strEnd;
+  }
 
-    nodeBegin = nodeEnd = pos;
-    while (nodeEnd != strEnd) {
-      FindCharInReadable('/', nodeEnd, strEnd);
-      targetFile->Append(NS_ConvertUTF8toUTF16(Substring(nodeBegin, nodeEnd)));
-      if (nodeEnd != strEnd) // If there's more left in the string, inc over the '/' nodeEnd is on.
-        ++nodeEnd;
-      nodeBegin = nodeEnd;
-    }
+  nodeBegin = nodeEnd = pos;
+  while (nodeEnd != strEnd) {
+    FindCharInReadable('/', nodeEnd, strEnd);
+    targetFile->Append(NS_ConvertUTF8toUTF16(Substring(nodeBegin, nodeEnd)));
+    if (nodeEnd != strEnd) // If there's more left in the string, inc over the '/' nodeEnd is on.
+      ++nodeEnd;
+    nodeBegin = nodeEnd;
+  }
 
-    return InitWithFile(targetFile);
+  return InitWithFile(targetFile);
 }
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -1,9 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Implementation of nsIFile for "unixy" systems.
  */
 
@@ -87,138 +88,138 @@ using namespace mozilla;
             return NS_ERROR_NOT_INITIALIZED;    \
     PR_END_MACRO
 
 /* directory enumerator */
 class
 nsDirEnumeratorUnix MOZ_FINAL : public nsISimpleEnumerator,
                                 public nsIDirectoryEnumerator
 {
-    public:
-    nsDirEnumeratorUnix();
-
-    // nsISupports interface
-    NS_DECL_ISUPPORTS
-
-    // nsISimpleEnumerator interface
-    NS_DECL_NSISIMPLEENUMERATOR
-
-    // nsIDirectoryEnumerator interface
-    NS_DECL_NSIDIRECTORYENUMERATOR
-
-    NS_IMETHOD Init(nsLocalFile *parent, bool ignored);
-
-    private:
-    ~nsDirEnumeratorUnix();
-
-    protected:
-    NS_IMETHOD GetNextEntry();
-
-    DIR           *mDir;
-    struct dirent *mEntry;
-    nsCString      mParentPath;
+public:
+  nsDirEnumeratorUnix();
+
+  // nsISupports interface
+  NS_DECL_ISUPPORTS
+
+  // nsISimpleEnumerator interface
+  NS_DECL_NSISIMPLEENUMERATOR
+
+  // nsIDirectoryEnumerator interface
+  NS_DECL_NSIDIRECTORYENUMERATOR
+
+  NS_IMETHOD Init(nsLocalFile *parent, bool ignored);
+
+private:
+  ~nsDirEnumeratorUnix();
+
+protected:
+  NS_IMETHOD GetNextEntry();
+
+  DIR           *mDir;
+  struct dirent *mEntry;
+  nsCString      mParentPath;
 };
 
 nsDirEnumeratorUnix::nsDirEnumeratorUnix() :
-                         mDir(nullptr), 
-                         mEntry(nullptr)
+  mDir(nullptr),
+  mEntry(nullptr)
 {
 }
 
 nsDirEnumeratorUnix::~nsDirEnumeratorUnix()
 {
-    Close();
+  Close();
 }
 
 NS_IMPL_ISUPPORTS(nsDirEnumeratorUnix, nsISimpleEnumerator, nsIDirectoryEnumerator)
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::Init(nsLocalFile *parent, bool resolveSymlinks /*ignored*/)
 {
-    nsAutoCString dirPath;
-    if (NS_FAILED(parent->GetNativePath(dirPath)) ||
-        dirPath.IsEmpty()) {
-        return NS_ERROR_FILE_INVALID_PATH;
-    }
-
-    if (NS_FAILED(parent->GetNativePath(mParentPath)))
-        return NS_ERROR_FAILURE;
-
-    mDir = opendir(dirPath.get());
-    if (!mDir)
-        return NSRESULT_FOR_ERRNO();
-    return GetNextEntry();
+  nsAutoCString dirPath;
+  if (NS_FAILED(parent->GetNativePath(dirPath)) ||
+      dirPath.IsEmpty()) {
+    return NS_ERROR_FILE_INVALID_PATH;
+  }
+
+  if (NS_FAILED(parent->GetNativePath(mParentPath)))
+    return NS_ERROR_FAILURE;
+
+  mDir = opendir(dirPath.get());
+  if (!mDir)
+    return NSRESULT_FOR_ERRNO();
+  return GetNextEntry();
 }
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::HasMoreElements(bool *result)
 {
-    *result = mDir && mEntry;
-    if (!*result)
-        Close();
-    return NS_OK;
+  *result = mDir && mEntry;
+  if (!*result)
+    Close();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::GetNext(nsISupports **_retval)
 {
-    nsCOMPtr<nsIFile> file;
-    nsresult rv = GetNextFile(getter_AddRefs(file));
-    if (NS_FAILED(rv))
-        return rv;
-    NS_IF_ADDREF(*_retval = file);
-    return NS_OK;
+  nsCOMPtr<nsIFile> file;
+  nsresult rv = GetNextFile(getter_AddRefs(file));
+  if (NS_FAILED(rv))
+    return rv;
+  NS_IF_ADDREF(*_retval = file);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::GetNextEntry()
 {
-    do {
-        errno = 0;
-        mEntry = readdir(mDir);
-
-        // end of dir or error
-        if (!mEntry)
-            return NSRESULT_FOR_ERRNO();
-
-        // keep going past "." and ".."
-    } while (mEntry->d_name[0] == '.'     &&
-            (mEntry->d_name[1] == '\0'    ||   // .\0
+  do {
+    errno = 0;
+    mEntry = readdir(mDir);
+
+    // end of dir or error
+    if (!mEntry)
+      return NSRESULT_FOR_ERRNO();
+
+    // keep going past "." and ".."
+  } while (mEntry->d_name[0] == '.'     &&
+           (mEntry->d_name[1] == '\0'    ||   // .\0
             (mEntry->d_name[1] == '.'     &&
-            mEntry->d_name[2] == '\0')));      // ..\0
-    return NS_OK;
+             mEntry->d_name[2] == '\0')));      // ..\0
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::GetNextFile(nsIFile **_retval)
 {
-    nsresult rv;
-    if (!mDir || !mEntry) {
-        *_retval = nullptr;
-        return NS_OK;
-    }
-
-    nsCOMPtr<nsIFile> file = new nsLocalFile();
-
-    if (NS_FAILED(rv = file->InitWithNativePath(mParentPath)) ||
-        NS_FAILED(rv = file->AppendNative(nsDependentCString(mEntry->d_name))))
-        return rv;
-
-    file.forget(_retval);
-    return GetNextEntry();
+  nsresult rv;
+  if (!mDir || !mEntry) {
+    *_retval = nullptr;
+    return NS_OK;
+  }
+
+  nsCOMPtr<nsIFile> file = new nsLocalFile();
+
+  if (NS_FAILED(rv = file->InitWithNativePath(mParentPath)) ||
+      NS_FAILED(rv = file->AppendNative(nsDependentCString(mEntry->d_name))))
+    return rv;
+
+  file.forget(_retval);
+  return GetNextEntry();
 }
 
-NS_IMETHODIMP 
+NS_IMETHODIMP
 nsDirEnumeratorUnix::Close()
 {
-    if (mDir) {
-        closedir(mDir);
-        mDir = nullptr;
-    }
-    return NS_OK;
+  if (mDir) {
+    closedir(mDir);
+    mDir = nullptr;
+  }
+  return NS_OK;
 }
 
 nsLocalFile::nsLocalFile()
 {
 }
 
 nsLocalFile::nsLocalFile(const nsLocalFile& other)
   : mPath(other.mPath)
@@ -234,1705 +235,1705 @@ NS_IMPL_ISUPPORTS(nsLocalFile,
 #else
 NS_IMPL_ISUPPORTS(nsLocalFile,
                   nsILocalFile,
                   nsIFile,
                   nsIHashable)
 #endif
 
 nsresult
-nsLocalFile::nsLocalFileConstructor(nsISupports *outer, 
+nsLocalFile::nsLocalFileConstructor(nsISupports *outer,
                                     const nsIID &aIID,
                                     void **aInstancePtr)
 {
-    if (NS_WARN_IF(!aInstancePtr))
-        return NS_ERROR_INVALID_ARG;
-    if (NS_WARN_IF(outer))
-        return NS_ERROR_NO_AGGREGATION;
-
-    *aInstancePtr = nullptr;
-
-    nsCOMPtr<nsIFile> inst = new nsLocalFile();
-    return inst->QueryInterface(aIID, aInstancePtr);
+  if (NS_WARN_IF(!aInstancePtr))
+    return NS_ERROR_INVALID_ARG;
+  if (NS_WARN_IF(outer))
+    return NS_ERROR_NO_AGGREGATION;
+
+  *aInstancePtr = nullptr;
+
+  nsCOMPtr<nsIFile> inst = new nsLocalFile();
+  return inst->QueryInterface(aIID, aInstancePtr);
 }
 
-bool 
+bool
 nsLocalFile::FillStatCache() {
-    if (STAT(mPath.get(), &mCachedStat) == -1) {
-        // try lstat it may be a symlink
-        if (LSTAT(mPath.get(), &mCachedStat) == -1) {
-            return false;
-        }
+  if (STAT(mPath.get(), &mCachedStat) == -1) {
+    // try lstat it may be a symlink
+    if (LSTAT(mPath.get(), &mCachedStat) == -1) {
+      return false;
     }
-    return true;
+  }
+  return true;
 }
 
 NS_IMETHODIMP
 nsLocalFile::Clone(nsIFile **file)
 {
-    // Just copy-construct ourselves
-    nsRefPtr<nsLocalFile> copy = new nsLocalFile(*this);
-    copy.forget(file);
-    return NS_OK;
+  // Just copy-construct ourselves
+  nsRefPtr<nsLocalFile> copy = new nsLocalFile(*this);
+  copy.forget(file);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::InitWithNativePath(const nsACString &filePath)
 {
-    if (filePath.Equals("~") || Substring(filePath, 0, 2).EqualsLiteral("~/")) {
-        nsCOMPtr<nsIFile> homeDir;
-        nsAutoCString homePath;
-        if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_HOME_DIR,
-                                             getter_AddRefs(homeDir))) ||
-            NS_FAILED(homeDir->GetNativePath(homePath))) {
-            return NS_ERROR_FAILURE;
-        }
- 
-        mPath = homePath;
-        if (filePath.Length() > 2)
-          mPath.Append(Substring(filePath, 1, filePath.Length() - 1));
-    } else {
-        if (filePath.IsEmpty() || filePath.First() != '/')
-            return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-        mPath = filePath;
+  if (filePath.Equals("~") || Substring(filePath, 0, 2).EqualsLiteral("~/")) {
+    nsCOMPtr<nsIFile> homeDir;
+    nsAutoCString homePath;
+    if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_HOME_DIR,
+                                         getter_AddRefs(homeDir))) ||
+        NS_FAILED(homeDir->GetNativePath(homePath))) {
+      return NS_ERROR_FAILURE;
     }
 
-    // trim off trailing slashes
-    ssize_t len = mPath.Length();
-    while ((len > 1) && (mPath[len - 1] == '/'))
-        --len;
-    mPath.SetLength(len);
-
-    return NS_OK;
+    mPath = homePath;
+    if (filePath.Length() > 2)
+      mPath.Append(Substring(filePath, 1, filePath.Length() - 1));
+  } else {
+    if (filePath.IsEmpty() || filePath.First() != '/')
+      return NS_ERROR_FILE_UNRECOGNIZED_PATH;
+    mPath = filePath;
+  }
+
+  // trim off trailing slashes
+  ssize_t len = mPath.Length();
+  while ((len > 1) && (mPath[len - 1] == '/'))
+    --len;
+  mPath.SetLength(len);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::CreateAllAncestors(uint32_t permissions)
 {
-    // <jband> I promise to play nice
-    char *buffer = mPath.BeginWriting(),
-         *slashp = buffer;
+  // <jband> I promise to play nice
+  char *buffer = mPath.BeginWriting(),
+        *slashp = buffer;
 
 #ifdef DEBUG_NSIFILE
-    fprintf(stderr, "nsIFile: before: %s\n", buffer);
+  fprintf(stderr, "nsIFile: before: %s\n", buffer);
 #endif
 
-    while ((slashp = strchr(slashp + 1, '/'))) {
-        /*
-         * Sequences of '/' are equivalent to a single '/'.
-         */
-        if (slashp[1] == '/')
-            continue;
-
-        /*
-         * If the path has a trailing slash, don't make the last component,
-         * because we'll get EEXIST in Create when we try to build the final
-         * component again, and it's easier to condition the logic here than
-         * there.
-         */
-        if (slashp[1] == '\0')
-            break;
-
-        /* Temporarily NUL-terminate here */
-        *slashp = '\0';
+  while ((slashp = strchr(slashp + 1, '/'))) {
+    /*
+     * Sequences of '/' are equivalent to a single '/'.
+     */
+    if (slashp[1] == '/')
+      continue;
+
+    /*
+     * If the path has a trailing slash, don't make the last component,
+     * because we'll get EEXIST in Create when we try to build the final
+     * component again, and it's easier to condition the logic here than
+     * there.
+     */
+    if (slashp[1] == '\0')
+      break;
+
+    /* Temporarily NUL-terminate here */
+    *slashp = '\0';
 #ifdef DEBUG_NSIFILE
-        fprintf(stderr, "nsIFile: mkdir(\"%s\")\n", buffer);
+    fprintf(stderr, "nsIFile: mkdir(\"%s\")\n", buffer);
 #endif
-        int mkdir_result = mkdir(buffer, permissions);
-        int mkdir_errno  = errno;
-        if (mkdir_result == -1) {
-            /*
-             * Always set |errno| to EEXIST if the dir already exists
-             * (we have to do this here since the errno value is not consistent
-             * in all cases - various reasons like different platform,
-             * automounter-controlled dir, etc. can affect it (see bug 125489
-             * for details)).
-             */
-            if (access(buffer, F_OK) == 0) {
-                mkdir_errno = EEXIST;
-            }
-        }
-
-        /* Put the / back before we (maybe) return */
-        *slashp = '/';
-
-        /*
-         * We could get EEXIST for an existing file -- not directory --
-         * with the name of one of our ancestors, but that's OK: we'll get
-         * ENOTDIR when we try to make the next component in the path,
-         * either here on back in Create, and error out appropriately.
-         */
-        if (mkdir_result == -1 && mkdir_errno != EEXIST)
-            return nsresultForErrno(mkdir_errno);
+    int mkdir_result = mkdir(buffer, permissions);
+    int mkdir_errno  = errno;
+    if (mkdir_result == -1) {
+      /*
+       * Always set |errno| to EEXIST if the dir already exists
+       * (we have to do this here since the errno value is not consistent
+       * in all cases - various reasons like different platform,
+       * automounter-controlled dir, etc. can affect it (see bug 125489
+       * for details)).
+       */
+      if (access(buffer, F_OK) == 0) {
+        mkdir_errno = EEXIST;
+      }
     }
 
+    /* Put the / back before we (maybe) return */
+    *slashp = '/';
+
+    /*
+     * We could get EEXIST for an existing file -- not directory --
+     * with the name of one of our ancestors, but that's OK: we'll get
+     * ENOTDIR when we try to make the next component in the path,
+     * either here on back in Create, and error out appropriately.
+     */
+    if (mkdir_result == -1 && mkdir_errno != EEXIST)
+      return nsresultForErrno(mkdir_errno);
+  }
+
 #ifdef DEBUG_NSIFILE
-    fprintf(stderr, "nsIFile: after: %s\n", buffer);
+  fprintf(stderr, "nsIFile: after: %s\n", buffer);
 #endif
 
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::OpenNSPRFileDesc(int32_t flags, int32_t mode, PRFileDesc **_retval)
 {
-    *_retval = PR_Open(mPath.get(), flags, mode);
-    if (! *_retval)
-        return NS_ErrorAccordingToNSPR();
-
-    if (flags & DELETE_ON_CLOSE) {
-        PR_Delete(mPath.get());
-    }
+  *_retval = PR_Open(mPath.get(), flags, mode);
+  if (! *_retval)
+    return NS_ErrorAccordingToNSPR();
+
+  if (flags & DELETE_ON_CLOSE) {
+    PR_Delete(mPath.get());
+  }
 
 #if defined(HAVE_POSIX_FADVISE)
-    if (flags & OS_READAHEAD) {
-        posix_fadvise(PR_FileDesc2NativeHandle(*_retval), 0, 0,
-                      POSIX_FADV_SEQUENTIAL);
-    }
+  if (flags & OS_READAHEAD) {
+    posix_fadvise(PR_FileDesc2NativeHandle(*_retval), 0, 0,
+                  POSIX_FADV_SEQUENTIAL);
+  }
 #endif
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::OpenANSIFileDesc(const char *mode, FILE **_retval)
 {
-    *_retval = fopen(mPath.get(), mode);
-    if (! *_retval)
-        return NS_ERROR_FAILURE;
-
-    return NS_OK;
+  *_retval = fopen(mPath.get(), mode);
+  if (! *_retval)
+    return NS_ERROR_FAILURE;
+
+  return NS_OK;
 }
 
 static int
 do_create(const char *path, int flags, mode_t mode, PRFileDesc **_retval)
 {
-    *_retval = PR_Open(path, flags, mode);
-    return *_retval ? 0 : -1;
+  *_retval = PR_Open(path, flags, mode);
+  return *_retval ? 0 : -1;
 }
 
 static int
 do_mkdir(const char *path, int flags, mode_t mode, PRFileDesc **_retval)
 {
-    *_retval = nullptr;
-    return mkdir(path, mode);
+  *_retval = nullptr;
+  return mkdir(path, mode);
 }
 
 nsresult
 nsLocalFile::CreateAndKeepOpen(uint32_t type, int flags,
                                uint32_t permissions, PRFileDesc **_retval)
 {
-    if (type != NORMAL_FILE_TYPE && type != DIRECTORY_TYPE)
-        return NS_ERROR_FILE_UNKNOWN_TYPE;
-
-    int result;
-    int (*createFunc)(const char *, int, mode_t, PRFileDesc **) =
-        (type == NORMAL_FILE_TYPE) ? do_create : do_mkdir;
-
-    result = createFunc(mPath.get(), flags, permissions, _retval);
-    if (result == -1 && errno == ENOENT) {
-        /*
-         * If we failed because of missing ancestor components, try to create
-         * them and then retry the original creation.
-         *
-         * Ancestor directories get the same permissions as the file we're
-         * creating, with the X bit set for each of (user,group,other) with
-         * an R bit in the original permissions.    If you want to do anything
-         * fancy like setgid or sticky bits, do it by hand.
-         */
-        int dirperm = permissions;
-        if (permissions & S_IRUSR)
-            dirperm |= S_IXUSR;
-        if (permissions & S_IRGRP)
-            dirperm |= S_IXGRP;
-        if (permissions & S_IROTH)
-            dirperm |= S_IXOTH;
+  if (type != NORMAL_FILE_TYPE && type != DIRECTORY_TYPE)
+    return NS_ERROR_FILE_UNKNOWN_TYPE;
+
+  int result;
+  int (*createFunc)(const char *, int, mode_t, PRFileDesc **) =
+    (type == NORMAL_FILE_TYPE) ? do_create : do_mkdir;
+
+  result = createFunc(mPath.get(), flags, permissions, _retval);
+  if (result == -1 && errno == ENOENT) {
+    /*
+     * If we failed because of missing ancestor components, try to create
+     * them and then retry the original creation.
+     *
+     * Ancestor directories get the same permissions as the file we're
+     * creating, with the X bit set for each of (user,group,other) with
+     * an R bit in the original permissions.    If you want to do anything
+     * fancy like setgid or sticky bits, do it by hand.
+     */
+    int dirperm = permissions;
+    if (permissions & S_IRUSR)
+      dirperm |= S_IXUSR;
+    if (permissions & S_IRGRP)
+      dirperm |= S_IXGRP;
+    if (permissions & S_IROTH)
+      dirperm |= S_IXOTH;
 
 #ifdef DEBUG_NSIFILE
-        fprintf(stderr, "nsIFile: perm = %o, dirperm = %o\n", permissions,
-                dirperm);
+    fprintf(stderr, "nsIFile: perm = %o, dirperm = %o\n", permissions,
+            dirperm);
 #endif
 
-        if (NS_FAILED(CreateAllAncestors(dirperm)))
-            return NS_ERROR_FAILURE;
+    if (NS_FAILED(CreateAllAncestors(dirperm)))
+      return NS_ERROR_FAILURE;
 
 #ifdef DEBUG_NSIFILE
-        fprintf(stderr, "nsIFile: Create(\"%s\") again\n", mPath.get());
+    fprintf(stderr, "nsIFile: Create(\"%s\") again\n", mPath.get());
 #endif
-        result = createFunc(mPath.get(), flags, permissions, _retval);
-    }
-    return NSRESULT_FOR_RETURN(result);
+    result = createFunc(mPath.get(), flags, permissions, _retval);
+  }
+  return NSRESULT_FOR_RETURN(result);
 }
 
 NS_IMETHODIMP
 nsLocalFile::Create(uint32_t type, uint32_t permissions)
 {
-    PRFileDesc *junk = nullptr;
-    nsresult rv = CreateAndKeepOpen(type,
-                                    PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE |
-                                    PR_EXCL,
-                                    permissions,
-                                    &junk);
-    if (junk)
-        PR_Close(junk);
-    return rv;
+  PRFileDesc *junk = nullptr;
+  nsresult rv = CreateAndKeepOpen(type,
+                                  PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE |
+                                  PR_EXCL,
+                                  permissions,
+                                  &junk);
+  if (junk)
+    PR_Close(junk);
+  return rv;
 }
 
 NS_IMETHODIMP
 nsLocalFile::AppendNative(const nsACString &fragment)
 {
-    if (fragment.IsEmpty())
-        return NS_OK;
-
-    // only one component of path can be appended
-    nsACString::const_iterator begin, end;
-    if (FindCharInReadable('/', fragment.BeginReading(begin),
-                                fragment.EndReading(end)))
-        return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-
-    return AppendRelativeNativePath(fragment);
+  if (fragment.IsEmpty())
+    return NS_OK;
+
+  // only one component of path can be appended
+  nsACString::const_iterator begin, end;
+  if (FindCharInReadable('/', fragment.BeginReading(begin),
+                         fragment.EndReading(end)))
+    return NS_ERROR_FILE_UNRECOGNIZED_PATH;
+
+  return AppendRelativeNativePath(fragment);
 }
 
 NS_IMETHODIMP
 nsLocalFile::AppendRelativeNativePath(const nsACString &fragment)
 {
-    if (fragment.IsEmpty())
-        return NS_OK;
-
-    // No leading '/' 
-    if (fragment.First() == '/')
-        return NS_ERROR_FILE_UNRECOGNIZED_PATH;
-
-    if (mPath.EqualsLiteral("/"))
-        mPath.Append(fragment);
-    else
-        mPath.Append(NS_LITERAL_CSTRING("/") + fragment);
-
+  if (fragment.IsEmpty())
     return NS_OK;
+
+  // No leading '/'
+  if (fragment.First() == '/')
+    return NS_ERROR_FILE_UNRECOGNIZED_PATH;
+
+  if (mPath.EqualsLiteral("/"))
+    mPath.Append(fragment);
+  else
+    mPath.Append(NS_LITERAL_CSTRING("/") + fragment);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::Normalize()
 {
-    char    resolved_path[PATH_MAX] = "";
-    char *resolved_path_ptr = nullptr;
-
-    resolved_path_ptr = realpath(mPath.get(), resolved_path);
-
-    // if there is an error, the return is null.
-    if (!resolved_path_ptr)
-        return NSRESULT_FOR_ERRNO();
-
-    mPath = resolved_path;
-    return NS_OK;
+  char resolved_path[PATH_MAX] = "";
+  char *resolved_path_ptr = nullptr;
+
+  resolved_path_ptr = realpath(mPath.get(), resolved_path);
+
+  // if there is an error, the return is null.
+  if (!resolved_path_ptr)
+    return NSRESULT_FOR_ERRNO();
+
+  mPath = resolved_path;
+  return NS_OK;
 }
 
 void
-nsLocalFile::LocateNativeLeafName(nsACString::const_iterator &begin, 
+nsLocalFile::LocateNativeLeafName(nsACString::const_iterator &begin,
                                   nsACString::const_iterator &end)
 {
-    // XXX perhaps we should cache this??
-
-    mPath.BeginReading(begin);
-    mPath.EndReading(end);
-    
-    nsACString::const_iterator it = end;
-    nsACString::const_iterator stop = begin;
-    --stop;
-    while (--it != stop) {
-        if (*it == '/') {
-            begin = ++it;
-            return;
-        }
+  // XXX perhaps we should cache this??
+
+  mPath.BeginReading(begin);
+  mPath.EndReading(end);
+
+  nsACString::const_iterator it = end;
+  nsACString::const_iterator stop = begin;
+  --stop;
+  while (--it != stop) {
+    if (*it == '/') {
+      begin = ++it;
+      return;
     }
-    // else, the entire path is the leaf name (which means this
-    // isn't an absolute path... unexpected??)
+  }
+  // else, the entire path is the leaf name (which means this
+  // isn't an absolute path... unexpected??)
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetNativeLeafName(nsACString &aLeafName)
 {
-    nsACString::const_iterator begin, end;
-    LocateNativeLeafName(begin, end);
-    aLeafName = Substring(begin, end);
-    return NS_OK;
+  nsACString::const_iterator begin, end;
+  LocateNativeLeafName(begin, end);
+  aLeafName = Substring(begin, end);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::SetNativeLeafName(const nsACString &aLeafName)
 {
-    nsACString::const_iterator begin, end;
-    LocateNativeLeafName(begin, end);
-    mPath.Replace(begin.get() - mPath.get(), Distance(begin, end), aLeafName);
-    return NS_OK;
+  nsACString::const_iterator begin, end;
+  LocateNativeLeafName(begin, end);
+  mPath.Replace(begin.get() - mPath.get(), Distance(begin, end), aLeafName);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetNativePath(nsACString &_retval)
 {
-    _retval = mPath;
-    return NS_OK;
+  _retval = mPath;
+  return NS_OK;
 }
 
 nsresult
-nsLocalFile::GetNativeTargetPathName(nsIFile *newParent, 
+nsLocalFile::GetNativeTargetPathName(nsIFile *newParent,
                                      const nsACString &newName,
                                      nsACString &_retval)
 {
-    nsresult rv;
-    nsCOMPtr<nsIFile> oldParent;
-
-    if (!newParent) {
-        if (NS_FAILED(rv = GetParent(getter_AddRefs(oldParent))))
-            return rv;
-        newParent = oldParent.get();
+  nsresult rv;
+  nsCOMPtr<nsIFile> oldParent;
+
+  if (!newParent) {
+    if (NS_FAILED(rv = GetParent(getter_AddRefs(oldParent))))
+      return rv;
+    newParent = oldParent.get();
+  } else {
+    // check to see if our target directory exists
+    bool targetExists;
+    if (NS_FAILED(rv = newParent->Exists(&targetExists)))
+      return rv;
+
+    if (!targetExists) {
+      // XXX create the new directory with some permissions
+      rv = newParent->Create(DIRECTORY_TYPE, 0755);
+      if (NS_FAILED(rv))
+        return rv;
     } else {
-        // check to see if our target directory exists
-        bool targetExists;
-        if (NS_FAILED(rv = newParent->Exists(&targetExists)))
-            return rv;
-
-        if (!targetExists) {
-            // XXX create the new directory with some permissions
-            rv = newParent->Create(DIRECTORY_TYPE, 0755);
-            if (NS_FAILED(rv))
-                return rv;
-        } else {
-            // make sure that the target is actually a directory
-            bool targetIsDirectory;
-            if (NS_FAILED(rv = newParent->IsDirectory(&targetIsDirectory)))
-                return rv;
-            if (!targetIsDirectory)
-                return NS_ERROR_FILE_DESTINATION_NOT_DIR;
-        }
+      // make sure that the target is actually a directory
+      bool targetIsDirectory;
+      if (NS_FAILED(rv = newParent->IsDirectory(&targetIsDirectory)))
+        return rv;
+      if (!targetIsDirectory)
+        return NS_ERROR_FILE_DESTINATION_NOT_DIR;
     }
-
-    nsACString::const_iterator nameBegin, nameEnd;
-    if (!newName.IsEmpty()) {
-        newName.BeginReading(nameBegin);
-        newName.EndReading(nameEnd);
-    }
-    else
-        LocateNativeLeafName(nameBegin, nameEnd);
-
-    nsAutoCString dirName;
-    if (NS_FAILED(rv = newParent->GetNativePath(dirName)))
-        return rv;
-
-    _retval = dirName
-            + NS_LITERAL_CSTRING("/")
-            + Substring(nameBegin, nameEnd);
-    return NS_OK;
+  }
+
+  nsACString::const_iterator nameBegin, nameEnd;
+  if (!newName.IsEmpty()) {
+    newName.BeginReading(nameBegin);
+    newName.EndReading(nameEnd);
+  }
+  else
+    LocateNativeLeafName(nameBegin, nameEnd);
+
+  nsAutoCString dirName;
+  if (NS_FAILED(rv = newParent->GetNativePath(dirName)))
+    return rv;
+
+  _retval = dirName
+    + NS_LITERAL_CSTRING("/")
+    + Substring(nameBegin, nameEnd);
+  return NS_OK;
 }
 
 nsresult
 nsLocalFile::CopyDirectoryTo(nsIFile *newParent)
 {
-    nsresult rv;
-    /*
-     * dirCheck is used for various boolean test results such as from Equals,
-     * Exists, isDir, etc.
-     */
-    bool dirCheck, isSymlink;
-    uint32_t oldPerms;
-
-    if (NS_FAILED(rv = IsDirectory(&dirCheck)))
-        return rv;
-    if (!dirCheck)
-        return CopyToNative(newParent, EmptyCString());
-    
-    if (NS_FAILED(rv = Equals(newParent, &dirCheck)))
-        return rv;
-    if (dirCheck) { 
-        // can't copy dir to itself
-        return NS_ERROR_INVALID_ARG;
-    }
-    
-    if (NS_FAILED(rv = newParent->Exists(&dirCheck))) 
-        return rv;
-    // get the dirs old permissions
-    if (NS_FAILED(rv = GetPermissions(&oldPerms)))
-        return rv;
-    if (!dirCheck) {
-        if (NS_FAILED(rv = newParent->Create(DIRECTORY_TYPE, oldPerms)))
+  nsresult rv;
+  /*
+   * dirCheck is used for various boolean test results such as from Equals,
+   * Exists, isDir, etc.
+   */
+  bool dirCheck, isSymlink;
+  uint32_t oldPerms;
+
+  if (NS_FAILED(rv = IsDirectory(&dirCheck)))
+    return rv;
+  if (!dirCheck)
+    return CopyToNative(newParent, EmptyCString());
+
+  if (NS_FAILED(rv = Equals(newParent, &dirCheck)))
+    return rv;
+  if (dirCheck) {
+    // can't copy dir to itself
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  if (NS_FAILED(rv = newParent->Exists(&dirCheck)))
+    return rv;
+  // get the dirs old permissions
+  if (NS_FAILED(rv = GetPermissions(&oldPerms)))
+    return rv;
+  if (!dirCheck) {
+    if (NS_FAILED(rv = newParent->Create(DIRECTORY_TYPE, oldPerms)))
+      return rv;
+  } else {    // dir exists lets try to use leaf
+    nsAutoCString leafName;
+    if (NS_FAILED(rv = GetNativeLeafName(leafName)))
+      return rv;
+    if (NS_FAILED(rv = newParent->AppendNative(leafName)))
+      return rv;
+    if (NS_FAILED(rv = newParent->Exists(&dirCheck)))
+      return rv;
+    if (dirCheck)
+      return NS_ERROR_FILE_ALREADY_EXISTS; // dest exists
+    if (NS_FAILED(rv = newParent->Create(DIRECTORY_TYPE, oldPerms)))
+      return rv;
+  }
+
+  nsCOMPtr<nsISimpleEnumerator> dirIterator;
+  if (NS_FAILED(rv = GetDirectoryEntries(getter_AddRefs(dirIterator))))
+    return rv;
+
+  bool hasMore = false;
+  while (dirIterator->HasMoreElements(&hasMore), hasMore) {
+    nsCOMPtr<nsISupports> supports;
+    nsCOMPtr<nsIFile> entry;
+    rv = dirIterator->GetNext(getter_AddRefs(supports));
+    entry = do_QueryInterface(supports);
+    if (NS_FAILED(rv) || !entry)
+      continue;
+    if (NS_FAILED(rv = entry->IsSymlink(&isSymlink)))
+      return rv;
+    if (NS_FAILED(rv = entry->IsDirectory(&dirCheck)))
+      return rv;
+    if (dirCheck && !isSymlink) {
+      nsCOMPtr<nsIFile> destClone;
+      rv = newParent->Clone(getter_AddRefs(destClone));
+      if (NS_SUCCEEDED(rv)) {
+        if (NS_FAILED(rv = entry->CopyToNative(destClone, EmptyCString()))) {
+#ifdef DEBUG
+          nsresult rv2;
+          nsAutoCString pathName;
+          if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
+            return rv2;
+          printf("Operation not supported: %s\n", pathName.get());
+#endif
+          if (rv == NS_ERROR_OUT_OF_MEMORY)
             return rv;
-    } else {    // dir exists lets try to use leaf
-        nsAutoCString leafName;
-        if (NS_FAILED(rv = GetNativeLeafName(leafName)))
-            return rv;
-        if (NS_FAILED(rv = newParent->AppendNative(leafName)))
-            return rv;
-        if (NS_FAILED(rv = newParent->Exists(&dirCheck)))
-            return rv;
-        if (dirCheck) 
-            return NS_ERROR_FILE_ALREADY_EXISTS; // dest exists
-        if (NS_FAILED(rv = newParent->Create(DIRECTORY_TYPE, oldPerms)))
-            return rv;
+          continue;
+        }
+      }
+    } else {
+      if (NS_FAILED(rv = entry->CopyToNative(newParent, EmptyCString()))) {
+#ifdef DEBUG
+        nsresult rv2;
+        nsAutoCString pathName;
+        if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
+          return rv2;
+        printf("Operation not supported: %s\n", pathName.get());
+#endif
+        if (rv == NS_ERROR_OUT_OF_MEMORY)
+          return rv;
+        continue;
+      }
     }
-
-    nsCOMPtr<nsISimpleEnumerator> dirIterator;
-    if (NS_FAILED(rv = GetDirectoryEntries(getter_AddRefs(dirIterator))))
-        return rv;
-
-    bool hasMore = false;
-    while (dirIterator->HasMoreElements(&hasMore), hasMore) {
-        nsCOMPtr<nsISupports> supports;
-        nsCOMPtr<nsIFile> entry;
-        rv = dirIterator->GetNext(getter_AddRefs(supports));
-        entry = do_QueryInterface(supports);
-        if (NS_FAILED(rv) || !entry)
-            continue;
-        if (NS_FAILED(rv = entry->IsSymlink(&isSymlink)))
-            return rv;
-        if (NS_FAILED(rv = entry->IsDirectory(&dirCheck)))
-            return rv;
-        if (dirCheck && !isSymlink) {
-            nsCOMPtr<nsIFile> destClone;
-            rv = newParent->Clone(getter_AddRefs(destClone));
-            if (NS_SUCCEEDED(rv)) {
-                if (NS_FAILED(rv = entry->CopyToNative(destClone, EmptyCString()))) {
-#ifdef DEBUG
-                    nsresult rv2;
-                    nsAutoCString pathName;
-                    if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
-                        return rv2;
-                    printf("Operation not supported: %s\n", pathName.get());
-#endif
-                    if (rv == NS_ERROR_OUT_OF_MEMORY) 
-                        return rv;
-                    continue;
-                }
-            }
-        } else {
-            if (NS_FAILED(rv = entry->CopyToNative(newParent, EmptyCString()))) {
-#ifdef DEBUG
-                nsresult rv2;
-                nsAutoCString pathName;
-                if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
-                    return rv2;
-                printf("Operation not supported: %s\n", pathName.get());
-#endif
-                if (rv == NS_ERROR_OUT_OF_MEMORY) 
-                    return rv;
-                continue;
-            }
-        }
-    }
-    return NS_OK;
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::CopyToNative(nsIFile *newParent, const nsACString &newName)
 {
-    nsresult rv;
-    // check to make sure that this has been initialized properly
-    CHECK_mPath();
-
-    // we copy the parent here so 'newParent' remains immutable
-    nsCOMPtr <nsIFile> workParent;
-    if (newParent) {
-        if (NS_FAILED(rv = newParent->Clone(getter_AddRefs(workParent))))
-            return rv;
-    } else {
-        if (NS_FAILED(rv = GetParent(getter_AddRefs(workParent))))
-            return rv;
-    }
-    
-    // check to see if we are a directory or if we are a file
-    bool isDirectory;
-    if (NS_FAILED(rv = IsDirectory(&isDirectory)))
+  nsresult rv;
+  // check to make sure that this has been initialized properly
+  CHECK_mPath();
+
+  // we copy the parent here so 'newParent' remains immutable
+  nsCOMPtr <nsIFile> workParent;
+  if (newParent) {
+    if (NS_FAILED(rv = newParent->Clone(getter_AddRefs(workParent))))
+      return rv;
+  } else {
+    if (NS_FAILED(rv = GetParent(getter_AddRefs(workParent))))
+      return rv;
+  }
+
+  // check to see if we are a directory or if we are a file
+  bool isDirectory;
+  if (NS_FAILED(rv = IsDirectory(&isDirectory)))
+    return rv;
+
+  nsAutoCString newPathName;
+  if (isDirectory) {
+    if (!newName.IsEmpty()) {
+      if (NS_FAILED(rv = workParent->AppendNative(newName)))
         return rv;
-
-    nsAutoCString newPathName;
-    if (isDirectory) {
-        if (!newName.IsEmpty()) {
-            if (NS_FAILED(rv = workParent->AppendNative(newName)))
-                return rv;
-        } else {
-            if (NS_FAILED(rv = GetNativeLeafName(newPathName)))
-                return rv;
-            if (NS_FAILED(rv = workParent->AppendNative(newPathName)))
-                return rv;
-        }
-        if (NS_FAILED(rv = CopyDirectoryTo(workParent)))
-            return rv;
     } else {
-        rv = GetNativeTargetPathName(workParent, newName, newPathName);
-        if (NS_FAILED(rv)) 
-            return rv;
+      if (NS_FAILED(rv = GetNativeLeafName(newPathName)))
+        return rv;
+      if (NS_FAILED(rv = workParent->AppendNative(newPathName)))
+        return rv;
+    }
+    if (NS_FAILED(rv = CopyDirectoryTo(workParent)))
+      return rv;
+  } else {
+    rv = GetNativeTargetPathName(workParent, newName, newPathName);
+    if (NS_FAILED(rv))
+      return rv;
 
 #ifdef DEBUG_blizzard
-        printf("nsLocalFile::CopyTo() %s -> %s\n", mPath.get(), newPathName.get());
+    printf("nsLocalFile::CopyTo() %s -> %s\n", mPath.get(), newPathName.get());
 #endif
 
-        // actually create the file.
-        nsLocalFile *newFile = new nsLocalFile();
-        if (!newFile)
-            return NS_ERROR_OUT_OF_MEMORY;
-
-        nsCOMPtr<nsIFile> fileRef(newFile); // release on exit
-
-        rv = newFile->InitWithNativePath(newPathName);
-        if (NS_FAILED(rv))
-            return rv;
-
-        // get the old permissions
-        uint32_t myPerms;
-        GetPermissions(&myPerms);
-
-        // Create the new file with the old file's permissions, even if write
-        // permission is missing.  We can't create with write permission and
-        // then change back to myPerm on all filesystems (FAT on Linux, e.g.).
-        // But we can write to a read-only file on all Unix filesystems if we
-        // open it successfully for writing.
-
-        PRFileDesc *newFD;
-        rv = newFile->CreateAndKeepOpen(NORMAL_FILE_TYPE,
-                                        PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE,
-                                        myPerms,
-                                        &newFD);
-        if (NS_FAILED(rv))
-            return rv;
-
-        // open the old file, too
-        bool specialFile;
-        if (NS_FAILED(rv = IsSpecial(&specialFile))) {
-            PR_Close(newFD);
-            return rv;
-        }
-        if (specialFile) {
+    // actually create the file.
+    nsLocalFile *newFile = new nsLocalFile();
+    if (!newFile)
+      return NS_ERROR_OUT_OF_MEMORY;
+
+    nsCOMPtr<nsIFile> fileRef(newFile); // release on exit
+
+    rv = newFile->InitWithNativePath(newPathName);
+    if (NS_FAILED(rv))
+      return rv;
+
+    // get the old permissions
+    uint32_t myPerms;
+    GetPermissions(&myPerms);
+
+    // Create the new file with the old file's permissions, even if write
+    // permission is missing.  We can't create with write permission and
+    // then change back to myPerm on all filesystems (FAT on Linux, e.g.).
+    // But we can write to a read-only file on all Unix filesystems if we
+    // open it successfully for writing.
+
+    PRFileDesc *newFD;
+    rv = newFile->CreateAndKeepOpen(NORMAL_FILE_TYPE,
+                                    PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE,
+                                    myPerms,
+                                    &newFD);
+    if (NS_FAILED(rv))
+      return rv;
+
+    // open the old file, too
+    bool specialFile;
+    if (NS_FAILED(rv = IsSpecial(&specialFile))) {
+      PR_Close(newFD);
+      return rv;
+    }
+    if (specialFile) {
 #ifdef DEBUG
-            printf("Operation not supported: %s\n", mPath.get());
+      printf("Operation not supported: %s\n", mPath.get());
 #endif
-            // make sure to clean up properly
-            PR_Close(newFD);
-            return NS_OK;
-        }
-               
-        PRFileDesc *oldFD;
-        rv = OpenNSPRFileDesc(PR_RDONLY, myPerms, &oldFD);
-        if (NS_FAILED(rv)) {
-            // make sure to clean up properly
-            PR_Close(newFD);
-            return rv;
-        }
+      // make sure to clean up properly
+      PR_Close(newFD);
+      return NS_OK;
+    }
+
+    PRFileDesc *oldFD;
+    rv = OpenNSPRFileDesc(PR_RDONLY, myPerms, &oldFD);
+    if (NS_FAILED(rv)) {
+      // make sure to clean up properly
+      PR_Close(newFD);
+      return rv;
+    }
 
 #ifdef DEBUG_blizzard
-        int32_t totalRead = 0;
-        int32_t totalWritten = 0;
+    int32_t totalRead = 0;
+    int32_t totalWritten = 0;
 #endif
-        char buf[BUFSIZ];
-        int32_t bytesRead;
-
-        // record PR_Write() error for better error message later.
-        nsresult saved_write_error = NS_OK;
-        nsresult saved_read_error = NS_OK;
-        nsresult saved_read_close_error = NS_OK;
-        nsresult saved_write_close_error = NS_OK;
-
-        // DONE: Does PR_Read() return bytesRead < 0 for error?
-        // Yes., The errors from PR_Read are not so common and
-        // the value may not ha