Bug 688012 - Move the open-brace for if, else, for, while, and switch to the same line as the keyword or condition. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 14 Oct 2011 10:52:48 -0700
changeset 78743 2efe763ee2ca511dd5461de4d5e9a013bc48e0f6
parent 78742 0a2a7c748da6a979a262067d5ae4684db82b7c52
child 78744 25a5c9891392c72ac42f2771176d3f0d803ae890
push idunknown
push userunknown
push dateunknown
reviewersmrbkap
bugs688012
milestone10.0a1
Bug 688012 - Move the open-brace for if, else, for, while, and switch to the same line as the keyword or condition. r=mrbkap xpcfix -bpc `find | grep -P "cpp$|h$" | perl -pe 's/\n/ /'` This is a huge, repetitive patch, and I confess having only skimmed a lot of it. I'm reasonably confident in the tool here though. Updated to fix 'else' as well.
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/src/XPCCallContext.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCContext.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCDebug.cpp
js/xpconnect/src/XPCException.cpp
js/xpconnect/src/XPCInlines.h
js/xpconnect/src/XPCJSID.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCJSWeakReference.cpp
js/xpconnect/src/XPCLog.cpp
js/xpconnect/src/XPCLog.h
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/XPCQuickStubs.h
js/xpconnect/src/XPCRuntimeService.cpp
js/xpconnect/src/XPCStack.cpp
js/xpconnect/src/XPCString.cpp
js/xpconnect/src/XPCThreadContext.cpp
js/xpconnect/src/XPCThrower.cpp
js/xpconnect/src/XPCVariant.cpp
js/xpconnect/src/XPCWrappedJS.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeInfo.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/src/XPCWrappedNativeProto.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/nsDOMQS.h
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -227,48 +227,44 @@ mozJSSubScriptLoader::LoadSubScript (con
     rv = cc->GetArgvPtr (&argv);
     if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
     jsval *rval;
     rv = cc->GetRetValPtr (&rval);
     if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
     /* set mJSPrincipals if it's not here already */
-    if (!mSystemPrincipal)
-    {
+    if (!mSystemPrincipal) {
         nsCOMPtr<nsIScriptSecurityManager> secman =
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
         if (!secman)
             return rv;
 
         rv = secman->GetSystemPrincipal(getter_AddRefs(mSystemPrincipal));
         if (NS_FAILED(rv) || !mSystemPrincipal)
             return rv;
     }
 
     JSAutoRequest ar(cx);
 
     JSString *url;
     JSObject *target_obj = nsnull;
     jschar   *charset = nsnull;
     ok = JS_ConvertArguments (cx, argc, argv, "S / o W", &url, &target_obj, &charset);
-    if (!ok)
-    {
+    if (!ok) {
         /* let the exception raised by JS_ConvertArguments show through */
         return NS_OK;
     }
 
     JSAutoByteString urlbytes(cx, url);
-    if (!urlbytes)
-    {
+    if (!urlbytes) {
         return NS_OK;
     }
 
-    if (!target_obj)
-    {
+    if (!target_obj) {
         /* if the user didn't provide an object to eval onto, find the global
          * object by walking the parent chain of the calling object */
 
 #ifdef DEBUG_rginda
         JSObject *got_glob = JS_GetGlobalObject (cx);
         fprintf (stderr, "JS_GetGlobalObject says glob is %p.\n", got_glob);
         target_obj = JS_GetPrototype (cx, got_glob);
         fprintf (stderr, "That glob's prototype is %p.\n", target_obj);
@@ -282,18 +278,17 @@ mozJSSubScriptLoader::LoadSubScript (con
 
         rv = wn->GetJSObject (&target_obj);
         if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
 #ifdef DEBUG_rginda
         fprintf (stderr, "Parent chain: %p", target_obj);
 #endif
         JSObject *maybe_glob = JS_GetParent (cx, target_obj);
-        while (maybe_glob != nsnull)
-        {
+        while (maybe_glob != nsnull) {
 #ifdef DEBUG_rginda
             fprintf (stderr, ", %p", maybe_glob);
 #endif
             target_obj = maybe_glob;
             maybe_glob = JS_GetParent (cx, maybe_glob);
         }
 #ifdef DEBUG_rginda
         fprintf (stderr, "\n");
@@ -303,18 +298,17 @@ mozJSSubScriptLoader::LoadSubScript (con
     // Remember an object out of the calling compartment so that we
     // can properly wrap the result later.
     nsCOMPtr<nsIPrincipal> principal = mSystemPrincipal;
     JSObject *result_obj = target_obj;
     target_obj = JS_FindCompilationScope(cx, target_obj);
     if (!target_obj)
         return NS_ERROR_FAILURE;
 
-    if (target_obj != result_obj)
-    {
+    if (target_obj != result_obj) {
         nsCOMPtr<nsIScriptSecurityManager> secman =
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
         if (!secman)
             return NS_ERROR_FAILURE;
 
         rv = secman->GetObjectPrincipal(cx, target_obj, getter_AddRefs(principal));
         NS_ENSURE_SUCCESS(rv, rv);
 
@@ -340,18 +334,17 @@ mozJSSubScriptLoader::LoadSubScript (con
     do
     {
         frame = JS_FrameIterator(cx, &frame);
 
         if (frame)
             script = JS_GetFrameScript(cx, frame);
     } while (frame && !script);
 
-    if (!script)
-    {
+    if (!script) {
         // No script means we don't know who's calling, bail.
 
         return NS_ERROR_FAILURE;
     }
 
     // Suppress caching if we're compiling as content.
     StartupCache* cache = (principal == mSystemPrincipal)
                           ? StartupCache::GetSingleton()
@@ -373,18 +366,17 @@ mozJSSubScriptLoader::LoadSubScript (con
         return ReportError(cx, LOAD_ERROR_NOSPEC);
     }
 
     rv = uri->GetScheme(scheme);
     if (NS_FAILED(rv)) {
         return ReportError(cx, LOAD_ERROR_NOSCHEME);
     }
 
-    if (!scheme.EqualsLiteral("chrome"))
-    {
+    if (!scheme.EqualsLiteral("chrome")) {
         // This might be a URI to a local file, though!
         nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(uri);
         nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(innerURI);
         if (!fileURL) {
             return ReportError(cx, LOAD_ERROR_URI_NOT_LOCAL);
         }
 
         // For file URIs prepend the filename with the filename of the
--- a/js/xpconnect/src/XPCCallContext.cpp
+++ b/js/xpconnect/src/XPCCallContext.cpp
@@ -104,44 +104,40 @@ XPCCallContext::Init(XPCContext::LangTyp
     mThreadData = XPCPerThreadData::GetData(mJSContext);
 
     if (!mThreadData)
         return;
 
     XPCJSContextStack* stack = mThreadData->GetJSContextStack();
     JSContext* topJSContext;
 
-    if (!stack || NS_FAILED(stack->Peek(&topJSContext)))
-    {
+    if (!stack || NS_FAILED(stack->Peek(&topJSContext))) {
         // If we don't have a stack we're probably in shutdown.
         NS_ASSERTION(!stack, "Bad, Peek failed!");
         mJSContext = nsnull;
         return;
     }
 
-    if (!mJSContext)
-    {
+    if (!mJSContext) {
         // This is slightly questionable. If called without an explicit
         // JSContext (generally a call to a wrappedJS) we will use the JSContext
         // on the top of the JSContext stack - if there is one - *before*
         // falling back on the safe JSContext.
         // This is good AND bad because it makes calls from JS -> native -> JS
         // have JS stack 'continuity' for purposes of stack traces etc.
         // Note: this *is* what the pre-XPCCallContext xpconnect did too.
 
         if (topJSContext)
             mJSContext = topJSContext;
         else if (NS_FAILED(stack->GetSafeJSContext(&mJSContext)) || !mJSContext)
             return;
     }
 
-    if (topJSContext != mJSContext)
-    {
-        if (NS_FAILED(stack->Push(mJSContext)))
-        {
+    if (topJSContext != mJSContext) {
+        if (NS_FAILED(stack->Push(mJSContext))) {
             NS_ERROR("bad!");
             return;
         }
         mContextPopRequired = JS_TRUE;
     }
 
     // Get into the request as early as we can to avoid problems with scanning
     // callcontexts on other threads from within the gc callbacks.
@@ -171,35 +167,32 @@ XPCCallContext::Init(XPCContext::LangTyp
 
     mState = HAVE_SCOPE;
 
     mMethodIndex = 0xDEAD;
 
     mState = HAVE_OBJECT;
 
     mTearOff = nsnull;
-    if (wrapperInitOptions == INIT_SHOULD_LOOKUP_WRAPPER)
-    {
+    if (wrapperInitOptions == INIT_SHOULD_LOOKUP_WRAPPER) {
         mWrapper = XPCWrappedNative::GetWrappedNativeOfJSObject(mJSContext, obj,
                                                                 funobj,
                                                                 &mFlattenedJSObject,
                                                                 &mTearOff);
-        if (mWrapper)
-        {
+        if (mWrapper) {
             DEBUG_CheckWrapperThreadSafety(mWrapper);
 
             mFlattenedJSObject = mWrapper->GetFlatJSObject();
 
             if (mTearOff)
                 mScriptableInfo = nsnull;
             else
                 mScriptableInfo = mWrapper->GetScriptableInfo();
         }
-        else
-        {
+        else {
             NS_ABORT_IF_FALSE(!mFlattenedJSObject || IS_SLIM_WRAPPER(mFlattenedJSObject),
                               "should have a slim wrapper");
         }
     }
 
     if (!JSID_IS_VOID(name))
         SetName(name);
 
@@ -211,41 +204,37 @@ XPCCallContext::Init(XPCContext::LangTyp
 
 void
 XPCCallContext::SetName(jsid name)
 {
     CHECK_STATE(HAVE_OBJECT);
 
     mName = name;
 
-    if (mTearOff)
-    {
+    if (mTearOff) {
         mSet = nsnull;
         mInterface = mTearOff->GetInterface();
         mMember = mInterface->FindMember(name);
         mStaticMemberIsLocal = JS_TRUE;
         if (mMember && !mMember->IsConstant())
             mMethodIndex = mMember->GetIndex();
     }
-    else
-    {
+    else {
         mSet = mWrapper ? mWrapper->GetSet() : nsnull;
 
         if (mSet &&
             mSet->FindMember(name, &mMember, &mInterface,
                              mWrapper->HasProto() ?
                              mWrapper->GetProto()->GetSet() :
                              nsnull,
-                             &mStaticMemberIsLocal))
-        {
+                             &mStaticMemberIsLocal)) {
             if (mMember && !mMember->IsConstant())
                 mMethodIndex = mMember->GetIndex();
         }
-        else
-        {
+        else {
             mMember = nsnull;
             mInterface = nsnull;
             mStaticMemberIsLocal = JS_FALSE;
         }
     }
 
     mState = HAVE_NAME;
 }
@@ -275,18 +264,17 @@ XPCCallContext::SetCallInfo(XPCNativeInt
 
 void
 XPCCallContext::SetArgsAndResultPtr(uintN argc,
                                     jsval *argv,
                                     jsval *rval)
 {
     CHECK_STATE(HAVE_OBJECT);
 
-    if (mState < HAVE_NAME)
-    {
+    if (mState < HAVE_NAME) {
         mSet = nsnull;
         mInterface = nsnull;
         mMember = nsnull;
         mStaticMemberIsLocal = JS_FALSE;
     }
 
     mArgc   = argc;
     mArgv   = argv;
@@ -301,21 +289,19 @@ XPCCallContext::CanCallNow()
 {
     nsresult rv;
 
     if (!HasInterfaceAndMember())
         return NS_ERROR_UNEXPECTED;
     if (mState < HAVE_ARGS)
         return NS_ERROR_UNEXPECTED;
 
-    if (!mTearOff)
-    {
+    if (!mTearOff) {
         mTearOff = mWrapper->FindTearOff(*this, mInterface, JS_FALSE, &rv);
-        if (!mTearOff || mTearOff->GetInterface() != mInterface)
-        {
+        if (!mTearOff || mTearOff->GetInterface() != mInterface) {
             mTearOff = nsnull;
             return NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED;
         }
     }
 
     // Refresh in case FindTearOff extended the set
     mSet = mWrapper->GetSet();
 
@@ -338,108 +324,98 @@ XPCCallContext::SystemIsBeingShutDown()
 }
 
 XPCCallContext::~XPCCallContext()
 {
     // do cleanup...
 
     bool shouldReleaseXPC = false;
 
-    if (mXPCContext)
-    {
+    if (mXPCContext) {
         mXPCContext->SetCallingLangType(mPrevCallerLanguage);
 
 #ifdef DEBUG
         XPCCallContext* old = mThreadData->SetCallContext(mPrevCallContext);
         NS_ASSERTION(old == this, "bad pop from per thread data");
 #else
         (void) mThreadData->SetCallContext(mPrevCallContext);
 #endif
 
         shouldReleaseXPC = mPrevCallContext == nsnull;
     }
 
     // NB: Needs to happen before the context stack pop.
     if (mJSContext && mCallerLanguage == NATIVE_CALLER)
         JS_EndRequest(mJSContext);
 
-    if (mContextPopRequired)
-    {
+    if (mContextPopRequired) {
         XPCJSContextStack* stack = mThreadData->GetJSContextStack();
         NS_ASSERTION(stack, "bad!");
-        if (stack)
-        {
+        if (stack) {
 #ifdef DEBUG
             JSContext* poppedCX;
             nsresult rv = stack->Pop(&poppedCX);
             NS_ASSERTION(NS_SUCCEEDED(rv) && poppedCX == mJSContext, "bad pop");
 #else
             (void) stack->Pop(nsnull);
 #endif
         }
     }
 
-    if (mJSContext)
-    {
-        if (mDestroyJSContextInDestructor)
-        {
+    if (mJSContext) {
+        if (mDestroyJSContextInDestructor) {
 #ifdef DEBUG_xpc_hacker
             printf("!xpc - doing deferred destruction of JSContext @ %p\n",
                    mJSContext);
 #endif
             NS_ASSERTION(!mThreadData->GetJSContextStack() ||
                          !mThreadData->GetJSContextStack()->
                          DEBUG_StackHasJSContext(mJSContext),
                          "JSContext still in threadjscontextstack!");
 
             JS_DestroyContext(mJSContext);
         }
     }
 
 #ifdef DEBUG
-    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
-    {
+    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) {
         NS_ASSERTION(!mScratchStrings[i].mInUse, "Uh, string wrapper still in use!");
     }
 #endif
 
     if (shouldReleaseXPC && mXPC)
         NS_RELEASE(mXPC);
 }
 
 XPCReadableJSStringWrapper *
 XPCCallContext::NewStringWrapper(const PRUnichar *str, PRUint32 len)
 {
-    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
-    {
+    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) {
         StringWrapperEntry& ent = mScratchStrings[i];
 
-        if (!ent.mInUse)
-        {
+        if (!ent.mInUse) {
             ent.mInUse = PR_TRUE;
 
             // Construct the string using placement new.
 
             return new (ent.mString.addr()) XPCReadableJSStringWrapper(str, len);
         }
     }
 
     // All our internal string wrappers are used, allocate a new string.
 
     return new XPCReadableJSStringWrapper(str, len);
 }
 
 void
 XPCCallContext::DeleteString(nsAString *string)
 {
-    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i)
-    {
+    for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) {
         StringWrapperEntry& ent = mScratchStrings[i];
-        if (string == ent.mString.addr())
-        {
+        if (string == ent.mString.addr()) {
             // One of our internal strings is no longer in use, mark
             // it as such and destroy the string.
 
             ent.mInUse = PR_FALSE;
             ent.mString.addr()->~XPCReadableJSStringWrapper();
 
             return;
         }
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -73,18 +73,17 @@ JSValIsInterfaceOfType(JSContext *cx, js
     nsCOMPtr<nsIXPConnect> xpc;
     nsCOMPtr<nsIXPConnectWrappedNative> wn;
     nsCOMPtr<nsISupports> sup;
     nsISupports* iface;
     if (!JSVAL_IS_PRIMITIVE(v) &&
         nsnull != (xpc = nsXPConnect::GetXPConnect()) &&
         NS_SUCCEEDED(xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(v),
                                                      getter_AddRefs(wn))) && wn &&
-        NS_SUCCEEDED(wn->Native()->QueryInterface(iid, (void**)&iface)) && iface)
-    {
+        NS_SUCCEEDED(wn->Native()->QueryInterface(iid, (void**)&iface)) && iface) {
         NS_RELEASE(iface);
         return JS_TRUE;
     }
     return JS_FALSE;
 }
 
 char* xpc_CloneAllAccess()
 {
@@ -260,18 +259,17 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 NS_IMETHODIMP
 nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
                                          JSContext * cx, JSObject * obj,
                                          PRUint32 enum_op, jsval * statep,
                                          jsid * idp, bool *_retval)
 {
     nsIEnumerator* e;
 
-    switch (enum_op)
-    {
+    switch (enum_op) {
         case JSENUMERATE_INIT:
         case JSENUMERATE_INIT_ALL:
         {
             if (!mManager ||
                 NS_FAILED(mManager->EnumerateInterfaces(&e)) || !e ||
                 NS_FAILED(e->First()))
 
             {
@@ -285,39 +283,34 @@ nsXPCComponents_Interfaces::NewEnumerate
             return NS_OK;
         }
         case JSENUMERATE_NEXT:
         {
             nsCOMPtr<nsISupports> isup;
 
             e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
 
-            while (1)
-            {
+            while (1) {
                 if (NS_ENUMERATOR_FALSE == e->IsDone() &&
-                    NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup)
-                {
+                    NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup) {
                     e->Next();
                     nsCOMPtr<nsIInterfaceInfo> iface(do_QueryInterface(isup));
-                    if (iface)
-                    {
+                    if (iface) {
                         JSString* idstr;
                         const char* name;
                         bool scriptable;
 
                         if (NS_SUCCEEDED(iface->IsScriptable(&scriptable)) &&
-                            !scriptable)
-                        {
+                            !scriptable) {
                             continue;
                         }
 
                         if (NS_SUCCEEDED(iface->GetNameShared(&name)) && name &&
                             nsnull != (idstr = JS_NewStringCopyZ(cx, name)) &&
-                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
-                        {
+                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp)) {
                             return NS_OK;
                         }
                     }
                 }
                 // else...
                 break;
             }
             // FALL THROUGH
@@ -338,41 +331,36 @@ nsXPCComponents_Interfaces::NewResolve(n
                                        JSContext * cx, JSObject * obj,
                                        jsid id, PRUint32 flags,
                                        JSObject * *objp, bool *_retval)
 {
     JSAutoByteString name;
     if (mManager &&
         JSID_IS_STRING(id) &&
         name.encode(cx, JSID_TO_STRING(id)) &&
-        name.ptr()[0] != '{') // we only allow interfaces by name here
-    {
+        name.ptr()[0] != '{') { // we only allow interfaces by name here
         nsCOMPtr<nsIInterfaceInfo> info;
         mManager->GetInfoForName(name.ptr(), getter_AddRefs(info));
         if (!info)
             return NS_OK;
 
         nsCOMPtr<nsIJSIID> nsid =
             dont_AddRef(static_cast<nsIJSIID*>(nsJSIID::NewID(info)));
 
-        if (nsid)
-        {
+        if (nsid) {
             nsCOMPtr<nsIXPConnect> xpc;
             wrapper->GetXPConnect(getter_AddRefs(xpc));
-            if (xpc)
-            {
+            if (xpc) {
                 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
                 if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
                                                  static_cast<nsIJSIID*>(nsid),
                                                  NS_GET_IID(nsIJSIID),
-                                                 getter_AddRefs(holder))))
-                {
+                                                 getter_AddRefs(holder)))) {
                     JSObject* idobj;
-                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
-                    {
+                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj))) {
                         *objp = obj;
                         *_retval = JS_DefinePropertyById(cx, obj, id,
                                                          OBJECT_TO_JSVAL(idobj),
                                                          nsnull, nsnull,
                                                          JSPROP_ENUMERATE |
                                                          JSPROP_READONLY |
                                                          JSPROP_PERMANENT);
                     }
@@ -572,18 +560,17 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 NS_IMETHODIMP
 nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
                                              JSContext * cx, JSObject * obj,
                                              PRUint32 enum_op, jsval * statep,
                                              jsid * idp, bool *_retval)
 {
     nsIEnumerator* e;
 
-    switch (enum_op)
-    {
+    switch (enum_op) {
         case JSENUMERATE_INIT:
         case JSENUMERATE_INIT_ALL:
         {
             if (!mManager ||
                 NS_FAILED(mManager->EnumerateInterfaces(&e)) || !e ||
                 NS_FAILED(e->First()))
 
             {
@@ -597,43 +584,37 @@ nsXPCComponents_InterfacesByID::NewEnume
             return NS_OK;
         }
         case JSENUMERATE_NEXT:
         {
             nsCOMPtr<nsISupports> isup;
 
             e = (nsIEnumerator*) JSVAL_TO_PRIVATE(*statep);
 
-            while (1)
-            {
+            while (1) {
                 if (NS_ENUMERATOR_FALSE == e->IsDone() &&
-                    NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup)
-                {
+                    NS_SUCCEEDED(e->CurrentItem(getter_AddRefs(isup))) && isup) {
                     e->Next();
                     nsCOMPtr<nsIInterfaceInfo> iface(do_QueryInterface(isup));
-                    if (iface)
-                    {
+                    if (iface) {
                         nsIID const *iid;
                         char idstr[NSID_LENGTH];
                         JSString* jsstr;
                         bool scriptable;
 
                         if (NS_SUCCEEDED(iface->IsScriptable(&scriptable)) &&
-                            !scriptable)
-                        {
+                            !scriptable) {
                             continue;
                         }
 
-                        if (NS_SUCCEEDED(iface->GetIIDShared(&iid)))
-                        {
+                        if (NS_SUCCEEDED(iface->GetIIDShared(&iid))) {
                             iid->ToProvidedString(idstr);
                             jsstr = JS_NewStringCopyZ(cx, idstr);
                             if (jsstr &&
-                                JS_ValueToId(cx, STRING_TO_JSVAL(jsstr), idp))
-                            {
+                                JS_ValueToId(cx, STRING_TO_JSVAL(jsstr), idp)) {
                                 return NS_OK;
                             }
                         }
                     }
                 }
                 // else...
                 break;
             }
@@ -656,18 +637,17 @@ nsXPCComponents_InterfacesByID::NewResol
                                            jsid id, PRUint32 flags,
                                            JSObject * *objp, bool *_retval)
 {
     const jschar* name = nsnull;
 
     if (mManager &&
         JSID_IS_STRING(id) &&
         38 == JS_GetStringLength(JSID_TO_STRING(id)) &&
-        nsnull != (name = JS_GetInternedStringChars(JSID_TO_STRING(id))))
-    {
+        nsnull != (name = JS_GetInternedStringChars(JSID_TO_STRING(id)))) {
         nsID iid;
         if (!iid.Parse(NS_ConvertUTF16toUTF8(name).get()))
             return NS_OK;
 
         nsCOMPtr<nsIInterfaceInfo> info;
         mManager->GetInfoForIID(&iid, getter_AddRefs(info));
         if (!info)
             return NS_OK;
@@ -675,27 +655,24 @@ nsXPCComponents_InterfacesByID::NewResol
         nsCOMPtr<nsIJSIID> nsid =
             dont_AddRef(static_cast<nsIJSIID*>(nsJSIID::NewID(info)));
 
         if (!nsid)
             return NS_ERROR_OUT_OF_MEMORY;
 
         nsCOMPtr<nsIXPConnect> xpc;
         wrapper->GetXPConnect(getter_AddRefs(xpc));
-        if (xpc)
-        {
+        if (xpc) {
             nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
             if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
                                              static_cast<nsIJSIID*>(nsid),
                                              NS_GET_IID(nsIJSIID),
-                                             getter_AddRefs(holder))))
-            {
+                                             getter_AddRefs(holder)))) {
                 JSObject* idobj;
-                if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
-                {
+                if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj))) {
                     *objp = obj;
                     *_retval =
                         JS_DefinePropertyById(cx, obj, id,
                                               OBJECT_TO_JSVAL(idobj),
                                               nsnull, nsnull,
                                               JSPROP_ENUMERATE |
                                               JSPROP_READONLY |
                                               JSPROP_PERMANENT);
@@ -890,53 +867,47 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 NS_IMETHODIMP
 nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
                                       JSContext * cx, JSObject * obj,
                                       PRUint32 enum_op, jsval * statep,
                                       jsid * idp, bool *_retval)
 {
     nsISimpleEnumerator* e;
 
-    switch (enum_op)
-    {
+    switch (enum_op) {
         case JSENUMERATE_INIT:
         case JSENUMERATE_INIT_ALL:
         {
             nsCOMPtr<nsIComponentRegistrar> compMgr;
             if (NS_FAILED(NS_GetComponentRegistrar(getter_AddRefs(compMgr))) || !compMgr ||
-                NS_FAILED(compMgr->EnumerateContractIDs(&e)) || !e )
-            {
+                NS_FAILED(compMgr->EnumerateContractIDs(&e)) || !e ) {
                 *statep = JSVAL_NULL;
                 return NS_ERROR_UNEXPECTED;
             }
 
             *statep = PRIVATE_TO_JSVAL(e);
             if (idp)
                 *idp = INT_TO_JSID(0); // indicate that we don't know the count
             return NS_OK;
         }
         case JSENUMERATE_NEXT:
         {
             nsCOMPtr<nsISupports> isup;
             bool hasMore;
             e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
 
             if (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore &&
-                NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup)
-            {
+                NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup) {
                 nsCOMPtr<nsISupportsCString> holder(do_QueryInterface(isup));
-                if (holder)
-                {
+                if (holder) {
                     nsCAutoString name;
-                    if (NS_SUCCEEDED(holder->GetData(name)))
-                    {
+                    if (NS_SUCCEEDED(holder->GetData(name))) {
                         JSString* idstr = JS_NewStringCopyN(cx, name.get(), name.Length());
                         if (idstr &&
-                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
-                        {
+                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp)) {
                             return NS_OK;
                         }
                     }
                 }
             }
             // else... FALL THROUGH
         }
 
@@ -956,35 +927,30 @@ nsXPCComponents_Classes::NewResolve(nsIX
                                     jsid id, PRUint32 flags,
                                     JSObject * *objp, bool *_retval)
 
 {
     JSAutoByteString name;
 
     if (JSID_IS_STRING(id) &&
         name.encode(cx, JSID_TO_STRING(id)) &&
-        name.ptr()[0] != '{') // we only allow contractids here
-    {
+        name.ptr()[0] != '{') { // we only allow contractids here
         nsCOMPtr<nsIJSCID> nsid =
             dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name.ptr())));
-        if (nsid)
-        {
+        if (nsid) {
             nsCOMPtr<nsIXPConnect> xpc;
             wrapper->GetXPConnect(getter_AddRefs(xpc));
-            if (xpc)
-            {
+            if (xpc) {
                 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
                 if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
                                                  static_cast<nsIJSCID*>(nsid),
                                                  NS_GET_IID(nsIJSCID),
-                                                 getter_AddRefs(holder))))
-                {
+                                                 getter_AddRefs(holder)))) {
                     JSObject* idobj;
-                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
-                    {
+                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj))) {
                         *objp = obj;
                         *_retval = JS_DefinePropertyById(cx, obj, id,
                                                          OBJECT_TO_JSVAL(idobj),
                                                          nsnull, nsnull,
                                                          JSPROP_ENUMERATE |
                                                          JSPROP_READONLY |
                                                          JSPROP_PERMANENT);
                     }
@@ -1140,54 +1106,48 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 NS_IMETHODIMP
 nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
                                           JSContext * cx, JSObject * obj,
                                           PRUint32 enum_op, jsval * statep,
                                           jsid * idp, bool *_retval)
 {
     nsISimpleEnumerator* e;
 
-    switch (enum_op)
-    {
+    switch (enum_op) {
         case JSENUMERATE_INIT:
         case JSENUMERATE_INIT_ALL:
         {
             nsCOMPtr<nsIComponentRegistrar> compMgr;
             if (NS_FAILED(NS_GetComponentRegistrar(getter_AddRefs(compMgr))) || !compMgr ||
-                NS_FAILED(compMgr->EnumerateCIDs(&e)) || !e )
-            {
+                NS_FAILED(compMgr->EnumerateCIDs(&e)) || !e ) {
                 *statep = JSVAL_NULL;
                 return NS_ERROR_UNEXPECTED;
             }
 
             *statep = PRIVATE_TO_JSVAL(e);
             if (idp)
                 *idp = INT_TO_JSID(0); // indicate that we don't know the count
             return NS_OK;
         }
         case JSENUMERATE_NEXT:
         {
             nsCOMPtr<nsISupports> isup;
             bool hasMore;
             e = (nsISimpleEnumerator*) JSVAL_TO_PRIVATE(*statep);
 
             if (NS_SUCCEEDED(e->HasMoreElements(&hasMore)) && hasMore &&
-                NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup)
-            {
+                NS_SUCCEEDED(e->GetNext(getter_AddRefs(isup))) && isup) {
                 nsCOMPtr<nsISupportsID> holder(do_QueryInterface(isup));
-                if (holder)
-                {
+                if (holder) {
                     char* name;
-                    if (NS_SUCCEEDED(holder->ToString(&name)) && name)
-                    {
+                    if (NS_SUCCEEDED(holder->ToString(&name)) && name) {
                         JSString* idstr = JS_NewStringCopyZ(cx, name);
                         nsMemory::Free(name);
                         if (idstr &&
-                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
-                        {
+                            JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp)) {
                             return NS_OK;
                         }
                     }
                 }
             }
             // else... FALL THROUGH
         }
 
@@ -1224,35 +1184,30 @@ nsXPCComponents_ClassesByID::NewResolve(
                                         jsid id, PRUint32 flags,
                                         JSObject * *objp, bool *_retval)
 {
     JSAutoByteString name;
 
     if (JSID_IS_STRING(id) &&
         name.encode(cx, JSID_TO_STRING(id)) &&
         name.ptr()[0] == '{' &&
-        IsRegisteredCLSID(name.ptr())) // we only allow canonical CLSIDs here
-    {
+        IsRegisteredCLSID(name.ptr())) { // we only allow canonical CLSIDs here
         nsCOMPtr<nsIJSCID> nsid =
             dont_AddRef(static_cast<nsIJSCID*>(nsJSCID::NewID(name.ptr())));
-        if (nsid)
-        {
+        if (nsid) {
             nsCOMPtr<nsIXPConnect> xpc;
             wrapper->GetXPConnect(getter_AddRefs(xpc));
-            if (xpc)
-            {
+            if (xpc) {
                 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
                 if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
                                                  static_cast<nsIJSCID*>(nsid),
                                                  NS_GET_IID(nsIJSCID),
-                                                 getter_AddRefs(holder))))
-                {
+                                                 getter_AddRefs(holder)))) {
                     JSObject* idobj;
-                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj)))
-                    {
+                    if (holder && NS_SUCCEEDED(holder->GetJSObject(&idobj))) {
                         *objp = obj;
                         *_retval = JS_DefinePropertyById(cx, obj, id,
                                                          OBJECT_TO_JSVAL(idobj),
                                                          nsnull, nsnull,
                                                          JSPROP_ENUMERATE |
                                                          JSPROP_READONLY |
                                                          JSPROP_PERMANENT);
                     }
@@ -1410,35 +1365,33 @@ NS_IMPL_THREADSAFE_RELEASE(nsXPCComponen
 NS_IMETHODIMP
 nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
                                       JSContext * cx, JSObject * obj,
                                       PRUint32 enum_op, jsval * statep,
                                       jsid * idp, bool *_retval)
 {
     void** iter;
 
-    switch (enum_op)
-    {
+    switch (enum_op) {
         case JSENUMERATE_INIT:
         case JSENUMERATE_INIT_ALL:
         {
             if (idp)
                 *idp = INT_TO_JSID(nsXPCException::GetNSResultCount());
 
             void** space = (void**) new char[sizeof(void*)];
             *space = nsnull;
             *statep = PRIVATE_TO_JSVAL(space);
             return NS_OK;
         }
         case JSENUMERATE_NEXT:
         {
             const char* name;
             iter = (void**) JSVAL_TO_PRIVATE(*statep);
-            if (nsXPCException::IterateNSResults(nsnull, &name, nsnull, iter))
-            {
+            if (nsXPCException::IterateNSResults(nsnull, &name, nsnull, iter)) {
                 JSString* idstr = JS_NewStringCopyZ(cx, name);
                 if (idstr && JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp))
                     return NS_OK;
             }
             // else... FALL THROUGH
         }
 
         case JSENUMERATE_DESTROY:
@@ -1455,35 +1408,31 @@ nsXPCComponents_Results::NewEnumerate(ns
 NS_IMETHODIMP
 nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
                                     JSContext * cx, JSObject * obj,
                                     jsid id, PRUint32 flags,
                                     JSObject * *objp, bool *_retval)
 {
     JSAutoByteString name;
 
-    if (JSID_IS_STRING(id) && name.encode(cx, JSID_TO_STRING(id)))
-    {
+    if (JSID_IS_STRING(id) && name.encode(cx, JSID_TO_STRING(id))) {
         const char* rv_name;
         void* iter = nsnull;
         nsresult rv;
-        while (nsXPCException::IterateNSResults(&rv, &rv_name, nsnull, &iter))
-        {
-            if (!strcmp(name.ptr(), rv_name))
-            {
+        while (nsXPCException::IterateNSResults(&rv, &rv_name, nsnull, &iter)) {
+            if (!strcmp(name.ptr(), rv_name)) {
                 jsval val;
 
                 *objp = obj;
                 if (!JS_NewNumberValue(cx, (jsdouble)rv, &val) ||
                     !JS_DefinePropertyById(cx, obj, id, val,
                                            nsnull, nsnull,
                                            JSPROP_ENUMERATE |
                                            JSPROP_READONLY |
-                                           JSPROP_PERMANENT))
-                {
+                                           JSPROP_PERMANENT)) {
                     return NS_ERROR_UNEXPECTED;
                 }
             }
         }
     }
     return NS_OK;
 }
 
@@ -1667,33 +1616,31 @@ nsXPCComponents_ID::CallOrConstruct(nsIX
         return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
 
     XPCContext* xpcc = ccx.GetXPCContext();
 
     // Do the security check if necessary
 
     nsIXPCSecurityManager* sm =
             xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_INSTANCE);
-    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsJSID::GetCID())))
-    {
+    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsJSID::GetCID()))) {
         // the security manager vetoed. It should have set an exception.
         *_retval = JS_FALSE;
         return NS_OK;
     }
 
     // convert the first argument into a string and see if it looks like an id
 
     JSString* jsstr;
     JSAutoByteString bytes;
     nsID id;
 
     if (!(jsstr = JS_ValueToString(cx, argv[0])) ||
         !bytes.encode(cx, jsstr) ||
-        !id.Parse(bytes.ptr()))
-    {
+        !id.Parse(bytes.ptr())) {
         return ThrowAndFail(NS_ERROR_XPC_BAD_ID_STRING, cx, _retval);
     }
 
     // make the new object and return it.
 
     JSObject* newobj = xpc_NewIDObject(cx, obj, id);
 
     if (vp)
@@ -1889,56 +1836,50 @@ nsXPCComponents_Exception::CallOrConstru
 
     nsXPConnect* xpc = ccx.GetXPConnect();
     XPCContext* xpcc = ccx.GetXPCContext();
 
     // Do the security check if necessary
 
     nsIXPCSecurityManager* sm =
             xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_INSTANCE);
-    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsXPCException::GetCID())))
-    {
+    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsXPCException::GetCID()))) {
         // the security manager vetoed. It should have set an exception.
         *_retval = JS_FALSE;
         return NS_OK;
     }
 
     // initialization params for the exception object we will create
     const char*             eMsg = "exception";
     JSAutoByteString        eMsgBytes;
     nsresult                eResult = NS_ERROR_FAILURE;
     nsCOMPtr<nsIStackFrame> eStack;
     nsCOMPtr<nsISupports>   eData;
 
     // all params are optional - grab any passed in
-    switch (argc)
-    {
+    switch (argc) {
         default:    // more than 4 - ignore extra
             // ...fall through...
         case 4:     // argv[3] is object for eData
-            if (JSVAL_IS_NULL(argv[3]))
-            {
+            if (JSVAL_IS_NULL(argv[3])) {
                 // do nothing, leave eData as null
             }
-            else
-            {
+            else {
                 if (JSVAL_IS_PRIMITIVE(argv[3]) ||
                     NS_FAILED(xpc->WrapJS(cx, JSVAL_TO_OBJECT(argv[3]),
                                           NS_GET_IID(nsISupports),
                                           (void**)getter_AddRefs(eData))))
                     return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
             }
             // ...fall through...
         case 3:     // argv[2] is object for eStack
-            if (JSVAL_IS_NULL(argv[2]))
-            {
+            if (JSVAL_IS_NULL(argv[2])) {
                 // do nothing, leave eStack as null
             }
-            else
-            {
+            else {
                 if (JSVAL_IS_PRIMITIVE(argv[2]) ||
                     NS_FAILED(xpc->WrapJS(cx, JSVAL_TO_OBJECT(argv[2]),
                                           NS_GET_IID(nsIStackFrame),
                                           (void**)getter_AddRefs(eStack))))
                     return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
             }
             // fall through...
         case 2:     // argv[1] is nsresult for eResult
@@ -1961,18 +1902,17 @@ nsXPCComponents_Exception::CallOrConstru
     if (!e)
         return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
 
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
     JSObject* newObj = nsnull;
 
     if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIXPCException),
                                   getter_AddRefs(holder))) || !holder ||
-        NS_FAILED(holder->GetJSObject(&newObj)) || !newObj)
-    {
+        NS_FAILED(holder->GetJSObject(&newObj)) || !newObj) {
         return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
     }
 
     if (vp)
         *vp = OBJECT_TO_JSVAL(newObj);
 
     return NS_OK;
 }
@@ -2222,52 +2162,47 @@ nsXPCConstructor::CallOrConstruct(nsIXPC
     JSObject* cidObj;
     JSObject* iidObj;
 
     if (NS_FAILED(xpc->WrapNative(cx, obj, mClassID, NS_GET_IID(nsIJSCID),
                                   getter_AddRefs(cidHolder))) || !cidHolder ||
         NS_FAILED(cidHolder->GetJSObject(&cidObj)) || !cidObj ||
         NS_FAILED(xpc->WrapNative(cx, obj, mInterfaceID, NS_GET_IID(nsIJSIID),
                                   getter_AddRefs(iidHolder))) || !iidHolder ||
-        NS_FAILED(iidHolder->GetJSObject(&iidObj)) || !iidObj)
-    {
+        NS_FAILED(iidHolder->GetJSObject(&iidObj)) || !iidObj) {
         return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
     }
 
     jsval ctorArgs[1] = {OBJECT_TO_JSVAL(iidObj)};
     jsval val;
 
     if (!JS_CallFunctionName(cx, cidObj, "createInstance", 1, ctorArgs, &val) ||
-        JSVAL_IS_PRIMITIVE(val))
-    {
+        JSVAL_IS_PRIMITIVE(val)) {
         // createInstance will have thrown an exception
         *_retval = JS_FALSE;
         return NS_OK;
     }
 
     // root the result
     if (vp)
         *vp = val;
 
     // call initializer method if supplied
-    if (mInitializer)
-    {
+    if (mInitializer) {
         JSObject* newObj = JSVAL_TO_OBJECT(val);
         jsval fun;
         jsval ignored;
 
         // first check existence of function property for better error reporting
         if (!JS_GetProperty(cx, newObj, mInitializer, &fun) ||
-            JSVAL_IS_PRIMITIVE(fun))
-        {
+            JSVAL_IS_PRIMITIVE(fun)) {
             return ThrowAndFail(NS_ERROR_XPC_BAD_INITIALIZER_NAME, cx, _retval);
         }
 
-        if (!JS_CallFunctionValue(cx, newObj, fun, argc, argv, &ignored))
-        {
+        if (!JS_CallFunctionValue(cx, newObj, fun, argc, argv, &ignored)) {
             // function should have thrown an exception
             *_retval = JS_FALSE;
             return NS_OK;
         }
     }
 
     return NS_OK;
 }
@@ -2459,83 +2394,76 @@ nsXPCComponents_Constructor::CallOrConst
 
     if (!xpc || !xpcc || !scope || !(comp = scope->GetComponents()))
         return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
 
     // Do the security check if necessary
 
     nsIXPCSecurityManager* sm =
             xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_INSTANCE);
-    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsXPCConstructor::GetCID())))
-    {
+    if (sm && NS_FAILED(sm->CanCreateInstance(cx, nsXPCConstructor::GetCID()))) {
         // the security manager vetoed. It should have set an exception.
         *_retval = JS_FALSE;
         return NS_OK;
     }
 
     // initialization params for the Constructor object we will create
     nsCOMPtr<nsIJSCID> cClassID;
     nsCOMPtr<nsIJSIID> cInterfaceID;
     const char*        cInitializer = nsnull;
     JSAutoByteString  cInitializerBytes;
 
-    if (argc >= 3)
-    {
+    if (argc >= 3) {
         // argv[2] is an initializer function or property name
         JSString* str = JS_ValueToString(cx, argv[2]);
         if (!str || !(cInitializer = cInitializerBytes.encode(cx, str)))
             return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
     }
 
-    if (argc >= 2)
-    {
+    if (argc >= 2) {
         // argv[1] is an iid name string
         // XXXjband support passing "Components.interfaces.foo"?
 
         nsCOMPtr<nsIXPCComponents_Interfaces> ifaces;
         nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
         JSObject* ifacesObj = nsnull;
 
         // we do the lookup by asking the Components.interfaces object
         // for the property with this name - i.e. we let its caching of these
         // nsIJSIID objects work for us.
 
         if (NS_FAILED(comp->GetInterfaces(getter_AddRefs(ifaces))) ||
             NS_FAILED(xpc->WrapNative(cx, obj, ifaces,
                                       NS_GET_IID(nsIXPCComponents_Interfaces),
                                       getter_AddRefs(holder))) || !holder ||
-            NS_FAILED(holder->GetJSObject(&ifacesObj)) || !ifacesObj)
-        {
+            NS_FAILED(holder->GetJSObject(&ifacesObj)) || !ifacesObj) {
             return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
         }
 
         JSString* str = JS_ValueToString(cx, argv[1]);
         jsid id;
         if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &id))
             return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
 
         jsval val;
         if (!JS_GetPropertyById(cx, ifacesObj, id, &val) || JSVAL_IS_PRIMITIVE(val))
             return ThrowAndFail(NS_ERROR_XPC_BAD_IID, cx, _retval);
 
         nsCOMPtr<nsIXPConnectWrappedNative> wn;
         if (NS_FAILED(xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(val),
                                                       getter_AddRefs(wn))) || !wn ||
-            !(cInterfaceID = do_QueryWrappedNative(wn)))
-        {
+            !(cInterfaceID = do_QueryWrappedNative(wn))) {
             return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
         }
     }
-    else
-    {
+    else {
         nsCOMPtr<nsIInterfaceInfo> info;
         xpc->GetInfoForIID(&NS_GET_IID(nsISupports), getter_AddRefs(info));
 
-        if (info)
-        {
+        if (info) {
             cInterfaceID =
                 dont_AddRef(static_cast<nsIJSIID*>(nsJSIID::NewID(info)));
         }
         if (!cInterfaceID)
             return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
     }
 
     // a new scope to avoid warnings about shadowed names
@@ -2550,52 +2478,49 @@ nsXPCComponents_Constructor::CallOrConst
         nsCOMPtr<nsIXPCComponents_Classes> classes;
         nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
         JSObject* classesObj = nsnull;
 
         if (NS_FAILED(comp->GetClasses(getter_AddRefs(classes))) ||
             NS_FAILED(xpc->WrapNative(cx, obj, classes,
                                       NS_GET_IID(nsIXPCComponents_Classes),
                                       getter_AddRefs(holder))) || !holder ||
-            NS_FAILED(holder->GetJSObject(&classesObj)) || !classesObj)
-        {
+            NS_FAILED(holder->GetJSObject(&classesObj)) || !classesObj) {
             return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
         }
 
         JSString* str = JS_ValueToString(cx, argv[0]);
         jsid id;
         if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &id))
             return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
 
         jsval val;
         if (!JS_GetPropertyById(cx, classesObj, id, &val) || JSVAL_IS_PRIMITIVE(val))
             return ThrowAndFail(NS_ERROR_XPC_BAD_CID, cx, _retval);
 
         nsCOMPtr<nsIXPConnectWrappedNative> wn;
         if (NS_FAILED(xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(val),
                                                       getter_AddRefs(wn))) || !wn ||
-            !(cClassID = do_QueryWrappedNative(wn)))
-        {
+            !(cClassID = do_QueryWrappedNative(wn))) {
             return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
         }
     }
 
     nsCOMPtr<nsIXPCConstructor> ctor =
         static_cast<nsIXPCConstructor*>
                    (new nsXPCConstructor(cClassID, cInterfaceID, cInitializer));
     if (!ctor)
         return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
 
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder2;
     JSObject* newObj = nsnull;
 
     if (NS_FAILED(xpc->WrapNative(cx, obj, ctor, NS_GET_IID(nsIXPCConstructor),
                                   getter_AddRefs(holder2))) || !holder2 ||
-        NS_FAILED(holder2->GetJSObject(&newObj)) || !newObj)
-    {
+        NS_FAILED(holder2->GetJSObject(&newObj)) || !newObj) {
         return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
     }
 
     if (vp)
         *vp = OBJECT_TO_JSVAL(newObj);
 
     return NS_OK;
 }
@@ -2870,18 +2795,17 @@ nsXPCComponents_Utils::ReportError()
     jsval* argv;
     rv = cc->GetArgvPtr(&argv);
     if (NS_FAILED(rv) || !argv)
         return NS_OK;
 
     const PRUint64 innerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
 
     JSErrorReport* err = JS_ErrorFromException(cx, argv[0]);
-    if (err)
-    {
+    if (err) {
         // It's a proper JS Error
         nsAutoString fileUni;
         CopyUTF8toUTF16(err->filename, fileUni);
 
         PRUint32 column = err->uctokenptr - err->uclinebuf;
 
         rv = scripterr->InitWithWindowID(reinterpret_cast<const PRUnichar*>
                                          (err->ucmessage),
@@ -2897,45 +2821,42 @@ nsXPCComponents_Utils::ReportError()
 
         nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scripterr);
         console->LogMessage(logError);
         return NS_OK;
     }
 
     // It's not a JS Error object, so we synthesize as best we're able
     JSString* msgstr = JS_ValueToString(cx, argv[0]);
-    if (msgstr)
-    {
+    if (msgstr) {
         // Root the string during scripterr->Init
         argv[0] = STRING_TO_JSVAL(msgstr);
 
         nsCOMPtr<nsIStackFrame> frame;
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
         if (xpc)
             xpc->GetCurrentJSStack(getter_AddRefs(frame));
 
         nsXPIDLCString fileName;
         PRInt32 lineNo = 0;
-        if (frame)
-        {
+        if (frame) {
             frame->GetFilename(getter_Copies(fileName));
             frame->GetLineNumber(&lineNo);
         }
 
         const jschar *msgchars = JS_GetStringCharsZ(cx, msgstr);
         if (!msgchars)
             return NS_OK;
 
         rv = scripterr->InitWithWindowID(reinterpret_cast<const PRUnichar *>(msgchars),
                                          NS_ConvertUTF8toUTF16(fileName).get(),
                                          nsnull,
                                          lineNo, 0, 0,
                                          "XPConnect JavaScript", innerWindowID);
-        if (NS_SUCCEEDED(rv))
-        {
+        if (NS_SUCCEEDED(rv)) {
             nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scripterr);
             console->LogMessage(logError);
         }
     }
 
     return NS_OK;
 }
 
@@ -3432,18 +3353,17 @@ private:
 };
 
 NS_IMPL_ISUPPORTS0(ContextHolder)
 
 ContextHolder::ContextHolder(JSContext *aOuterCx, JSObject *aSandbox)
     : mJSContext(JS_NewContext(JS_GetRuntime(aOuterCx), 1024)),
       mOrigCx(aOuterCx)
 {
-    if (mJSContext)
-    {
+    if (mJSContext) {
         JSAutoRequest ar(mJSContext);
         JS_SetOptions(mJSContext,
                       JS_GetOptions(mJSContext) |
                       JSOPTION_DONT_REPORT_UNCAUGHT |
                       JSOPTION_PRIVATE_IS_NSISUPPORTS);
         JS_SetGlobalObject(mJSContext, aSandbox);
         JS_SetContextPrivate(mJSContext, this);
         JS_SetOperationCallback(mJSContext, ContextHolderOperationCallback);
@@ -4295,30 +4215,27 @@ nsXPCComponents::GetProperty(nsIXPConnec
 {
     XPCContext* xpcc = XPCContext::GetXPCContext(cx);
     if (!xpcc)
         return NS_ERROR_FAILURE;
 
     bool doResult = JS_FALSE;
     nsresult res;
     XPCJSRuntime* rt = xpcc->GetRuntime();
-    if (id == rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT))
-    {
+    if (id == rt->GetStringID(XPCJSRuntime::IDX_LAST_RESULT)) {
         res = xpcc->GetLastResult();
         doResult = JS_TRUE;
     }
-    else if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
-    {
+    else if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE)) {
         res = xpcc->GetPendingResult();
         doResult = JS_TRUE;
     }
 
     nsresult rv = NS_OK;
-    if (doResult)
-    {
+    if (doResult) {
         if (!JS_NewNumberValue(cx, (jsdouble) res, vp))
             return NS_ERROR_OUT_OF_MEMORY;
         rv = NS_SUCCESS_I_DID_SOMETHING;
     }
 
     return rv;
 }
 
@@ -4331,21 +4248,19 @@ nsXPCComponents::SetProperty(nsIXPConnec
     XPCContext* xpcc = XPCContext::GetXPCContext(cx);
     if (!xpcc)
         return NS_ERROR_FAILURE;
 
     XPCJSRuntime* rt = xpcc->GetRuntime();
     if (!rt)
         return NS_ERROR_FAILURE;
 
-    if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE))
-    {
+    if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE)) {
         nsresult rv;
-        if (JS_ValueToECMAUint32(cx, *vp, (uint32*)&rv))
-        {
+        if (JS_ValueToECMAUint32(cx, *vp, (uint32*)&rv)) {
             xpcc->SetPendingResult(rv);
             xpcc->SetLastResult(rv);
             return NS_SUCCESS_I_DID_SOMETHING;
         }
         return NS_ERROR_FAILURE;
     }
 
     return NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN;
--- a/js/xpconnect/src/XPCContext.cpp
+++ b/js/xpconnect/src/XPCContext.cpp
@@ -69,18 +69,17 @@ XPCContext::~XPCContext()
     NS_ASSERTION(mJSContext->data2 == this, "Must match this");
     mJSContext->data2 = nsnull;
     NS_IF_RELEASE(mException);
     NS_IF_RELEASE(mSecurityManager);
 
     // Iterate over our scopes and tell them that we have been destroyed
     for (PRCList *scopeptr = PR_NEXT_LINK(&mScopes);
          scopeptr != &mScopes;
-         scopeptr = PR_NEXT_LINK(scopeptr))
-    {
+         scopeptr = PR_NEXT_LINK(scopeptr)) {
         XPCWrappedNativeScope *scope = (XPCWrappedNativeScope *)scopeptr;
         scope->SetContext(nsnull);
     }
 
     // we do not call JS_RemoveArgumentFormatter because we now only
     // delete XPCContext *after* the underlying JSContext is dead
 }
 
@@ -94,18 +93,17 @@ XPCContext::DebugDump(PRInt16 depth)
         XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
         XPC_LOG_ALWAYS(("mJSContext @ %x", mJSContext));
         XPC_LOG_ALWAYS(("mLastResult of %x", mLastResult));
         XPC_LOG_ALWAYS(("mPendingResult of %x", mPendingResult));
         XPC_LOG_ALWAYS(("mSecurityManager @ %x", mSecurityManager));
         XPC_LOG_ALWAYS(("mSecurityManagerFlags of %x", mSecurityManagerFlags));
 
         XPC_LOG_ALWAYS(("mException @ %x", mException));
-        if (depth && mException)
-        {
+        if (depth && mException) {
             // XXX show the exception here...
         }
 
         XPC_LOG_ALWAYS(("mCallingLangType of %s",
                         mCallingLangType == LANG_UNKNOWN ? "LANG_UNKNOWN" :
                         mCallingLangType == LANG_JS      ? "LANG_JS" :
                         "LANG_NATIVE"));
         XPC_LOG_OUTDENT();
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -133,18 +133,17 @@ static intN sXPCOMUCStringFinalizerIndex
 
 // static
 JSBool
 XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
 {
     if (XPT_MD_IS_NOTXPCOM(info.flags) || XPT_MD_IS_HIDDEN(info.flags))
         return JS_FALSE;
 
-    for (int i = info.num_args-1; i >= 0; i--)
-    {
+    for (int i = info.num_args-1; i >= 0; i--) {
         const nsXPTParamInfo& param = info.params[i];
         const nsXPTType& type = param.GetType();
 
         uint8 base_type = type.TagPart();
         NS_ASSERTION(base_type < XPC_FLAG_COUNT, "BAD TYPE");
 
         if (!XPC_IS_REFLECTABLE(xpc_reflectable_flags[base_type],
                                 type.IsPointer(), param.IsOut()))
@@ -158,18 +157,17 @@ XPCConvert::IsMethodReflectable(const XP
 // static
 JSBool
 XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface)
 {
     JSClass* jsclass = js::GetObjectJSClass(obj);
     NS_ASSERTION(jsclass, "obj has no class");
     if (jsclass &&
         (jsclass->flags & JSCLASS_HAS_PRIVATE) &&
-        (jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS))
-    {
+        (jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
         *iface = (nsISupports*) xpc_GetJSPrivate(obj);
         return JS_TRUE;
     }
     return JS_FALSE;
 }
 
 /***************************************************************************/
 
@@ -187,18 +185,17 @@ FinalizeXPCOMUCString(JSContext *cx, JSS
 
 static JSBool
 AddXPCOMUCStringFinalizer()
 {
 
     sXPCOMUCStringFinalizerIndex =
         JS_AddExternalStringFinalizer(FinalizeXPCOMUCString);
 
-    if (sXPCOMUCStringFinalizerIndex == -1)
-    {
+    if (sXPCOMUCStringFinalizerIndex == -1) {
         return JS_FALSE;
     }
 
     return JS_TRUE;
 }
 
 //static
 void
@@ -253,18 +250,17 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
     // the value is primitive (viz., XPCNativeMember::GetConstantValue).
     NS_ABORT_IF_FALSE(type.IsArithmetic() ||
                       cx->compartment == js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()),
                       "bad scope for new JSObjects");
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
     case nsXPTType::T_I8    : *d = INT_TO_JSVAL((int32)*((int8*)s));                 break;
     case nsXPTType::T_I16   : *d = INT_TO_JSVAL((int32)*((int16*)s));                break;
     case nsXPTType::T_I32   : *d = INT_TO_JSVAL(*((int32*)s));                       break;
     case nsXPTType::T_I64   : *d = DOUBLE_TO_JSVAL(INT64_TO_DOUBLE(*((int64*)s)));   break;
     case nsXPTType::T_U8    : *d = INT_TO_JSVAL((int32)*((uint8*)s));                break;
     case nsXPTType::T_U16   : *d = INT_TO_JSVAL((int32)*((uint16*)s));               break;
     case nsXPTType::T_U32   : *d = FIT_U32(*((uint32*)s));                           break;
     case nsXPTType::T_U64   : *d = DOUBLE_TO_JSVAL(UINT64_TO_DOUBLE(*((uint64*)s))); break;
@@ -311,27 +307,25 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
         {
             *d = *((jsval*)s);
             if (!JS_WrapValue(cx, d))
                 return JS_FALSE;
             break;
         }
 
     default:
-        if (!type.IsPointer())
-        {
+        if (!type.IsPointer()) {
             XPC_LOG_ERROR(("XPCConvert::NativeData2JS : unsupported type"));
             return JS_FALSE;
         }
 
         // set the default result
         *d = JSVAL_NULL;
 
-        switch (type.TagPart())
-        {
+        switch (type.TagPart()) {
         case nsXPTType::T_VOID:
             XPC_LOG_ERROR(("XPCConvert::NativeData2JS : void* params not supported"));
             return JS_FALSE;
 
         case nsXPTType::T_IID:
             {
                 nsID* iid2 = *((nsID**)s);
                 if (!iid2)
@@ -404,18 +398,17 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
             }
         case nsXPTType::T_UTF8STRING:
             {
                 const nsACString* cString = *((const nsACString**)s);
 
                 if (!cString)
                     break;
 
-                if (!cString->IsVoid())
-                {
+                if (!cString->IsVoid()) {
                     PRUint32 len;
                     jschar *p = (jschar *)UTF8ToNewUnicode(*cString, &len);
 
                     if (!p)
                         return JS_FALSE;
 
                     if (sXPCOMUCStringFinalizerIndex == -1 &&
                         !AddXPCOMUCStringFinalizer())
@@ -438,51 +431,47 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
             }
         case nsXPTType::T_CSTRING:
             {
                 const nsACString* cString = *((const nsACString**)s);
 
                 if (!cString)
                     break;
 
-                if (!cString->IsVoid())
-                {
+                if (!cString->IsVoid()) {
                     PRUnichar* unicodeString = ToNewUnicode(*cString);
                     if (!unicodeString)
                         return JS_FALSE;
 
                     if (sXPCOMUCStringFinalizerIndex == -1 &&
                         !AddXPCOMUCStringFinalizer())
                         return JS_FALSE;
 
                     JSString* jsString = JS_NewExternalString(cx,
                                                               (jschar*)unicodeString,
                                                               cString->Length(),
                                                               sXPCOMUCStringFinalizerIndex);
 
-                    if (!jsString)
-                    {
+                    if (!jsString) {
                         nsMemory::Free(unicodeString);
                         return JS_FALSE;
                     }
 
                     *d = STRING_TO_JSVAL(jsString);
                 }
 
                 break;
             }
 
         case nsXPTType::T_INTERFACE:
         case nsXPTType::T_INTERFACE_IS:
             {
                 nsISupports* iface = *((nsISupports**)s);
-                if (iface)
-                {
-                    if (iid->Equals(NS_GET_IID(nsIVariant)))
-                    {
+                if (iface) {
+                    if (iid->Equals(NS_GET_IID(nsIVariant))) {
                         nsCOMPtr<nsIVariant> variant = do_QueryInterface(iface);
                         if (!variant)
                             return JS_FALSE;
 
                         return XPCVariant::VariantDataToJS(lccx, variant,
                                                            pErr, d);
                     }
                     // else...
@@ -517,18 +506,17 @@ XPCConvert::NativeData2JS(XPCLazyCallCon
 }
 
 /***************************************************************************/
 
 #ifdef DEBUG
 static bool
 CheckJSCharInCharRange(jschar c)
 {
-    if (ILLEGAL_RANGE(c))
-    {
+    if (ILLEGAL_RANGE(c)) {
         /* U+0080/U+0100 - U+FFFF data lost. */
         static const size_t MSG_BUF_SIZE = 64;
         char msg[MSG_BUF_SIZE];
         JS_snprintf(msg, MSG_BUF_SIZE, "jschar out of char range; high bits of data lost: 0x%x", c);
         NS_WARNING(msg);
         return false;
     }
 
@@ -551,42 +539,39 @@ XPCConvert::JSData2Native(XPCCallContext
     uint32   tu;
     jsdouble td;
     JSBool   tb;
     JSBool isDOMString = JS_TRUE;
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
 
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
     case nsXPTType::T_I8     :
         if (!JS_ValueToECMAInt32(cx, s, &ti))
             return JS_FALSE;
         *((int8*)d)  = (int8) ti;
         break;
     case nsXPTType::T_I16    :
         if (!JS_ValueToECMAInt32(cx, s, &ti))
             return JS_FALSE;
         *((int16*)d)  = (int16) ti;
         break;
     case nsXPTType::T_I32    :
         if (!JS_ValueToECMAInt32(cx, s, (int32*)d))
             return JS_FALSE;
         break;
     case nsXPTType::T_I64    :
-        if (JSVAL_IS_INT(s))
-        {
+        if (JSVAL_IS_INT(s)) {
             if (!JS_ValueToECMAInt32(cx, s, &ti))
                 return JS_FALSE;
             LL_I2L(*((int64*)d),ti);
 
         }
-        else
-        {
+        else {
             if (!JS_ValueToNumber(cx, s, &td))
                 return JS_FALSE;
             LL_D2L(*((int64*)d),td);
         }
         break;
     case nsXPTType::T_U8     :
         if (!JS_ValueToECMAUint32(cx, s, &tu))
             return JS_FALSE;
@@ -597,24 +582,22 @@ XPCConvert::JSData2Native(XPCCallContext
             return JS_FALSE;
         *((uint16*)d)  = (uint16) tu;
         break;
     case nsXPTType::T_U32    :
         if (!JS_ValueToECMAUint32(cx, s, (uint32*)d))
             return JS_FALSE;
         break;
     case nsXPTType::T_U64    :
-        if (JSVAL_IS_INT(s))
-        {
+        if (JSVAL_IS_INT(s)) {
             if (!JS_ValueToECMAUint32(cx, s, &tu))
                 return JS_FALSE;
             LL_UI2L(*((int64*)d),tu);
         }
-        else
-        {
+        else {
             if (!JS_ValueToNumber(cx, s, &td))
                 return JS_FALSE;
 #ifdef XP_WIN
             // Note: Win32 can't handle double to uint64 directly
             *((uint64*)d) = (uint64)((int64) td);
 #else
             LL_D2L(*((uint64*)d),td);
 #endif
@@ -631,93 +614,83 @@ XPCConvert::JSData2Native(XPCCallContext
         break;
     case nsXPTType::T_BOOL   :
         JS_ValueToBoolean(cx, s, &tb);
         *((bool*)d) = tb;
         break;
     case nsXPTType::T_CHAR   :
         {
             JSString* str = JS_ValueToString(cx, s);
-            if (!str)
-            {
+            if (!str) {
                 return JS_FALSE;
             }
             size_t length;
             const jschar* chars = JS_GetStringCharsAndLength(cx, str, &length);
-            if (!chars)
-            {
+            if (!chars) {
                 return JS_FALSE;
             }
             jschar ch = length ? chars[0] : 0;
 #ifdef DEBUG
             CheckJSCharInCharRange(ch);
 #endif
             *((char*)d) = char(ch);
             break;
         }
     case nsXPTType::T_WCHAR  :
         {
             JSString* str;
-            if (!(str = JS_ValueToString(cx, s)))
-            {
+            if (!(str = JS_ValueToString(cx, s))) {
                 return JS_FALSE;
             }
             size_t length;
             const jschar* chars = JS_GetStringCharsAndLength(cx, str, &length);
-            if (!chars)
-            {
+            if (!chars) {
                 return JS_FALSE;
             }
-            if (length == 0)
-            {
+            if (length == 0) {
                 *((uint16*)d) = 0;
                 break;
             }
             *((uint16*)d) = (uint16) chars[0];
             break;
         }
     case nsXPTType::T_JSVAL :
         *((jsval*)d) = s;
         break;
     default:
-        if (!type.IsPointer())
-        {
+        if (!type.IsPointer()) {
             NS_ERROR("unsupported type");
             return JS_FALSE;
         }
 
-        switch (type.TagPart())
-        {
+        switch (type.TagPart()) {
         case nsXPTType::T_VOID:
             XPC_LOG_ERROR(("XPCConvert::JSData2Native : void* params not supported"));
             NS_ERROR("void* params not supported");
             return JS_FALSE;
         case nsXPTType::T_IID:
         {
             JSObject* obj;
             const nsID* pid=nsnull;
 
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (type.IsReference())
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
                 // else ...
                 *((const nsID**)d) = nsnull;
                 return JS_TRUE;
             }
 
             if (!JSVAL_IS_OBJECT(s) ||
                 (!(obj = JSVAL_TO_OBJECT(s))) ||
                 (!(pid = xpc_JSObjectToID(cx, obj))) ||
-                (!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID)))))
-            {
+                (!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID))))) {
                 return JS_FALSE;
             }
             *((const nsID**)d) = pid;
             return JS_TRUE;
         }
 
         case nsXPTType::T_ASTRING:
         {
@@ -729,322 +702,283 @@ XPCConvert::JSData2Native(XPCCallContext
             static const PRUnichar EMPTY_STRING[] = { '\0' };
             static const PRUnichar VOID_STRING[] = { 'u', 'n', 'd', 'e', 'f', 'i', 'n', 'e', 'd', '\0' };
 
             const PRUnichar* chars = nsnull;
             JSString* str = nsnull;
             JSBool isNewString = JS_FALSE;
             PRUint32 length = 0;
 
-            if (JSVAL_IS_VOID(s))
-            {
-                if (isDOMString)
-                {
+            if (JSVAL_IS_VOID(s)) {
+                if (isDOMString) {
                     chars  = VOID_STRING;
                     length = NS_ARRAY_LENGTH(VOID_STRING) - 1;
                 }
-                else
-                {
+                else {
                     chars = EMPTY_STRING;
                     length = 0;
                 }
             }
-            else if (!JSVAL_IS_NULL(s))
-            {
+            else if (!JSVAL_IS_NULL(s)) {
                 str = JS_ValueToString(cx, s);
                 if (!str)
                     return JS_FALSE;
 
                 length = (PRUint32) JS_GetStringLength(str);
-                if (length)
-                {
+                if (length) {
                     chars = JS_GetStringCharsZ(cx, str);
                     if (!chars)
                         return JS_FALSE;
                     if (STRING_TO_JSVAL(str) != s)
                         isNewString = JS_TRUE;
                 }
-                else
-                {
+                else {
                     str = nsnull;
                     chars = EMPTY_STRING;
                 }
             }
 
-            if (useAllocator)
-            {
+            if (useAllocator) {
                 // XXX extra string copy when isNewString
-                if (str && !isNewString)
-                {
+                if (str && !isNewString) {
                     size_t strLength;
                     const jschar *strChars = JS_GetStringCharsZAndLength(cx, str, &strLength);
                     if (!strChars)
                         return JS_FALSE;
 
                     XPCReadableJSStringWrapper *wrapper =
                         ccx.NewStringWrapper(strChars, strLength);
                     if (!wrapper)
                         return JS_FALSE;
 
                     *((const nsAString**)d) = wrapper;
                 }
-                else if (JSVAL_IS_NULL(s))
-                {
+                else if (JSVAL_IS_NULL(s)) {
                     XPCReadableJSStringWrapper *wrapper =
                         new XPCReadableJSStringWrapper();
                     if (!wrapper)
                         return JS_FALSE;
 
                     *((const nsAString**)d) = wrapper;
                 }
-                else
-                {
+                else {
                     // use nsString to encourage sharing
                     const nsAString *rs = new nsString(chars, length);
                     if (!rs)
                         return JS_FALSE;
                     *((const nsAString**)d) = rs;
                 }
             }
-            else
-            {
+            else {
                 nsAString* ws = *((nsAString**)d);
 
-                if (JSVAL_IS_NULL(s) || (!isDOMString && JSVAL_IS_VOID(s)))
-                {
+                if (JSVAL_IS_NULL(s) || (!isDOMString && JSVAL_IS_VOID(s))) {
                     ws->Truncate();
                     ws->SetIsVoid(PR_TRUE);
                 }
                 else
                     ws->Assign(chars, length);
             }
             return JS_TRUE;
         }
 
         case nsXPTType::T_CHAR_STR:
         {
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (type.IsReference())
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
                 // else ...
                 *((char**)d) = nsnull;
                 return JS_TRUE;
             }
 
             JSString* str = JS_ValueToString(cx, s);
-            if (!str)
-            {
+            if (!str) {
                 return JS_FALSE;
             }
 #ifdef DEBUG
             const jschar* chars=nsnull;
-            if (nsnull != (chars = JS_GetStringCharsZ(cx, str)))
-            {
+            if (nsnull != (chars = JS_GetStringCharsZ(cx, str))) {
                 bool legalRange = true;
                 int len = JS_GetStringLength(str);
                 const jschar* t;
                 PRInt32 i=0;
                 for (t=chars; (i< len) && legalRange ; i++,t++) {
                     if (!CheckJSCharInCharRange(*t))
                         break;
                 }
             }
 #endif // DEBUG
             size_t length = JS_GetStringEncodingLength(cx, str);
-            if (length == size_t(-1))
-            {
+            if (length == size_t(-1)) {
                 return JS_FALSE;
             }
             char *buffer = static_cast<char *>(nsMemory::Alloc(length + 1));
-            if (!buffer)
-            {
+            if (!buffer) {
                 return JS_FALSE;
             }
             JS_EncodeStringToBuffer(str, buffer, length);
             buffer[length] = '\0';
             *((void**)d) = buffer;
             return JS_TRUE;
         }
 
         case nsXPTType::T_WCHAR_STR:
         {
             const jschar* chars=nsnull;
             JSString* str;
 
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (type.IsReference())
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
                 // else ...
                 *((jschar**)d) = nsnull;
                 return JS_TRUE;
             }
 
-            if (!(str = JS_ValueToString(cx, s)))
-            {
+            if (!(str = JS_ValueToString(cx, s))) {
                 return JS_FALSE;
             }
-            if (!(chars = JS_GetStringCharsZ(cx, str)))
-            {
+            if (!(chars = JS_GetStringCharsZ(cx, str))) {
                 return JS_FALSE;
             }
             int len = JS_GetStringLength(str);
             int byte_len = (len+1)*sizeof(jschar);
-            if (!(*((void**)d) = nsMemory::Alloc(byte_len)))
-            {
+            if (!(*((void**)d) = nsMemory::Alloc(byte_len))) {
                 // XXX should report error
                 return JS_FALSE;
             }
             jschar* destchars = *((jschar**)d);
             memcpy(destchars, chars, byte_len);
             destchars[len] = 0;
 
             return JS_TRUE;
         }
 
         case nsXPTType::T_UTF8STRING:
         {
             const jschar* chars;
             PRUint32 length;
             JSString* str;
 
-            if (JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s))
-            {
-                if (useAllocator)
-                {
+            if (JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s)) {
+                if (useAllocator) {
                     nsACString *rs = new nsCString();
                     if (!rs)
                         return JS_FALSE;
 
                     rs->SetIsVoid(PR_TRUE);
                     *((nsACString**)d) = rs;
                 }
-                else
-                {
+                else {
                     nsCString* rs = *((nsCString**)d);
                     rs->Truncate();
                     rs->SetIsVoid(PR_TRUE);
                 }
                 return JS_TRUE;
             }
 
             // The JS val is neither null nor void...
 
             if (!(str = JS_ValueToString(cx, s))||
-                !(chars = JS_GetStringCharsZ(cx, str)))
-            {
+                !(chars = JS_GetStringCharsZ(cx, str))) {
                 return JS_FALSE;
             }
 
             length = JS_GetStringLength(str);
 
             nsCString *rs;
-            if (useAllocator)
-            {
+            if (useAllocator) {
                 // Use nsCString to enable sharing
                 rs = new nsCString();
                 if (!rs)
                     return JS_FALSE;
 
                 *((const nsCString**)d) = rs;
             }
-            else
-            {
+            else {
                 rs = *((nsCString**)d);
             }
             const PRUnichar* start = (const PRUnichar*)chars;
             const PRUnichar* end = start + length;
             CopyUTF16toUTF8(nsDependentSubstring(start, end), *rs);
             return JS_TRUE;
         }
 
         case nsXPTType::T_CSTRING:
         {
-            if (JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s))
-            {
-                if (useAllocator)
-                {
+            if (JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s)) {
+                if (useAllocator) {
                     nsACString *rs = new nsCString();
                     if (!rs)
                         return JS_FALSE;
 
                     rs->SetIsVoid(PR_TRUE);
                     *((nsACString**)d) = rs;
                 }
-                else
-                {
+                else {
                     nsACString* rs = *((nsACString**)d);
                     rs->Truncate();
                     rs->SetIsVoid(PR_TRUE);
                 }
                 return JS_TRUE;
             }
 
             // The JS val is neither null nor void...
             JSString* str = JS_ValueToString(cx, s);
-            if (!str)
-            {
+            if (!str) {
                 return JS_FALSE;
             }
 
             size_t length = JS_GetStringEncodingLength(cx, str);
-            if (length == size_t(-1))
-            {
+            if (length == size_t(-1)) {
                 return JS_FALSE;
             }
 
             nsACString *rs;
-            if (useAllocator)
-            {
+            if (useAllocator) {
                 rs = new nsCString();
                 if (!rs)
                     return JS_FALSE;
                 *((const nsACString**)d) = rs;
             }
-            else
-            {
+            else {
                 rs = *((nsACString**)d);
             }
 
             rs->SetLength(PRUint32(length));
-            if (rs->Length() != PRUint32(length))
-            {
+            if (rs->Length() != PRUint32(length)) {
                 return JS_FALSE;
             }
             JS_EncodeStringToBuffer(str, rs->BeginWriting(), length);
 
             return JS_TRUE;
         }
 
         case nsXPTType::T_INTERFACE:
         case nsXPTType::T_INTERFACE_IS:
         {
             JSObject* obj;
             NS_ASSERTION(iid,"can't do interface conversions without iid");
 
-            if (iid->Equals(NS_GET_IID(nsIVariant)))
-            {
+            if (iid->Equals(NS_GET_IID(nsIVariant))) {
                 XPCVariant* variant = XPCVariant::newVariant(ccx, s);
                 if (!variant)
                     return JS_FALSE;
                 *((nsISupports**)d) = static_cast<nsIVariant*>(variant);
                 return JS_TRUE;
             }
             else if (iid->Equals(NS_GET_IID(nsIAtom)) &&
-                     JSVAL_IS_STRING(s))
-            {
+                     JSVAL_IS_STRING(s)) {
                 // We're trying to pass a string as an nsIAtom.  Let's atomize!
                 JSString* str = JSVAL_TO_STRING(s);
                 const PRUnichar* chars = JS_GetStringCharsZ(cx, str);
                 if (!chars) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
@@ -1053,32 +987,29 @@ XPCConvert::JSData2Native(XPCCallContext
                                                                 chars + length));
                 if (!atom && pErr)
                     *pErr = NS_ERROR_OUT_OF_MEMORY;
                 *((nsISupports**)d) = atom;
                 return atom != nsnull;
             }
             //else ...
 
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (type.IsReference())
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
                 // else ...
                 *((nsISupports**)d) = nsnull;
                 return JS_TRUE;
             }
 
             // only wrap JSObjects
-            if (!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s)))
-            {
+            if (!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s))) {
                 if (pErr && JSVAL_IS_INT(s) && 0 == JSVAL_TO_INT(s))
                     *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL;
                 return JS_FALSE;
             }
 
             return JSObject2NativeInterface(ccx, (void**)d, obj, iid,
                                             nsnull, pErr);
         }
@@ -1089,18 +1020,17 @@ XPCConvert::JSData2Native(XPCCallContext
     }
     return JS_TRUE;
 }
 
 inline JSBool
 CreateHolderIfNeeded(XPCCallContext& ccx, JSObject* obj, jsval* d,
                      nsIXPConnectJSObjectHolder** dest)
 {
-    if (dest)
-    {
+    if (dest) {
         XPCJSObjectHolder* objHolder = XPCJSObjectHolder::newHolder(ccx, obj);
         if (!objHolder)
             return JS_FALSE;
 
         NS_ADDREF(*dest = objHolder);
     }
 
     *d = OBJECT_TO_JSVAL(obj);
@@ -1155,21 +1085,19 @@ XPCConvert::NativeInterface2JSObject(XPC
     // implementing it doesn't want a wrapped native as its JS Object, but
     // instead it provides its own proxy object. In that case, the object
     // to use is found as cache->GetWrapper(). If that is null, then the
     // object will create (and fill the cache) from its WrapObject call.
     nsWrapperCache *cache = aHelper.GetWrapperCache();
 
     bool tryConstructSlimWrapper = false;
     JSObject *flat;
-    if (cache)
-    {
+    if (cache) {
         flat = cache->GetWrapper();
-        if (cache->IsProxy())
-        {
+        if (cache->IsProxy()) {
             XPCCallContext &ccx = lccx.GetXPCCallContext();
             if (!ccx.IsValid())
                 return JS_FALSE;
 
             if (!flat) {
                 bool triedToWrap;
                 flat = cache->WrapObject(lccx.GetJSContext(), xpcscope,
                                          &triedToWrap);
@@ -1180,48 +1108,41 @@ XPCConvert::NativeInterface2JSObject(XPC
             if (flat) {
                 if (!JS_WrapObject(ccx, &flat))
                     return JS_FALSE;
 
                 return CreateHolderIfNeeded(ccx, flat, d, dest);
             }
         }
 
-        if (!dest)
-        {
-            if (!flat)
-            {
+        if (!dest) {
+            if (!flat) {
                 tryConstructSlimWrapper = PR_TRUE;
             }
-            else if (IS_SLIM_WRAPPER_OBJECT(flat))
-            {
-                if (js::GetObjectCompartment(flat) == cx->compartment)
-                {
+            else if (IS_SLIM_WRAPPER_OBJECT(flat)) {
+                if (js::GetObjectCompartment(flat) == cx->compartment) {
                     *d = OBJECT_TO_JSVAL(flat);
                     return JS_TRUE;
                 }
             }
         }
     }
-    else
-    {
+    else {
         flat = nsnull;
     }
 
     // If we're not handing this wrapper to an nsIXPConnectJSObjectHolder, and
     // the object supports slim wrappers, try to create one here.
-    if (tryConstructSlimWrapper)
-    {
+    if (tryConstructSlimWrapper) {
         XPCCallContext &ccx = lccx.GetXPCCallContext();
         if (!ccx.IsValid())
             return JS_FALSE;
 
         jsval slim;
-        if (ConstructSlimWrapper(ccx, aHelper, xpcscope, &slim))
-        {
+        if (ConstructSlimWrapper(ccx, aHelper, xpcscope, &slim)) {
             *d = slim;
             return JS_TRUE;
         }
 
         // Even if ConstructSlimWrapper returns JS_FALSE it might have created a
         // wrapper (while calling the PreCreate hook). In that case we need to
         // fall through because we either have a slim wrapper that needs to be
         // morphed or an XPCWrappedNative.
@@ -1229,76 +1150,71 @@ XPCConvert::NativeInterface2JSObject(XPC
     }
 
     // We can't simply construct a slim wrapper. Go ahead and create an
     // XPCWrappedNative for this object. At this point, |flat| could be
     // non-null, meaning that either we already have a wrapped native from
     // the cache (which might need to be QI'd to the new interface) or that
     // we found a slim wrapper that we'll have to morph.
     AutoMarkingNativeInterfacePtr iface;
-    if (iid)
-    {
+    if (iid) {
         XPCCallContext &ccx = lccx.GetXPCCallContext();
         if (!ccx.IsValid())
             return JS_FALSE;
 
         iface.Init(ccx);
 
         if (Interface)
             iface = *Interface;
 
-        if (!iface)
-        {
+        if (!iface) {
             iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
             if (!iface)
                 return JS_FALSE;
 
             if (Interface)
                 *Interface = iface;
         }
     }
 
     NS_ASSERTION(!flat || IS_WRAPPER_CLASS(js::GetObjectClass(flat)),
                  "What kind of wrapper is this?");
 
     nsresult rv;
     XPCWrappedNative* wrapper;
     nsRefPtr<XPCWrappedNative> strongWrapper;
-    if (!flat)
-    {
+    if (!flat) {
         XPCCallContext &ccx = lccx.GetXPCCallContext();
         if (!ccx.IsValid())
             return JS_FALSE;
 
         rv = XPCWrappedNative::GetNewOrUsed(ccx, aHelper, xpcscope, iface,
                                             isGlobal,
                                             getter_AddRefs(strongWrapper));
 
         wrapper = strongWrapper;
     }
-    else if (IS_WN_WRAPPER_OBJECT(flat))
-    {
+    else if (IS_WN_WRAPPER_OBJECT(flat)) {
         wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat));
 
         // If asked to return the wrapper we'll return a strong reference,
         // otherwise we'll just return its JSObject in d (which should be
         // rooted in that case).
         if (dest)
             strongWrapper = wrapper;
         // If iface is not null we know lccx.GetXPCCallContext() returns
         // a valid XPCCallContext because we checked when calling Init on
         // iface.
         if (iface)
             wrapper->FindTearOff(lccx.GetXPCCallContext(), iface, JS_FALSE,
                                  &rv);
         else
             rv = NS_OK;
     }
-    else
-    {
+    else {
         NS_ASSERTION(IS_SLIM_WRAPPER(flat),
                      "What kind of wrapper is this?");
 
         XPCCallContext &ccx = lccx.GetXPCCallContext();
         if (!ccx.IsValid())
             return JS_FALSE;
 
         SLIM_LOG(("***** morphing from XPCConvert::NativeInterface2JSObject"
@@ -1317,18 +1233,17 @@ XPCConvert::NativeInterface2JSObject(XPC
     if (NS_FAILED(rv) || !wrapper)
         return JS_FALSE;
 
     // If we're not creating security wrappers, we can return the
     // XPCWrappedNative as-is here.
     flat = wrapper->GetFlatJSObject();
     jsval v = OBJECT_TO_JSVAL(flat);
     if (!XPCPerThreadData::IsMainThread(lccx.GetJSContext()) ||
-        !allowNativeWrapper)
-    {
+        !allowNativeWrapper) {
         *d = v;
         if (dest)
             *dest = strongWrapper.forget().get();
         return JS_TRUE;
     }
 
     XPCCallContext &ccx = lccx.GetXPCCallContext();
     if (!ccx.IsValid())
@@ -1336,71 +1251,62 @@ XPCConvert::NativeInterface2JSObject(XPC
 
     JSObject *original = flat;
     if (!JS_WrapObject(ccx, &flat))
         return JS_FALSE;
 
     // If the object was not wrapped, we are same compartment and don't need
     // to enforce any cross origin policies, except in case of the location
     // object, which always needs a wrapper in between.
-    if (original == flat)
-    {
-        if (xpc::WrapperFactory::IsLocationObject(flat))
-        {
+    if (original == flat) {
+        if (xpc::WrapperFactory::IsLocationObject(flat)) {
             JSObject *locationWrapper = wrapper->GetWrapper();
-            if (!locationWrapper)
-            {
+            if (!locationWrapper) {
                 locationWrapper = xpc::WrapperFactory::WrapLocationObject(cx, flat);
                 if (!locationWrapper)
                     return JS_FALSE;
 
                 // Cache the location wrapper to ensure that we maintain
                 // the identity of window/document.location.
                 wrapper->SetWrapper(locationWrapper);
             }
 
             flat = locationWrapper;
         }
         else if (wrapper->NeedsSOW() &&
-                 !xpc::AccessCheck::isChrome(cx->compartment))
-        {
+                 !xpc::AccessCheck::isChrome(cx->compartment)) {
             JSObject *sowWrapper = wrapper->GetWrapper();
-            if (!sowWrapper)
-            {
+            if (!sowWrapper) {
                 sowWrapper = xpc::WrapperFactory::WrapSOWObject(cx, flat);
                 if (!sowWrapper)
                     return JS_FALSE;
 
                 // Cache the sow wrapper to ensure that we maintain
                 // the identity of this node.
                 wrapper->SetWrapper(sowWrapper);
             }
 
             flat = sowWrapper;
         }
-        else
-        {
+        else {
             flat = JS_ObjectToOuterObject(cx, flat);
             NS_ASSERTION(flat, "bad outer object hook!");
             NS_ASSERTION(js::GetObjectCompartment(flat) == cx->compartment,
                          "bad compartment");
         }
     }
 
     *d = OBJECT_TO_JSVAL(flat);
 
-    if (dest)
-    {
+    if (dest) {
         // The strongWrapper still holds the original flat object.
-        if (flat == original)
-        {
+        if (flat == original) {
             *dest = strongWrapper.forget().get();
         }
-        else
-        {
+        else {
             nsRefPtr<XPCJSObjectHolder> objHolder =
                 XPCJSObjectHolder::newHolder(ccx, flat);
             if (!objHolder)
                 return JS_FALSE;
 
             *dest = objHolder.forget().get();
         }
     }
@@ -1421,88 +1327,81 @@ XPCConvert::JSObject2NativeInterface(XPC
     NS_ASSERTION(dest, "bad param");
     NS_ASSERTION(src, "bad param");
     NS_ASSERTION(iid, "bad param");
 
     JSContext* cx = ccx.GetJSContext();
 
     JSAutoEnterCompartment ac;
 
-    if (!ac.enter(cx, src))
-    {
+    if (!ac.enter(cx, src)) {
        if (pErr)
            *pErr = NS_ERROR_UNEXPECTED;
        return PR_FALSE;
     }
 
     *dest = nsnull;
      if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
 
     nsISupports* iface;
 
-    if (!aOuter)
-    {
+    if (!aOuter) {
         // Note that if we have a non-null aOuter then it means that we are
         // forcing the creation of a wrapper even if the object *is* a
         // wrappedNative or other wise has 'nsISupportness'.
         // This allows wrapJSAggregatedToNative to work.
 
         // If we're looking at a security wrapper, see now if we're allowed to
         // pass it to C++. If we are, then fall through to the code below. If
         // we aren't, throw an exception eagerly.
         JSObject* inner = nsnull;
-        if (XPCWrapper::IsSecurityWrapper(src))
-        {
+        if (XPCWrapper::IsSecurityWrapper(src)) {
             inner = XPCWrapper::Unwrap(cx, src);
-            if (!inner)
-            {
+            if (!inner) {
                 if (pErr)
                     *pErr = NS_ERROR_XPC_SECURITY_MANAGER_VETO;
                 return JS_FALSE;
             }
         }
 
         // Is this really a native xpcom object with a wrapper?
         XPCWrappedNative* wrappedNative =
                     XPCWrappedNative::GetWrappedNativeOfJSObject(cx,
                                                                  inner
                                                                  ? inner
                                                                  : src);
-        if (wrappedNative)
-        {
+        if (wrappedNative) {
             iface = wrappedNative->GetIdentityObject();
             return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
         }
         // else...
 
         // XXX E4X breaks the world. Don't try wrapping E4X objects!
         // This hack can be removed (or changed accordingly) when the
         // DOM <-> E4X bindings are complete, see bug 270553
         if (JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML)
             return JS_FALSE;
 
         // Deal with slim wrappers here.
-        if (GetISupportsFromJSObject(src, &iface))
-        {
+        if (GetISupportsFromJSObject(src, &iface)) {
             if (iface)
                 return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
 
             return JS_FALSE;
         }
     }
 
     // else...
 
     nsXPCWrappedJS* wrapper;
     nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, src, *iid, aOuter, &wrapper);
     if (pErr)
         *pErr = rv;
-    if (NS_SUCCEEDED(rv) && wrapper)
-    {
+    if (NS_SUCCEEDED(rv) && wrapper) {
         // We need to go through the QueryInterface logic to make this return
         // the right thing for the various 'special' interfaces; e.g.
         // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
         // there is an outer to avoid nasty recursion.
         rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
                       wrapper->QueryInterface(*iid, dest);
         if (pErr)
             *pErr = rv;
@@ -1544,18 +1443,17 @@ XPCConvert::ConstructException(nsresult 
     if (!msg)
         if (!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &msg) || ! msg)
             msg = "<error>";
     if (ifaceName && methodName)
         msg = sz = JS_smprintf(format, msg, ifaceName, methodName);
 
     nsresult res = nsXPCException::NewException(msg, rv, nsnull, data, exceptn);
 
-    if (NS_SUCCEEDED(res) && cx && jsExceptionPtr && *exceptn)
-    {
+    if (NS_SUCCEEDED(res) && cx && jsExceptionPtr && *exceptn) {
         nsCOMPtr<nsIXPCException> xpcEx = do_QueryInterface(*exceptn);
         if (xpcEx)
             xpcEx->StowJSVal(cx, *jsExceptionPtr);
     }
 
     if (sz)
         JS_smprintf_free(sz);
     return res;
@@ -1588,59 +1486,52 @@ XPCConvert::JSValToXPCException(XPCCallC
                                 jsval s,
                                 const char* ifaceName,
                                 const char* methodName,
                                 nsIException** exceptn)
 {
     JSContext* cx = ccx.GetJSContext();
     AutoExceptionRestorer aer(cx, s);
 
-    if (!JSVAL_IS_PRIMITIVE(s))
-    {
+    if (!JSVAL_IS_PRIMITIVE(s)) {
         // we have a JSObject
         JSObject* obj = JSVAL_TO_OBJECT(s);
 
-        if (!obj)
-        {
+        if (!obj) {
             NS_ERROR("when is an object not an object?");
             return NS_ERROR_FAILURE;
         }
 
         // is this really a native xpcom object with a wrapper?
         XPCWrappedNative* wrapper;
         if (nsnull != (wrapper =
-                       XPCWrappedNative::GetWrappedNativeOfJSObject(cx,obj)))
-        {
+                       XPCWrappedNative::GetWrappedNativeOfJSObject(cx,obj))) {
             nsISupports* supports = wrapper->GetIdentityObject();
             nsCOMPtr<nsIException> iface = do_QueryInterface(supports);
-            if (iface)
-            {
+            if (iface) {
                 // just pass through the exception (with extra ref and all)
                 nsIException* temp = iface;
                 NS_ADDREF(temp);
                 *exceptn = temp;
                 return NS_OK;
             }
-            else
-            {
+            else {
                 // it is a wrapped native, but not an exception!
                 return ConstructException(NS_ERROR_XPC_JS_THREW_NATIVE_OBJECT,
                                           nsnull, ifaceName, methodName, supports,
                                           exceptn, nsnull, nsnull);
             }
         }
-        else
-        {
+        else {
             // It is a JSObject, but not a wrapped native...
 
             // If it is an engine Error with an error report then let's
             // extract the report and build an xpcexception from that
             const JSErrorReport* report;
-            if (nsnull != (report = JS_ErrorFromException(cx, s)))
-            {
+            if (nsnull != (report = JS_ErrorFromException(cx, s))) {
                 JSAutoByteString message;
                 JSString* str;
                 if (nsnull != (str = JS_ValueToString(cx, s)))
                     message.encode(cx, str);
                 return JSErrorToXPCException(ccx, message.ptr(), ifaceName,
                                              methodName, report, exceptn);
             }
 
@@ -1650,18 +1541,17 @@ XPCConvert::JSValToXPCException(XPCCallC
 
             // heuristic to see if it might be usable as an xpcexception
             if (!JS_GetPropertyAttributes(cx, obj, "message", &ignored, &found))
                return NS_ERROR_FAILURE;
 
             if (found && !JS_GetPropertyAttributes(cx, obj, "result", &ignored, &found))
                 return NS_ERROR_FAILURE;
 
-            if (found)
-            {
+            if (found) {
                 // lets try to build a wrapper around the JSObject
                 nsXPCWrappedJS* jswrapper;
                 nsresult rv =
                     nsXPCWrappedJS::GetNewOrUsed(ccx, obj,
                                                  NS_GET_IID(nsIException),
                                                  nsnull, &jswrapper);
                 if (NS_FAILED(rv))
                     return rv;
@@ -1687,56 +1577,50 @@ XPCConvert::JSValToXPCException(XPCCallC
                 return NS_ERROR_FAILURE;
 
             return ConstructException(NS_ERROR_XPC_JS_THREW_JS_OBJECT,
                                       strBytes.ptr(), ifaceName, methodName,
                                       nsnull, exceptn, cx, &s);
         }
     }
 
-    if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-    {
+    if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
         return ConstructException(NS_ERROR_XPC_JS_THREW_NULL,
                                   nsnull, ifaceName, methodName, nsnull,
                                   exceptn, cx, &s);
     }
 
-    if (JSVAL_IS_NUMBER(s))
-    {
+    if (JSVAL_IS_NUMBER(s)) {
         // lets see if it looks like an nsresult
         nsresult rv;
         double number;
         JSBool isResult = JS_FALSE;
 
-        if (JSVAL_IS_INT(s))
-        {
+        if (JSVAL_IS_INT(s)) {
             rv = (nsresult) JSVAL_TO_INT(s);
             if (NS_FAILED(rv))
                 isResult = JS_TRUE;
             else
                 number = (double) JSVAL_TO_INT(s);
         }
-        else
-        {
+        else {
             number = JSVAL_TO_DOUBLE(s);
             if (number > 0.0 &&
                 number < (double)0xffffffff &&
-                0.0 == fmod(number,1))
-            {
+                0.0 == fmod(number,1)) {
                 rv = (nsresult) number;
                 if (NS_FAILED(rv))
                     isResult = JS_TRUE;
             }
         }
 
         if (isResult)
             return ConstructException(rv, nsnull, ifaceName, methodName,
                                       nsnull, exceptn, cx, &s);
-        else
-        {
+        else {
             // XXX all this nsISupportsDouble code seems a little redundant
             // now that we're storing the jsval in the exception...
             nsISupportsDouble* data;
             nsCOMPtr<nsIComponentManager> cm;
             if (NS_FAILED(NS_GetComponentManager(getter_AddRefs(cm))) || !cm ||
                 NS_FAILED(cm->CreateInstanceByContractID(NS_SUPPORTS_DOUBLE_CONTRACTID,
                                                          nsnull,
                                                          NS_GET_IID(nsISupportsDouble),
@@ -1749,21 +1633,19 @@ XPCConvert::JSValToXPCException(XPCCallC
             return rv;
         }
     }
 
     // otherwise we'll just try to convert it to a string
     // Note: e.g., JSBools get converted to JSStrings by this code.
 
     JSString* str = JS_ValueToString(cx, s);
-    if (str)
-    {
+    if (str) {
         JSAutoByteString strBytes(cx, str);
-        if (!!strBytes)
-        {
+        if (!!strBytes) {
             return ConstructException(NS_ERROR_XPC_JS_THREW_STRING,
                                       strBytes.ptr(), ifaceName, methodName,
                                       nsnull, exceptn, cx, &s);
         }
     }
     return NS_ERROR_FAILURE;
 }
 
@@ -1775,57 +1657,51 @@ XPCConvert::JSErrorToXPCException(XPCCal
                                   const char* message,
                                   const char* ifaceName,
                                   const char* methodName,
                                   const JSErrorReport* report,
                                   nsIException** exceptn)
 {
     nsresult rv = NS_ERROR_FAILURE;
     nsRefPtr<nsScriptError> data;
-    if (report)
-    {
+    if (report) {
         nsAutoString bestMessage;
-        if (report && report->ucmessage)
-        {
+        if (report && report->ucmessage) {
             bestMessage = (const PRUnichar *)report->ucmessage;
         }
-        else if (message)
-        {
+        else if (message) {
             bestMessage.AssignWithConversion(message);
         }
-        else
-        {
+        else {
             bestMessage.AssignLiteral("JavaScript Error");
         }
 
         data = new nsScriptError();
         if (!data)
             return NS_ERROR_OUT_OF_MEMORY;
 
 
         data->InitWithWindowID(bestMessage.get(),
                                NS_ConvertASCIItoUTF16(report->filename).get(),
                                (const PRUnichar *)report->uclinebuf, report->lineno,
                                report->uctokenptr - report->uclinebuf, report->flags,
                                "XPConnect JavaScript",
                                nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(ccx.GetJSContext()));
     }
 
-    if (data)
-    {
+    if (data) {
         nsCAutoString formattedMsg;
         data->ToString(formattedMsg);
 
         rv = ConstructException(NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS,
                                 formattedMsg.get(), ifaceName, methodName,
                                 static_cast<nsIScriptError*>(data.get()),
                                 exceptn, nsnull, nsnull);
     }
-    else
-    {
+    else {
         rv = ConstructException(NS_ERROR_XPC_JAVASCRIPT_ERROR,
                                 nsnull, ifaceName, methodName, nsnull,
                                 exceptn, nsnull, nsnull);
     }
     return rv;
 }
 
 /***************************************************************************/
@@ -1871,28 +1747,26 @@ XPCConvert::NativeArray2JS(XPCLazyCallCo
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
     JSUint32 i;
     jsval current = JSVAL_NULL;
     AUTO_MARK_JSVAL(ccx, &current);
 
 #define POPULATE(_t)                                                          \
     PR_BEGIN_MACRO                                                            \
-        for (i = 0; i < count; i++)                                           \
-        {                                                                     \
+        for (i = 0; i < count; i++) {                                         \
             if (!NativeData2JS(ccx, &current, ((_t*)*s)+i, type, iid, pErr) ||\
                 !JS_SetElement(cx, array, i, &current))                       \
                 goto failure;                                                 \
         }                                                                     \
     PR_END_MACRO
 
     // XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*)
 
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
     case nsXPTType::T_I8            : POPULATE(int8);           break;
     case nsXPTType::T_I16           : POPULATE(int16);          break;
     case nsXPTType::T_I32           : POPULATE(int32);          break;
     case nsXPTType::T_I64           : POPULATE(int64);          break;
     case nsXPTType::T_U8            : POPULATE(uint8);          break;
     case nsXPTType::T_U16           : POPULATE(uint16);         break;
     case nsXPTType::T_U32           : POPULATE(uint32);         break;
     case nsXPTType::T_U64           : POPULATE(uint64);         break;
@@ -1944,88 +1818,80 @@ XPCConvert::JSArray2Native(XPCCallContex
     void* array = nsnull;
     JSUint32 initedCount;
     jsval current;
 
     // XXX add support for getting chars from strings
 
     // XXX add support to indicate *which* array element was not convertable
 
-    if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-    {
-        if (0 != count)
-        {
+    if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+        if (0 != count) {
             if (pErr)
                 *pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY;
             return JS_FALSE;
         }
 
         // If a non-zero capacity was indicated then we build an
         // empty array rather than return nsnull.
         if (0 != capacity)
             goto fill_array;
 
         *d = nsnull;
         return JS_TRUE;
     }
 
-    if (!JSVAL_IS_OBJECT(s))
-    {
+    if (!JSVAL_IS_OBJECT(s)) {
         if (pErr)
             *pErr = NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY;
         return JS_FALSE;
     }
 
     jsarray = JSVAL_TO_OBJECT(s);
-    if (!JS_IsArrayObject(cx, jsarray))
-    {
+    if (!JS_IsArrayObject(cx, jsarray)) {
         if (pErr)
             *pErr = NS_ERROR_XPC_CANT_CONVERT_OBJECT_TO_ARRAY;
         return JS_FALSE;
     }
 
     jsuint len;
-    if (!JS_GetArrayLength(cx, jsarray, &len) || len < count || capacity < count)
-    {
+    if (!JS_GetArrayLength(cx, jsarray, &len) || len < count || capacity < count) {
         if (pErr)
             *pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY;
         return JS_FALSE;
     }
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
 
 #define POPULATE(_mode, _t)                                                   \
     PR_BEGIN_MACRO                                                            \
         cleanupMode = _mode;                                                  \
         size_t max = PR_UINT32_MAX / sizeof(_t);                              \
         if (capacity > max ||                                                 \
-            nsnull == (array = nsMemory::Alloc(capacity * sizeof(_t))))       \
-        {                                                                     \
+            nsnull == (array = nsMemory::Alloc(capacity * sizeof(_t)))) {     \
             if (pErr)                                                         \
                 *pErr = NS_ERROR_OUT_OF_MEMORY;                               \
             goto failure;                                                     \
         }                                                                     \
-        for (initedCount = 0; initedCount < count; initedCount++)             \
-        {                                                                     \
+        for (initedCount = 0; initedCount < count; initedCount++) {           \
             if (!JS_GetElement(cx, jsarray, initedCount, &current) ||         \
                 !JSData2Native(ccx, ((_t*)array)+initedCount, current, type,  \
                                JS_TRUE, iid, pErr))                           \
                 goto failure;                                                 \
         }                                                                     \
     PR_END_MACRO
 
 
     // XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*)
 
     // XXX make extra space at end of char* and wchar* and null termintate
 
 fill_array:
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
     case nsXPTType::T_I8            : POPULATE(na, int8);           break;
     case nsXPTType::T_I16           : POPULATE(na, int16);          break;
     case nsXPTType::T_I32           : POPULATE(na, int32);          break;
     case nsXPTType::T_I64           : POPULATE(na, int64);          break;
     case nsXPTType::T_U8            : POPULATE(na, uint8);          break;
     case nsXPTType::T_U16           : POPULATE(na, uint16);         break;
     case nsXPTType::T_U32           : POPULATE(na, uint32);         break;
     case nsXPTType::T_U64           : POPULATE(na, uint64);         break;
@@ -2049,32 +1915,27 @@ fill_array:
 
     *d = array;
     if (pErr)
         *pErr = NS_OK;
     return JS_TRUE;
 
 failure:
     // we may need to cleanup the partially filled array of converted stuff
-    if (array)
-    {
-        if (cleanupMode == re)
-        {
+    if (array) {
+        if (cleanupMode == re) {
             nsISupports** a = (nsISupports**) array;
-            for (PRUint32 i = 0; i < initedCount; i++)
-            {
+            for (PRUint32 i = 0; i < initedCount; i++) {
                 nsISupports* p = a[i];
                 NS_IF_RELEASE(p);
             }
         }
-        else if (cleanupMode == fr)
-        {
+        else if (cleanupMode == fr) {
             void** a = (void**) array;
-            for (PRUint32 i = 0; i < initedCount; i++)
-            {
+            for (PRUint32 i = 0; i < initedCount; i++) {
                 void* p = a[i];
                 if (p) nsMemory::Free(p);
             }
         }
         nsMemory::Free(array);
     }
 
     return JS_FALSE;
@@ -2091,23 +1952,21 @@ XPCConvert::NativeStringWithSize2JS(JSCo
                                     nsresult* pErr)
 {
     NS_PRECONDITION(s, "bad param");
     NS_PRECONDITION(d, "bad param");
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
-    if (!type.IsPointer())
-    {
+    if (!type.IsPointer()) {
         XPC_LOG_ERROR(("XPCConvert::NativeStringWithSize2JS : unsupported type"));
         return JS_FALSE;
     }
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
         case nsXPTType::T_PSTRING_SIZE_IS:
         {
             char* p = *((char**)s);
             if (!p)
                 break;
             JSString* str;
             if (!(str = JS_NewStringCopyN(cx, p, count)))
                 return JS_FALSE;
@@ -2144,150 +2003,131 @@ XPCConvert::JSStringWithSize2Native(XPCC
 
     JSContext* cx = ccx.GetJSContext();
 
     JSUint32 len;
 
     if (pErr)
         *pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
 
-    if (capacity < count)
-    {
+    if (capacity < count) {
         if (pErr)
             *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
         return JS_FALSE;
     }
 
-    if (!type.IsPointer())
-    {
+    if (!type.IsPointer()) {
         XPC_LOG_ERROR(("XPCConvert::JSStringWithSize2Native : unsupported type"));
         return JS_FALSE;
     }
-    switch (type.TagPart())
-    {
+    switch (type.TagPart()) {
         case nsXPTType::T_PSTRING_SIZE_IS:
         {
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (0 != count)
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (0 != count) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                     return JS_FALSE;
                 }
-                if (type.IsReference())
-                {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
 
-                if (0 != capacity)
-                {
+                if (0 != capacity) {
                     len = (capacity + 1) * sizeof(char);
                     if (!(*((void**)d) = nsMemory::Alloc(len)))
                         return JS_FALSE;
                     return JS_TRUE;
                 }
                 // else ...
 
                 *((char**)d) = nsnull;
                 return JS_TRUE;
             }
 
             JSString* str = JS_ValueToString(cx, s);
-            if (!str)
-            {
+            if (!str) {
                 return JS_FALSE;
             }
 
             size_t length = JS_GetStringEncodingLength(cx, str);
-            if (length == size_t(-1))
-            {
+            if (length == size_t(-1)) {
                 return JS_FALSE;
             }
-            if (length > count)
-            {
+            if (length > count) {
                 if (pErr)
                     *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                 return JS_FALSE;
             }
             len = PRUint32(length);
 
             if (len < capacity)
                 len = capacity;
 
             JSUint32 alloc_len = (len + 1) * sizeof(char);
             char *buffer = static_cast<char *>(nsMemory::Alloc(alloc_len));
-            if (!buffer)
-            {
+            if (!buffer) {
                 return JS_FALSE;
             }
             JS_EncodeStringToBuffer(str, buffer, len);
             buffer[len] = '\0';
             *((char**)d) = buffer;
 
             return JS_TRUE;
         }
 
         case nsXPTType::T_PWSTRING_SIZE_IS:
         {
             const jschar* chars=nsnull;
             JSString* str;
 
-            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
-            {
-                if (0 != count)
-                {
+            if (JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s)) {
+                if (0 != count) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                     return JS_FALSE;
                 }
-                if (type.IsReference())
-                {
+                if (type.IsReference()) {
                     if (pErr)
                         *pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
                     return JS_FALSE;
                 }
 
-                if (0 != capacity)
-                {
+                if (0 != capacity) {
                     len = (capacity + 1) * sizeof(jschar);
                     if (!(*((void**)d) = nsMemory::Alloc(len)))
                         return JS_FALSE;
                     return JS_TRUE;
                 }
 
                 // else ...
                 *((const jschar**)d) = nsnull;
                 return JS_TRUE;
             }
 
-            if (!(str = JS_ValueToString(cx, s)))
-            {
+            if (!(str = JS_ValueToString(cx, s))) {
                 return JS_FALSE;
             }
 
             len = JS_GetStringLength(str);
-            if (len > count)
-            {
+            if (len > count) {
                 if (pErr)
                     *pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
                 return JS_FALSE;
             }
             if (len < capacity)
                 len = capacity;
 
-            if (!(chars = JS_GetStringCharsZ(cx, str)))
-            {
+            if (!(chars = JS_GetStringCharsZ(cx, str))) {
                 return JS_FALSE;
             }
             JSUint32 alloc_len = (len + 1) * sizeof(jschar);
-            if (!(*((void**)d) = nsMemory::Alloc(alloc_len)))
-            {
+            if (!(*((void**)d) = nsMemory::Alloc(alloc_len))) {
                 // XXX should report error
                 return JS_FALSE;
             }
             memcpy(*((jschar**)d), chars, alloc_len);
             (*((jschar**)d))[count] = 0;
 
             return JS_TRUE;
         }
--- a/js/xpconnect/src/XPCDebug.cpp
+++ b/js/xpconnect/src/XPCDebug.cpp
@@ -48,18 +48,17 @@
 static const char* JSVAL2String(JSContext* cx, jsval val, JSBool* isString,
                                 JSAutoByteString *bytes)
 {
     JSAutoRequest ar(cx);
     const char* value = nsnull;
     JSString* value_str = JS_ValueToString(cx, val);
     if (value_str)
         value = bytes->encode(cx, value_str);
-    if (value)
-    {
+    if (value) {
         const char* found = strstr(value, "function ");
         if (found && (value == found || value+1 == found || value+2 == found))
             value = "[function]";
     }
 
     if (isString)
         *isString = JSVAL_IS_STRING(val);
     return value;
@@ -88,62 +87,56 @@ static char* FormatJSFrame(JSContext* cx
     JSScript* script = JS_GetFrameScript(cx, fp);
     jsbytecode* pc = JS_GetFramePC(cx, fp);
 
     JSAutoRequest ar(cx);
     JSAutoEnterCompartment ac;
     if (!ac.enter(cx, JS_GetGlobalForFrame(fp)))
         return buf;
 
-    if (script && pc)
-    {
+    if (script && pc) {
         filename = JS_GetScriptFilename(cx, script);
         lineno =  (PRInt32) JS_PCToLineNumber(cx, script, pc);
         fun = JS_GetFrameFunction(cx, fp);
         if (fun)
             funname = JS_GetFunctionId(fun);
 
-        if (showArgs || showLocals)
-        {
+        if (showArgs || showLocals) {
             callObj = JS_GetFrameCallObject(cx, fp);
             if (callObj)
                 if (!JS_GetPropertyDescArray(cx, callObj, &callProps))
                     callProps.array = nsnull;  // just to be sure
         }
 
         gotThisVal = JS_GetFrameThis(cx, fp, &thisVal);
         if (!gotThisVal ||
             !showThisProps ||
             JSVAL_IS_PRIMITIVE(thisVal) ||
             !JS_GetPropertyDescArray(cx, JSVAL_TO_OBJECT(thisVal),
-                                     &thisProps))
-        {
+                                     &thisProps)) {
             thisProps.array = nsnull;  // just to be sure
         }
     }
 
     // print the frame number and function name
 
     if (funname)
         buf = JS_sprintf_append(buf, "%d %s(", num, funbytes.encode(cx, funname));
     else if (fun)
         buf = JS_sprintf_append(buf, "%d anonymous(", num);
     else
         buf = JS_sprintf_append(buf, "%d <TOP LEVEL>", num);
     if (!buf) goto out;
 
     // print the function arguments
 
-    if (showArgs && callObj)
-    {
-        for (uint32 i = 0; i < callProps.length; i++)
-        {
+    if (showArgs && callObj) {
+        for (uint32 i = 0; i < callProps.length; i++) {
             JSPropertyDesc* desc = &callProps.array[i];
-            if (desc->flags & JSPD_ARGUMENT)
-            {
+            if (desc->flags & JSPD_ARGUMENT) {
                 JSAutoByteString nameBytes;
                 const char* name = JSVAL2String(cx, desc->id, &isString, &nameBytes);
                 if (!isString)
                     name = nsnull;
                 JSAutoByteString valueBytes;
                 const char* value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
 
                 buf = JS_sprintf_append(buf, "%s%s%s%s%s%s",
@@ -156,31 +149,27 @@ static char* FormatJSFrame(JSContext* cx
                 if (!buf) goto out;
                 namedArgCount++;
             }
         }
 
         // print any unnamed trailing args (found in 'arguments' object)
 
         if (JS_GetProperty(cx, callObj, "arguments", &val) &&
-            JSVAL_IS_OBJECT(val))
-        {
+            JSVAL_IS_OBJECT(val)) {
             uint32 argCount;
             JSObject* argsObj = JSVAL_TO_OBJECT(val);
             if (JS_GetProperty(cx, argsObj, "length", &val) &&
                 JS_ValueToECMAUint32(cx, val, &argCount) &&
-                argCount > namedArgCount)
-            {
-                for (uint32 k = namedArgCount; k < argCount; k++)
-                {
+                argCount > namedArgCount) {
+                for (uint32 k = namedArgCount; k < argCount; k++) {
                     char number[8];
                     JS_snprintf(number, 8, "%d", (int) k);
 
-                    if (JS_GetProperty(cx, argsObj, number, &val))
-                    {
+                    if (JS_GetProperty(cx, argsObj, number, &val)) {
                         JSAutoByteString valueBytes;
                         const char *value = JSVAL2String(cx, val, &isString, &valueBytes);
                         buf = JS_sprintf_append(buf, "%s%s%s%s",
                                                 k ? ", " : "",
                                                 isString ? "\"" : "",
                                                 value ? value : "?unknown?",
                                                 isString ? "\"" : "");
                         if (!buf) goto out;
@@ -195,77 +184,66 @@ static char* FormatJSFrame(JSContext* cx
     buf = JS_sprintf_append(buf, "%s [\"%s\":%d]\n",
                             fun ? ")" : "",
                             filename ? filename : "<unknown>",
                             lineno);
     if (!buf) goto out;
 
     // print local variables
 
-    if (showLocals && callProps.array)
-    {
-        for (uint32 i = 0; i < callProps.length; i++)
-        {
+    if (showLocals && callProps.array) {
+        for (uint32 i = 0; i < callProps.length; i++) {
             JSPropertyDesc* desc = &callProps.array[i];
-            if (desc->flags & JSPD_VARIABLE)
-            {
+            if (desc->flags & JSPD_VARIABLE) {
                 JSAutoByteString nameBytes;
                 JSAutoByteString valueBytes;
                 const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
                 const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
 
-                if (name && value)
-                {
+                if (name && value) {
                     buf = JS_sprintf_append(buf, TAB "%s = %s%s%s\n",
                                             name,
                                             isString ? "\"" : "",
                                             value,
                                             isString ? "\"" : "");
                     if (!buf) goto out;
                 }
             }
         }
     }
 
     // print the value of 'this'
 
-    if (showLocals)
-    {
-        if (gotThisVal)
-        {
+    if (showLocals) {
+        if (gotThisVal) {
             JSString* thisValStr;
             JSAutoByteString thisValBytes;
 
             if (nsnull != (thisValStr = JS_ValueToString(cx, thisVal)) &&
-                thisValBytes.encode(cx, thisValStr))
-            {
+                thisValBytes.encode(cx, thisValStr)) {
                 buf = JS_sprintf_append(buf, TAB "this = %s\n", thisValBytes.ptr());
                 if (!buf) goto out;
             }
         }
         else
             buf = JS_sprintf_append(buf, TAB "<failed to get 'this' value>\n");
     }
 
     // print the properties of 'this', if it is an object
 
-    if (showThisProps && thisProps.array)
-    {
+    if (showThisProps && thisProps.array) {
 
-        for (uint32 i = 0; i < thisProps.length; i++)
-        {
+        for (uint32 i = 0; i < thisProps.length; i++) {
             JSPropertyDesc* desc = &thisProps.array[i];
-            if (desc->flags & JSPD_ENUMERATE)
-            {
+            if (desc->flags & JSPD_ENUMERATE) {
                 JSAutoByteString nameBytes;
                 JSAutoByteString valueBytes;
                 const char *name = JSVAL2String(cx, desc->id, nsnull, &nameBytes);
                 const char *value = JSVAL2String(cx, desc->value, &isString, &valueBytes);
-                if (name && value)
-                {
+                if (name && value) {
                     buf = JS_sprintf_append(buf, TAB "this.%s = %s%s%s\n",
                                             name,
                                             isString ? "\"" : "",
                                             value,
                                             isString ? "\"" : "");
                     if (!buf) goto out;
                 }
             }
@@ -283,33 +261,31 @@ out:
 static char* FormatJSStackDump(JSContext* cx, char* buf,
                                JSBool showArgs, JSBool showLocals,
                                JSBool showThisProps)
 {
     JSStackFrame* fp;
     JSStackFrame* iter = nsnull;
     int num = 0;
 
-    while (nsnull != (fp = JS_FrameIterator(cx, &iter)))
-    {
+    while (nsnull != (fp = JS_FrameIterator(cx, &iter))) {
         buf = FormatJSFrame(cx, fp, buf, num, showArgs, showLocals, showThisProps);
         num++;
     }
 
     if (!num)
         buf = JS_sprintf_append(buf, "JavaScript stack is empty\n");
 
     return buf;
 }
 
 JSBool
 xpc_DumpJSStack(JSContext* cx, JSBool showArgs, JSBool showLocals, JSBool showThisProps)
 {
-    if (char* buf = xpc_PrintJSStack(cx, showArgs, showLocals, showThisProps))
-    {
+    if (char* buf = xpc_PrintJSStack(cx, showArgs, showLocals, showThisProps)) {
         fputs(buf, stdout);
         JS_smprintf_free(buf);
     }
     return JS_TRUE;
 }
 
 char*
 xpc_PrintJSStack(JSContext* cx, JSBool showArgs, JSBool showLocals,
@@ -341,49 +317,45 @@ xpcDumpEvalErrorReporter(JSContext *cx, 
 
 JSBool
 xpc_DumpEvalInJSStackFrame(JSContext* cx, JSUint32 frameno, const char* text)
 {
     JSStackFrame* fp;
     JSStackFrame* iter = nsnull;
     JSUint32 num = 0;
 
-    if (!cx || !text)
-    {
+    if (!cx || !text) {
         puts("invalid params passed to xpc_DumpEvalInJSStackFrame!");
         return JS_FALSE;
     }
 
     printf("js[%d]> %s\n", frameno, text);
 
-    while (nsnull != (fp = JS_FrameIterator(cx, &iter)))
-    {
+    while (nsnull != (fp = JS_FrameIterator(cx, &iter))) {
         if (num == frameno)
             break;
         num++;
     }
 
-    if (!fp)
-    {
+    if (!fp) {
         puts("invalid frame number!");
         return JS_FALSE;
     }
 
     JSAutoRequest ar(cx);
 
     JSExceptionState* exceptionState = JS_SaveExceptionState(cx);
     JSErrorReporter older = JS_SetErrorReporter(cx, xpcDumpEvalErrorReporter);
 
     jsval rval;
     JSString* str;
     JSAutoByteString bytes;
     if (JS_EvaluateInStackFrame(cx, fp, text, strlen(text), "eval", 1, &rval) &&
         nsnull != (str = JS_ValueToString(cx, rval)) &&
-        bytes.encode(cx, str))
-    {
+        bytes.encode(cx, str)) {
         printf("%s\n", bytes.ptr());
     }
     else
         puts("eval failed!");
     JS_SetErrorReporter(cx, older);
     JS_RestoreExceptionState(cx, exceptionState);
     return JS_TRUE;
 }
@@ -452,18 +424,17 @@ static void PrintObjectBasics(JSObject* 
     else
         printf("%p 'host'", (void *)obj);
 }
 
 static void PrintObject(JSObject* obj, int depth, ObjectPile* pile)
 {
     PrintObjectBasics(obj);
 
-    switch (pile->Visit(obj))
-    {
+    switch (pile->Visit(obj)) {
     case ObjectPile::primary:
         puts("");
         break;
     case ObjectPile::seen:
         puts(" (SEE ABOVE)");
         return;
     case ObjectPile::overflow:
         puts(" (TOO MANY OBJECTS)");
--- a/js/xpconnect/src/XPCException.cpp
+++ b/js/xpconnect/src/XPCException.cpp
@@ -68,20 +68,18 @@ static struct ResultMap
 
 // static
 JSBool
 nsXPCException::NameAndFormatForNSResult(nsresult rv,
                                          const char** name,
                                          const char** format)
 {
 
-    for (ResultMap* p = map; p->name; p++)
-    {
-        if (rv == p->rv)
-        {
+    for (ResultMap* p = map; p->name; p++) {
+        if (rv == p->rv) {
             if (name) *name = p->name;
             if (format) *format = p->format;
             return JS_TRUE;
         }
     }
     return JS_FALSE;
 }
 
@@ -94,18 +92,17 @@ nsXPCException::IterateNSResults(nsresul
 {
     ResultMap* p = (ResultMap*) *iterp;
     if (!p)
         p = map;
     else
         p++;
     if (!p->name)
         p = nsnull;
-    else
-    {
+    else {
         if (rv)
             *rv = p->rv;
         if (name)
             *name = p->name;
         if (format)
             *format = p->format;
     }
     *iterp = p;
@@ -154,51 +151,46 @@ nsXPCException::~nsXPCException()
     MOZ_COUNT_DTOR(nsXPCException);
     Reset();
 }
 
 /* [noscript] xpcexJSVal stealJSVal (); */
 NS_IMETHODIMP
 nsXPCException::StealJSVal(jsval *vp NS_OUTPARAM)
 {
-    if (mThrownJSVal.IsHeld())
-    {
+    if (mThrownJSVal.IsHeld()) {
         *vp = mThrownJSVal.Release();
         return NS_OK;
     }
     return NS_ERROR_FAILURE;
 }
 
 /* [noscript] void stowJSVal (in xpcexJSContextPtr cx, in xpcexJSVal val); */
 NS_IMETHODIMP
 nsXPCException::StowJSVal(JSContext* cx, jsval v)
 {
-    if (mThrownJSVal.Hold(cx))
-    {
+    if (mThrownJSVal.Hold(cx)) {
         mThrownJSVal = v;
         return NS_OK;
     }
     return NS_ERROR_FAILURE;
 }
 
 void
 nsXPCException::Reset()
 {
-    if (mMessage)
-    {
+    if (mMessage) {
         nsMemory::Free(mMessage);
         mMessage = nsnull;
     }
-    if (mName)
-    {
+    if (mName) {
         nsMemory::Free(mName);
         mName = nsnull;
     }
-    if (mFilename)
-    {
+    if (mFilename) {
         nsMemory::Free(mFilename);
         mFilename = nsnull;
     }
     mLineNumber = (PRUint32)-1;
     NS_IF_RELEASE(mLocation);
     NS_IF_RELEASE(mData);
     NS_IF_RELEASE(mInner);
 }
@@ -310,62 +302,56 @@ nsXPCException::GetInner(nsIException* *
 NS_IMETHODIMP
 nsXPCException::Initialize(const char *aMessage, nsresult aResult, const char *aName, nsIStackFrame *aLocation, nsISupports *aData, nsIException *aInner)
 {
     if (mInitialized)
         return NS_ERROR_ALREADY_INITIALIZED;
 
     Reset();
 
-    if (aMessage)
-    {
+    if (aMessage) {
         if (!(mMessage = (char*) nsMemory::Clone(aMessage,
                                                  sizeof(char)*(strlen(aMessage)+1))))
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    if (aName)
-    {
+    if (aName) {
         if (!(mName = (char*) nsMemory::Clone(aName,
                                               sizeof(char)*(strlen(aName)+1))))
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
     mResult = aResult;
 
-    if (aLocation)
-    {
+    if (aLocation) {
         mLocation = aLocation;
         NS_ADDREF(mLocation);
         // For now, fill in our location details from our stack frame.
         // Later we may allow other locations?
         nsresult rc;
         if (NS_FAILED(rc = aLocation->GetFilename(&mFilename)))
             return rc;
         if (NS_FAILED(rc = aLocation->GetLineNumber(&mLineNumber)))
             return rc;
     }
-    else
-    {
+    else {
         nsresult rv;
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
         if (!xpc)
             return NS_ERROR_FAILURE;
         rv = xpc->GetCurrentJSStack(&mLocation);
         if (NS_FAILED(rv))
             return rv;
     }
 
-    if (aData)
-    {
+    if (aData) {
         mData = aData;
         NS_ADDREF(mData);
     }
-    if (aInner)
-    {
+    if (aInner) {
         mInner = aInner;
         NS_ADDREF(mInner);
     }
 
     mInitialized = PR_TRUE;
     return NS_OK;
 }
 
@@ -380,44 +366,41 @@ nsXPCException::ToString(char **_retval)
 
     static const char defaultMsg[] = "<no message>";
     static const char defaultLocation[] = "<unknown>";
     static const char format[] =
  "[Exception... \"%s\"  nsresult: \"0x%x (%s)\"  location: \"%s\"  data: %s]";
 
     char* indicatedLocation = nsnull;
 
-    if (mLocation)
-    {
+    if (mLocation) {
         // we need to free this if it does not fail
         nsresult rv = mLocation->ToString(&indicatedLocation);
         if (NS_FAILED(rv))
             return rv;
     }
 
     const char* msg = mMessage ? mMessage : nsnull;
     const char* location = indicatedLocation ?
                                 indicatedLocation : defaultLocation;
     const char* resultName = mName;
     if (!resultName && !NameAndFormatForNSResult(mResult, &resultName,
-                                                 (!msg) ? &msg : nsnull))
-    {
+                                                 (!msg) ? &msg : nsnull)) {
         if (!msg)
             msg = defaultMsg;
         resultName = "<unknown>";
     }
     const char* data = mData ? "yes" : "no";
 
     char* temp = JS_smprintf(format, msg, mResult, resultName, location, data);
     if (indicatedLocation)
         nsMemory::Free(indicatedLocation);
 
     char* final = nsnull;
-    if (temp)
-    {
+    if (temp) {
         final = (char*) nsMemory::Clone(temp, sizeof(char)*(strlen(temp)+1));
         JS_smprintf_free(temp);
     }
 
     *_retval = final;
     return final ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
@@ -433,66 +416,58 @@ nsXPCException::NewException(const char 
 {
     // A little hack... The nsIGenericModule nsIClassInfo scheme relies on there
     // having been at least one instance made via the factory. Otherwise, the
     // shared factory/classinsance object never gets created and our QI getter
     // for our instance's pointer to our nsIClassInfo will always return null.
     // This is bad because it means that wrapped exceptions will never have a
     // shared prototype. So... We force one to be created via the factory
     // *once* and then go about our business.
-    if (!sEverMadeOneFromFactory)
-    {
+    if (!sEverMadeOneFromFactory) {
         nsCOMPtr<nsIXPCException> e =
             do_CreateInstance(XPC_EXCEPTION_CONTRACTID);
         sEverMadeOneFromFactory = JS_TRUE;
     }
 
     nsresult rv;
     nsXPCException* e = new nsXPCException();
-    if (e)
-    {
+    if (e) {
         NS_ADDREF(e);
 
         nsIStackFrame* location;
-        if (aLocation)
-        {
+        if (aLocation) {
             location = aLocation;
             NS_ADDREF(location);
         }
-        else
-        {
+        else {
             nsXPConnect* xpc = nsXPConnect::GetXPConnect();
-            if (!xpc)
-            {
+            if (!xpc) {
                 NS_RELEASE(e);
                 return NS_ERROR_FAILURE;
             }
             rv = xpc->GetCurrentJSStack(&location);
-            if (NS_FAILED(rv))
-            {
+            if (NS_FAILED(rv)) {
                 NS_RELEASE(e);
                 return NS_ERROR_FAILURE;
             }
             // it is legal for there to be no active JS stack, if C++ code
             // is operating on a JS-implemented interface pointer without
             // having been called in turn by JS.  This happens in the JS
             // component loader, and will become more common as additional
             // components are implemented in JS.
         }
         // We want to trim off any leading native 'dataless' frames
         if (location)
-            while (1)
-            {
+            while (1) {
                 PRUint32 language;
                 PRInt32 lineNumber;
                 if (NS_FAILED(location->GetLanguage(&language)) ||
                     language == nsIProgrammingLanguage::JAVASCRIPT ||
                     NS_FAILED(location->GetLineNumber(&lineNumber)) ||
-                    lineNumber)
-                {
+                    lineNumber) {
                     break;
                 }
                 nsCOMPtr<nsIStackFrame> caller;
                 if (NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller)
                     break;
                 NS_RELEASE(location);
                 caller->QueryInterface(NS_GET_IID(nsIStackFrame), (void **)&location);
             }
--- a/js/xpconnect/src/XPCInlines.h
+++ b/js/xpconnect/src/XPCInlines.h
@@ -51,18 +51,17 @@ bool
 xpc::PtrAndPrincipalHashKey::KeyEquals(const PtrAndPrincipalHashKey* aKey) const
 {
     if (aKey->mPtr != mPtr)
         return PR_FALSE;
     if (aKey->mPrincipal == mPrincipal)
         return PR_TRUE;
 
     bool equals;
-    if (NS_FAILED(mPrincipal->EqualsIgnoringDomain(aKey->mPrincipal, &equals)))
-    {
+    if (NS_FAILED(mPrincipal->EqualsIgnoringDomain(aKey->mPrincipal, &equals))) {
         NS_ERROR("we failed, guessing!");
         return PR_FALSE;
     }
 
     return equals;
 }
 
 inline void
@@ -413,34 +412,30 @@ XPCNativeSet::FindMember(jsid name, XPCN
                          PRUint16* pInterfaceIndex) const
 {
     XPCNativeInterface* const * iface;
     int count = (int) mInterfaceCount;
     int i;
 
     // look for interface names first
 
-    for (i = 0, iface = mInterfaces; i < count; i++, iface++)
-    {
-        if (name == (*iface)->GetName())
-        {
+    for (i = 0, iface = mInterfaces; i < count; i++, iface++) {
+        if (name == (*iface)->GetName()) {
             if (pMember)
                 *pMember = nsnull;
             if (pInterfaceIndex)
                 *pInterfaceIndex = (PRUint16) i;
             return JS_TRUE;
         }
     }
 
     // look for method names
-    for (i = 0, iface = mInterfaces; i < count; i++, iface++)
-    {
+    for (i = 0, iface = mInterfaces; i < count; i++, iface++) {
         XPCNativeMember* member = (*iface)->FindMember(name);
-        if (member)
-        {
+        if (member) {
             if (pMember)
                 *pMember = member;
             if (pInterfaceIndex)
                 *pInterfaceIndex = (PRUint16) i;
             return JS_TRUE;
         }
     }
     return JS_FALSE;
@@ -485,48 +480,45 @@ XPCNativeSet::FindMember(jsid name,
     return JS_TRUE;
 }
 
 inline XPCNativeInterface*
 XPCNativeSet::FindNamedInterface(jsid name) const
 {
     XPCNativeInterface* const * pp = mInterfaces;
 
-    for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
-    {
+    for (int i = (int) mInterfaceCount; i > 0; i--, pp++) {
         XPCNativeInterface* iface = *pp;
 
         if (name == iface->GetName())
             return iface;
     }
     return nsnull;
 }
 
 inline XPCNativeInterface*
 XPCNativeSet::FindInterfaceWithIID(const nsIID& iid) const
 {
     XPCNativeInterface* const * pp = mInterfaces;
 
-    for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
-    {
+    for (int i = (int) mInterfaceCount; i > 0; i--, pp++) {
         XPCNativeInterface* iface = *pp;
 
         if (iface->GetIID()->Equals(iid))
             return iface;
     }
     return nsnull;
 }
 
 inline JSBool
 XPCNativeSet::HasInterface(XPCNativeInterface* aInterface) const
 {
     XPCNativeInterface* const * pp = mInterfaces;
 
-    for (int i = (int) mInterfaceCount; i > 0; i--, pp++)
-    {
+    for (int i = (int) mInterfaceCount; i > 0; i--, pp++) {
         if (aInterface == *pp)
             return JS_TRUE;
     }
     return JS_FALSE;
 }
 
 inline JSBool
 XPCNativeSet::HasInterfaceWithAncestor(XPCNativeInterface* aInterface) const
@@ -554,18 +546,17 @@ inline JSBool
 XPCNativeSet::MatchesSetUpToInterface(const XPCNativeSet* other,
                                       XPCNativeInterface* iface) const
 {
     int count = JS_MIN((int)mInterfaceCount, (int)other->mInterfaceCount);
 
     XPCNativeInterface* const * pp1 = mInterfaces;
     XPCNativeInterface* const * pp2 = other->mInterfaces;
 
-    for (int i = (int) count; i > 0; i--, pp1++, pp2++)
-    {
+    for (int i = (int) count; i > 0; i--, pp1++, pp2++) {
         XPCNativeInterface* cur = (*pp1);
         if (cur != (*pp2))
             return JS_FALSE;
         if (cur == iface)
             return JS_TRUE;
     }
     return JS_FALSE;
 }
@@ -622,33 +613,29 @@ XPCWrappedNative::HasInterfaceNoQI(const
 {
     return nsnull != GetSet()->FindInterfaceWithIID(iid);
 }
 
 inline void
 XPCWrappedNative::SweepTearOffs()
 {
     XPCWrappedNativeTearOffChunk* chunk;
-    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
-    {
+    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
-        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK; i > 0; i--, to++)
-        {
+        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK; i > 0; i--, to++) {
             JSBool marked = to->IsMarked();
             to->Unmark();
             if (marked)
                 continue;
 
             // If this tearoff does not have a live dedicated JSObject,
             // then let's recycle it.
-            if (!to->GetJSObject())
-            {
+            if (!to->GetJSObject()) {
                 nsISupports* obj = to->GetNative();
-                if (obj)
-                {
+                if (obj) {
                     obj->Release();
                     to->SetNative(nsnull);
                 }
                 to->SetInterface(nsnull);
             }
         }
     }
 }
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -98,18 +98,17 @@ nsJSID::GetName(char * *aName)
 }
 
 NS_IMETHODIMP
 nsJSID::GetNumber(char * *aNumber)
 {
     if (!aNumber)
         return NS_ERROR_NULL_POINTER;
 
-    if (!mNumber)
-    {
+    if (!mNumber) {
         if (!(mNumber = mID.ToString()))
             mNumber = gNoString;
     }
 
     *aNumber = NS_strdup(mNumber);
     return *aNumber ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
@@ -130,40 +129,36 @@ nsJSID::GetValid(bool *aValid)
 }
 
 NS_IMETHODIMP
 nsJSID::Equals(nsIJSID *other, bool *_retval)
 {
     if (!_retval)
         return NS_ERROR_NULL_POINTER;
 
-    if (!other || mID.Equals(GetInvalidIID()))
-    {
+    if (!other || mID.Equals(GetInvalidIID())) {
         *_retval = PR_FALSE;
         return NS_OK;
     }
 
     *_retval = other->GetID()->Equals(mID);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsJSID::Initialize(const char *idString)
 {
     if (!idString)
         return NS_ERROR_NULL_POINTER;
 
-    if (*idString != '\0' && mID.Equals(GetInvalidIID()))
-    {
+    if (*idString != '\0' && mID.Equals(GetInvalidIID())) {
         Reset();
 
-        if (idString[0] == '{')
-        {
-            if (mID.Parse(idString))
-            {
+        if (idString[0] == '{') {
+            if (mID.Parse(idString)) {
                 return NS_OK;
             }
 
             // error - reset to invalid state
             mID = GetInvalidIID();
         }
     }
     return NS_ERROR_FAILURE;
@@ -196,39 +191,36 @@ nsJSID::GetInvalidIID() const
                             {0x98, 0x41, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22}};
     return invalid;
 }
 
 //static
 nsJSID*
 nsJSID::NewID(const char* str)
 {
-    if (!str)
-    {
+    if (!str) {
         NS_ERROR("no string");
         return nsnull;
     }
 
     nsJSID* idObj = new nsJSID();
-    if (idObj)
-    {
+    if (idObj) {
         NS_ADDREF(idObj);
         if (NS_FAILED(idObj->Initialize(str)))
             NS_RELEASE(idObj);
     }
     return idObj;
 }
 
 //static
 nsJSID*
 nsJSID::NewID(const nsID& id)
 {
     nsJSID* idObj = new nsJSID();
-    if (idObj)
-    {
+    if (idObj) {
         NS_ADDREF(idObj);
         idObj->mID = id;
         idObj->mName = nsnull;
         idObj->mNumber = nsnull;
     }
     return idObj;
 }
 
@@ -267,18 +259,17 @@ NS_IMPL_THREADSAFE_RELEASE(SharedScripta
                                     nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
 #include "xpc_map_end.h" /* This will #undef the above */
 
 static nsIXPCScriptable* gSharedScriptableHelperForJSIID;
 
 NS_METHOD GetSharedScriptableHelperForJSIID(PRUint32 language,
                                             nsISupports **helper)
 {
-    if (language == nsIProgrammingLanguage::JAVASCRIPT)
-    {
+    if (language == nsIProgrammingLanguage::JAVASCRIPT) {
         NS_IF_ADDREF(gSharedScriptableHelperForJSIID);
         *helper = gSharedScriptableHelperForJSIID;
     }
     else
         *helper = nsnull;
     return NS_OK;
 }
 
@@ -378,18 +369,17 @@ NS_IMETHODIMP nsJSIID::GetValid(bool *aV
     return NS_OK;
 }
 
 NS_IMETHODIMP nsJSIID::Equals(nsIJSID *other, bool *_retval)
 {
     if (!_retval)
         return NS_ERROR_NULL_POINTER;
 
-    if (!other)
-    {
+    if (!other) {
         *_retval = PR_FALSE;
         return NS_OK;
     }
 
     mInfo->IsIID(other->GetID(), _retval);
     return NS_OK;
 }
 
@@ -402,18 +392,17 @@ NS_IMETHODIMP nsJSIID::ToString(char **_
 {
     return mInfo->GetName(_retval);
 }
 
 // static
 nsJSIID*
 nsJSIID::NewID(nsIInterfaceInfo* aInfo)
 {
-    if (!aInfo)
-    {
+    if (!aInfo) {
         NS_ERROR("no info");
         return nsnull;
     }
 
     bool canScript;
     if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
         return nsnull;
 
@@ -438,18 +427,17 @@ nsJSIID::NewResolve(nsIXPConnectWrappedN
     mInfo->GetIIDShared(&iid);
 
     iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
 
     if (!iface)
         return NS_OK;
 
     XPCNativeMember* member = iface->FindMember(id);
-    if (member && member->IsConstant())
-    {
+    if (member && member->IsConstant()) {
         jsval val;
         if (!member->GetConstantValue(ccx, iface, &val))
             return NS_ERROR_OUT_OF_MEMORY;
 
         *objp = obj;
         *_retval = JS_DefinePropertyById(cx, obj, id, val, nsnull, nsnull,
                                          JSPROP_ENUMERATE | JSPROP_READONLY |
                                          JSPROP_PERMANENT);
@@ -473,68 +461,62 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNa
     mInfo->GetIIDShared(&iid);
 
     iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
 
     if (!iface)
         return NS_OK;
 
     PRUint16 count = iface->GetMemberCount();
-    for (PRUint16 i = 0; i < count; i++)
-    {
+    for (PRUint16 i = 0; i < count; i++) {
         XPCNativeMember* member = iface->GetMemberAt(i);
         if (member && member->IsConstant() &&
-            !xpc_ForcePropertyResolve(cx, obj, member->GetName()))
-        {
+            !xpc_ForcePropertyResolve(cx, obj, member->GetName())) {
             return NS_ERROR_UNEXPECTED;
         }
     }
     return NS_OK;
 }
 
 /* bool hasInstance (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval val, out bool bp); */
 NS_IMETHODIMP
 nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
                      JSContext * cx, JSObject * obj,
                      const jsval &val, bool *bp, bool *_retval)
 {
     *bp = JS_FALSE;
     nsresult rv = NS_OK;
 
-    if (!JSVAL_IS_PRIMITIVE(val))
-    {
+    if (!JSVAL_IS_PRIMITIVE(val)) {
         // we have a JSObject
         JSObject* obj = JSVAL_TO_OBJECT(val);
 
         NS_ASSERTION(obj, "when is an object not an object?");
 
         // is this really a native xpcom object with a wrapper?
         const nsIID* iid;
         mInfo->GetIIDShared(&iid);
 
-        if (IS_SLIM_WRAPPER(obj))
-        {
+        if (IS_SLIM_WRAPPER(obj)) {
             XPCWrappedNativeProto* proto = GetSlimWrapperProto(obj);
-            if (proto->GetSet()->HasInterfaceWithAncestor(iid))
-            {
+            if (proto->GetSet()->HasInterfaceWithAncestor(iid)) {
                 *bp = JS_TRUE;
                 return NS_OK;
             }
 
 #ifdef DEBUG_slimwrappers
             char foo[NSID_LENGTH];
             iid->ToProvidedString(foo);
             SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, foo);
 #endif
             if (!MorphSlimWrapper(cx, obj))
                 return NS_ERROR_FAILURE;
         }
 
-        if (mozilla::dom::binding::instanceIsProxy(obj))
-        {
+        if (mozilla::dom::binding::instanceIsProxy(obj)) {
             nsISupports *identity =
                 static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
             nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(identity);
 
             XPCCallContext ccx(JS_CALLER, cx);
 
             AutoMarkingNativeSetPtr set(ccx);
             set = XPCNativeSet::GetNewOrUsed(ccx, ci);
@@ -548,18 +530,17 @@ nsJSIID::HasInstance(nsIXPConnectWrapped
            XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
 
         if (!other_wrapper)
             return NS_OK;
 
         // We'll trust the interface set of the wrapper if this is known
         // to be an interface that the objects *expects* to be able to
         // handle.
-        if (other_wrapper->HasInterfaceNoQI(*iid))
-        {
+        if (other_wrapper->HasInterfaceNoQI(*iid)) {
             *bp = JS_TRUE;
             return NS_OK;
         }
 
         // Otherwise, we'll end up Querying the native object to be sure.
         XPCCallContext ccx(JS_CALLER, cx);
 
         AutoMarkingNativeInterfacePtr iface(ccx);
@@ -663,42 +644,36 @@ nsJSCID::ResolveName()
     if (!mDetails.NameIsSet())
         mDetails.SetNameToNoString();
 }
 
 //static
 nsJSCID*
 nsJSCID::NewID(const char* str)
 {
-    if (!str)
-    {
+    if (!str) {
         NS_ERROR("no string");
         return nsnull;
     }
 
     nsJSCID* idObj = new nsJSCID();
-    if (idObj)
-    {
+    if (idObj) {
         bool success = false;
         NS_ADDREF(idObj);
 
-        if (str[0] == '{')
-        {
+        if (str[0] == '{') {
             if (NS_SUCCEEDED(idObj->Initialize(str)))
                 success = PR_TRUE;
         }
-        else
-        {
+        else {
             nsCOMPtr<nsIComponentRegistrar> registrar;
             NS_GetComponentRegistrar(getter_AddRefs(registrar));
-            if (registrar)
-            {
+            if (registrar) {
                 nsCID *cid;
-                if (NS_SUCCEEDED(registrar->ContractIDToCID(str, &cid)))
-                {
+                if (NS_SUCCEEDED(registrar->ContractIDToCID(str, &cid))) {
                     success = idObj->mDetails.InitWithName(*cid, str);
                     nsMemory::Free(cid);
                 }
             }
         }
         if (!success)
             NS_RELEASE(idObj);
     }
@@ -706,24 +681,22 @@ nsJSCID::NewID(const char* str)
 }
 
 static const nsID*
 GetIIDArg(PRUint32 argc, jsval* argv, JSContext* cx)
 {
     const nsID* iid;
 
     // If an IID was passed in then use it
-    if (argc)
-    {
+    if (argc) {
         JSObject* iidobj;
         jsval val = *argv;
         if (JSVAL_IS_PRIMITIVE(val) ||
             !(iidobj = JSVAL_TO_OBJECT(val)) ||
-            !(iid = xpc_JSObjectToID(cx, iidobj)))
-        {
+            !(iid = xpc_JSObjectToID(cx, iidobj))) {
             return nsnull;
         }
     }
     else
         iid = &NS_GET_IID(nsISupports);
 
     return iid;
 }
@@ -760,18 +733,17 @@ nsJSCID::CreateInstance(nsISupports **_r
     wrapper->GetJSObject(&obj);
 
     // Do the security check if necessary
 
     XPCContext* xpcc = XPCContext::GetXPCContext(cx);
 
     nsIXPCSecurityManager* sm;
     sm = xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_INSTANCE);
-    if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
-    {
+    if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID()))) {
         NS_ERROR("how are we not being called from chrome here?");
         return NS_OK;
     }
 
     // If an IID was passed in then use it
     const nsID* iid = GetIIDArg(argc, argv, cx);
     if (!iid)
         return NS_ERROR_XPC_BAD_IID;
@@ -827,18 +799,17 @@ nsJSCID::GetService(nsISupports **_retva
     wrapper->GetJSObject(&obj);
 
     // Do the security check if necessary
 
     XPCContext* xpcc = XPCContext::GetXPCContext(cx);
 
     nsIXPCSecurityManager* sm;
     sm = xpcc->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_GET_SERVICE);
-    if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID())))
-    {
+    if (sm && NS_FAILED(sm->CanCreateInstance(cx, mDetails.ID()))) {
         NS_ASSERTION(JS_IsExceptionPending(cx),
                      "security manager vetoed GetService without setting exception");
         return NS_OK;
     }
 
     // If an IID was passed in then use it
     const nsID* iid = GetIIDArg(argc, argv, cx);
     if (!iid)
@@ -890,18 +861,17 @@ nsJSCID::Construct(nsIXPConnectWrappedNa
 NS_IMETHODIMP
 nsJSCID::HasInstance(nsIXPConnectWrappedNative *wrapper,
                      JSContext * cx, JSObject * obj,
                      const jsval &val, bool *bp, bool *_retval)
 {
     *bp = JS_FALSE;
     nsresult rv = NS_OK;
 
-    if (!JSVAL_IS_PRIMITIVE(val))
-    {
+    if (!JSVAL_IS_PRIMITIVE(val)) {
         // we have a JSObject
         JSObject* obj = JSVAL_TO_OBJECT(val);
 
         NS_ASSERTION(obj, "when is an object not an object?");
 
         // is this really a native xpcom object with a wrapper?
         JSObject* obj2;
         XPCWrappedNative* other_wrapper =
@@ -911,18 +881,17 @@ nsJSCID::HasInstance(nsIXPConnectWrapped
             return NS_OK;
 
         nsIClassInfo* ci = other_wrapper ?
                            other_wrapper->GetClassInfo() :
                            GetSlimWrapperProto(obj2)->GetClassInfo();
 
         // We consider CID equality to be the thing that matters here.
         // This is perhaps debatable.
-        if (ci)
-        {
+        if (ci) {
             nsID cid;
             if (NS_SUCCEEDED(ci->GetClassIDNoAlloc(&cid)))
                 *bp = cid.Equals(mDetails.ID());
         }
     }
     return rv;
 }
 
@@ -931,28 +900,25 @@ nsJSCID::HasInstance(nsIXPConnectWrapped
 
 JSObject *
 xpc_NewIDObject(JSContext *cx, JSObject* jsobj, const nsID& aID)
 {
     JSObject *obj = nsnull;
 
     nsCOMPtr<nsIJSID> iid =
             dont_AddRef(static_cast<nsIJSID*>(nsJSID::NewID(aID)));
-    if (iid)
-    {
+    if (iid) {
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
-        if (xpc)
-        {
+        if (xpc) {
             nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
             nsresult rv = xpc->WrapNative(cx, jsobj,
                                           static_cast<nsISupports*>(iid),
                                           NS_GET_IID(nsIJSID),
                                           getter_AddRefs(holder));
-            if (NS_SUCCEEDED(rv) && holder)
-            {
+            if (NS_SUCCEEDED(rv) && holder) {
                 holder->GetJSObject(&obj);
             }
         }
     }
     return obj;
 }
 
 // note: returned pointer is only valid while |obj| remains alive!
@@ -963,18 +929,17 @@ xpc_JSObjectToID(JSContext *cx, JSObject
         return nsnull;
 
     // NOTE: this call does NOT addref
     XPCWrappedNative* wrapper =
         XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
     if (wrapper &&
         (wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSID))  ||
          wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSIID)) ||
-         wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID))))
-    {
+         wrapper->HasInterfaceNoQI(NS_GET_IID(nsIJSCID)))) {
         return ((nsIJSID*)wrapper->GetIdentityObject())->GetID();
     }
     return nsnull;
 }
 
 JSBool
 xpc_JSObjectIsID(JSContext *cx, JSObject* obj)
 {
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -101,20 +101,18 @@ static JSDHashOperator
 WrappedJSDyingJSObjectFinder(JSDHashTable *table, JSDHashEntryHdr *hdr,
                              uint32 number, void *arg)
 {
     JSDyingJSObjectData* data = (JSDyingJSObjectData*) arg;
     nsXPCWrappedJS* wrapper = ((JSObject2WrappedJSMap::Entry*)hdr)->value;
     NS_ASSERTION(wrapper, "found a null JS wrapper!");
 
     // walk the wrapper chain and find any whose JSObject is to be finalized
-    while (wrapper)
-    {
-        if (wrapper->IsSubjectToFinalization())
-        {
+    while (wrapper) {
+        if (wrapper->IsSubjectToFinalization()) {
             js::AutoSwitchCompartment sc(data->cx,
                                          wrapper->GetJSObjectPreserveColor());
             if (JS_IsAboutToBeFinalized(data->cx,
                                         wrapper->GetJSObjectPreserveColor()))
                 data->array->AppendElement(wrapper);
         }
         wrapper = wrapper->GetNextWrapper();
     }
@@ -127,18 +125,17 @@ struct CX_AND_XPCRT_Data
     XPCJSRuntime* rt;
 };
 
 static JSDHashOperator
 NativeInterfaceSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
                        uint32 number, void *arg)
 {
     XPCNativeInterface* iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value;
-    if (iface->IsMarked())
-    {
+    if (iface->IsMarked()) {
         iface->Unmark();
         return JS_DHASH_NEXT;
     }
 
 #ifdef XPC_REPORT_NATIVE_INTERFACE_AND_SET_FLUSHING
     fputs("- Destroying XPCNativeInterface for ", stdout);
     JS_PutString(JSVAL_TO_STRING(iface->GetName()), stdout);
     putc('\n', stdout);
@@ -163,27 +160,25 @@ NativeUnMarkedSetRemover(JSDHashTable *t
     return JS_DHASH_REMOVE;
 }
 
 static JSDHashOperator
 NativeSetSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
                  uint32 number, void *arg)
 {
     XPCNativeSet* set = ((NativeSetMap::Entry*)hdr)->key_value;
-    if (set->IsMarked())
-    {
+    if (set->IsMarked()) {
         set->Unmark();
         return JS_DHASH_NEXT;
     }
 
 #ifdef XPC_REPORT_NATIVE_INTERFACE_AND_SET_FLUSHING
     printf("- Destroying XPCNativeSet for:\n");
     PRUint16 count = set->GetInterfaceCount();
-    for (PRUint16 k = 0; k < count; k++)
-    {
+    for (PRUint16 k = 0; k < count; k++) {
         XPCNativeInterface* iface = set->GetInterfaceAt(k);
         fputs("    ", stdout);
         JS_PutString(JSVAL_TO_STRING(iface->GetName()), stdout);
         putc('\n', stdout);
     }
 #endif
 
     XPCNativeSet::DestroyInstance(set);
@@ -191,18 +186,17 @@ NativeSetSweeper(JSDHashTable *table, JS
 }
 
 static JSDHashOperator
 JSClassSweeper(JSDHashTable *table, JSDHashEntryHdr *hdr,
                uint32 number, void *arg)
 {
     XPCNativeScriptableShared* shared =
         ((XPCNativeScriptableSharedMap::Entry*) hdr)->key;
-    if (shared->IsMarked())
-    {
+    if (shared->IsMarked()) {
 #ifdef off_XPC_REPORT_JSCLASS_FLUSHING
         printf("+ Marked XPCNativeScriptableShared for: %s @ %x\n",
                shared->GetJSClass()->name,
                shared->GetJSClass());
 #endif
         shared->Unmark();
         return JS_DHASH_NEXT;
     }
@@ -238,25 +232,22 @@ DetachedWrappedNativeProtoMarker(JSDHash
     return JS_DHASH_NEXT;
 }
 
 // GCCallback calls are chained
 static JSBool
 ContextCallback(JSContext *cx, uintN operation)
 {
     XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
-    if (self)
-    {
-        if (operation == JSCONTEXT_NEW)
-        {
+    if (self) {
+        if (operation == JSCONTEXT_NEW) {
             if (!self->OnJSContextNew(cx))
                 return JS_FALSE;
         }
-        else if (operation == JSCONTEXT_DESTROY)
-        {
+        else if (operation == JSCONTEXT_DESTROY) {
             delete XPCContext::GetXPCContext(cx);
         }
     }
     return JS_TRUE;
 }
 
 xpc::CompartmentPrivate::~CompartmentPrivate()
 {
@@ -271,30 +262,28 @@ CompartmentCallback(JSContext *cx, JSCom
     XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
     if (!self)
         return JS_TRUE;
 
     nsAutoPtr<xpc::CompartmentPrivate> priv(static_cast<xpc::CompartmentPrivate*>(JS_SetCompartmentPrivate(cx, compartment, nsnull)));
     if (!priv)
         return JS_TRUE;
 
-    if (xpc::PtrAndPrincipalHashKey *key = priv->key)
-    {
+    if (xpc::PtrAndPrincipalHashKey *key = priv->key) {
         XPCCompartmentMap &map = self->GetCompartmentMap();
 #ifdef DEBUG
         {
             JSCompartment *current = NULL;  // init to shut GCC up
             NS_ASSERTION(map.Get(key, &current), "no compartment?");
             NS_ASSERTION(current == compartment, "compartment mismatch");
         }
 #endif
         map.Remove(key);
     }
-    else
-    {
+    else {
         nsISupports *ptr = priv->ptr;
         XPCMTCompartmentMap &map = self->GetMTCompartmentMap();
 #ifdef DEBUG
         {
             JSCompartment *current;
             NS_ASSERTION(map.Get(ptr, &current), "no compartment?");
             NS_ASSERTION(current == compartment, "compartment mismatch");
         }
@@ -343,29 +332,27 @@ XPCJSRuntime::RemoveJSHolder(void* aHold
 
 // static
 void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
 {
     XPCJSRuntime* self = (XPCJSRuntime*)data;
 
     // Skip this part if XPConnect is shutting down. We get into
     // bad locking problems with the thread iteration otherwise.
-    if (!self->GetXPConnect()->IsShuttingDown())
-    {
+    if (!self->GetXPConnect()->IsShuttingDown()) {
         Mutex* threadLock = XPCPerThreadData::GetLock();
         if (threadLock)
         { // scoped lock
             MutexAutoLock lock(*threadLock);
 
             XPCPerThreadData* iterp = nsnull;
             XPCPerThreadData* thread;
 
             while (nsnull != (thread =
-                              XPCPerThreadData::IterateThreads(&iterp)))
-            {
+                              XPCPerThreadData::IterateThreads(&iterp))) {
                 // Trace those AutoMarkingPtr lists!
                 thread->TraceJS(trc);
             }
         }
     }
 
     {
         XPCAutoLock lock(self->mMapLock);
@@ -386,18 +373,17 @@ void XPCJSRuntime::TraceGrayJS(JSTracer*
     // Mark these roots as gray so the CC can walk them later.
     self->TraceXPConnectRoots(trc);
 }
 
 static void
 TraceJSObject(PRUint32 aLangID, void *aScriptThing, const char *name,
               void *aClosure)
 {
-    if (aLangID == nsIProgrammingLanguage::JAVASCRIPT)
-    {
+    if (aLangID == nsIProgrammingLanguage::JAVASCRIPT) {
         JS_CALL_TRACER(static_cast<JSTracer*>(aClosure), aScriptThing,
                        js_GetGCThingTraceKind(aScriptThing), name);
     }
 }
 
 static JSDHashOperator
 TraceJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
               void *arg)
@@ -480,18 +466,17 @@ struct Closure
 static void
 CheckParticipatesInCycleCollection(PRUint32 aLangID, void *aThing,
                                    const char *name, void *aClosure)
 {
     Closure *closure = static_cast<Closure*>(aClosure);
 
     if (!closure->cycleCollectionEnabled &&
         aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
-        js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT)
-    {
+        js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT) {
         closure->cycleCollectionEnabled =
             xpc::ParticipatesInCycleCollection(closure->cx,
                                                static_cast<JSObject*>(aThing));
     }
 }
 
 static JSDHashOperator
 NoteJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
@@ -574,18 +559,17 @@ XPCJSRuntime::AddXPConnectRoots(JSContex
     // through rooting or locking, we need to add all the native objects that
     // hold them so that the JS objects are colored correctly in the cycle
     // collector. This includes JSContexts that don't have outstanding requests,
     // because their global object wasn't marked by the JS GC. All other JS
     // roots were marked by the JS GC and will be colored correctly in the cycle
     // collector.
 
     JSContext *iter = nsnull, *acx;
-    while ((acx = JS_ContextIterator(GetJSRuntime(), &iter)))
-    {
+    while ((acx = JS_ContextIterator(GetJSRuntime(), &iter))) {
         // Only skip JSContexts with outstanding requests if the
         // callback does not want all traces (a debug feature).
         // Otherwise, we do want to know about all JSContexts to get
         // better graphs and explanations.
         if (!cb.WantAllTraces() && nsXPConnect::GetXPConnect()->GetOutstandingRequests(acx))
             continue;
         cb.NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, acx,
                     nsXPConnect::JSContextParticipant());
@@ -593,47 +577,43 @@ XPCJSRuntime::AddXPConnectRoots(JSContex
 
     XPCAutoLock lock(mMapLock);
 
     XPCWrappedNativeScope::SuspectAllWrappers(this, cx, cb);
 
     for (XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
         cb.NoteXPCOMRoot(static_cast<XPCTraceableVariant*>(e));
 
-    for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
-    {
+    for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot()) {
         nsXPCWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
         JSObject *obj = wrappedJS->GetJSObjectPreserveColor();
 
         // Only suspect wrappedJSObjects that are in a compartment that
         // participates in cycle collection.
         if (!xpc::ParticipatesInCycleCollection(cx, obj))
             continue;
 
         cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
     }
 
     Closure closure = { cx, PR_TRUE, &cb };
-    if (mJSHolders.ops)
-    {
+    if (mJSHolders.ops) {
         JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &closure);
     }
 
     // Suspect wrapped natives with expando objects.
     GetCompartmentMap().EnumerateRead(SuspectCompartment, &closure);
 }
 
 template<class T> static void
 DoDeferredRelease(nsTArray<T> &array)
 {
-    while (1)
-    {
+    while (1) {
         PRUint32 count = array.Length();
-        if (!count)
-        {
+        if (!count) {
             array.Compact();
             break;
         }
         T wrapper = array[count-1];
         array.RemoveElementAt(count-1);
         NS_RELEASE(wrapper);
     }
 }
@@ -674,22 +654,20 @@ SweepCompartment(nsCStringHashKey& aKey,
 
 // static
 JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
 {
     XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
     if (!self)
         return JS_TRUE;
 
-    switch (status)
-    {
+    switch (status) {
         case JSGC_BEGIN:
         {
-            if (!NS_IsMainThread())
-            {
+            if (!NS_IsMainThread()) {
                 return JS_FALSE;
             }
 
             // We seem to sometime lose the unrooted global flag. Restore it
             // here. FIXME: bug 584495.
             JSContext *iter = nsnull, *acx;
 
             while ((acx = JS_ContextIterator(cx->runtime, &iter))) {
@@ -765,64 +743,58 @@ JSBool XPCJSRuntime::GCCallback(JSContex
             // chance that a wrapper's set will change *while* a call is
             // happening which uses that wrapper's old interfface set. So,
             // we need to do this marking to avoid collecting those sets
             // that might no longer be otherwise reachable from the wrappers
             // or the wrapperprotos.
 
             // Skip this part if XPConnect is shutting down. We get into
             // bad locking problems with the thread iteration otherwise.
-            if (!self->GetXPConnect()->IsShuttingDown())
-            {
+            if (!self->GetXPConnect()->IsShuttingDown()) {
                 Mutex* threadLock = XPCPerThreadData::GetLock();
                 if (threadLock)
                 { // scoped lock
                     MutexAutoLock lock(*threadLock);
 
                     XPCPerThreadData* iterp = nsnull;
                     XPCPerThreadData* thread;
 
                     while (nsnull != (thread =
-                                      XPCPerThreadData::IterateThreads(&iterp)))
-                    {
+                                      XPCPerThreadData::IterateThreads(&iterp))) {
                         // Mark those AutoMarkingPtr lists!
                         thread->MarkAutoRootsAfterJSFinalize();
 
                         XPCCallContext* ccxp = thread->GetCallContext();
-                        while (ccxp)
-                        {
+                        while (ccxp) {
                             // Deal with the strictness of callcontext that
                             // complains if you ask for a set when
                             // it is in a state where the set could not
                             // possibly be valid.
-                            if (ccxp->CanGetSet())
-                            {
+                            if (ccxp->CanGetSet()) {
                                 XPCNativeSet* set = ccxp->GetSet();
                                 if (set)
                                     set->Mark();
                             }
-                            if (ccxp->CanGetInterface())
-                            {
+                            if (ccxp->CanGetInterface()) {
                                 XPCNativeInterface* iface = ccxp->GetInterface();
                                 if (iface)
                                     iface->Mark();
                             }
                             ccxp = ccxp->GetPrevCallContext();
                         }
                     }
                 }
             }
 
             // Do the sweeping...
 
             // We don't want to sweep the JSClasses at shutdown time.
             // At this point there may be JSObjects using them that have
             // been removed from the other maps.
-            if (!self->GetXPConnect()->IsShuttingDown())
-            {
+            if (!self->GetXPConnect()->IsShuttingDown()) {
                 self->mNativeScriptableSharedMap->
                     Enumerate(JSClassSweeper, nsnull);
             }
 
             self->mClassInfo2NativeSetMap->
                 Enumerate(NativeUnMarkedSetRemover, nsnull);
 
             self->mNativeSetMap->
@@ -859,41 +831,36 @@ JSBool XPCJSRuntime::GCCallback(JSContex
             // This allows us to perhaps minimize the growth of the
             // tearoffs. And also makes us not hold references to interfaces
             // on our wrapped natives that we are not actually using.
             //
             // XXX We may decide to not do this on *every* gc cycle.
 
             // Skip this part if XPConnect is shutting down. We get into
             // bad locking problems with the thread iteration otherwise.
-            if (!self->GetXPConnect()->IsShuttingDown())
-            {
+            if (!self->GetXPConnect()->IsShuttingDown()) {
                 Mutex* threadLock = XPCPerThreadData::GetLock();
-                if (threadLock)
-                {
+                if (threadLock) {
                     // Do the marking...
 
                     { // scoped lock
                         MutexAutoLock lock(*threadLock);
 
                         XPCPerThreadData* iterp = nsnull;
                         XPCPerThreadData* thread;
 
                         while (nsnull != (thread =
-                                          XPCPerThreadData::IterateThreads(&iterp)))
-                        {
+                                          XPCPerThreadData::IterateThreads(&iterp))) {
                             XPCCallContext* ccxp = thread->GetCallContext();
-                            while (ccxp)
-                            {
+                            while (ccxp) {
                                 // Deal with the strictness of callcontext that
                                 // complains if you ask for a tearoff when
                                 // it is in a state where the tearoff could not
                                 // possibly be valid.
-                                if (ccxp->CanGetTearOff())
-                                {
+                                if (ccxp->CanGetTearOff()) {
                                     XPCWrappedNativeTearOff* to =
                                         ccxp->GetTearOff();
                                     if (to)
                                         to->Mark();
                                 }
                                 ccxp = ccxp->GetPrevCallContext();
                             }
                         }
@@ -982,51 +949,47 @@ void
 XPCJSRuntime::WatchdogMain(void *arg)
 {
     XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
 
     // Lock lasts until we return
     AutoLockJSGC lock(self->mJSRuntime);
 
     PRIntervalTime sleepInterval;
-    while (self->mWatchdogThread)
-    {
+    while (self->mWatchdogThread) {
         // Sleep only 1 second if recently (or currently) active; otherwise, hibernate
         if (self->mLastActiveTime == -1 || PR_Now() - self->mLastActiveTime <= PRTime(2*PR_USEC_PER_SEC))
             sleepInterval = PR_TicksPerSecond();
-        else
-        {
+        else {
             sleepInterval = PR_INTERVAL_NO_TIMEOUT;
             self->mWatchdogHibernating = PR_TRUE;
         }
 #ifdef DEBUG
         PRStatus status =
 #endif
             PR_WaitCondVar(self->mWatchdogWakeup, sleepInterval);
         JS_ASSERT(status == PR_SUCCESS);
         JSContext* cx = nsnull;
-        while ((cx = js_NextActiveContext(self->mJSRuntime, cx)))
-        {
+        while ((cx = js_NextActiveContext(self->mJSRuntime, cx))) {
             js::TriggerOperationCallback(cx);
         }
     }
 
     /* Wake up the main thread waiting for the watchdog to terminate. */
     PR_NotifyCondVar(self->mWatchdogWakeup);
 }
 
 //static
 void
 XPCJSRuntime::ActivityCallback(void *arg, JSBool active)
 {
     XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
     if (active) {
         self->mLastActiveTime = -1;
-        if (self->mWatchdogHibernating)
-        {
+        if (self->mWatchdogHibernating) {
             self->mWatchdogHibernating = PR_FALSE;
             PR_NotifyCondVar(self->mWatchdogWakeup);
         }
     } else {
         self->mLastActiveTime = PR_Now();
     }
 }
 
@@ -1086,36 +1049,34 @@ XPCJSRuntime::GetJSCycleCollectionContex
             return nsnull;
         JS_ClearContextThread(mJSCycleCollectionContext);
     }
     return mJSCycleCollectionContext;
 }
 
 XPCJSRuntime::~XPCJSRuntime()
 {
-    if (mWatchdogWakeup)
-    {
+    if (mWatchdogWakeup) {
         // If the watchdog thread is running, tell it to terminate waking it
         // up if necessary and wait until it signals that it finished. As we
         // must release the lock before calling PR_DestroyCondVar, we use an
         // extra block here.
         {
             AutoLockJSGC lock(mJSRuntime);
             if (mWatchdogThread) {
                 mWatchdogThread = nsnull;
                 PR_NotifyCondVar(mWatchdogWakeup);
                 PR_WaitCondVar(mWatchdogWakeup, PR_INTERVAL_NO_TIMEOUT);
             }
         }
         PR_DestroyCondVar(mWatchdogWakeup);
         mWatchdogWakeup = nsnull;
     }
 
-    if (mJSCycleCollectionContext)
-    {
+    if (mJSCycleCollectionContext) {
         JS_SetContextThread(mJSCycleCollectionContext);
         JS_DestroyContextNoGC(mJSCycleCollectionContext);
     }
 
 #ifdef XPC_DUMP_AT_SHUTDOWN
     {
     // count the total JSContexts in use
     JSContext* iter = nsnull;
@@ -1123,145 +1084,132 @@ XPCJSRuntime::~XPCJSRuntime()
     while (JS_ContextIterator(mJSRuntime, &iter))
         count ++;
     if (count)
         printf("deleting XPCJSRuntime with %d live JSContexts\n", count);
     }
 #endif
 
     // clean up and destroy maps...
-    if (mWrappedJSMap)
-    {
+    if (mWrappedJSMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mWrappedJSMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live wrapped JSObject\n", (int)count);
 #endif
         mWrappedJSMap->Enumerate(WrappedJSShutdownMarker, mJSRuntime);
         delete mWrappedJSMap;
     }
 
-    if (mWrappedJSClassMap)
-    {
+    if (mWrappedJSClassMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mWrappedJSClassMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live nsXPCWrappedJSClass\n", (int)count);
 #endif
         delete mWrappedJSClassMap;
     }
 
-    if (mIID2NativeInterfaceMap)
-    {
+    if (mIID2NativeInterfaceMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mIID2NativeInterfaceMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live XPCNativeInterfaces\n", (int)count);
 #endif
         delete mIID2NativeInterfaceMap;
     }
 
-    if (mClassInfo2NativeSetMap)
-    {
+    if (mClassInfo2NativeSetMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mClassInfo2NativeSetMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count);
 #endif
         delete mClassInfo2NativeSetMap;
     }
 
-    if (mNativeSetMap)
-    {
+    if (mNativeSetMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mNativeSetMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count);
 #endif
         delete mNativeSetMap;
     }
 
     if (mMapLock)
         XPCAutoLock::DestroyLock(mMapLock);
 
-    if (mThisTranslatorMap)
-    {
+    if (mThisTranslatorMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mThisTranslatorMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live ThisTranslator\n", (int)count);
 #endif
         delete mThisTranslatorMap;
     }
 
 #ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN
-    if (DEBUG_WrappedNativeHashtable)
-    {
+    if (DEBUG_WrappedNativeHashtable) {
         int LiveWrapperCount = 0;
         JS_DHashTableEnumerate(DEBUG_WrappedNativeHashtable,
                                DEBUG_WrapperChecker, &LiveWrapperCount);
         if (LiveWrapperCount)
             printf("deleting XPCJSRuntime with %d live XPCWrappedNative (found in wrapper check)\n", (int)LiveWrapperCount);
         JS_DHashTableDestroy(DEBUG_WrappedNativeHashtable);
     }
 #endif
 
-    if (mNativeScriptableSharedMap)
-    {
+    if (mNativeScriptableSharedMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mNativeScriptableSharedMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live XPCNativeScriptableShared\n", (int)count);
 #endif
         delete mNativeScriptableSharedMap;
     }
 
-    if (mDyingWrappedNativeProtoMap)
-    {
+    if (mDyingWrappedNativeProtoMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mDyingWrappedNativeProtoMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live but dying XPCWrappedNativeProto\n", (int)count);
 #endif
         delete mDyingWrappedNativeProtoMap;
     }
 
-    if (mDetachedWrappedNativeProtoMap)
-    {
+    if (mDetachedWrappedNativeProtoMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mDetachedWrappedNativeProtoMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live detached XPCWrappedNativeProto\n", (int)count);
 #endif
         delete mDetachedWrappedNativeProtoMap;
     }
 
-    if (mExplicitNativeWrapperMap)
-    {
+    if (mExplicitNativeWrapperMap) {
 #ifdef XPC_DUMP_AT_SHUTDOWN
         uint32 count = mExplicitNativeWrapperMap->Count();
         if (count)
             printf("deleting XPCJSRuntime with %d live explicit XPCNativeWrapper\n", (int)count);
 #endif
         delete mExplicitNativeWrapperMap;
     }
 
     // unwire the readable/JSString sharing magic
     XPCStringConvert::ShutdownDOMStringFinalizer();
 
     XPCConvert::RemoveXPCOMUCStringFinalizer();
 
-    if (mJSHolders.ops)
-    {
+    if (mJSHolders.ops) {
         JS_DHashTableFinish(&mJSHolders);
         mJSHolders.ops = nsnull;
     }
 
-    if (mJSRuntime)
-    {
+    if (mJSRuntime) {
         JS_DestroyRuntime(mJSRuntime);
         JS_ShutDown();
 #ifdef DEBUG_shaver_off
         fprintf(stderr, "nJRSI: destroyed runtime %p\n", (void *)mJSRuntime);
 #endif
     }
 
     XPCPerThreadData::ShutDown();
@@ -1269,18 +1217,17 @@ XPCJSRuntime::~XPCJSRuntime()
 
 namespace {
 
 #ifdef JS_TRACER
 
 PRInt64
 GetCompartmentTjitCodeSize(JSCompartment *c)
 {
-    if (c->hasTraceMonitor())
-    {
+    if (c->hasTraceMonitor()) {
         size_t total, frag_size, free_size;
         c->traceMonitor()->getCodeAllocStats(total, frag_size, free_size);
         return total;
     }
     return 0;
 }
 
 PRInt64
@@ -1355,18 +1302,17 @@ ArenaCallback(JSContext *cx, void *vdata
 
 void
 CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind,
              size_t thingSize)
 {
     IterateData *data = static_cast<IterateData *>(vdata);
     CompartmentStats *curr = data->currCompartmentStats;
     curr->gcHeapKinds[traceKind] += thingSize;
-    switch (traceKind)
-    {
+    switch (traceKind) {
         case JSTRACE_OBJECT:
         {
             JSObject *obj = static_cast<JSObject *>(thing);
             curr->objectSlots += obj->sizeOfSlotsArray(moz_malloc_usable_size);
             break;
         }
         case JSTRACE_STRING:
         {
@@ -1536,66 +1482,58 @@ NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJS
 namespace mozilla {
 namespace xpconnect {
 namespace memory {
 
 CompartmentStats::CompartmentStats(JSContext *cx, JSCompartment *c)
 {
     memset(this, 0, sizeof(*this));
 
-    if (c == cx->runtime->atomsCompartment)
-    {
+    if (c == cx->runtime->atomsCompartment) {
         name.AssignLiteral("atoms");
     }
-    else if (c->principals)
-    {
-        if (c->principals->codebase)
-        {
+    else if (c->principals) {
+        if (c->principals->codebase) {
             name.Assign(c->principals->codebase);
 
             // If it's the system compartment, append the address.
             // This means that multiple system compartments (and there
             // can be many) can be distinguished.
-            if (c->isSystemCompartment)
-            {
+            if (c->isSystemCompartment) {
                 if (c->data &&
-                    !((xpc::CompartmentPrivate*)c->data)->location.IsEmpty())
-                {
+                    !((xpc::CompartmentPrivate*)c->data)->location.IsEmpty()) {
                     name.AppendLiteral(", ");
                     name.Append(((xpc::CompartmentPrivate*)c->data)->location);
                 }
 
                 // ample; 64-bit address max is 18 chars
                 static const int maxLength = 31;
                 nsPrintfCString address(maxLength, ", 0x%llx", PRUint64(c));
                 name.Append(address);
             }
 
             // A hack: replace forward slashes with '\\' so they aren't
             // treated as path separators.  Users of the reporters
             // (such as about:memory) have to undo this change.
             name.ReplaceChar('/', '\\');
         }
-        else
-        {
+        else {
             name.AssignLiteral("null-codebase");
         }
     }
-    else
-    {
+    else {
         name.AssignLiteral("null-principal");
     }
 }
 
 JSBool
 CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
 {
     JSContext *cx = JS_NewContext(rt, 0);
-    if (!cx)
-    {
+    if (!cx) {
         NS_ERROR("couldn't create context for memory tracing");
         return false;
     }
 
     {
         JSAutoRequest ar(cx);
 
         data->compartmentStatsVector.SetCapacity(rt->compartments.length());
@@ -1627,18 +1565,17 @@ CollectCompartmentStatsForRuntime(JSRunt
     // This is initialized to all bytes stored in used chunks, and then we
     // subtract used space from it each time around the loop.
     data->gcHeapChunkDirtyUnused = data->gcHeapChunkTotal -
                                    data->gcHeapChunkCleanUnused;
     data->gcHeapArenaUnused = 0;
 
     for (PRUint32 index = 0;
          index < data->compartmentStatsVector.Length();
-         index++)
-    {
+         index++) {
         CompartmentStats &stats = data->compartmentStatsVector[index];
 
         PRInt64 used = stats.gcHeapArenaHeaders +
                        stats.gcHeapArenaPadding +
                        stats.gcHeapArenaUnused;
         for (size_t i = 0; i != JS_ARRAY_LENGTH(stats.gcHeapKinds); ++i)
             used += stats.gcHeapKinds[i];
 
@@ -1887,18 +1824,17 @@ ReportCompartmentStats(const Compartment
 
 void
 ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
                      nsIMemoryMultiReporterCallback *callback,
                      nsISupports *closure)
 {
     for (PRUint32 index = 0;
          index < data.compartmentStatsVector.Length();
-         index++)
-    {
+         index++) {
         ReportCompartmentStats(data.compartmentStatsVector[index], pathPrefix,
                                callback, closure);
     }
 
     ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("runtime/runtime-object"),
                       nsIMemoryReporter::KIND_NONHEAP, data.runtimeObjectSize,
                       "Memory used by the JSRuntime object." SLOP_BYTES_STRING,
                       callback, closure);
@@ -2156,46 +2092,42 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnec
         self->GetIID2NativeInterfaceMap()     &&
         self->GetClassInfo2NativeSetMap()     &&
         self->GetNativeSetMap()               &&
         self->GetThisTranslatorMap()          &&
         self->GetNativeScriptableSharedMap()  &&
         self->GetDyingWrappedNativeProtoMap() &&
         self->GetExplicitNativeWrapperMap()   &&
         self->GetMapLock()                    &&
-        self->mWatchdogThread)
-    {
+        self->mWatchdogThread) {
         return self;
     }
 
     NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize.");
 
     delete self;
     return nsnull;
 }
 
 JSBool
 XPCJSRuntime::OnJSContextNew(JSContext *cx)
 {
     NS_TIME_FUNCTION;
 
     // if it is our first context then we need to generate our string ids
     JSBool ok = JS_TRUE;
-    if (JSID_IS_VOID(mStrIDs[0]))
-    {
+    if (JSID_IS_VOID(mStrIDs[0])) {
         JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 16 * 1024 * 1024);
         {
             // Scope the JSAutoRequest so it goes out of scope before calling
             // mozilla::dom::binding::DefineStaticJSVals.
             JSAutoRequest ar(cx);
-            for (uintN i = 0; i < IDX_TOTAL_COUNT; i++)
-            {
+            for (uintN i = 0; i < IDX_TOTAL_COUNT; i++) {
                 JSString* str = JS_InternString(cx, mStrings[i]);
-                if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i]))
-                {
+                if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i])) {
                     mStrIDs[0] = JSID_VOID;
                     ok = JS_FALSE;
                     break;
                 }
                 mStrJSVals[i] = STRING_TO_JSVAL(str);
             }
         }
 
@@ -2220,18 +2152,17 @@ XPCJSRuntime::OnJSContextNew(JSContext *
     return JS_TRUE;
 }
 
 JSBool
 XPCJSRuntime::DeferredRelease(nsISupports* obj)
 {
     NS_ASSERTION(obj, "bad param");
 
-    if (mNativesToReleaseArray.IsEmpty())
-    {
+    if (mNativesToReleaseArray.IsEmpty()) {
         // This array sometimes has 1000's
         // of entries, and usually has 50-200 entries. Avoid lots
         // of incremental grows.  We compact it down when we're done.
         mNativesToReleaseArray.SetCapacity(256);
     }
     return mNativesToReleaseArray.AppendElement(obj) != nsnull;
 }
 
@@ -2278,40 +2209,37 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
 
         int cxCount = 0;
         JSContext* iter = nsnull;
         while (JS_ContextIterator(mJSRuntime, &iter))
             ++cxCount;
         XPC_LOG_ALWAYS(("%d JS context(s)", cxCount));
 
         iter = nsnull;
-        while (JS_ContextIterator(mJSRuntime, &iter))
-        {
+        while (JS_ContextIterator(mJSRuntime, &iter)) {
             XPCContext *xpc = XPCContext::GetXPCContext(iter);
             XPC_LOG_INDENT();
             xpc->DebugDump(depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %x with %d wrapperclasses(s)",  \
                         mWrappedJSClassMap, mWrappedJSClassMap ?              \
                         mWrappedJSClassMap->Count() : 0));
         // iterate wrappersclasses...
-        if (depth && mWrappedJSClassMap && mWrappedJSClassMap->Count())
-        {
+        if (depth && mWrappedJSClassMap && mWrappedJSClassMap->Count()) {
             XPC_LOG_INDENT();
             mWrappedJSClassMap->Enumerate(WrappedJSClassMapDumpEnumerator, &depth);
             XPC_LOG_OUTDENT();
         }
         XPC_LOG_ALWAYS(("mWrappedJSMap @ %x with %d wrappers(s)",             \
                         mWrappedJSMap, mWrappedJSMap ?                        \
                         mWrappedJSMap->Count() : 0));
         // iterate wrappers...
-        if (depth && mWrappedJSMap && mWrappedJSMap->Count())
-        {
+        if (depth && mWrappedJSMap && mWrappedJSMap->Count()) {
             XPC_LOG_INDENT();
             mWrappedJSMap->Enumerate(WrappedJSMapDumpEnumerator, &depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_ALWAYS(("mIID2NativeInterfaceMap @ %x with %d interface(s)",  \
                         mIID2NativeInterfaceMap, mIID2NativeInterfaceMap ?    \
                         mIID2NativeInterfaceMap->Count() : 0));
@@ -2324,18 +2252,17 @@ XPCJSRuntime::DebugDump(PRInt16 depth)
                         mThisTranslatorMap, mThisTranslatorMap ?              \
                         mThisTranslatorMap->Count() : 0));
 
         XPC_LOG_ALWAYS(("mNativeSetMap @ %x with %d sets(s)",                 \
                         mNativeSetMap, mNativeSetMap ?                        \
                         mNativeSetMap->Count() : 0));
 
         // iterate sets...
-        if (depth && mNativeSetMap && mNativeSetMap->Count())
-        {
+        if (depth && mNativeSetMap && mNativeSetMap->Count()) {
             XPC_LOG_INDENT();
             mNativeSetMap->Enumerate(NativeSetDumpEnumerator, &depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_OUTDENT();
 #endif
 }
@@ -2346,18 +2273,17 @@ void
 XPCRootSetElem::AddToRootSet(XPCLock *lock, XPCRootSetElem **listHead)
 {
     NS_ASSERTION(!mSelfp, "Must be not linked");
 
     XPCAutoLock autoLock(lock);
 
     mSelfp = listHead;
     mNext = *listHead;
-    if (mNext)
-    {
+    if (mNext) {
         NS_ASSERTION(mNext->mSelfp == listHead, "Must be list start");
         mNext->mSelfp = &mNext;
     }
     *listHead = this;
 }
 
 void
 XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
--- a/js/xpconnect/src/XPCJSWeakReference.cpp
+++ b/js/xpconnect/src/XPCJSWeakReference.cpp
@@ -118,26 +118,24 @@ xpcJSWeakReference::Get()
 
     nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj;
 
     if (mWrappedJSObject &&
         NS_SUCCEEDED(mWrappedJSObject->QueryReferent(NS_GET_IID(nsIXPConnectWrappedJS), getter_AddRefs(wrappedObj))) &&
         wrappedObj) {
         JSObject *obj;
         wrappedObj->GetJSObject(&obj);
-        if (obj)
-        {
+        if (obj) {
             // Most users of XPCWrappedJS don't need to worry about
             // re-wrapping because things are implicitly rewrapped by
             // xpcconvert. However, because we're doing this directly
             // through the native call context, we need to call
             // JS_WrapObject().
 
-            if (!JS_WrapObject(cx, &obj))
-            {
+            if (!JS_WrapObject(cx, &obj)) {
                 return NS_ERROR_FAILURE;
             }
 
             *retval = OBJECT_TO_JSVAL(obj);
         }
     }
 
     return NS_OK;
--- a/js/xpconnect/src/XPCLog.cpp
+++ b/js/xpconnect/src/XPCLog.cpp
@@ -55,33 +55,31 @@ static char*    g_Spaces;
 static int      g_InitState = 0;
 static int      g_Indent = 0;
 static PRLogModuleInfo* g_LogMod = nsnull;
 
 static bool Init()
 {
     g_LogMod = PR_NewLogModule("xpclog");
     g_Spaces = new char[SPACE_COUNT+1];
-    if (!g_LogMod || !g_Spaces || !PR_LOG_TEST(g_LogMod,1))
-    {
+    if (!g_LogMod || !g_Spaces || !PR_LOG_TEST(g_LogMod,1)) {
         g_InitState = 1;
         XPC_Log_Finish();
         return PR_FALSE;
     }
     memset(g_Spaces, ' ', SPACE_COUNT);
     g_Spaces[SPACE_COUNT] = 0;
     g_InitState = 1;
     return PR_TRUE;
 }
 
 void
 XPC_Log_Finish()
 {
-    if (g_InitState == 1)
-    {
+    if (g_InitState == 1) {
         delete [] g_Spaces;
         // we'd like to properly cleanup the LogModule, but nspr owns that
         g_LogMod = nsnull;
     }
     g_InitState = -1;
 }
 
 void
@@ -127,18 +125,17 @@ XPC_Log_Clear_Indent()
 
 #endif
 
 #ifdef DEBUG_slimwrappers
 void
 LogSlimWrapperWillMorph(JSContext *cx, JSObject *obj, const char *propname,
                         const char *functionName)
 {
-    if (obj && IS_SLIM_WRAPPER(obj))
-    {
+    if (obj && IS_SLIM_WRAPPER(obj)) {
         XPCNativeScriptableInfo *si =
             GetSlimWrapperProto(obj)->GetScriptableInfo();
         printf("***** morphing %s from %s", si->GetJSClass()->name,
                functionName);
         if (propname)
             printf(" for %s", propname);
         printf(" (%p, %p)\n", obj,
                static_cast<nsISupports*>(xpc_GetJSPrivate(obj)));
--- a/js/xpconnect/src/XPCLog.h
+++ b/js/xpconnect/src/XPCLog.h
@@ -112,18 +112,17 @@ extern void LogSlimWrapperNotCreated(JSC
 
 #define SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, prop)                           \
     PR_BEGIN_MACRO                                                            \
         LogSlimWrapperWillMorph(cx, obj, (const char*)prop, __FUNCTION__);    \
     PR_END_MACRO
 #define SLIM_LOG_WILL_MORPH_FOR_ID(cx, obj, id)                               \
     PR_BEGIN_MACRO                                                            \
         JSString* strId = ::JS_ValueToString(cx, id);                         \
-        if (strId)                                                            \
-        {                                                                     \
+        if (strId) {                                                          \
           NS_ConvertUTF16toUTF8 name((PRUnichar*)::JS_GetStringChars(strId),  \
                                      ::JS_GetStringLength(strId));            \
           LOG_WILL_MORPH_FOR_PROP(cx, obj, name.get());                       \
         }                                                                     \
         else                                                                  \
         {                                                                     \
           LOG_WILL_MORPH_FOR_PROP(cx, obj, nsnull);                           \
         }                                                                     \
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -69,53 +69,46 @@ HashNativeKey(JSDHashTable *table, const
     XPCNativeSetKey* Key = (XPCNativeSetKey*) key;
 
     JSDHashNumber h = 0;
 
     XPCNativeSet*       Set;
     XPCNativeInterface* Addition;
     PRUint16            Position;
 
-    if (Key->IsAKey())
-    {
+    if (Key->IsAKey()) {
         Set      = Key->GetBaseSet();
         Addition = Key->GetAddition();
         Position = Key->GetPosition();
     }
-    else
-    {
+    else {
         Set      = (XPCNativeSet*) Key;
         Addition = nsnull;
         Position = 0;
     }
 
-    if (!Set)
-    {
+    if (!Set) {
         NS_ASSERTION(Addition, "bad key");
         // This would be an XOR like below.
         // But "0 ^ x == x". So it does not matter.
         h = (JSHashNumber) NS_PTR_TO_INT32(Addition) >> 2;
     }
-    else
-    {
+    else {
         XPCNativeInterface** Current = Set->GetInterfaceArray();
         PRUint16 count = Set->GetInterfaceCount();
-        if (Addition)
-        {
+        if (Addition) {
             count++;
-            for (PRUint16 i = 0; i < count; i++)
-            {
+            for (PRUint16 i = 0; i < count; i++) {
                 if (i == Position)
                     h ^= (JSHashNumber) NS_PTR_TO_INT32(Addition) >> 2;
                 else
                     h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
             }
         }
-        else
-        {
+        else {
             for (PRUint16 i = 0; i < count; i++)
                 h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
         }
     }
 
     return h;
 }
 
@@ -302,45 +295,42 @@ ClassInfo2WrappedNativeProtoMap::~ClassI
 JSBool
 NativeSetMap::Entry::Match(JSDHashTable *table,
                            const JSDHashEntryHdr *entry,
                            const void *key)
 {
     XPCNativeSetKey* Key = (XPCNativeSetKey*) key;
 
     // See the comment in the XPCNativeSetKey declaration in xpcprivate.h.
-    if (!Key->IsAKey())
-    {
+    if (!Key->IsAKey()) {
         XPCNativeSet* Set1 = (XPCNativeSet*) key;
         XPCNativeSet* Set2 = ((Entry*)entry)->key_value;
 
         if (Set1 == Set2)
             return JS_TRUE;
 
         PRUint16 count = Set1->GetInterfaceCount();
         if (count != Set2->GetInterfaceCount())
             return JS_FALSE;
 
         XPCNativeInterface** Current1 = Set1->GetInterfaceArray();
         XPCNativeInterface** Current2 = Set2->GetInterfaceArray();
-        for (PRUint16 i = 0; i < count; i++)
-        {
+        for (PRUint16 i = 0; i < count; i++) {
             if (*(Current1++) != *(Current2++))
                 return JS_FALSE;
         }
 
         return JS_TRUE;
     }
 
     XPCNativeSet*       SetInTable = ((Entry*)entry)->key_value;
     XPCNativeSet*       Set        = Key->GetBaseSet();
     XPCNativeInterface* Addition   = Key->GetAddition();
 
-    if (!Set)
-    {
+    if (!Set) {
         // This is a special case to deal with the invariant that says:
         // "All sets have exactly one nsISupports interface and it comes first."
         // See XPCNativeSet::NewInstance for details.
         //
         // Though we might have a key that represents only one interface, we
         // know that if that one interface were contructed into a set then
         // it would end up really being a set with two interfaces (except for
         // the case where the one interface happened to be nsISupports).
@@ -356,25 +346,22 @@ NativeSetMap::Entry::Match(JSDHashTable 
 
     PRUint16 count = Set->GetInterfaceCount() + (Addition ? 1 : 0);
     if (count != SetInTable->GetInterfaceCount())
         return JS_FALSE;
 
     PRUint16 Position = Key->GetPosition();
     XPCNativeInterface** CurrentInTable = SetInTable->GetInterfaceArray();
     XPCNativeInterface** Current = Set->GetInterfaceArray();
-    for (PRUint16 i = 0; i < count; i++)
-    {
-        if (Addition && i == Position)
-        {
+    for (PRUint16 i = 0; i < count; i++) {
+        if (Addition && i == Position) {
             if (Addition != *(CurrentInTable++))
                 return JS_FALSE;
         }
-        else
-        {
+        else {
             if (*(Current++) != *(CurrentInTable++))
                 return JS_FALSE;
         }
     }
 
     return JS_TRUE;
 }
 
@@ -556,18 +543,17 @@ XPCNativeScriptableSharedMap::GetNewOrUs
     XPCNativeScriptableShared key(flags, name, interfacesBitmap);
     Entry* entry = (Entry*)
         JS_DHashTableOperate(mTable, &key, JS_DHASH_ADD);
     if (!entry)
         return JS_FALSE;
 
     XPCNativeScriptableShared* shared = entry->key;
 
-    if (!shared)
-    {
+    if (!shared) {
         entry->key = shared =
             new XPCNativeScriptableShared(flags, key.TransferNameOwnership(),
                                           interfacesBitmap);
         if (!shared)
             return JS_FALSE;
         shared->PopulateJSClass(isGlobal);
     }
     si->SetScriptableShared(shared);
@@ -659,23 +645,21 @@ WrappedNative2WrapperMap::MoveLink(JSDHa
                                    JSDHashEntryHdr* to)
 {
     const Entry* oldEntry = static_cast<const Entry*>(from);
     Entry* newEntry = static_cast<Entry*>(to);
 
     newEntry->key = oldEntry->key;
 
     // Now update the list.
-    if (PR_CLIST_IS_EMPTY(&oldEntry->value))
-    {
+    if (PR_CLIST_IS_EMPTY(&oldEntry->value)) {
         PR_INIT_CLIST(&newEntry->value);
         newEntry->value.obj = oldEntry->value.obj;
     }
-    else
-    {
+    else {
         newEntry->value = oldEntry->value;
         newEntry->value.next->prev = &newEntry->value;
         newEntry->value.prev->next = &newEntry->value;
     }
 }
 
 // static
 WrappedNative2WrapperMap*
@@ -710,30 +694,27 @@ WrappedNative2WrapperMap::Add(WrappedNat
     if (!entry)
         return nsnull;
     NS_ASSERTION(!entry->key || this == head, "dangling pointer?");
     entry->key = wrappedObject;
     Link* l = &entry->value;
 
     NS_ASSERTION(!l->obj, "Uh, how'd this happen?");
 
-    if (!l->next)
-    {
+    if (!l->next) {
         // Initialize the circular list. This case only happens when
         // this == head.
         PR_INIT_CLIST(l);
     }
 
     l->obj = wrapper;
 
-    if (this != head)
-    {
+    if (this != head) {
         Link* headLink = head->FindLink(wrappedObject);
-        if (!headLink)
-        {
+        if (!headLink) {
             Entry* dummy = (Entry*)
                 JS_DHashTableOperate(head->mTable, wrappedObject, JS_DHASH_ADD);
             dummy->key = wrappedObject;
             headLink = &dummy->value;
             PR_INIT_CLIST(headLink);
             headLink->obj = nsnull;
         }
 
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -44,18 +44,17 @@
 #include "XPCInlines.h"
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 
 static inline QITableEntry *
 GetOffsets(nsISupports *identity, XPCWrappedNativeProto* proto)
 {
     QITableEntry* offsets = proto ? proto->GetOffsets() : nsnull;
-    if (!offsets)
-    {
+    if (!offsets) {
         static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
         identity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
     }
     return offsets;
 }
 
 static inline QITableEntry *
 GetOffsetsFromSlimWrapper(JSObject *obj)
@@ -82,34 +81,31 @@ LookupEntry(PRUint32 tableSize, const xp
     return nsnull;
 }
 
 static const xpc_qsHashEntry *
 LookupInterfaceOrAncestor(PRUint32 tableSize, const xpc_qsHashEntry *table,
                           const nsID &iid)
 {
     const xpc_qsHashEntry *entry = LookupEntry(tableSize, table, iid);
-    if (!entry)
-    {
+    if (!entry) {
         /*
          * On a miss, we have to search for every interface the object
          * supports, including ancestors.
          */
         nsCOMPtr<nsIInterfaceInfo> info;
         if (NS_FAILED(nsXPConnect::GetXPConnect()->GetInfoForIID(&iid, getter_AddRefs(info))))
             return nsnull;
 
         const nsIID *piid;
-        for (;;)
-        {
+        for (;;) {
             nsCOMPtr<nsIInterfaceInfo> parent;
             if (NS_FAILED(info->GetParent(getter_AddRefs(parent))) ||
                 !parent ||
-                NS_FAILED(parent->GetIIDShared(&piid)))
-            {
+                NS_FAILED(parent->GetIIDShared(&piid))) {
                 break;
             }
             entry = LookupEntry(tableSize, table, *piid);
             if (entry)
                 break;
             info.swap(parent);
         }
     }
@@ -218,30 +214,28 @@ ReifyPropertyOps(JSContext *cx, JSObject
                  JSObject **getterobjp, JSObject **setterobjp)
 {
     // Generate both getter and setter and stash them in the prototype.
     jsval roots[2] = { JSVAL_NULL, JSVAL_NULL };
     js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), roots);
 
     uintN attrs = JSPROP_SHARED | (orig_attrs & JSPROP_ENUMERATE);
     JSObject *getterobj;
-    if (getter)
-    {
+    if (getter) {
         getterobj = GeneratePropertyOp(cx, obj, id, 0, getter);
         if (!getterobj)
             return JS_FALSE;
         roots[0] = OBJECT_TO_JSVAL(getterobj);
         attrs |= JSPROP_GETTER;
     }
     else
         getterobj = nsnull;
 
     JSObject *setterobj;
-    if (setter)
-    {
+    if (setter) {
         setterobj = GeneratePropertyOp(cx, obj, id, 1, setter);
         if (!setterobj)
             return JS_FALSE;
         roots[1] = OBJECT_TO_JSVAL(setterobj);
         attrs |= JSPROP_SETTER;
     }
     else
         setterobj = nsnull;
@@ -256,79 +250,71 @@ ReifyPropertyOps(JSContext *cx, JSObject
                                  attrs);
 }
 
 static JSBool
 LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, uintN argc, jsval *vp)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
-    if (argc == 0)
-    {
+    if (argc == 0) {
         JS_SET_RVAL(cx, vp, JSVAL_VOID);
         return JS_TRUE;
     }
 
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
     jsval idval = JS_ARGV(cx, vp)[0];
     jsid id;
     JSPropertyDescriptor desc;
     if (!JS_ValueToId(cx, idval, &id) ||
         !JS_GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED, &desc))
         return JS_FALSE;
 
     // No property at all means no getters or setters possible.
-    if (!desc.obj)
-    {
+    if (!desc.obj) {
         JS_SET_RVAL(cx, vp, JSVAL_VOID);
         return JS_TRUE;
     }
 
     // Inline obj_lookup[GS]etter here.
-    if (wantGetter)
-    {
-        if (desc.attrs & JSPROP_GETTER)
-        {
+    if (wantGetter) {
+        if (desc.attrs & JSPROP_GETTER) {
             JS_SET_RVAL(cx, vp,
                         OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.getter)));
             return JS_TRUE;
         }
     }
-    else
-    {
-        if (desc.attrs & JSPROP_SETTER)
-        {
+    else {
+        if (desc.attrs & JSPROP_SETTER) {
             JS_SET_RVAL(cx, vp,
                         OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.setter)));
             return JS_TRUE;
         }
     }
 
     // Since XPConnect doesn't use JSPropertyOps in any other contexts,
     // ensuring that we have an XPConnect prototype object ensures that
     // we are only going to expose quickstubbed properties to script.
     // Also be careful not to overwrite existing properties!
 
     if (!JSID_IS_STRING(id) ||
         !IS_PROTO_CLASS(js::GetObjectClass(desc.obj)) ||
         (desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
         !(desc.getter || desc.setter) ||
-        desc.setter == js::GetObjectJSClass(desc.obj)->setProperty)
-    {
+        desc.setter == js::GetObjectJSClass(desc.obj)->setProperty) {
         JS_SET_RVAL(cx, vp, JSVAL_VOID);
         return JS_TRUE;
     }
 
     JSObject *getterobj, *setterobj;
     if (!ReifyPropertyOps(cx, desc.obj, id, desc.attrs, desc.getter, desc.setter,
-                          &getterobj, &setterobj))
-    {
+                          &getterobj, &setterobj)) {
         return JS_FALSE;
     }
 
     JSObject *wantedobj = wantGetter ? getterobj : setterobj;
     jsval v = wantedobj ? OBJECT_TO_JSVAL(wantedobj) : JSVAL_VOID;
     JS_SET_RVAL(cx, vp, v);
     return JS_TRUE;
 }
@@ -410,58 +396,49 @@ xpc_qsDefineQuickStubs(JSContext *cx, JS
      * Walk interfaces in reverse order to behave like XPConnect when a
      * feature is defined in more than one of the interfaces.
      *
      * XPCNativeSet::FindMethod returns the first matching feature it finds,
      * searching the interfaces forward.  Here, definitions toward the
      * front of 'interfaces' overwrite those toward the back.
      */
     bool definedProperty = false;
-    for (uint32 i = ifacec; i-- != 0;)
-    {
+    for (uint32 i = ifacec; i-- != 0;) {
         const nsID &iid = *interfaces[i];
         const xpc_qsHashEntry *entry =
             LookupInterfaceOrAncestor(tableSize, table, iid);
 
-        if (entry)
-        {
-            for (;;)
-            {
+        if (entry) {
+            for (;;) {
                 // Define quick stubs for attributes.
                 const xpc_qsPropertySpec *ps = entry->properties;
-                if (ps)
-                {
-                    for (; ps->name; ps++)
-                    {
+                if (ps) {
+                    for (; ps->name; ps++) {
                         definedProperty = PR_TRUE;
                         if (!JS_DefineProperty(cx, proto, ps->name, JSVAL_VOID,
                                                ps->getter, ps->setter,
                                                flags | JSPROP_SHARED))
                             return JS_FALSE;
                     }
                 }
 
                 // Define quick stubs for methods.
                 const xpc_qsFunctionSpec *fs = entry->functions;
-                if (fs)
-                {
-                    for (; fs->name; fs++)
-                    {
+                if (fs) {
+                    for (; fs->name; fs++) {
                         if (!JS_DefineFunction(cx, proto, fs->name,
                                                reinterpret_cast<JSNative>(fs->native),
                                                fs->arity, flags))
                             return JS_FALSE;
                     }
                 }
 
                 const xpc_qsTraceableSpec *ts = entry->traceables;
-                if (ts)
-                {
-                    for (; ts->name; ts++)
-                    {
+                if (ts) {
+                    for (; ts->name; ts++) {
                         if (!JS_DefineFunction(cx, proto, ts->name, ts->native, ts->arity,
                                                flags | JSFUN_STUB_GSOPS | JSFUN_TRCINFO))
                             return JS_FALSE;
                     }
                 }
 
                 // Next.
                 size_t j = entry->parentInterface;
@@ -511,30 +488,26 @@ GetMemberInfo(JSObject *obj, jsid member
     // We could instead make the quick stub could pass in its interface name,
     // but this code often produces a more specific error message, e.g.
     *ifaceName = "Unknown";
 
     NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)) ||
                  js::GetObjectClass(obj) == &XPC_WN_Tearoff_JSClass,
                  "obj must be a wrapper");
     XPCWrappedNativeProto *proto;
-    if (IS_SLIM_WRAPPER(obj))
-    {
+    if (IS_SLIM_WRAPPER(obj)) {
         proto = GetSlimWrapperProto(obj);
     }
-    else
-    {
+    else {
         XPCWrappedNative *wrapper = (XPCWrappedNative *) js::GetObjectPrivate(obj);
         proto = wrapper->GetProto();
     }
-    if (proto)
-    {
+    if (proto) {
         XPCNativeSet *set = proto->GetSet();
-        if (set)
-        {
+        if (set) {
             XPCNativeMember *member;
             XPCNativeInterface *iface;
 
             if (set->FindMember(memberId, &member, &iface))
                 *ifaceName = iface->GetNameString();
         }
     }
 }
@@ -570,35 +543,32 @@ ThrowCallFailed(JSContext *cx, nsresult 
      *  call. So we'll just throw that exception into our JS.
      */
     if (XPCThrower::CheckForPendingException(rv, cx))
         return JS_FALSE;
 
     // else...
 
     if (!nsXPCException::NameAndFormatForNSResult(NS_ERROR_XPC_NATIVE_RETURNED_FAILURE, nsnull, &format) ||
-        !format)
-    {
+        !format) {
         format = "";
     }
 
     JSAutoByteString memberNameBytes;
     if (!memberName) {
         memberName = JSID_IS_STRING(memberId)
                      ? memberNameBytes.encode(cx, JSID_TO_STRING(memberId))
                      : "unknown";
     }
     if (nsXPCException::NameAndFormatForNSResult(rv, &name, nsnull)
-        && name)
-    {
+        && name) {
         sz = JS_smprintf("%s 0x%x (%s) [%s.%s]",
                          format, rv, name, ifaceName, memberName);
     }
-    else
-    {
+    else {
         sz = JS_smprintf("%s 0x%x [%s.%s]",
                          format, rv, ifaceName, memberName);
     }
 
     XPCThrower::BuildAndThrowException(cx, rv, sz);
 
     if (sz)
         JS_smprintf_free(sz);
@@ -738,25 +708,23 @@ xpc_qsACString::xpc_qsACString(JSContext
     typedef implementation_type::char_traits traits;
     // From the T_CSTRING case in XPCConvert::JSData2Native.
     JSString *s = InitOrStringify<traits>(cx, v, pval, nullBehavior,
                                           undefinedBehavior);
     if (!s)
         return;
 
     size_t len = JS_GetStringEncodingLength(cx, s);
-    if (len == size_t(-1))
-    {
+    if (len == size_t(-1)) {
         mValid = JS_FALSE;
         return;
     }
 
     JSAutoByteString bytes(cx, s);
-    if (!bytes)
-    {
+    if (!bytes) {
         mValid = JS_FALSE;
         return;
     }
 
     new(mBuf) implementation_type(bytes.ptr(), len);
     mValid = JS_TRUE;
 }
 
@@ -784,22 +752,19 @@ getNative(nsISupports *idobj,
           QITableEntry* entries,
           JSObject *obj,
           const nsIID &iid,
           void **ppThis,
           nsISupports **pThisRef,
           jsval *vp)
 {
     // Try using the QITableEntry to avoid the extra AddRef and Release.
-    if (entries)
-    {
-        for (QITableEntry* e = entries; e->iid; e++)
-        {
-            if (e->iid->Equals(iid))
-            {
+    if (entries) {
+        for (QITableEntry* e = entries; e->iid; e++) {
+            if (e->iid->Equals(iid)) {
                 *ppThis = (char*) idobj + e->offset - entries[0].offset;
                 *vp = OBJECT_TO_JSVAL(obj);
                 *pThisRef = nsnull;
                 return NS_OK;
             }
         }
     }
 
@@ -827,18 +792,17 @@ nsresult
 getWrapper(JSContext *cx,
            JSObject *obj,
            JSObject *callee,
            XPCWrappedNative **wrapper,
            JSObject **cur,
            XPCWrappedNativeTearOff **tearoff)
 {
     if (XPCWrapper::IsSecurityWrapper(obj) &&
-        !(obj = XPCWrapper::Unwrap(cx, obj)))
-    {
+        !(obj = XPCWrapper::Unwrap(cx, obj))) {
         return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
     }
 
     *cur = obj;
     *tearoff = nsnull;
 
     *wrapper =
         XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj, callee, cur,
@@ -853,48 +817,42 @@ castNative(JSContext *cx,
            JSObject *cur,
            XPCWrappedNativeTearOff *tearoff,
            const nsIID &iid,
            void **ppThis,
            nsISupports **pThisRef,
            jsval *vp,
            XPCLazyCallContext *lccx)
 {
-    if (wrapper)
-    {
+    if (wrapper) {
         nsresult rv = getNativeFromWrapper(cx,wrapper, iid, ppThis, pThisRef,
                                            vp);
 
         if (lccx && NS_SUCCEEDED(rv))
             lccx->SetWrapper(wrapper, tearoff);
 
         if (rv != NS_ERROR_NO_INTERFACE)
             return rv;
     }
-    else if (cur)
-    {
+    else if (cur) {
         nsISupports *native;
         QITableEntry *entries;
-        if (IS_SLIM_WRAPPER(cur))
-        {
+        if (IS_SLIM_WRAPPER(cur)) {
             native = static_cast<nsISupports*>(xpc_GetJSPrivate(cur));
             entries = GetOffsetsFromSlimWrapper(cur);
         }
-        else
-        {
+        else {
             NS_ABORT_IF_FALSE(mozilla::dom::binding::instanceIsProxy(cur),
                               "what kind of wrapper is this?");
             native = static_cast<nsISupports*>(js::GetProxyPrivate(cur).toPrivate());
             entries = nsnull;
         }
 
-        if (NS_SUCCEEDED(getNative(native, entries, cur, iid, ppThis, pThisRef, vp)))
-        {
-            if (lccx)
-            {
+        if (NS_SUCCEEDED(getNative(native, entries, cur, iid, ppThis, pThisRef, vp))) {
+            if (lccx) {
                 // This only matters for unwrapping of this objects, so we
                 // shouldn't end up here for the new DOM bindings.
                 NS_ABORT_IF_FALSE(IS_SLIM_WRAPPER(cur),
                                   "what kind of wrapper is this?");
                 lccx->SetWrapper(cur);
             }
 
             return NS_OK;
@@ -922,25 +880,23 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallConte
     if (NS_FAILED(rv))
         return xpc_qsThrow(ccx.GetJSContext(), rv);
     return JS_TRUE;
 }
 
 JSObject*
 xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv)
 {
-    if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
-    {
+    if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
         *ppArgRef = nsnull;
         *rv = NS_OK;
         return nsnull;
     }
 
-    if (!JSVAL_IS_OBJECT(v))
-    {
+    if (!JSVAL_IS_OBJECT(v)) {
         *ppArgRef = nsnull;
         *rv = ((JSVAL_IS_INT(v) && JSVAL_TO_INT(v) == 0)
                ? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL
                : NS_ERROR_XPC_BAD_CONVERT_JS);
         return nsnull;
     }
 
     *rv = NS_OK;
@@ -952,138 +908,122 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
                     jsval v,
                     const nsIID &iid,
                     void **ppArg,
                     nsISupports **ppArgRef,
                     jsval *vp)
 {
     nsresult rv;
     JSObject *src = xpc_qsUnwrapObj(v, ppArgRef, &rv);
-    if (!src)
-    {
+    if (!src) {
         *ppArg = nsnull;
 
         return rv;
     }
 
     XPCWrappedNative *wrapper;
     XPCWrappedNativeTearOff *tearoff;
     JSObject *obj2;
-    if (mozilla::dom::binding::instanceIsProxy(src))
-    {
+    if (mozilla::dom::binding::instanceIsProxy(src)) {
         wrapper = nsnull;
         obj2 = src;
     }
-    else
-    {
+    else {
         rv = getWrapper(cx, src, nsnull, &wrapper, &obj2, &tearoff);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    if (wrapper || obj2)
-    {
+    if (wrapper || obj2) {
         if (NS_FAILED(castNative(cx, wrapper, obj2, tearoff, iid, ppArg,
                                  ppArgRef, vp, nsnull)))
             return NS_ERROR_XPC_BAD_CONVERT_JS;
         return NS_OK;
     }
     // else...
     // Slow path.
 
     // XXX E4X breaks the world. Don't try wrapping E4X objects!
     // This hack can be removed (or changed accordingly) when the
     // DOM <-> E4X bindings are complete, see bug 270553
-    if (JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML)
-    {
+    if (JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML) {
         *ppArgRef = nsnull;
         return NS_ERROR_XPC_BAD_CONVERT_JS;
     }
 
     // Try to unwrap a slim wrapper.
     nsISupports *iface;
-    if (XPCConvert::GetISupportsFromJSObject(src, &iface))
-    {
-        if (!iface || NS_FAILED(iface->QueryInterface(iid, ppArg)))
-        {
+    if (XPCConvert::GetISupportsFromJSObject(src, &iface)) {
+        if (!iface || NS_FAILED(iface->QueryInterface(iid, ppArg))) {
             *ppArgRef = nsnull;
             return NS_ERROR_XPC_BAD_CONVERT_JS;
         }
 
         *ppArgRef = static_cast<nsISupports*>(*ppArg);
         return NS_OK;
     }
 
     // Create the ccx needed for quick stubs.
     XPCCallContext ccx(JS_CALLER, cx);
-    if (!ccx.IsValid())
-    {
+    if (!ccx.IsValid()) {
         *ppArgRef = nsnull;
         return NS_ERROR_XPC_BAD_CONVERT_JS;
     }
 
     nsRefPtr<nsXPCWrappedJS> wrappedJS;
     rv = nsXPCWrappedJS::GetNewOrUsed(ccx, src, iid, nsnull,
                                       getter_AddRefs(wrappedJS));
-    if (NS_FAILED(rv) || !wrappedJS)
-    {
+    if (NS_FAILED(rv) || !wrappedJS) {
         *ppArgRef = nsnull;
         return rv;
     }
 
     // We need to go through the QueryInterface logic to make this return
     // the right thing for the various 'special' interfaces; e.g.
     // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
     // there is an outer to avoid nasty recursion.
     rv = wrappedJS->QueryInterface(iid, ppArg);
-    if (NS_SUCCEEDED(rv))
-    {
+    if (NS_SUCCEEDED(rv)) {
         *ppArgRef = static_cast<nsISupports*>(*ppArg);
         *vp = OBJECT_TO_JSVAL(wrappedJS->GetJSObject());
     }
     return rv;
 }
 
 JSBool
 xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes)
 {
     JSString *str;
 
     JS_ASSERT(!bytes->ptr());
-    if (JSVAL_IS_STRING(v))
-    {
+    if (JSVAL_IS_STRING(v)) {
         str = JSVAL_TO_STRING(v);
     }
-    else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
-    {
+    else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
         return true;
     }
-    else
-    {
+    else {
         if (!(str = JS_ValueToString(cx, v)))
             return false;
     }
     return !!bytes->encode(cx, str);
 }
 
 JSBool
 xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, PRUnichar **pstr)
 {
     JSString *str;
 
-    if (JSVAL_IS_STRING(v))
-    {
+    if (JSVAL_IS_STRING(v)) {
         str = JSVAL_TO_STRING(v);
     }
-    else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v))
-    {
+    else if (JSVAL_IS_VOID(v) || JSVAL_IS_NULL(v)) {
         *pstr = NULL;
         return JS_TRUE;
     }
-    else
-    {
+    else {
         if (!(str = JS_ValueToString(cx, v)))
             return JS_FALSE;
         *pval = STRING_TO_JSVAL(str);  // Root the new string.
     }
 
     const jschar *chars = JS_GetStringCharsZ(cx, str);
     if (!chars)
         return JS_FALSE;
@@ -1092,53 +1032,49 @@ xpc_qsJsvalToWcharStr(JSContext *cx, jsv
     *pstr = const_cast<jschar *>(chars);
     return JS_TRUE;
 }
 
 JSBool
 xpc_qsStringToJsval(JSContext *cx, nsString &str, jsval *rval)
 {
     // From the T_DOMSTRING case in XPCConvert::NativeData2JS.
-    if (str.IsVoid())
-    {
+    if (str.IsVoid()) {
         *rval = JSVAL_NULL;
         return JS_TRUE;
     }
 
     nsStringBuffer* sharedBuffer;
     jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer);
     if (JSVAL_IS_NULL(jsstr))
         return JS_FALSE;
     *rval = jsstr;
-    if (sharedBuffer)
-    {
+    if (sharedBuffer) {
         // The string was shared but ReadableToJSVal didn't addref it.
         // Move the ownership from str to jsstr.
         str.ForgetSharedBuffer();
     }
     return JS_TRUE;
 }
 
 JSBool
 xpc_qsStringToJsstring(JSContext *cx, nsString &str, JSString **rval)
 {
     // From the T_DOMSTRING case in XPCConvert::NativeData2JS.
-    if (str.IsVoid())
-    {
+    if (str.IsVoid()) {
         *rval = nsnull;
         return JS_TRUE;
     }
 
     nsStringBuffer* sharedBuffer;
     jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer);
     if (JSVAL_IS_NULL(jsstr))
         return JS_FALSE;
     *rval = JSVAL_TO_STRING(jsstr);
-    if (sharedBuffer)
-    {
+    if (sharedBuffer) {
         // The string was shared but ReadableToJSVal didn't addref it.
         // Move the ownership from str to jsstr.
         str.ForgetSharedBuffer();
     }
     return JS_TRUE;
 }
 
 JSBool
@@ -1157,18 +1093,17 @@ xpc_qsXPCOMObjectToJsval(XPCLazyCallCont
     // fact, this code is depending on the fact that the
     // global object will not have been collected, and
     // therefore this NativeInterface2JSObject will not end up
     // creating a new XPCNativeScriptableShared.
 
     nsresult rv;
     if (!XPCConvert::NativeInterface2JSObject(lccx, rval, nsnull,
                                               aHelper, iid, iface,
-                                              PR_TRUE, OBJ_IS_NOT_GLOBAL, &rv))
-    {
+                                              PR_TRUE, OBJ_IS_NOT_GLOBAL, &rv)) {
         // I can't tell if NativeInterface2JSObject throws JS exceptions
         // or not.  This is a sloppy stab at the right semantics; the
         // method really ought to be fixed to behave consistently.
         if (!JS_IsExceptionPending(cx))
             xpc_qsThrow(cx, NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED);
         return JS_FALSE;
     }
 
@@ -1184,18 +1119,17 @@ xpc_qsXPCOMObjectToJsval(XPCLazyCallCont
 
 JSBool
 xpc_qsVariantToJsval(XPCLazyCallContext &lccx,
                      nsIVariant *p,
                      jsval *rval)
 {
     // From the T_INTERFACE case in XPCConvert::NativeData2JS.
     // Error handling is in XPCWrappedNative::CallMethod.
-    if (p)
-    {
+    if (p) {
         nsresult rv;
         JSBool ok = XPCVariant::VariantDataToJS(lccx, p, &rv, rval);
         if (!ok)
             xpc_qsThrow(lccx.GetJSContext(), rv);
         return ok;
     }
     *rval = JSVAL_NULL;
     return JS_TRUE;
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -134,31 +134,29 @@ public:
                     aCache, QS_IS_NODE(T))
   {}
   template <class T>
   inline
   qsObjectHelper(nsCOMPtr<T>& aObject, nsWrapperCache *aCache)
   : xpcObjectHelper(ToSupports(aObject.get()),
                     ToCanonicalSupports(aObject.get()), aCache, QS_IS_NODE(T))
   {
-    if (mCanonical)
-    {
+    if (mCanonical) {
         // Transfer the strong reference.
         mCanonicalStrong = dont_AddRef(mCanonical);
         aObject.forget();
     }
   }
   template <class T>
   inline
   qsObjectHelper(nsRefPtr<T>& aObject, nsWrapperCache *aCache)
   : xpcObjectHelper(ToSupports(aObject.get()),
                     ToCanonicalSupports(aObject.get()), aCache, QS_IS_NODE(T))
   {
-    if (mCanonical)
-    {
+    if (mCanonical) {
         // Transfer the strong reference.
         mCanonicalStrong = dont_AddRef(mCanonical);
         aObject.forget();
     }
   }
 };
 
 JSBool
@@ -350,48 +348,42 @@ protected:
      * *pval.  nullBehavior and undefinedBehavior control what happens
      * when |v| is JSVAL_IS_NULL and JSVAL_IS_VOID respectively.
      */
     template<class traits>
     JSString* InitOrStringify(JSContext* cx, jsval v, jsval* pval,
                               StringificationBehavior nullBehavior,
                               StringificationBehavior undefinedBehavior) {
         JSString *s;
-        if (JSVAL_IS_STRING(v))
-        {
+        if (JSVAL_IS_STRING(v)) {
             s = JSVAL_TO_STRING(v);
         }
-        else
-        {
+        else {
             StringificationBehavior behavior = eStringify;
-            if (JSVAL_IS_NULL(v))
-            {
+            if (JSVAL_IS_NULL(v)) {
                 behavior = nullBehavior;
             }
-            else if (JSVAL_IS_VOID(v))
-            {
+            else if (JSVAL_IS_VOID(v)) {
                 behavior = undefinedBehavior;
             }
 
             // If pval is null, that means the argument was optional and
             // not passed; turn those into void strings if they're
             // supposed to be stringified.
-            if (behavior != eStringify || !pval)
-            {
+            if (behavior != eStringify || !pval) {
                 // Here behavior == eStringify implies !pval, so both eNull and
                 // eStringify should end up with void strings.
                 (new(mBuf) implementation_type(traits::sEmptyBuffer, PRUint32(0)))->
                     SetIsVoid(behavior != eEmpty);
                 mValid = JS_TRUE;
                 return nsnull;
             }
 
             s = JS_ValueToString(cx, v);
-            if (!s)
-            {
+            if (!s) {
                 mValid = JS_FALSE;
                 return nsnull;
             }
             *pval = STRING_TO_JSVAL(s);  // Root the new string.
         }
 
         return s;
     }
@@ -562,39 +554,35 @@ castNativeFromWrapper(JSContext *cx,
                       jsval *pVal,
                       XPCLazyCallContext *lccx,
                       nsresult *rv NS_OUTPARAM)
 {
     XPCWrappedNative *wrapper;
     XPCWrappedNativeTearOff *tearoff;
     JSObject *cur;
 
-    if (!callee && IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
-    {
+    if (!callee && IS_WRAPPER_CLASS(js::GetObjectClass(obj))) {
         cur = obj;
         wrapper = IS_WN_WRAPPER_OBJECT(cur) ?
                   (XPCWrappedNative*)xpc_GetJSPrivate(obj) :
                   nsnull;
         tearoff = nsnull;
     }
-    else
-    {
+    else {
         *rv = getWrapper(cx, obj, callee, &wrapper, &cur, &tearoff);
         if (NS_FAILED(*rv))
             return nsnull;
     }
 
     nsISupports *native;
-    if (wrapper)
-    {
+    if (wrapper) {
         native = wrapper->GetIdentityObject();
         cur = wrapper->GetFlatJSObject();
     }
-    else
-    {
+    else {
         native = cur ?
                  static_cast<nsISupports*>(xpc_GetJSPrivate(cur)) :
                  nsnull;
     }
 
     *rv = NS_ERROR_XPC_BAD_CONVERT_JS;
 
     if (!native)
@@ -605,18 +593,17 @@ castNativeFromWrapper(JSContext *cx,
     XPCNativeScriptableSharedJSClass *clasp =
       (XPCNativeScriptableSharedJSClass*)js::GetObjectClass(cur);
     if (!(clasp->interfacesBitmap & (1 << interfaceBit)))
         return nsnull;
 
     *pRef = nsnull;
     *pVal = OBJECT_TO_JSVAL(cur);
 
-    if (lccx)
-    {
+    if (lccx) {
         if (wrapper)
             lccx->SetWrapper(wrapper, tearoff);
         else
             lccx->SetWrapper(cur);
     }
 
     *rv = NS_OK;
 
--- a/js/xpconnect/src/XPCRuntimeService.cpp
+++ b/js/xpconnect/src/XPCRuntimeService.cpp
@@ -74,18 +74,17 @@ BackstagePass::NewResolve(nsIXPConnectWr
                           JSObject * *objp, bool *_retval)
 {
     JSBool resolved;
 
     *_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
     if (!*_retval)
         return NS_OK;
 
-    if (resolved)
-    {
+    if (resolved) {
         *objp = obj;
         return NS_OK;
     }
 
     *_retval = !!ResolveWorkerClasses(cx, obj, id, flags, objp);
     return NS_OK;
 }
 
--- a/js/xpconnect/src/XPCStack.cpp
+++ b/js/xpconnect/src/XPCStack.cpp
@@ -131,74 +131,61 @@ nsresult
 XPCJSStackFrame::CreateStack(JSContext* cx, JSStackFrame* fp,
                              XPCJSStackFrame** stack)
 {
     static const unsigned MAX_FRAMES = 3000;
     unsigned numFrames = 0;
 
     nsRefPtr<XPCJSStackFrame> first = new XPCJSStackFrame();
     nsRefPtr<XPCJSStackFrame> self = first;
-    while (fp && self)
-    {
-        if (!JS_IsScriptFrame(cx, fp))
-        {
+    while (fp && self) {
+        if (!JS_IsScriptFrame(cx, fp)) {
             self->mLanguage = nsIProgrammingLanguage::CPLUSPLUS;
         }
-        else
-        {
+        else {
             self->mLanguage = nsIProgrammingLanguage::JAVASCRIPT;
             JSScript* script = JS_GetFrameScript(cx, fp);
             jsbytecode* pc = JS_GetFramePC(cx, fp);
-            if (script && pc)
-            {
+            if (script && pc) {
                 JS::AutoEnterFrameCompartment ac;
-                if (ac.enter(cx, fp))
-                {
+                if (ac.enter(cx, fp)) {
                     const char* filename = JS_GetScriptFilename(cx, script);
-                    if (filename)
-                    {
+                    if (filename) {
                         self->mFilename = (char*)
                             nsMemory::Clone(filename,
                                             sizeof(char)*(strlen(filename)+1));
                     }
 
                     self->mLineno = (PRInt32) JS_PCToLineNumber(cx, script, pc);
 
                     JSFunction* fun = JS_GetFrameFunction(cx, fp);
-                    if (fun)
-                    {
+                    if (fun) {
                         JSString *funid = JS_GetFunctionId(fun);
-                        if (funid)
-                        {
+                        if (funid) {
                             size_t length = JS_GetStringEncodingLength(cx, funid);
-                            if (length != size_t(-1))
-                            {
+                            if (length != size_t(-1)) {
                                 self->mFunname = static_cast<char *>(nsMemory::Alloc(length + 1));
-                                if (self->mFunname)
-                                {
+                                if (self->mFunname) {
                                     JS_EncodeStringToBuffer(funid, self->mFunname, length);
                                     self->mFunname[length] = '\0';
                                 }
                             }
                         }
                     }
                 }
             }
-            else
-            {
+            else {
                 self->mLanguage = nsIProgrammingLanguage::CPLUSPLUS;
             }
         }
 
-        if (++numFrames > MAX_FRAMES)
-        {
+        if (++numFrames > MAX_FRAMES) {
             fp = NULL;
         }
-        else if (JS_FrameIterator(cx, &fp))
-        {
+        else if (JS_FrameIterator(cx, &fp)) {
             XPCJSStackFrame* frame = new XPCJSStackFrame();
             self->mCaller = frame;
             self = frame;
         }
     }
 
     *stack = first.forget().get();
     return NS_OK;
@@ -215,47 +202,42 @@ XPCJSStackFrame::CreateStackFrameLocatio
 {
     JSBool failed = JS_FALSE;
     XPCJSStackFrame* self = new XPCJSStackFrame();
     if (self)
         NS_ADDREF(self);
     else
         failed = JS_TRUE;
 
-    if (!failed)
-    {
+    if (!failed) {
         self->mLanguage = aLanguage;
         self->mLineno = aLineNumber;
     }
 
-    if (!failed && aFilename)
-    {
+    if (!failed && aFilename) {
         self->mFilename = (char*)
                 nsMemory::Clone(aFilename,
                                 sizeof(char)*(strlen(aFilename)+1));
         if (!self->mFilename)
             failed = JS_TRUE;
     }
 
-    if (!failed && aFunctionName)
-    {
+    if (!failed && aFunctionName) {
         self->mFunname = (char*)
                 nsMemory::Clone(aFunctionName,
                                 sizeof(char)*(strlen(aFunctionName)+1));
         if (!self->mFunname)
             failed = JS_TRUE;
     }
 
-    if (!failed && aCaller)
-    {
+    if (!failed && aCaller) {
         self->mCaller = aCaller;
     }
 
-    if (failed && self)
-    {
+    if (failed && self) {
         NS_RELEASE(self);   // sets self to nsnull
     }
 
     *stack = self;
     return self ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 /* readonly attribute PRUint32 language; */
--- a/js/xpconnect/src/XPCString.cpp
+++ b/js/xpconnect/src/XPCString.cpp
@@ -83,57 +83,51 @@ XPCStringConvert::ReadableToJSVal(JSCont
                                   nsStringBuffer** sharedBuffer)
 {
     JSString *str;
     *sharedBuffer = nsnull;
 
     PRUint32 length = readable.Length();
 
     JSAtom *atom;
-    if (length == 0 && (atom = cx->runtime->atomState.emptyAtom))
-    {
+    if (length == 0 && (atom = cx->runtime->atomState.emptyAtom)) {
         return STRING_TO_JSVAL(atom);
     }
 
     nsStringBuffer *buf = nsStringBuffer::FromString(readable);
-    if (buf)
-    {
+    if (buf) {
         // yay, we can share the string's buffer!
 
-        if (sDOMStringFinalizerIndex == -1)
-        {
+        if (sDOMStringFinalizerIndex == -1) {
             sDOMStringFinalizerIndex =
                     JS_AddExternalStringFinalizer(DOMStringFinalizer);
             if (sDOMStringFinalizerIndex == -1)
                 return JSVAL_NULL;
         }
 
         str = JS_NewExternalString(cx,
                                    reinterpret_cast<jschar *>(buf->Data()),
                                    length, sDOMStringFinalizerIndex);
 
-        if (str)
-        {
+        if (str) {
             *sharedBuffer = buf;
         }
     }
-    else
-    {
+    else {
         // blech, have to copy.
 
         jschar *chars = reinterpret_cast<jschar *>
                                         (JS_malloc(cx, (length + 1) *
                                                    sizeof(jschar)));
         if (!chars)
             return JSVAL_NULL;
 
         if (length && !CopyUnicodeTo(readable, 0,
                                      reinterpret_cast<PRUnichar *>(chars),
-                                     length))
-        {
+                                     length)) {
             JS_free(cx, chars);
             return JSVAL_NULL;
         }
 
         chars[length] = 0;
 
         str = JS_NewUCString(cx, chars, length);
         if (!str)
--- a/js/xpconnect/src/XPCThreadContext.cpp
+++ b/js/xpconnect/src/XPCThreadContext.cpp
@@ -57,18 +57,17 @@ XPCJSContextStack::XPCJSContextStack()
       mSafeJSContext(nsnull),
       mOwnSafeJSContext(nsnull)
 {
     // empty...
 }
 
 XPCJSContextStack::~XPCJSContextStack()
 {
-    if (mOwnSafeJSContext)
-    {
+    if (mOwnSafeJSContext) {
         JS_SetContextThread(mOwnSafeJSContext);
         JS_DestroyContext(mOwnSafeJSContext);
         mOwnSafeJSContext = nsnull;
     }
 }
 
 /* readonly attribute PRInt32 count; */
 NS_IMETHODIMP
@@ -93,77 +92,66 @@ XPCJSContextStack::Pop(JSContext * *_ret
     NS_ASSERTION(!mStack.IsEmpty(), "ThreadJSContextStack underflow");
 
     PRUint32 idx = mStack.Length() - 1; // The thing we're popping
 
     if (_retval)
         *_retval = mStack[idx].cx;
 
     mStack.RemoveElementAt(idx);
-    if (idx > 0)
-    {
+    if (idx > 0) {
         --idx; // Advance to new top of the stack
 
         XPCJSContextInfo & e = mStack[idx];
         NS_ASSERTION(!e.suspendDepth || e.cx, "Shouldn't have suspendDepth without a cx!");
-        if (e.cx)
-        {
-            if (e.suspendDepth)
-            {
+        if (e.cx) {
+            if (e.suspendDepth) {
                 JS_ResumeRequest(e.cx, e.suspendDepth);
                 e.suspendDepth = 0;
             }
 
-            if (e.savedFrameChain)
-            {
+            if (e.savedFrameChain) {
                 // Pop() can be called outside any request for e.cx.
                 JSAutoRequest ar(e.cx);
                 JS_RestoreFrameChain(e.cx);
                 e.savedFrameChain = false;
             }
         }
     }
     return NS_OK;
 }
 
 static nsIPrincipal*
 GetPrincipalFromCx(JSContext *cx)
 {
     nsIScriptContextPrincipal* scp = GetScriptContextPrincipalFromJSContext(cx);
-    if (scp)
-    {
+    if (scp) {
         nsIScriptObjectPrincipal* globalData = scp->GetObjectPrincipal();
         if (globalData)
             return globalData->GetPrincipal();
     }
     return nsnull;
 }
 
 /* void push (in JSContext cx); */
 NS_IMETHODIMP
 XPCJSContextStack::Push(JSContext * cx)
 {
     JS_ASSERT_IF(cx, JS_GetContextThread(cx));
-    if (mStack.Length() > 0)
-    {
+    if (mStack.Length() > 0) {
         XPCJSContextInfo & e = mStack[mStack.Length() - 1];
-        if (e.cx)
-        {
-            if (e.cx == cx)
-            {
+        if (e.cx) {
+            if (e.cx == cx) {
                 nsIScriptSecurityManager* ssm = XPCWrapper::GetSecurityManager();
-                if (ssm)
-                {
-                    if (nsIPrincipal* globalObjectPrincipal = GetPrincipalFromCx(cx))
-                    {
+                if (ssm) {
+                    if (nsIPrincipal* globalObjectPrincipal = GetPrincipalFromCx(cx)) {
                         nsIPrincipal* subjectPrincipal = ssm->GetCxSubjectPrincipal(cx);
                         bool equals = false;
                         globalObjectPrincipal->Equals(subjectPrincipal, &equals);
-                        if (equals)
-                        {
+                        if (equals) {
                             goto append;
                         }
                     }
                 }
             }
 
             {
                 // Push() can be called outside any request for e.cx.
@@ -217,89 +205,80 @@ static JSClass global_class = {
     JS_EnumerateStub, SafeGlobalResolve, JS_ConvertStub, SafeFinalize,
     JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 /* attribute JSContext safeJSContext; */
 NS_IMETHODIMP
 XPCJSContextStack::GetSafeJSContext(JSContext * *aSafeJSContext)
 {
-    if (!mSafeJSContext)
-    {
+    if (!mSafeJSContext) {
         // Start by getting the principal holder and principal for this
         // context.  If we can't manage that, don't bother with the rest.
         nsRefPtr<nsNullPrincipal> principal = new nsNullPrincipal();
         nsCOMPtr<nsIScriptObjectPrincipal> sop;
-        if (principal)
-        {
+        if (principal) {
             nsresult rv = principal->Init();
             if (NS_SUCCEEDED(rv))
               sop = new PrincipalHolder(principal);
         }
-        if (!sop)
-        {
+        if (!sop) {
             *aSafeJSContext = nsnull;
             return NS_ERROR_FAILURE;
         }
 
         JSRuntime *rt;
         XPCJSRuntime* xpcrt;
 
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
         nsCOMPtr<nsIXPConnect> xpcholder(static_cast<nsIXPConnect*>(xpc));
 
-        if (xpc && (xpcrt = xpc->GetRuntime()) && (rt = xpcrt->GetJSRuntime()))
-        {
+        if (xpc && (xpcrt = xpc->GetRuntime()) && (rt = xpcrt->GetJSRuntime())) {
             JSObject *glob;
             mSafeJSContext = JS_NewContext(rt, 8192);
-            if (mSafeJSContext)
-            {
+            if (mSafeJSContext) {
                 // scoped JS Request
                 JSAutoRequest req(mSafeJSContext);
 
                 // Because we can run off the main thread, we create an MT
                 // global object. Our principal is the unique key.
                 JSCompartment *compartment;
                 nsresult rv = xpc_CreateMTGlobalObject(mSafeJSContext,
                                                        &global_class,
                                                        principal, &glob,
                                                        &compartment);
                 if (NS_FAILED(rv))
                     glob = nsnull;
 
-                if (glob)
-                {
+                if (glob) {
                     // Make sure the context is associated with a proper compartment
                     // and not the default compartment.
                     JS_SetGlobalObject(mSafeJSContext, glob);
 
                     // Note: make sure to set the private before calling
                     // InitClasses
                     nsIScriptObjectPrincipal* priv = nsnull;
                     sop.swap(priv);
-                    if (!JS_SetPrivate(mSafeJSContext, glob, priv))
-                    {
+                    if (!JS_SetPrivate(mSafeJSContext, glob, priv)) {
                         // Drop the whole thing
                         NS_RELEASE(priv);
                         glob = nsnull;
                     }
                 }
 
                 // After this point either glob is null and the
                 // nsIScriptObjectPrincipal ownership is either handled by the
                 // nsCOMPtr or dealt with, or we'll release in the finalize
                 // hook.
-                if (glob && NS_FAILED(xpc->InitClasses(mSafeJSContext, glob)))
-                {
+                if (glob && NS_FAILED(xpc->InitClasses(mSafeJSContext, glob))) {
                     glob = nsnull;
                 }
 
             }
-            if (mSafeJSContext && !glob)
-            {
+            if (mSafeJSContext && !glob) {
                 // Destroy the context outside the scope of JSAutoRequest that
                 // uses the context in its destructor.
                 JS_DestroyContext(mSafeJSContext);
                 mSafeJSContext = nsnull;
             }
             // Save it off so we can destroy it later.
             mOwnSafeJSContext = mSafeJSContext;
         }
@@ -327,18 +306,17 @@ XPCPerThreadData::XPCPerThreadData()
         mException(nsnull),
         mExceptionManagerNotAvailable(JS_FALSE),
         mAutoRoots(nsnull)
 #ifdef XPC_CHECK_WRAPPER_THREADSAFETY
       , mWrappedNativeThreadsafetyReportDepth(0)
 #endif
 {
     MOZ_COUNT_CTOR(xpcPerThreadData);
-    if (gLock)
-    {
+    if (gLock) {
         MutexAutoLock lock(*gLock);
         mNextThread = gThreads;
         gThreads = this;
     }
 }
 
 void
 XPCPerThreadData::Cleanup()
@@ -361,40 +339,35 @@ XPCPerThreadData::~XPCPerThreadData()
        atomically.  See bug 557586. */
     bool doDestroyLock = false;
 
     MOZ_COUNT_DTOR(xpcPerThreadData);
 
     Cleanup();
 
     // Unlink 'this' from the list of threads.
-    if (gLock)
-    {
+    if (gLock) {
         MutexAutoLock lock(*gLock);
         if (gThreads == this)
             gThreads = mNextThread;
-        else
-        {
+        else {
             XPCPerThreadData* cur = gThreads;
-            while (cur)
-            {
-                if (cur->mNextThread == this)
-                {
+            while (cur) {
+                if (cur->mNextThread == this) {
                     cur->mNextThread = mNextThread;
                     break;
                 }
                 cur = cur->mNextThread;
             }
         }
         if (!gThreads)
             doDestroyLock = PR_TRUE;
     }
 
-    if (gLock && doDestroyLock)
-    {
+    if (gLock && doDestroyLock) {
         delete gLock;
         gLock = nsnull;
     }
 }
 
 static void
 xpc_ThreadDataDtorCB(void* ptr)
 {
@@ -428,57 +401,49 @@ void XPCPerThreadData::MarkAutoRootsAfte
 }
 
 // static
 XPCPerThreadData*
 XPCPerThreadData::GetDataImpl(JSContext *cx)
 {
     XPCPerThreadData* data;
 
-    if (!gLock)
-    {
+    if (!gLock) {
         gLock = new Mutex("XPCPerThreadData.gLock");
     }
 
-    if (gTLSIndex == BAD_TLS_INDEX)
-    {
+    if (gTLSIndex == BAD_TLS_INDEX) {
         MutexAutoLock lock(*gLock);
         // check again now that we have the lock...
-        if (gTLSIndex == BAD_TLS_INDEX)
-        {
+        if (gTLSIndex == BAD_TLS_INDEX) {
             if (PR_FAILURE ==
-                PR_NewThreadPrivateIndex(&gTLSIndex, xpc_ThreadDataDtorCB))
-            {
+                PR_NewThreadPrivateIndex(&gTLSIndex, xpc_ThreadDataDtorCB)) {
                 NS_ERROR("PR_NewThreadPrivateIndex failed!");
                 gTLSIndex = BAD_TLS_INDEX;
                 return nsnull;
             }
         }
     }
 
     data = (XPCPerThreadData*) PR_GetThreadPrivate(gTLSIndex);
-    if (!data)
-    {
+    if (!data) {
         data = new XPCPerThreadData();
-        if (!data || !data->IsValid())
-        {
+        if (!data || !data->IsValid()) {
             NS_ERROR("new XPCPerThreadData() failed!");
             delete data;
             return nsnull;
         }
-        if (PR_FAILURE == PR_SetThreadPrivate(gTLSIndex, data))
-        {
+        if (PR_FAILURE == PR_SetThreadPrivate(gTLSIndex, data)) {
             NS_ERROR("PR_SetThreadPrivate failed!");
             delete data;
             return nsnull;
         }
     }
 
-    if (cx && !sMainJSThread && NS_IsMainThread())
-    {
+    if (cx && !sMainJSThread && NS_IsMainThread()) {
         sMainJSThread = cx->thread();
 
         sMainThreadData = data;
 
         sMainThreadData->mThread = PR_GetCurrentThread();
     }
 
     return data;
@@ -493,38 +458,34 @@ XPCPerThreadData::CleanupAllThreads()
     // cleaup while holding this lock. So, we are going to go to the trouble
     // to copy out the data that needs to be cleaned up *outside* of
     // the lock. Yuk!
 
     XPCJSContextStack** stacks = nsnull;
     int count = 0;
     int i;
 
-    if (gLock)
-    {
+    if (gLock) {
         MutexAutoLock lock(*gLock);
 
         for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
             count++;
 
         stacks = (XPCJSContextStack**) new XPCJSContextStack*[count] ;
-        if (stacks)
-        {
+        if (stacks) {
             i = 0;
-            for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
-            {
+            for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread) {
                 stacks[i++] = cur->mJSContextStack;
                 cur->mJSContextStack = nsnull;
                 cur->Cleanup();
             }
         }
     }
 
-    if (stacks)
-    {
+    if (stacks) {
         for (i = 0; i < count; i++)
             delete stacks[i];
         delete [] stacks;
     }
 
     if (gTLSIndex != BAD_TLS_INDEX)
         PR_SetThreadPrivate(gTLSIndex, nsnull);
 }
--- a/js/xpconnect/src/XPCThrower.cpp
+++ b/js/xpconnect/src/XPCThrower.cpp
@@ -171,31 +171,28 @@ XPCThrower::ThrowBadParam(nsresult rv, u
 
 // static
 void
 XPCThrower::Verbosify(XPCCallContext& ccx,
                       char** psz, bool own)
 {
     char* sz = nsnull;
 
-    if (ccx.HasInterfaceAndMember())
-    {
+    if (ccx.HasInterfaceAndMember()) {
         XPCNativeInterface* iface = ccx.GetInterface();
         jsid id = ccx.GetMember()->GetName();
         JSAutoByteString bytes;
         const char *name = JSID_IS_VOID(id) ? "Unknown" : bytes.encode(ccx, JSID_TO_STRING(id));
-        if (!name)
-        {
+        if (!name) {
             name = "";
         }
         sz = JS_smprintf("%s [%s.%s]", *psz, iface->GetNameString(), name);
     }
 
-    if (sz)
-    {
+    if (sz) {
         if (own)
             JS_smprintf_free(*psz);
         *psz = sz;
     }
 }
 
 // static
 void
@@ -205,30 +202,27 @@ XPCThrower::BuildAndThrowException(JSCon
 
     /* no need to set an expection if the security manager already has */
     if (rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO && JS_IsExceptionPending(cx))
         return;
     nsCOMPtr<nsIException> finalException;
     nsCOMPtr<nsIException> defaultException;
     nsXPCException::NewException(sz, rv, nsnull, nsnull, getter_AddRefs(defaultException));
     XPCPerThreadData* tls = XPCPerThreadData::GetData(cx);
-    if (tls)
-    {
+    if (tls) {
         nsIExceptionManager * exceptionManager = tls->GetExceptionManager();
-        if (exceptionManager)
-        {
+        if (exceptionManager) {
            // Ask the provider for the exception, if there is no provider
            // we expect it to set e to null
             exceptionManager->GetExceptionFromProvider(rv,
                                                        defaultException,
                                                        getter_AddRefs(finalException));
             // We should get at least the defaultException back,
             // but just in case
-            if (finalException == nsnull)
-            {
+            if (finalException == nsnull) {
                 finalException = defaultException;
             }
         }
     }
     // XXX Should we put the following test and call to JS_ReportOutOfMemory
     // inside this test?
     if (finalException)
         success = ThrowExceptionObject(cx, finalException);
@@ -239,22 +233,20 @@ XPCThrower::BuildAndThrowException(JSCon
 }
 
 static bool
 IsCallerChrome(JSContext* cx)
 {
     nsresult rv;
 
     nsCOMPtr<nsIScriptSecurityManager> secMan;
-    if (XPCPerThreadData::IsMainThread(cx))
-    {
+    if (XPCPerThreadData::IsMainThread(cx)) {
         secMan = XPCWrapper::GetSecurityManager();
     }
-    else
-    {
+    else {
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
         if (!xpc)
             return PR_FALSE;
 
         nsCOMPtr<nsIXPCSecurityManager> xpcSecMan;
         PRUint16 flags = 0;
         rv = xpc->GetSecurityManagerForJSContext(cx, getter_AddRefs(xpcSecMan),
                                                  &flags);
@@ -272,49 +264,44 @@ IsCallerChrome(JSContext* cx)
     return NS_SUCCEEDED(rv) && isChrome;
 }
 
 // static
 JSBool
 XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
 {
     JSBool success = JS_FALSE;
-    if (e)
-    {
+    if (e) {
         nsCOMPtr<nsIXPCException> xpcEx;
         jsval thrown;
         nsXPConnect* xpc;
 
         // If we stored the original thrown JS value in the exception
         // (see XPCConvert::ConstructException) and we are in a web
         // context (i.e., not chrome), rethrow the original value.
         if (!IsCallerChrome(cx) &&
             (xpcEx = do_QueryInterface(e)) &&
-            NS_SUCCEEDED(xpcEx->StealJSVal(&thrown)))
-        {
+            NS_SUCCEEDED(xpcEx->StealJSVal(&thrown))) {
             if (!JS_WrapValue(cx, &thrown))
                 return JS_FALSE;
             JS_SetPendingException(cx, thrown);
             success = JS_TRUE;
         }
-        else if ((xpc = nsXPConnect::GetXPConnect()))
-        {
+        else if ((xpc = nsXPConnect::GetXPConnect())) {
             JSObject* glob = JS_GetGlobalForScopeChain(cx);
             if (!glob)
                 return JS_FALSE;
 
             nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
             nsresult rv = xpc->WrapNative(cx, glob, e,
                                           NS_GET_IID(nsIException),
                                           getter_AddRefs(holder));
-            if (NS_SUCCEEDED(rv) && holder)
-            {
+            if (NS_SUCCEEDED(rv) && holder) {
                 JSObject* obj;
-                if (NS_SUCCEEDED(holder->GetJSObject(&obj)))
-                {
+                if (NS_SUCCEEDED(holder->GetJSObject(&obj))) {
                     JS_SetPendingException(cx, OBJECT_TO_JSVAL(obj));
                     success = JS_TRUE;
                 }
             }
         }
     }
     return success;
 }
--- a/js/xpconnect/src/XPCVariant.cpp
+++ b/js/xpconnect/src/XPCVariant.cpp
@@ -56,18 +56,17 @@ NS_IMPL_CI_INTERFACE_GETTER2(XPCVariant,
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(XPCVariant)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(XPCVariant)
 
 XPCVariant::XPCVariant(XPCCallContext& ccx, jsval aJSVal)
     : mJSVal(aJSVal)
 {
     nsVariant::Initialize(&mData);
-    if (!JSVAL_IS_PRIMITIVE(mJSVal))
-    {
+    if (!JSVAL_IS_PRIMITIVE(mJSVal)) {
         JSObject *obj = JS_ObjectToInnerObject(ccx, JSVAL_TO_OBJECT(mJSVal));
 
         mJSVal = OBJECT_TO_JSVAL(obj);
 
         // If the incoming object is an XPCWrappedNative, then it could be a
         // double-wrapped object, and we should return the double-wrapped
         // object back out to script.
 
@@ -129,18 +128,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XP
     jsval val = tmp->GetJSValPreserveColor();
 
     // We're sharing val's buffer, clear the pointer to it so Cleanup() won't
     // try to delete it
     if (JSVAL_IS_STRING(val))
         tmp->mData.u.wstr.mWStringValue = nsnull;
     nsVariant::Cleanup(&tmp->mData);
 
-    if (JSVAL_IS_TRACEABLE(val))
-    {
+    if (JSVAL_IS_TRACEABLE(val)) {
         XPCTraceableVariant *v = static_cast<XPCTraceableVariant*>(tmp);
         v->RemoveFromRootSet(nsXPConnect::GetRuntimeInstance()->GetMapLock());
     }
     tmp->mJSVal = JSVAL_NULL;
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 // static
 XPCVariant* XPCVariant::newVariant(XPCCallContext& ccx, jsval aJSVal)
@@ -215,39 +213,36 @@ XPCArrayHomogenizer::StateTable[tTypeCou
 JSBool
 XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
                                      jsuint length,
                                      nsXPTType* resultType, nsID* resultID)
 {
     Type state = tUnk;
     Type type;
 
-    for (jsuint i = 0; i < length; i++)
-    {
+    for (jsuint i = 0; i < length; i++) {
         jsval val;
         if (!JS_GetElement(ccx, array, i, &val))
             return JS_FALSE;
 
         if (JSVAL_IS_INT(val))
             type = tInt;
         else if (JSVAL_IS_DOUBLE(val))
             type = tDbl;
         else if (JSVAL_IS_BOOLEAN(val))
             type = tBool;
-        else if (JSVAL_IS_VOID(val))
-        {
+        else if (JSVAL_IS_VOID(val)) {
             state = tVar;
             break;
         }
         else if (JSVAL_IS_NULL(val))
             type = tNull;
         else if (JSVAL_IS_STRING(val))
             type = tStr;
-        else
-        {
+        else {
             NS_ASSERTION(JSVAL_IS_OBJECT(val), "invalid type of jsval!");
             JSObject* jsobj = JSVAL_TO_OBJECT(val);
             if (JS_IsArrayObject(ccx, jsobj))
                 type = tArr;
             else if (xpc_JSObjectIsID(ccx, jsobj))
                 type = tID;
             else
                 type = tISup;
@@ -262,18 +257,17 @@ XPCArrayHomogenizer::GetTypeForArray(XPC
 
         NS_ASSERTION(state != tErr, "bad state table!");
         NS_ASSERTION(state != tUnk, "bad state table!");
 
         if (state == tVar)
             break;
     }
 
-    switch (state)
-    {
+    switch (state) {
         case tInt :
             *resultType = nsXPTType((uint8)TD_INT32);
             break;
         case tDbl :
             *resultType = nsXPTType((uint8)TD_DOUBLE);
             break;
         case tBool:
             *resultType = nsXPTType((uint8)TD_BOOL);
@@ -320,18 +314,17 @@ JSBool XPCVariant::InitializeData(XPCCal
                                                      JSVAL_TO_DOUBLE(val)));
     if (JSVAL_IS_BOOLEAN(val))
         return NS_SUCCEEDED(nsVariant::SetFromBool(&mData,
                                                    JSVAL_TO_BOOLEAN(val)));
     if (JSVAL_IS_VOID(val))
         return NS_SUCCEEDED(nsVariant::SetToVoid(&mData));
     if (JSVAL_IS_NULL(val))
         return NS_SUCCEEDED(nsVariant::SetToEmpty(&mData));
-    if (JSVAL_IS_STRING(val))
-    {
+    if (JSVAL_IS_STRING(val)) {
         // Make our string immutable.  This will also ensure null-termination,
         // which nsVariant assumes for its PRUnichar* stuff.
         JSString* str = JSVAL_TO_STRING(val);
         if (!JS_MakeStringImmutable(ccx, str))
             return JS_FALSE;
 
         // Don't use nsVariant::SetFromWStringWithSize, because that will copy
         // the data.  Just handle this ourselves.  Note that it's ok to not
@@ -365,20 +358,18 @@ JSBool XPCVariant::InitializeData(XPCCal
     const nsID* id = xpc_JSObjectToID(ccx, jsobj);
     if (id)
         return NS_SUCCEEDED(nsVariant::SetFromID(&mData, *id));
 
     // Let's see if it is a js array object.
 
     jsuint len;
 
-    if (JS_IsArrayObject(ccx, jsobj) && JS_GetArrayLength(ccx, jsobj, &len))
-    {
-        if (!len)
-        {
+    if (JS_IsArrayObject(ccx, jsobj) && JS_GetArrayLength(ccx, jsobj, &len)) {
+        if (!len) {
             // Zero length array
             nsVariant::SetToEmptyArray(&mData);
             return JS_TRUE;
         }
 
         nsXPTType type;
         nsID id;
 
@@ -432,28 +423,26 @@ XPCVariant::VariantDataToJS(XPCLazyCallC
 
     jsval realVal;
     nsresult rv = variant->GetAsJSVal(&realVal);
 
     if (NS_SUCCEEDED(rv) &&
         (JSVAL_IS_PRIMITIVE(realVal) ||
          type == nsIDataType::VTYPE_ARRAY ||
          type == nsIDataType::VTYPE_EMPTY_ARRAY ||
-         type == nsIDataType::VTYPE_ID))
-    {
+         type == nsIDataType::VTYPE_ID)) {
         JSContext *cx = lccx.GetJSContext();
         if (!JS_WrapValue(cx, &realVal))
             return JS_FALSE;
         *pJSVal = realVal;
         return JS_TRUE;
     }
 
     nsCOMPtr<XPCVariant> xpcvariant = do_QueryInterface(variant);
-    if (xpcvariant && xpcvariant->mReturnRawObject)
-    {
+    if (xpcvariant && xpcvariant->mReturnRawObject) {
         NS_ASSERTION(type == nsIDataType::VTYPE_INTERFACE ||
                      type == nsIDataType::VTYPE_INTERFACE_IS,
                      "Weird variant");
 
         JSContext *cx = lccx.GetJSContext();
         if (!JS_WrapValue(cx, &realVal))
             return JS_FALSE;
         *pJSVal = realVal;
@@ -478,18 +467,17 @@ XPCVariant::VariantDataToJS(XPCLazyCallC
     PRUint32 size;
     xpctvar.flags = 0;
     JSBool success;
 
     JSContext* cx = lccx.GetJSContext();
     NS_ABORT_IF_FALSE(js::GetObjectCompartment(lccx.GetScopeForNewJSObjects()) == cx->compartment,
                       "bad scope for new JSObjects");
 
-    switch (type)
-    {
+    switch (type) {
         case nsIDataType::VTYPE_INT8:
         case nsIDataType::VTYPE_INT16:
         case nsIDataType::VTYPE_INT32:
         case nsIDataType::VTYPE_INT64:
         case nsIDataType::VTYPE_UINT8:
         case nsIDataType::VTYPE_UINT16:
         case nsIDataType::VTYPE_UINT32:
         case nsIDataType::VTYPE_UINT64:
@@ -606,18 +594,17 @@ XPCVariant::VariantDataToJS(XPCLazyCallC
             // must exit via VARIANT_DONE from here on...
             du.mType = nsIDataType::VTYPE_ARRAY;
             success = JS_FALSE;
 
             nsXPTType conversionType;
             PRUint16 elementType = du.u.array.mArrayType;
             const nsID* pid = nsnull;
 
-            switch (elementType)
-            {
+            switch (elementType) {
                 case nsIDataType::VTYPE_INT8:
                 case nsIDataType::VTYPE_INT16:
                 case nsIDataType::VTYPE_INT32:
                 case nsIDataType::VTYPE_INT64:
                 case nsIDataType::VTYPE_UINT8:
                 case nsIDataType::VTYPE_UINT16:
                 case nsIDataType::VTYPE_UINT32:
                 case nsIDataType::VTYPE_UINT64:
@@ -688,34 +675,31 @@ VARIANT_DONE:
         default:
             NS_ERROR("bad type in variant!");
             return JS_FALSE;
     }
 
     // If we are here then we need to convert the data in the xpctvar.
 
     if (xpctvar.type.TagPart() == TD_PSTRING_SIZE_IS ||
-        xpctvar.type.TagPart() == TD_PWSTRING_SIZE_IS)
-    {
+        xpctvar.type.TagPart() == TD_PWSTRING_SIZE_IS) {
         success = XPCConvert::NativeStringWithSize2JS(cx, pJSVal,
                                                       (const void*)&xpctvar.val,
                                                       xpctvar.type,
                                                       size, pErr);
     }
-    else
-    {
+    else {
         success = XPCConvert::NativeData2JS(lccx, pJSVal,
                                             (const void*)&xpctvar.val,
                                             xpctvar.type,
                                             &iid, pErr);
     }
 
     // We may have done something in the above code that requires cleanup.
-    if (xpctvar.DoesValNeedCleanup())
-    {
+    if (xpctvar.DoesValNeedCleanup()) {
         if (type == nsIDataType::VTYPE_INTERFACE ||
             type == nsIDataType::VTYPE_INTERFACE_IS)
             ((nsISupports*)xpctvar.val.p)->Release();
         else
             nsMemory::Free((char*)xpctvar.val.p);
     }
 
     return success;
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -104,54 +104,50 @@ nsXPCWrappedJS::AggregatedQueryInterface
 
     if (!IsValid())
         return NS_ERROR_UNEXPECTED;
 
     // Put this here rather that in DelegatedQueryInterface because it needs
     // to be in QueryInterface before the possible delegation to 'outer', but
     // we don't want to do this check twice in one call in the normal case:
     // once in QueryInterface and once in DelegatedQueryInterface.
-    if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS))) {
         NS_ADDREF(this);
         *aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
         return NS_OK;
     }
 
     return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
 }
 
 NS_IMETHODIMP
 nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
 {
-    if (nsnull == aInstancePtr)
-    {
+    if (nsnull == aInstancePtr) {
         NS_PRECONDITION(0, "null pointer");
         return NS_ERROR_NULL_POINTER;
     }
 
     if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {
         *aInstancePtr = & NS_CYCLE_COLLECTION_NAME(nsXPCWrappedJS);
         return NS_OK;
     }
 
-    if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports))) {
         *aInstancePtr =
             NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(this);
         return NS_OK;
     }
 
     if (!IsValid())
         return NS_ERROR_UNEXPECTED;
 
     // Always check for this first so that our 'outer' can get this interface
     // from us without recurring into a call to the outer's QI!
-    if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS))) {
         NS_ADDREF(this);
         *aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
         return NS_OK;
     }
 
     nsISupports* outer = GetAggregatedNativeObject();
     if (outer)
         return outer->QueryInterface(aIID, aInstancePtr);
@@ -182,18 +178,17 @@ nsXPCWrappedJS::QueryInterface(REFNSIID 
 // an addref and cause us to re-root the JSObject and continue on more normally.
 
 nsrefcnt
 nsXPCWrappedJS::AddRef(void)
 {
     nsrefcnt cnt = NS_AtomicIncrementRefcnt(mRefCnt);
     NS_LOG_ADDREF(this, cnt, "nsXPCWrappedJS", sizeof(*this));
 
-    if (2 == cnt && IsValid())
-    {
+    if (2 == cnt && IsValid()) {
         XPCJSRuntime* rt = mClass->GetRuntime();
         rt->AddWrappedJSRoot(this);
     }
 
     return cnt;
 }
 
 nsrefcnt
@@ -206,23 +201,21 @@ nsXPCWrappedJS::Release(void)
     XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
     XPCAutoLock lock(rt->GetMapLock());
 
 do_decrement:
 
     nsrefcnt cnt = NS_AtomicDecrementRefcnt(mRefCnt);
     NS_LOG_RELEASE(this, cnt, "nsXPCWrappedJS");
 
-    if (0 == cnt)
-    {
+    if (0 == cnt) {
         delete this;   // also unlinks us from chain
         return 0;
     }
-    if (1 == cnt)
-    {
+    if (1 == cnt) {
         if (IsValid())
             RemoveFromRootSet(rt->GetMapLock());
 
         // If we are not the root wrapper or if we are not being used from a
         // weak reference, then this extra ref is not needed and we can let
         // ourself be deleted.
         // Note: HasWeakReferences() could only return true for the root.
         if (!HasWeakReferences())
@@ -283,18 +276,17 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallCont
     JSObject* rootJSObj;
     nsXPCWrappedJS* root = nsnull;
     nsXPCWrappedJS* wrapper = nsnull;
     nsXPCWrappedJSClass* clazz = nsnull;
     XPCJSRuntime* rt = ccx.GetRuntime();
     JSBool release_root = JS_FALSE;
 
     map = rt->GetWrappedJSMap();
-    if (!map)
-    {
+    if (!map) {
         NS_ASSERTION(map,"bad map");
         return NS_ERROR_FAILURE;
     }
 
     nsXPCWrappedJSClass::GetNewOrUsed(ccx, aIID, &clazz);
     if (!clazz)
         return NS_ERROR_FAILURE;
     // from here on we need to return through 'return_wrapper'
@@ -305,48 +297,43 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallCont
         goto return_wrapper;
 
     // look for the root wrapper, and if found, hold the map lock until
     // we've added our ref to prevent another thread from destroying it
     // under us
     {   // scoped lock
         XPCAutoLock lock(rt->GetMapLock());
         root = map->Find(rootJSObj);
-        if (root)
-        {
+        if (root) {
             if ((nsnull != (wrapper = root->Find(aIID))) ||
-                (nsnull != (wrapper = root->FindInherited(aIID))))
-            {
+                (nsnull != (wrapper = root->FindInherited(aIID)))) {
                 NS_ADDREF(wrapper);
                 goto return_wrapper;
             }
         }
     }
 
-    if (!root)
-    {
+    if (!root) {
         // build the root wrapper
-        if (rootJSObj == aJSObj)
-        {
+        if (rootJSObj == aJSObj) {
             // the root will do double duty as the interface wrapper
             wrapper = root = new nsXPCWrappedJS(ccx, aJSObj, clazz, nsnull,
                                                 aOuter);
             if (root)
             {   // scoped lock
 #if DEBUG_xpc_leaks
                 printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
                        (void*)wrapper, (void*)aJSObj);
 #endif
                 XPCAutoLock lock(rt->GetMapLock());
                 map->Add(root);
             }
             goto return_wrapper;
         }
-        else
-        {
+        else {
             // just a root wrapper
             nsXPCWrappedJSClass* rootClazz = nsnull;
             nsXPCWrappedJSClass::GetNewOrUsed(ccx, NS_GET_IID(nsISupports),
                                               &rootClazz);
             if (!rootClazz)
                 goto return_wrapper;
 
             root = new nsXPCWrappedJS(ccx, rootJSObj, rootClazz, nsnull, aOuter);
@@ -367,18 +354,17 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallCont
             }
         }
     }
 
     // at this point we have a root and may need to build the specific wrapper
     NS_ASSERTION(root,"bad root");
     NS_ASSERTION(clazz,"bad clazz");
 
-    if (!wrapper)
-    {
+    if (!wrapper) {
         wrapper = new nsXPCWrappedJS(ccx, aJSObj, clazz, root, aOuter);
         if (!wrapper)
             goto return_wrapper;
 #if DEBUG_xpc_leaks
         printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
                (void*)wrapper, (void*)aJSObj);
 #endif
     }
@@ -431,117 +417,102 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallCo
         NS_ADDREF(mRoot);
 
 }
 
 nsXPCWrappedJS::~nsXPCWrappedJS()
 {
     NS_PRECONDITION(0 == mRefCnt, "refcounting error");
 
-    if (mRoot == this)
-    {
+    if (mRoot == this) {
         // Remove this root wrapper from the map
         XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
         JSObject2WrappedJSMap* map = rt->GetWrappedJSMap();
-        if (map)
-        {
+        if (map) {
             XPCAutoLock lock(rt->GetMapLock());
             map->Remove(this);
         }
     }
     Unlink();
 }
 
 void
 nsXPCWrappedJS::Unlink()
 {
-    if (IsValid())
-    {
+    if (IsValid()) {
         XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-        if (rt)
-        {
-            if (mRoot == this)
-            {
+        if (rt) {
+            if (mRoot == this) {
                 // remove this root wrapper from the map
                 JSObject2WrappedJSMap* map = rt->GetWrappedJSMap();
-                if (map)
-                {
+                if (map) {
                     XPCAutoLock lock(rt->GetMapLock());
                     map->Remove(this);
                 }
             }
 
             if (mRefCnt > 1)
                 RemoveFromRootSet(rt->GetMapLock());
         }
 
         mJSObj = nsnull;
     }
 
-    if (mRoot == this)
-    {
+    if (mRoot == this) {
         ClearWeakReferences();
     }
-    else if (mRoot)
-    {
+    else if (mRoot) {
         // unlink this wrapper
         nsXPCWrappedJS* cur = mRoot;
-        while (1)
-        {
-            if (cur->mNext == this)
-            {
+        while (1) {
+            if (cur->mNext == this) {
                 cur->mNext = mNext;
                 break;
             }
             cur = cur->mNext;
             NS_ASSERTION(cur, "failed to find wrapper in its own chain");
         }
         // let the root go
         NS_RELEASE(mRoot);
     }
 
     NS_IF_RELEASE(mClass);
-    if (mOuter)
-    {
+    if (mOuter) {
         XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-        if (rt->GetThreadRunningGC())
-        {
+        if (rt->GetThreadRunningGC()) {
             rt->DeferredRelease(mOuter);
             mOuter = nsnull;
         }
-        else
-        {
+        else {
             NS_RELEASE(mOuter);
         }
     }
 }
 
 nsXPCWrappedJS*
 nsXPCWrappedJS::Find(REFNSIID aIID)
 {
     if (aIID.Equals(NS_GET_IID(nsISupports)))
         return mRoot;
 
-    for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
-    {
+    for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext) {
         if (aIID.Equals(cur->GetIID()))
             return cur;
     }
 
     return nsnull;
 }
 
 // check if asking for an interface that some wrapper in the chain inherits from
 nsXPCWrappedJS*
 nsXPCWrappedJS::FindInherited(REFNSIID aIID)
 {
     NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)), "bad call sequence");
 
-    for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext)
-    {
+    for (nsXPCWrappedJS* cur = mRoot; cur; cur = cur->mNext) {
         bool found;
         if (NS_SUCCEEDED(cur->GetClass()->GetInterfaceInfo()->
                          HasAncestor(&aIID, &found)) && found)
             return cur;
     }
 
     return nsnull;
 }
@@ -667,20 +638,18 @@ nsXPCWrappedJS::DebugDump(PRInt16 depth)
         char * iid = GetClass()->GetIID().ToString();
         XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
         if (iid)
             NS_Free(iid);
         XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x", mClass));
 
         if (!isRoot)
             XPC_LOG_OUTDENT();
-        if (mNext)
-        {
-            if (isRoot)
-            {
+        if (mNext) {
+            if (isRoot) {
                 XPC_LOG_ALWAYS(("Additional wrappers for this object..."));
                 XPC_LOG_INDENT();
             }
             mNext->DebugDump(depth);
             if (isRoot)
                 XPC_LOG_OUTDENT();
         }
         if (isRoot)
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -57,18 +57,17 @@ static uint32 zero_methods_descriptor;
 bool AutoScriptEvaluate::StartEvaluating(JSObject *scope, JSErrorReporter errorReporter)
 {
     NS_PRECONDITION(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once");
 
     if (!mJSContext)
         return PR_TRUE;
 
     mEvaluated = PR_TRUE;
-    if (!mJSContext->errorReporter)
-    {
+    if (!mJSContext->errorReporter) {
         JS_SetErrorReporter(mJSContext, errorReporter);
         mErrorReporterSet = PR_TRUE;
     }
     mContextHasThread = JS_GetContextThread(mJSContext);
     if (mContextHasThread)
         JS_BeginRequest(mJSContext);
 
     if (!mEnterCompartment.enter(mJSContext, scope))
@@ -79,18 +78,17 @@ bool AutoScriptEvaluate::StartEvaluating
     // js debugger, as described in
     // http://bugzilla.mozilla.org/show_bug.cgi?id=88130 but presumably could
     // show up in any situation where a script calls into a wrapped js component
     // on the same context, while the context has a nonzero exception state.
     // Because JS_SaveExceptionState/JS_RestoreExceptionState use malloc
     // and addroot, we avoid them if possible by returning null (as opposed to
     // a JSExceptionState with no information) when there is no pending
     // exception.
-    if (JS_IsExceptionPending(mJSContext))
-    {
+    if (JS_IsExceptionPending(mJSContext)) {
         mState = JS_SaveExceptionState(mJSContext);
         JS_ClearPendingException(mJSContext);
     }
 
     return PR_TRUE;
 }
 
 AutoScriptEvaluate::~AutoScriptEvaluate()
@@ -108,18 +106,17 @@ AutoScriptEvaluate::~AutoScriptEvaluate(
     // If this is a JSContext that has a private context that provides a
     // nsIXPCScriptNotify interface, then notify the object the script has
     // been executed.
     //
     // Note: We rely on the rule that if any JSContext in our JSRuntime has
     // private data that points to an nsISupports subclass, it has also set
     // the JSOPTION_PRIVATE_IS_NSISUPPORTS option.
 
-    if (JS_GetOptions(mJSContext) & JSOPTION_PRIVATE_IS_NSISUPPORTS)
-    {
+    if (JS_GetOptions(mJSContext) & JSOPTION_PRIVATE_IS_NSISUPPORTS) {
         nsCOMPtr<nsIXPCScriptNotify> scriptNotify =
             do_QueryInterface(static_cast<nsISupports*>
                               (JS_GetContextPrivate(mJSContext)));
         if (scriptNotify)
             scriptNotify->ScriptExecuted();
     }
 
     if (mErrorReporterSet)
@@ -128,18 +125,17 @@ AutoScriptEvaluate::~AutoScriptEvaluate(
 
 // It turns out that some errors may be not worth reporting. So, this
 // function is factored out to manage that.
 JSBool xpc_IsReportableErrorCode(nsresult code)
 {
     if (NS_SUCCEEDED(code))
         return JS_FALSE;
 
-    switch (code)
-    {
+    switch (code) {
         // Error codes that we don't want to report as errors...
         // These generally indicate bad interface design AFAIC.
         case NS_ERROR_FACTORY_REGISTER_AGAIN:
         case NS_BASE_STREAM_WOULD_BLOCK:
             return JS_FALSE;
     }
 
     return JS_TRUE;
@@ -155,27 +151,24 @@ nsXPCWrappedJSClass::GetNewOrUsed(XPCCal
 
     {   // scoped lock
         XPCAutoLock lock(rt->GetMapLock());
         IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
         clazz = map->Find(aIID);
         NS_IF_ADDREF(clazz);
     }
 
-    if (!clazz)
-    {
+    if (!clazz) {
         nsCOMPtr<nsIInterfaceInfo> info;
         ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
-        if (info)
-        {
+        if (info) {
             bool canScript, isBuiltin;
             if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
                 NS_SUCCEEDED(info->IsBuiltinClass(&isBuiltin)) && !isBuiltin &&
-                nsXPConnect::IsISupportsDescendant(info))
-            {
+                nsXPConnect::IsISupportsDescendant(info)) {
                 clazz = new nsXPCWrappedJSClass(ccx, aIID, info);
                 if (clazz && !clazz->mDescriptors)
                     NS_RELEASE(clazz);  // sets clazz to nsnull
             }
         }
     }
     *resultClazz = clazz;
     return NS_OK;
@@ -193,44 +186,38 @@ nsXPCWrappedJSClass::nsXPCWrappedJSClass
     NS_ADDREF_THIS();
 
     {   // scoped lock
         XPCAutoLock lock(mRuntime->GetMapLock());
         mRuntime->GetWrappedJSClassMap()->Add(this);
     }
 
     uint16 methodCount;
-    if (NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount)))
-    {
-        if (methodCount)
-        {
+    if (NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount))) {
+        if (methodCount) {
             int wordCount = (methodCount/32)+1;
-            if (nsnull != (mDescriptors = new uint32[wordCount]))
-            {
+            if (nsnull != (mDescriptors = new uint32[wordCount])) {
                 int i;
                 // init flags to 0;
                 for (i = wordCount-1; i >= 0; i--)
                     mDescriptors[i] = 0;
 
-                for (i = 0; i < methodCount; i++)
-                {
+                for (i = 0; i < methodCount; i++) {
                     const nsXPTMethodInfo* info;
                     if (NS_SUCCEEDED(mInfo->GetMethodInfo(i, &info)))
                         SetReflectable(i, XPCConvert::IsMethodReflectable(*info));
-                    else
-                    {
+                    else {
                         delete [] mDescriptors;
                         mDescriptors = nsnull;
                         break;
                     }
                 }
             }
         }
-        else
-        {
+        else {
             mDescriptors = &zero_methods_descriptor;
         }
     }
 }
 
 nsXPCWrappedJSClass::~nsXPCWrappedJSClass()
 {
     if (mDescriptors && mDescriptors != &zero_methods_descriptor)
@@ -258,18 +245,17 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
     jsid funid;
     jsval fun;
 
     // Don't call the actual function on a content object. We'll determine
     // whether or not a content object is capable of implementing the
     // interface (i.e. whether the interface is scriptable) and most content
     // objects don't have QI implementations anyway. Also see bug 503926.
     if (XPCPerThreadData::IsMainThread(ccx) &&
-        !xpc::AccessCheck::isChrome(js::GetObjectCompartment(jsobj)))
-    {
+        !xpc::AccessCheck::isChrome(js::GetObjectCompartment(jsobj))) {
         return nsnull;
     }
 
     // OK, it looks like we'll be calling into JS code.
     AutoScriptEvaluate scriptEval(cx);
 
     // XXX we should install an error reporter that will send reports to
     // the JS error console service.
@@ -285,79 +271,71 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
     AUTO_MARK_JSVAL(ccx, fun);
 
     // Ensure that we are asking for a scriptable interface.
     // NB:  It's important for security that this check is here rather
     // than later, since it prevents untrusted objects from implementing
     // some interfaces in JS and aggregating a trusted object to
     // implement intentionally (for security) unscriptable interfaces.
     // We so often ask for nsISupports that we can short-circuit the test...
-    if (!aIID.Equals(NS_GET_IID(nsISupports)))
-    {
+    if (!aIID.Equals(NS_GET_IID(nsISupports))) {
         nsCOMPtr<nsIInterfaceInfo> info;
         ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
         if (!info)
             return nsnull;
         bool canScript, isBuiltin;
         if (NS_FAILED(info->IsScriptable(&canScript)) || !canScript ||
             NS_FAILED(info->IsBuiltinClass(&isBuiltin)) || isBuiltin)
             return nsnull;
     }
 
     id = xpc_NewIDObject(cx, jsobj, aIID);
-    if (id)
-    {
+    if (id) {
         // Throwing NS_NOINTERFACE is the prescribed way to fail QI from JS. It
         // is not an exception that is ever worth reporting, but we don't want
         // to eat all exceptions either.
 
         uint32 oldOpts =
           JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT);
 
         jsval args[1] = {OBJECT_TO_JSVAL(id)};
         success = JS_CallFunctionValue(cx, jsobj, fun, 1, args, &retval);
 
         JS_SetOptions(cx, oldOpts);
 
-        if (!success)
-        {
+        if (!success) {
             NS_ASSERTION(JS_IsExceptionPending(cx),
                          "JS failed without setting an exception!");
 
             jsval jsexception = JSVAL_NULL;
             AUTO_MARK_JSVAL(ccx, &jsexception);
 
-            if (JS_GetPendingException(cx, &jsexception))
-            {
+            if (JS_GetPendingException(cx, &jsexception)) {
                 nsresult rv;
-                if (JSVAL_IS_OBJECT(jsexception))
-                {
+                if (JSVAL_IS_OBJECT(jsexception)) {
                     // XPConnect may have constructed an object to represent a
                     // C++ QI failure. See if that is the case.
                     nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
 
                     nsXPConnect::GetXPConnect()->
                         GetWrappedNativeOfJSObject(ccx,
                                                    JSVAL_TO_OBJECT(jsexception),
                                                    getter_AddRefs(wrapper));
 
-                    if (wrapper)
-                    {
+                    if (wrapper) {
                         nsCOMPtr<nsIException> exception =
                             do_QueryWrappedNative(wrapper);
                         if (exception &&
                             NS_SUCCEEDED(exception->GetResult(&rv)) &&
-                            rv == NS_NOINTERFACE)
-                        {
+                            rv == NS_NOINTERFACE) {
                             JS_ClearPendingException(cx);
                         }
                     }
                 }
-                else if (JSVAL_IS_NUMBER(jsexception))
-                {
+                else if (JSVAL_IS_NUMBER(jsexception)) {
                     // JS often throws an nsresult.
                     if (JSVAL_IS_DOUBLE(jsexception))
                         rv = (nsresult)(JSVAL_TO_DOUBLE(jsexception));
                     else
                         rv = (nsresult)(JSVAL_TO_INT(jsexception));
 
                     if (rv == NS_NOINTERFACE)
                         JS_ClearPendingException(cx);
@@ -436,25 +414,23 @@ nsXPCWrappedJSClass::BuildPropertyEnumer
     if (!scriptEval.StartEvaluating(aJSObj))
         return NS_ERROR_FAILURE;
 
     idArray = JS_Enumerate(cx, aJSObj);
     if (!idArray)
         return retval;
 
     nsCOMArray<nsIProperty> propertyArray(idArray->length);
-    for (i = 0; i < idArray->length; i++)
-    {
+    for (i = 0; i < idArray->length; i++) {
         nsCOMPtr<nsIVariant> value;
         jsid idName = idArray->vector[i];
         nsresult rv;
 
         if (!GetNamedPropertyAsVariantRaw(ccx, aJSObj, idName,
-                                          getter_AddRefs(value), &rv))
-        {
+                                          getter_AddRefs(value), &rv)) {
             if (NS_FAILED(rv))
                 retval = rv;
             goto out;
         }
 
         jsval jsvalName;
         if (!JS_IdToValue(cx, idName, &jsvalName))
             goto out;
@@ -572,18 +548,17 @@ GetContextFromObject(JSObject *obj)
 
     JSAutoEnterCompartment ac;
     if (!ac.enter(ccx, obj))
         return nsnull;
     XPCWrappedNativeScope* scope =
         XPCWrappedNativeScope::FindInJSObjectScope(ccx, obj);
     XPCContext *xpcc = scope->GetContext();
 
-    if (xpcc)
-    {
+    if (xpcc) {
         JSContext *cx = xpcc->GetJSContext();
         if (cx->thread()->id == js_CurrentThreadId())
             return cx;
     }
 
     return nsnull;
 }
 
@@ -645,98 +620,88 @@ SameOriginCheckedComponent::CanSetProper
     return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 NS_IMETHODIMP
 nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
                                              REFNSIID aIID,
                                              void** aInstancePtr)
 {
-    if (aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder))) {
         NS_ADDREF(self);
         *aInstancePtr = (void*) static_cast<nsIXPConnectJSObjectHolder*>(self);
         return NS_OK;
     }
 
     // Objects internal to xpconnect are the only objects that even know *how*
     // to ask for this iid. And none of them bother refcounting the thing.
-    if (aIID.Equals(NS_GET_IID(WrappedJSIdentity)))
-    {
+    if (aIID.Equals(NS_GET_IID(WrappedJSIdentity))) {
         // asking to find out if this is a wrapper object
         *aInstancePtr = WrappedJSIdentity::GetSingleton();
         return NS_OK;
     }
 
-    if (aIID.Equals(NS_GET_IID(nsIPropertyBag)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsIPropertyBag))) {
         // We only want to expose one implementation from our aggregate.
         nsXPCWrappedJS* root = self->GetRootWrapper();
 
-        if (!root->IsValid())
-        {
+        if (!root->IsValid()) {
             *aInstancePtr = nsnull;
             return NS_NOINTERFACE;
         }
 
         NS_ADDREF(root);
         *aInstancePtr = (void*) static_cast<nsIPropertyBag*>(root);
         return NS_OK;
     }
 
     // We can't have a cached wrapper.
-    if (aIID.Equals(NS_GET_IID(nsWrapperCache)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsWrapperCache))) {
         *aInstancePtr = nsnull;
         return NS_NOINTERFACE;
     }
 
     JSContext *context = GetContextFromObject(self->GetJSObject());
     XPCCallContext ccx(NATIVE_CALLER, context);
-    if (!ccx.IsValid())
-    {
+    if (!ccx.IsValid()) {
         *aInstancePtr = nsnull;
         return NS_NOINTERFACE;
     }
 
     // We support nsISupportsWeakReference iff the root wrapped JSObject
     // claims to support it in its QueryInterface implementation.
-    if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference))) {
         // We only want to expose one implementation from our aggregate.
         nsXPCWrappedJS* root = self->GetRootWrapper();
 
         // Fail if JSObject doesn't claim support for nsISupportsWeakReference
         if (!root->IsValid() ||
-            !CallQueryInterfaceOnJSObject(ccx, root->GetJSObject(), aIID))
-        {
+            !CallQueryInterfaceOnJSObject(ccx, root->GetJSObject(), aIID)) {
             *aInstancePtr = nsnull;
             return NS_NOINTERFACE;
         }
 
         NS_ADDREF(root);
         *aInstancePtr = (void*) static_cast<nsISupportsWeakReference*>(root);
         return NS_OK;
     }
 
     nsXPCWrappedJS* sibling;
 
     // Checks for any existing wrapper explicitly constructed for this iid.
     // This includes the current 'self' wrapper. This also deals with the
     // nsISupports case (for which it returns mRoot).
-    if (nsnull != (sibling = self->Find(aIID)))
-    {
+    if (nsnull != (sibling = self->Find(aIID))) {
         NS_ADDREF(sibling);
         *aInstancePtr = sibling->GetXPTCStub();
         return NS_OK;
     }
 
     // Check if asking for an interface from which one of our wrappers inherits.
-    if (nsnull != (sibling = self->FindInherited(aIID)))
-    {
+    if (nsnull != (sibling = self->FindInherited(aIID))) {
         NS_ADDREF(sibling);
         *aInstancePtr = sibling->GetXPTCStub();
         return NS_OK;
     }
 
     // else we do the more expensive stuff...
 
     // Before calling out, ensure that we're not about to claim to implement
@@ -746,18 +711,17 @@ nsXPCWrappedJSClass::DelegatedQueryInter
     // content. If our JS object isn't a double-wrapped object (that is, we
     // don't have XPCWrappedJS(XPCWrappedNative(some C++ object))), then it
     // definitely will not have classinfo (and therefore won't be a DOM
     // object). Since content wants to be able to use these objects (directly
     // or indirectly, see bug 483672), we implement nsISecurityCheckedComponent
     // for them and tell caps that they are also bound by the same origin
     // model.
 
-    if (aIID.Equals(NS_GET_IID(nsISecurityCheckedComponent)))
-    {
+    if (aIID.Equals(NS_GET_IID(nsISecurityCheckedComponent))) {
         // XXX This code checks to see if the given object has chrome (also
         // known as system) principals. It really wants to do a
         // UniversalXPConnect type check.
 
         *aInstancePtr = nsnull;
 
         if (!XPCPerThreadData::IsMainThread(ccx.GetJSContext()))
             return NS_NOINTERFACE;
@@ -773,33 +737,31 @@ nsXPCWrappedJSClass::DelegatedQueryInter
         nsresult rv = secMan->GetObjectPrincipal(ccx, selfObj,
                                                  getter_AddRefs(objPrin));
         if (NS_FAILED(rv))
             return rv;
 
         bool isSystem;
         rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
         if ((NS_FAILED(rv) || !isSystem) &&
-            !IS_WRAPPER_CLASS(js::GetObjectClass(selfObj)))
-        {
+            !IS_WRAPPER_CLASS(js::GetObjectClass(selfObj))) {
             // A content object.
             nsRefPtr<SameOriginCheckedComponent> checked =
                 new SameOriginCheckedComponent(self);
             if (!checked)
                 return NS_ERROR_OUT_OF_MEMORY;
             *aInstancePtr = checked.forget().get();
             return NS_OK;
         }
     }
 
     // check if the JSObject claims to implement this interface
     JSObject* jsobj = CallQueryInterfaceOnJSObject(ccx, self->GetJSObject(),
                                                    aIID);
-    if (jsobj)
-    {
+    if (jsobj) {
         // protect jsobj until it is actually attached
         AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(jsobj));
 
         // We can't use XPConvert::JSObject2NativeInterface() here
         // since that can find a XPCWrappedNative directly on the
         // proto chain, and we don't want that here. We need to find
         // the actual JS object that claimed it supports the interface
         // we're looking for or we'll potentially bypass security
@@ -807,18 +769,17 @@ nsXPCWrappedJSClass::DelegatedQueryInter
         // the prototype chain.
         //
         // Instead, simply do the nsXPCWrappedJS part of
         // XPConvert::JSObject2NativeInterface() here to make sure we
         // get a new (or used) nsXPCWrappedJS.
         nsXPCWrappedJS* wrapper;
         nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, jsobj, aIID, nsnull,
                                                    &wrapper);
-        if (NS_SUCCEEDED(rv) && wrapper)
-        {
+        if (NS_SUCCEEDED(rv) && wrapper) {
             // We need to go through the QueryInterface logic to make
             // this return the right thing for the various 'special'
             // interfaces; e.g.  nsIPropertyBag.
             rv = wrapper->QueryInterface(aIID, aInstancePtr);
             NS_RELEASE(wrapper);
             return rv;
         }
     }
@@ -841,22 +802,20 @@ nsXPCWrappedJSClass::GetRootJSObject(XPC
         return inner;
     return result;
 }
 
 void
 xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
                           JSErrorReport *report)
 {
-    if (report)
-    {
+    if (report) {
         // If it is an exception report, then we can just deal with the
         // exception later (if not caught in the JS code).
-        if (JSREPORT_IS_EXCEPTION(report->flags))
-        {
+        if (JSREPORT_IS_EXCEPTION(report->flags)) {
             // XXX We have a problem with error reports from uncaught exceptions.
             //
             // http://bugzilla.mozilla.org/show_bug.cgi?id=66453
             //
             // The issue is...
             //
             // We can't assume that the exception will *stay* uncaught. So, if
             // we build an nsIXPCException here and the underlying exception
@@ -884,18 +843,17 @@ xpcWrappedJSErrorReporter(JSContext *cx,
             // This is inexact, but maybe the right thing to do?
             //
             // if (report->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)) ...
             //
 
             return;
         }
 
-        if (JSREPORT_IS_WARNING(report->flags))
-        {
+        if (JSREPORT_IS_WARNING(report->flags)) {
             // XXX printf the warning (#ifdef DEBUG only!).
             // XXX send the warning to the console service.
             return;
         }
     }
 
     XPCCallContext ccx(NATIVE_CALLER, cx);
     if (!ccx.IsValid())
@@ -949,95 +907,83 @@ nsXPCWrappedJSClass::GetInterfaceTypeFro
                                                const nsXPTParamInfo& param,
                                                uint16 methodIndex,
                                                const nsXPTType& type,
                                                nsXPTCMiniVariant* nativeParams,
                                                nsID* result)
 {
     uint8 type_tag = type.TagPart();
 
-    if (type_tag == nsXPTType::T_INTERFACE)
-    {
+    if (type_tag == nsXPTType::T_INTERFACE) {
         if (NS_SUCCEEDED(GetInterfaceInfo()->
-                         GetIIDForParamNoAlloc(methodIndex, &param, result)))
-        {
+                         GetIIDForParamNoAlloc(methodIndex, &param, result))) {
             return JS_TRUE;
         }
     }
-    else if (type_tag == nsXPTType::T_INTERFACE_IS)
-    {
+    else if (type_tag == nsXPTType::T_INTERFACE_IS) {
         uint8 argnum;
         nsresult rv;
         rv = mInfo->GetInterfaceIsArgNumberForParam(methodIndex,
                                                     &param, &argnum);
         if (NS_FAILED(rv))
             return JS_FALSE;
 
         const nsXPTParamInfo& arg_param = method->params[argnum];
         const nsXPTType& arg_type = arg_param.GetType();
         if (arg_type.IsPointer() &&
-            arg_type.TagPart() == nsXPTType::T_IID)
-        {
-            if (arg_param.IsIndirect())
-            {
+            arg_type.TagPart() == nsXPTType::T_IID) {
+            if (arg_param.IsIndirect()) {
                 nsID** p = (nsID**) nativeParams[argnum].val.p;
                 if (!p || !*p)
                     return JS_FALSE;
                 *result = **p;
             }
-            else
-            {
+            else {
                 nsID* p = (nsID*) nativeParams[argnum].val.p;
                 if (!p)
                     return JS_FALSE;
                 *result = *p;
             }
             return JS_TRUE;
         }
     }
     return JS_FALSE;
 }
 
 void
 nsXPCWrappedJSClass::CleanupPointerArray(const nsXPTType& datum_type,
                                          JSUint32 array_count,
                                          void** arrayp)
 {
-    if (datum_type.IsInterfacePointer())
-    {
+    if (datum_type.IsInterfacePointer()) {
         nsISupports** pp = (nsISupports**) arrayp;
-        for (JSUint32 k = 0; k < array_count; k++)
-        {
+        for (JSUint32 k = 0; k < array_count; k++) {
             nsISupports* p = pp[k];
             NS_IF_RELEASE(p);
         }
     }
-    else
-    {
+    else {
         void** pp = (void**) arrayp;
-        for (JSUint32 k = 0; k < array_count; k++)
-        {
+        for (JSUint32 k = 0; k < array_count; k++) {
             void* p = pp[k];
             if (p) nsMemory::Free(p);
         }
     }
 }
 
 void
 nsXPCWrappedJSClass::CleanupPointerTypeObject(const nsXPTType& type,
                                               void** pp)
 {
     NS_ASSERTION(pp,"null pointer");
-    if (type.IsInterfacePointer())
-    {
+    if (type.IsInterfacePointer()) {
         nsISupports* p = *((nsISupports**)pp);
         if (p) p->Release();
     }
-    else
-    {
+    else {
         void* p = *((void**)pp);
         if (p) nsMemory::Free(p);
     }
 }
 
 class AutoClearPendingException
 {
 public:
@@ -1065,153 +1011,136 @@ nsXPCWrappedJSClass::CheckForException(X
     // get this right away in case we do something below to cause JS code
     // to run on this JSContext
     nsresult pending_result = xpcc->GetPendingResult();
 
     jsval js_exception;
     JSBool is_js_exception = JS_GetPendingException(cx, &js_exception);
 
     /* JS might throw an expection whether the reporter was called or not */
-    if (is_js_exception)
-    {
+    if (is_js_exception) {
         if (!xpc_exception)
             XPCConvert::JSValToXPCException(ccx, js_exception, anInterfaceName,
                                             aPropertyName,
                                             getter_AddRefs(xpc_exception));
 
         /* cleanup and set failed even if we can't build an exception */
-        if (!xpc_exception)
-        {
+        if (!xpc_exception) {
             ccx.GetThreadData()->SetException(nsnull); // XXX necessary?
         }
     }
 
     AutoClearPendingException acpe(cx);
 
-    if (xpc_exception)
-    {
+    if (xpc_exception) {
         nsresult e_result;
-        if (NS_SUCCEEDED(xpc_exception->GetResult(&e_result)))
-        {
+        if (NS_SUCCEEDED(xpc_exception->GetResult(&e_result))) {
             // Figure out whether or not we should report this exception.
             bool reportable = xpc_IsReportableErrorCode(e_result);
-            if (reportable)
-            {
+            if (reportable) {
                 // Always want to report forced exceptions and XPConnect's own
                 // errors.
                 reportable = aForceReport ||
                     NS_ERROR_GET_MODULE(e_result) == NS_ERROR_MODULE_XPCONNECT;
 
                 // See if an environment variable was set or someone has told us
                 // that a user pref was set indicating that we should report all
                 // exceptions.
                 if (!reportable)
                     reportable = nsXPConnect::ReportAllJSExceptions();
 
                 // Finally, check to see if this is the last JS frame on the
                 // stack. If so then we always want to report it.
-                if (!reportable)
-                {
+                if (!reportable) {
                     bool onlyNativeStackFrames = true;
                     JSStackFrame * fp = nsnull;
-                    while ((fp = JS_FrameIterator(cx, &fp)))
-                    {
-                        if (JS_IsScriptFrame(cx, fp))
-                        {
+                    while ((fp = JS_FrameIterator(cx, &fp))) {
+                        if (JS_IsScriptFrame(cx, fp)) {
                             onlyNativeStackFrames = PR_FALSE;
                             break;
                         }
                     }
                     reportable = onlyNativeStackFrames;
                 }
 
                 // Ugly special case for GetInterface. It's "special" in the
                 // same way as QueryInterface in that a failure is not
                 // exceptional and shouldn't be reported. We have to do this
                 // check here instead of in xpcwrappedjs (like we do for QI) to
                 // avoid adding extra code to all xpcwrappedjs objects.
                 if (reportable && e_result == NS_ERROR_NO_INTERFACE &&
                     !strcmp(anInterfaceName, "nsIInterfaceRequestor") &&
-                    !strcmp(aPropertyName, "getInterface"))
-                {
+                    !strcmp(aPropertyName, "getInterface")) {
                     reportable = PR_FALSE;
                 }
             }
 
             // Try to use the error reporter set on the context to handle this
             // error if it came from a JS exception.
             if (reportable && is_js_exception &&
-                cx->errorReporter != xpcWrappedJSErrorReporter)
-            {
+                cx->errorReporter != xpcWrappedJSErrorReporter) {
                 reportable = !JS_ReportPendingException(cx);
             }
 
-            if (reportable)
-            {
+            if (reportable) {
 #ifdef DEBUG
                 static const char line[] =
                     "************************************************************\n";
                 static const char preamble[] =
                     "* Call to xpconnect wrapped JSObject produced this error:  *\n";
                 static const char cant_get_text[] =
                     "FAILED TO GET TEXT FROM EXCEPTION\n";
 
                 fputs(line, stdout);
                 fputs(preamble, stdout);
                 char* text;
-                if (NS_SUCCEEDED(xpc_exception->ToString(&text)) && text)
-                {
+                if (NS_SUCCEEDED(xpc_exception->ToString(&text)) && text) {
                     fputs(text, stdout);
                     fputs("\n", stdout);
                     nsMemory::Free(text);
                 }
                 else
                     fputs(cant_get_text, stdout);
                 fputs(line, stdout);
 #endif
 
                 // Log the exception to the JS Console, so that users can do
                 // something with it.
                 nsCOMPtr<nsIConsoleService> consoleService
                     (do_GetService(XPC_CONSOLE_CONTRACTID));
-                if (nsnull != consoleService)
-                {
+                if (nsnull != consoleService) {
                     nsresult rv;
                     nsCOMPtr<nsIScriptError> scriptError;
                     nsCOMPtr<nsISupports> errorData;
                     rv = xpc_exception->GetData(getter_AddRefs(errorData));
                     if (NS_SUCCEEDED(rv))
                         scriptError = do_QueryInterface(errorData);
 
-                    if (nsnull == scriptError)
-                    {
+                    if (nsnull == scriptError) {
                         // No luck getting one from the exception, so
                         // try to cook one up.
                         scriptError = do_CreateInstance(XPC_SCRIPT_ERROR_CONTRACTID);
-                        if (nsnull != scriptError)
-                        {
+                        if (nsnull != scriptError) {
                             char* exn_string;
                             rv = xpc_exception->ToString(&exn_string);
-                            if (NS_SUCCEEDED(rv))
-                            {
+                            if (NS_SUCCEEDED(rv)) {
                                 // use toString on the exception as the message
                                 nsAutoString newMessage;
                                 newMessage.AssignWithConversion(exn_string);
                                 nsMemory::Free((void *) exn_string);
 
                                 // try to get filename, lineno from the first
                                 // stack frame location.
                                 PRInt32 lineNumber = 0;
                                 nsXPIDLCString sourceName;
 
                                 nsCOMPtr<nsIStackFrame> location;
                                 xpc_exception->
                                     GetLocation(getter_AddRefs(location));
-                                if (location)
-                                {
+                                if (location) {
                                     // Get line number w/o checking; 0 is ok.
                                     location->GetLineNumber(&lineNumber);
 
                                     // get a filename.
                                     rv = location->GetFilename(getter_Copies(sourceName));
                                 }
 
                                 nsCOMPtr<nsIScriptError2> scriptError2 =
@@ -1228,28 +1157,25 @@ nsXPCWrappedJSClass::CheckForException(X
                         }
                     }
                     if (nsnull != scriptError)
                         consoleService->LogMessage(scriptError);
                 }
             }
             // Whether or not it passes the 'reportable' test, it might
             // still be an error and we have to do the right thing here...
-            if (NS_FAILED(e_result))
-            {
+            if (NS_FAILED(e_result)) {
                 ccx.GetThreadData()->SetException(xpc_exception);
                 return e_result;
             }
         }
     }
-    else
-    {
+    else {
         // see if JS code signaled failure result without throwing exception
-        if (NS_FAILED(pending_result))
-        {
+        if (NS_FAILED(pending_result)) {
             return pending_result;
         }
     }
     return NS_ERROR_FAILURE;
 }
 
 class ContextPrincipalGuard
 {
@@ -1319,32 +1245,28 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
 
     if (!scriptEval.StartEvaluating(obj, xpcWrappedJSErrorReporter))
         goto pre_call_clean_up;
 
     xpcc->SetPendingResult(pending_result);
     xpcc->SetException(nsnull);
     ccx.GetThreadData()->SetException(nsnull);
 
-    if (XPCPerThreadData::IsMainThread(ccx))
-    {
+    if (XPCPerThreadData::IsMainThread(ccx)) {
         // TODO Remove me in favor of security wrappers.
         nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager();
-        if (ssm)
-        {
+        if (ssm) {
             nsIPrincipal *objPrincipal =
                 xpc::AccessCheck::getPrincipal(js::GetObjectCompartment(obj));
-            if (objPrincipal)
-            {
+            if (objPrincipal) {
                 JSStackFrame* fp = nsnull;
                 nsresult rv =
                     ssm->PushContextPrincipal(ccx, JS_FrameIterator(ccx, &fp),
                                               objPrincipal);
-                if (NS_FAILED(rv))
-                {
+                if (NS_FAILED(rv)) {
                     JS_ReportOutOfMemory(ccx);
                     retval = NS_ERROR_OUT_OF_MEMORY;
                     goto pre_call_clean_up;
                 }
 
                 principalGuard.principalPushed(ssm);
             }
         }
@@ -1353,18 +1275,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
     // We use js_Invoke so that the gcthings we use as args will be rooted by
     // the engine as we do conversions and prepare to do the function call.
 
     js::LeaveTrace(cx);
 
     // setup stack
 
     // if this isn't a function call then we don't need to push extra stuff
-    if (!(XPT_MD_IS_SETTER(info->flags) || XPT_MD_IS_GETTER(info->flags)))
-    {
+    if (!(XPT_MD_IS_SETTER(info->flags) || XPT_MD_IS_GETTER(info->flags))) {
         // We get fval before allocating the stack to avoid gc badness that can
         // happen if the GetProperty call leaves our request and the gc runs
         // while the stack we allocate contains garbage.
 
         // If the interface is marked as a [function] then we will assume that
         // our JSObject is a function and not an object with a named method.
 
         bool isFunction;
@@ -1378,250 +1299,222 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
         //
         // In the normal (non-function) case we just lookup the property by
         // name and as long as the object has such a named property we go ahead
         // and try to make the call. If it turns out the named property is not
         // a callable object then the JS engine will throw an error and we'll
         // pass this along to the caller as an exception/result code.
 
         if (isFunction &&
-            JS_TypeOfValue(ccx, OBJECT_TO_JSVAL(obj)) == JSTYPE_FUNCTION)
-        {
+            JS_TypeOfValue(ccx, OBJECT_TO_JSVAL(obj)) == JSTYPE_FUNCTION) {
             fval = OBJECT_TO_JSVAL(obj);
 
             // We may need to translate the 'this' for the function object.
 
-            if (paramCount)
-            {
+            if (paramCount) {
                 const nsXPTParamInfo& firstParam = info->params[0];
-                if (firstParam.IsIn())
-                {
+                if (firstParam.IsIn()) {
                     const nsXPTType& firstType = firstParam.GetType();
-                    if (firstType.IsPointer() && firstType.IsInterfacePointer())
-                    {
+                    if (firstType.IsPointer() && firstType.IsInterfacePointer()) {
                         nsIXPCFunctionThisTranslator* translator;
 
                         IID2ThisTranslatorMap* map =
                             mRuntime->GetThisTranslatorMap();
 
                         {
                             XPCAutoLock lock(mRuntime->GetMapLock()); // scoped lock
                             translator = map->Find(mIID);
                         }
 
-                        if (translator)
-                        {
+                        if (translator) {
                             bool hideFirstParamFromJS = false;
                             nsIID* newWrapperIID = nsnull;
                             nsCOMPtr<nsISupports> newThis;
 
                             if (NS_FAILED(translator->
                                           TranslateThis((nsISupports*)nativeParams[0].val.p,
                                                         mInfo, methodIndex,
                                                         &hideFirstParamFromJS,
                                                         &newWrapperIID,
-                                                        getter_AddRefs(newThis))))
-                            {
+                                                        getter_AddRefs(newThis)))) {
                                 goto pre_call_clean_up;
                             }
-                            if (hideFirstParamFromJS)
-                            {
+                            if (hideFirstParamFromJS) {
                                 NS_ERROR("HideFirstParamFromJS not supported");
                                 goto pre_call_clean_up;
                             }
-                            if (newThis)
-                            {
+                            if (newThis) {
                                 jsval v;
                                 xpcObjectHelper helper(newThis);
                                 JSBool ok =
                                   XPCConvert::NativeInterface2JSObject(ccx,
                                                                        &v, nsnull, helper, newWrapperIID,
                                                                        nsnull, PR_FALSE, PR_FALSE,
                                                                        nsnull);
                                 if (newWrapperIID)
                                     nsMemory::Free(newWrapperIID);
-                                if (!ok)
-                                {
+                                if (!ok) {
                                     goto pre_call_clean_up;
                                 }
                                 thisObj = JSVAL_TO_OBJECT(v);
                                 if (!JS_WrapObject(cx, &thisObj))
                                     goto pre_call_clean_up;
                             }
                         }
                     }
                 }
             }
         }
-        else if (!JS_GetMethod(cx, obj, name, &thisObj, &fval))
-        {
+        else if (!JS_GetMethod(cx, obj, name, &thisObj, &fval)) {
             // XXX We really want to factor out the error reporting better and
             // specifically report the failure to find a function with this name.
             // This is what we do below if the property is found but is not a
             // function. We just need to factor better so we can get to that
             // reporting path from here.
             goto pre_call_clean_up;
         }
     }
 
-    if (!args.resize(argc))
-    {
+    if (!args.resize(argc)) {
         retval = NS_ERROR_OUT_OF_MEMORY;
         goto pre_call_clean_up;
     }
 
     argv = args.jsval_begin();
     sp = argv;
 
     // build the args
     // NB: This assignment *looks* wrong because we haven't yet called our
     // function. However, we *have* already entered the compartmen that we're
     // about to call, and that's the global that we want here. In other words:
     // we're trusting the JS engine to come up with a good global to use for
     // our object (whatever it was).
-    for (i = 0; i < argc; i++)
-    {
+    for (i = 0; i < argc; i++) {
         const nsXPTParamInfo& param = info->params[i];
         const nsXPTType& type = param.GetType();
         nsXPTType datum_type;
         JSUint32 array_count;
         bool isArray = type.IsArray();
         jsval val = JSVAL_NULL;
         AUTO_MARK_JSVAL(ccx, &val);
         bool isSizedString = isArray ?
                 JS_FALSE :
                 type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
                 type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;
 
 
         // verify that null was not passed for 'out' param
-        if (param.IsOut() && !nativeParams[i].val.p)
-        {
+        if (param.IsOut() && !nativeParams[i].val.p) {
             retval = NS_ERROR_INVALID_ARG;
             goto pre_call_clean_up;
         }
 
-        if (isArray)
-        {
+        if (isArray) {
             if (NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
                                                  &datum_type)))
                 goto pre_call_clean_up;
         }
         else
             datum_type = type;
 
-        if (param.IsIn())
-        {
+        if (param.IsIn()) {
             nsXPTCMiniVariant* pv;
 
             if (param.IsIndirect())
                 pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
             else
                 pv = &nativeParams[i];
 
             if (datum_type.IsInterfacePointer() &&
                 !GetInterfaceTypeFromParam(cx, info, param, methodIndex,
                                            datum_type, nativeParams,
                                            &param_iid))
                 goto pre_call_clean_up;
 
-            if (isArray || isSizedString)
-            {
+            if (isArray || isSizedString) {
                 if (!GetArraySizeFromParam(cx, info, param, methodIndex,
                                            i, GET_LENGTH, nativeParams,
                                            &array_count))
                     goto pre_call_clean_up;
             }
 
-            if (isArray)
-            {
+            if (isArray) {
                 XPCLazyCallContext lccx(ccx);
                 if (!XPCConvert::NativeArray2JS(lccx, &val,
                                                 (const void**)&pv->val,
                                                 datum_type, &param_iid,
                                                 array_count, nsnull))
                     goto pre_call_clean_up;
             }
-            else if (isSizedString)
-            {
+            else if (isSizedString) {
                 if (!XPCConvert::NativeStringWithSize2JS(ccx, &val,
                                                          (const void*)&pv->val,
                                                          datum_type,
                                                          array_count, nsnull))
                     goto pre_call_clean_up;
             }
-            else
-            {
+            else {
                 if (!XPCConvert::NativeData2JS(ccx, &val, &pv->val, type,
                                                &param_iid, nsnull))
                     goto pre_call_clean_up;
             }
         }
 
-        if (param.IsOut() || param.IsDipper())
-        {
+        if (param.IsOut() || param.IsDipper()) {
             // create an 'out' object
             JSObject* out_obj = NewOutObject(cx, obj);
-            if (!out_obj)
-            {
+            if (!out_obj) {
                 retval = NS_ERROR_OUT_OF_MEMORY;
                 goto pre_call_clean_up;
             }
 
-            if (param.IsIn())
-            {
+            if (param.IsIn()) {
                 if (!JS_SetPropertyById(cx, out_obj,
                                         mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
-                                        &val))
-                {
+                                        &val)) {
                     goto pre_call_clean_up;
                 }
             }
             *sp++ = OBJECT_TO_JSVAL(out_obj);
         }
         else
             *sp++ = val;
     }
 
     readyToDoTheCall = JS_TRUE;
 
 pre_call_clean_up:
     // clean up any 'out' params handed in
-    for (i = 0; i < paramCount; i++)
-    {
+    for (i = 0; i < paramCount; i++) {
         const nsXPTParamInfo& param = info->params[i];
         if (!param.IsOut())
             continue;
 
         const nsXPTType& type = param.GetType();
         if (!type.IsPointer())
             continue;
         void* p;
         if (!(p = nativeParams[i].val.p))
             continue;
 
-        if (param.IsIn())
-        {
-            if (type.IsArray())
-            {
+        if (param.IsIn()) {
+            if (type.IsArray()) {
                 void** pp;
-                if (nsnull != (pp = *((void***)p)))
-                {
+                if (nsnull != (pp = *((void***)p))) {
 
                     // we need to get the array length and iterate the items
                     JSUint32 array_count;
                     nsXPTType datum_type;
 
                     if (NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                             1, &datum_type)) &&
                         datum_type.IsPointer() &&
                         GetArraySizeFromParam(cx, info, param, methodIndex,
                                               i, GET_LENGTH, nativeParams,
-                                              &array_count) && array_count)
-                    {
+                                              &array_count) && array_count) {
                         CleanupPointerArray(datum_type, array_count, pp);
                     }
                     // always release the array if it is inout
                     nsMemory::Free(pp);
                 }
             }
             else
                 CleanupPointerTypeObject(type, (void**)p);
@@ -1635,39 +1528,34 @@ pre_call_clean_up:
     if (!readyToDoTheCall)
         return retval;
 
     // do the deed - note exceptions
 
     JS_ClearPendingException(cx);
 
     jsval rval;
-    if (XPT_MD_IS_GETTER(info->flags))
-    {
+    if (XPT_MD_IS_GETTER(info->flags)) {
         success = JS_GetProperty(cx, obj, name, argv);
         rval = *argv;
     }
-    else if (XPT_MD_IS_SETTER(info->flags))
-    {
+    else if (XPT_MD_IS_SETTER(info->flags)) {
         success = JS_SetProperty(cx, obj, name, argv);
         rval = *argv;
     }
-    else
-    {
-        if (!JSVAL_IS_PRIMITIVE(fval))
-        {
+    else {
+        if (!JSVAL_IS_PRIMITIVE(fval)) {
             uint32 oldOpts = JS_GetOptions(cx);
             JS_SetOptions(cx, oldOpts | JSOPTION_DONT_REPORT_UNCAUGHT);
 
             success = JS_CallFunctionValue(cx, thisObj, fval, argc, argv, &rval);
 
             JS_SetOptions(cx, oldOpts);
         }
-        else
-        {
+        else {
             // The property was not an object so can't be a function.
             // Let's build and 'throw' an exception.
 
             static const nsresult code =
                     NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED;
             static const char format[] = "%s \"%s\"";
             const char * msg;
             char* sz = nsnull;
@@ -1681,18 +1569,17 @@ pre_call_clean_up:
                                            nsnull, getter_AddRefs(e), nsnull, nsnull);
             xpcc->SetException(e);
             if (sz)
                 JS_smprintf_free(sz);
             success = JS_FALSE;
         }
     }
 
-    if (!success)
-    {
+    if (!success) {
         bool forceReport;
         if (NS_FAILED(mInfo->IsFunction(&forceReport)))
             forceReport = PR_FALSE;
 
         // May also want to check if we're moving from content->chrome and force
         // a report in that case.
 
         return CheckForException(ccx, name, GetInterfaceName(), forceReport);
@@ -1703,26 +1590,24 @@ pre_call_clean_up:
     // convert out args and result
     // NOTE: this is the total number of native params, not just the args
     // Convert independent params only.
     // When we later convert the dependent params (if any) we will know that
     // the params upon which they depend will have already been converted -
     // regardless of ordering.
 
     foundDependentParam = JS_FALSE;
-    for (i = 0; i < paramCount; i++)
-    {
+    for (i = 0; i < paramCount; i++) {
         const nsXPTParamInfo& param = info->params[i];
         NS_ABORT_IF_FALSE(!param.IsShared(), "[shared] implies [noscript]!");
         if (!param.IsOut() && !param.IsDipper())
             continue;
 
         const nsXPTType& type = param.GetType();
-        if (type.IsDependent())
-        {
+        if (type.IsDependent()) {
             foundDependentParam = JS_TRUE;
             continue;
         }
 
         jsval val;
         uint8 type_tag = type.TagPart();
         nsXPTCMiniVariant* pv;
 
@@ -1736,34 +1621,31 @@ pre_call_clean_up:
         else if (JSVAL_IS_PRIMITIVE(argv[i]) ||
                  !JS_GetPropertyById(cx, JSVAL_TO_OBJECT(argv[i]),
                                      mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                                      &val))
             break;
 
         // setup allocator and/or iid
 
-        if (type_tag == nsXPTType::T_INTERFACE)
-        {
+        if (type_tag == nsXPTType::T_INTERFACE) {
             if (NS_FAILED(GetInterfaceInfo()->
                           GetIIDForParamNoAlloc(methodIndex, &param,
                                                 &param_iid)))
                 break;
         }
 
         if (!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                        !param.IsDipper(), &param_iid, nsnull))
             break;
     }
 
     // if any params were dependent, then we must iterate again to convert them.
-    if (foundDependentParam && i == paramCount)
-    {
-        for (i = 0; i < paramCount; i++)
-        {
+    if (foundDependentParam && i == paramCount) {
+        for (i = 0; i < paramCount; i++) {
             const nsXPTParamInfo& param = info->params[i];
             if (!param.IsOut())
                 continue;
 
             const nsXPTType& type = param.GetType();
             if (!type.IsDependent())
                 continue;
 
@@ -1783,113 +1665,101 @@ pre_call_clean_up:
                 val = rval;
             else if (!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(argv[i]),
                                          mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
                                          &val))
                 break;
 
             // setup allocator and/or iid
 
-            if (isArray)
-            {
+            if (isArray) {
                 if (NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
                                                      &datum_type)))
                     break;
             }
             else
                 datum_type = type;
 
-            if (datum_type.IsInterfacePointer())
-            {
+            if (datum_type.IsInterfacePointer()) {
                if (!GetInterfaceTypeFromParam(cx, info, param, methodIndex,
                                               datum_type, nativeParams,
                                               &param_iid))
                    break;
             }
 
-            if (isArray || isSizedString)
-            {
+            if (isArray || isSizedString) {
                 if (!GetArraySizeFromParam(cx, info, param, methodIndex,
                                            i, GET_LENGTH, nativeParams,
                                            &array_count))
                     break;
             }
 
-            if (isArray)
-            {
+            if (isArray) {
                 if (array_count &&
                     !XPCConvert::JSArray2Native(ccx, (void**)&pv->val, val,
                                                 array_count, array_count,
                                                 datum_type, &param_iid,
                                                 nsnull))
                     break;
             }
-            else if (isSizedString)
-            {
+            else if (isSizedString) {
                 if (!XPCConvert::JSStringWithSize2Native(ccx,
                                                          (void*)&pv->val, val,
                                                          array_count, array_count,
                                                          datum_type, nsnull))
                     break;
             }
-            else
-            {
+            else {
                 if (!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
                                                JS_TRUE, &param_iid,
                                                nsnull))
                     break;
             }
         }
     }
 
-    if (i != paramCount)
-    {
+    if (i != paramCount) {
         // We didn't manage all the result conversions!
         // We have to cleanup any junk that *did* get converted.
 
-        for (uint8 k = 0; k < i; k++)
-        {
+        for (uint8 k = 0; k < i; k++) {
             const nsXPTParamInfo& param = info->params[k];
             if (!param.IsOut())
                 continue;
             const nsXPTType& type = param.GetType();
             if (!type.IsPointer())
                 continue;
             void* p;
             if (!(p = nativeParams[k].val.p))
                 continue;
 
-            if (type.IsArray())
-            {
+            if (type.IsArray()) {
                 void** pp;
-                if (nsnull != (pp = *((void***)p)))
-                {
+                if (nsnull != (pp = *((void***)p))) {
                     // we need to get the array length and iterate the items
                     JSUint32 array_count;
                     nsXPTType datum_type;
 
                     if (NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, &param,
                                                             1, &datum_type)) &&
                         datum_type.IsPointer() &&
                         GetArraySizeFromParam(cx, info, param, methodIndex,
                                               k, GET_LENGTH, nativeParams,
-                                              &array_count) && array_count)
-                    {
+                                              &array_count) && array_count) {
                         CleanupPointerArray(datum_type, array_count, pp);
                     }
                     nsMemory::Free(pp);
                 }
             }
             else
                 CleanupPointerTypeObject(type, (void**)p);
             *((void**)p) = nsnull;
         }
     }
-    else
-    {
+    else {
         // set to whatever the JS code might have set as the result
         retval = pending_result;
     }
 
     return retval;
 }
 
 const char*
@@ -1920,37 +1790,34 @@ nsXPCWrappedJSClass::DebugDump(PRInt16 d
         if (name)
             nsMemory::Free(name);
         char * iid = mIID.ToString();
         XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
         if (iid)
             NS_Free(iid);
         XPC_LOG_ALWAYS(("InterfaceInfo @ %x", mInfo));
         uint16 methodCount = 0;
-        if (depth)
-        {
+        if (depth) {
             uint16 i;
             nsCOMPtr<nsIInterfaceInfo> parent;
             XPC_LOG_INDENT();
             mInfo->GetParent(getter_AddRefs(parent));
             XPC_LOG_ALWAYS(("parent @ %x", parent.get()));
             mInfo->GetMethodCount(&methodCount);
             XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
             mInfo->GetConstantCount(&i);
             XPC_LOG_ALWAYS(("ConstantCount = %d", i));
             XPC_LOG_OUTDENT();
         }
         XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
         XPC_LOG_ALWAYS(("mDescriptors @ %x count = %d", mDescriptors, methodCount));
-        if (depth && mDescriptors && methodCount)
-        {
+        if (depth && mDescriptors && methodCount) {
             depth--;
             XPC_LOG_INDENT();
-            for (uint16 i = 0; i < methodCount; i++)
-            {
+            for (uint16 i = 0; i < methodCount; i++) {
                 XPC_LOG_ALWAYS(("Method %d is %s%s", \
                                 i, IsReflectable(i) ? "":" NOT ","reflectable"));
             }
             XPC_LOG_OUTDENT();
             depth++;
         }
     XPC_LOG_OUTDENT();
 #endif
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -159,24 +159,21 @@ void
 XPCWrappedNative::NoteTearoffs(nsCycleCollectionTraversalCallback& cb)
 {
     // Tearoffs hold their native object alive. If their JS object hasn't been
     // finalized yet we'll note the edge between the JS object and the native
     // (see nsXPConnect::Traverse), but if their JS object has been finalized
     // then the tearoff is only reachable through the XPCWrappedNative, so we
     // record an edge here.
     XPCWrappedNativeTearOffChunk* chunk;
-    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
-    {
+    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
-        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
-        {
+        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
             JSObject* jso = to->GetJSObject();
-            if (!jso)
-            {
+            if (!jso) {
                 NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "tearoff's mNative");
                 cb.NoteXPCOMChild(to->GetNative());
             }
         }
     }
 }
 
 #ifdef XPC_CHECK_CLASSINFO_CLAIMS
@@ -214,25 +211,23 @@ static void DEBUG_TrackNewWrapper(XPCWra
         NS_ERROR("failed to add wrapper");
 #endif
 #ifdef XPC_TRACK_WRAPPER_STATS
     DEBUG_TotalWrappedNativeCount++;
     DEBUG_TotalLiveWrappedNativeCount++;
     if (DEBUG_TotalMaxWrappedNativeCount < DEBUG_TotalLiveWrappedNativeCount)
         DEBUG_TotalMaxWrappedNativeCount = DEBUG_TotalLiveWrappedNativeCount;
 
-    if (wrapper->HasProto())
-    {
+    if (wrapper->HasProto()) {
         DEBUG_WrappedNativeWithProtoCount++;
         DEBUG_LiveWrappedNativeWithProtoCount++;
         if (DEBUG_MaxWrappedNativeWithProtoCount < DEBUG_LiveWrappedNativeWithProtoCount)
             DEBUG_MaxWrappedNativeWithProtoCount = DEBUG_LiveWrappedNativeWithProtoCount;
     }
-    else
-    {
+    else {
         DEBUG_WrappedNativeNoProtoCount++;
         DEBUG_LiveWrappedNativeNoProtoCount++;
         if (DEBUG_MaxWrappedNativeNoProtoCount < DEBUG_LiveWrappedNativeNoProtoCount)
             DEBUG_MaxWrappedNativeNoProtoCount = DEBUG_LiveWrappedNativeNoProtoCount;
     }
 #endif
 }
 
@@ -254,18 +249,17 @@ static void DEBUG_TrackDeleteWrapper(XPC
     DEBUG_WrappedNativeTearOffChunkCounts[extraChunkCount]++;
 #endif
 }
 static void DEBUG_TrackWrapperCall(XPCWrappedNative* wrapper,
                                    XPCWrappedNative::CallMode mode)
 {
 #ifdef XPC_TRACK_WRAPPER_STATS
     DEBUG_WrappedNativeTotalCalls++;
-    switch (mode)
-    {
+    switch (mode) {
         case XPCWrappedNative::CALL_METHOD:
             DEBUG_WrappedNativeMethodCalls++;
             break;
         case XPCWrappedNative::CALL_GETTER:
             DEBUG_WrappedNativeGetterCalls++;
             break;
         case XPCWrappedNative::CALL_SETTER:
             DEBUG_WrappedNativeSetterCalls++;
@@ -274,18 +268,17 @@ static void DEBUG_TrackWrapperCall(XPCWr
             NS_ERROR("bad value");
     }
 #endif
 }
 
 static void DEBUG_TrackShutdownWrapper(XPCWrappedNative* wrapper)
 {
 #ifdef XPC_TRACK_WRAPPER_STATS
-    if (!DEBUG_DumpedWrapperStats)
-    {
+    if (!DEBUG_DumpedWrapperStats) {
         DEBUG_DumpedWrapperStats = PR_TRUE;
         printf("%d WrappedNatives were constructed. "
                "(%d w/ protos, %d w/o)\n",
                DEBUG_TotalWrappedNativeCount,
                DEBUG_WrappedNativeWithProtoCount,
                DEBUG_WrappedNativeNoProtoCount);
 
         printf("%d WrappedNatives max alive at one time. "
@@ -304,18 +297,17 @@ static void DEBUG_TrackShutdownWrapper(X
                "(%d methods, %d getters, %d setters)\n",
                DEBUG_WrappedNativeTotalCalls,
                DEBUG_WrappedNativeMethodCalls,
                DEBUG_WrappedNativeGetterCalls,
                DEBUG_WrappedNativeSetterCalls);
 
         printf("(wrappers / tearoffs): (");
         int i;
-        for (i = 0; i < DEBUG_CHUNKS_TO_COUNT; i++)
-        {
+        for (i = 0; i < DEBUG_CHUNKS_TO_COUNT; i++) {
             printf("%d / %d, ",
                    DEBUG_WrappedNativeTearOffChunkCounts[i],
                    (i+1) * XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK);
         }
         printf("%d / more)\n", DEBUG_WrappedNativeTearOffChunkCounts[i]);
     }
 #endif
 }
@@ -352,45 +344,41 @@ XPCWrappedNative::GetNewOrUsed(XPCCallCo
 
     nsresult rv;
 
     NS_ASSERTION(!Scope->GetRuntime()->GetThreadRunningGC(),
                  "XPCWrappedNative::GetNewOrUsed called during GC");
 
     nsISupports *identity = helper.GetCanonical();
 
-    if (!identity)
-    {
+    if (!identity) {
         NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
         return NS_ERROR_FAILURE;
     }
 
     XPCLock* mapLock = Scope->GetRuntime()->GetMapLock();
 
     // We use an AutoMarkingPtr here because it is possible for JS gc to happen
     // after we have Init'd the wrapper but *before* we add it to the hashtable.
     // This would cause the mSet to get collected and we'd later crash. I've
     // *seen* this happen.
     AutoMarkingWrappedNativePtr wrapper(ccx);
 
     Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
-    if (!cache)
-    {
+    if (!cache) {
         {   // scoped lock
             XPCAutoLock lock(mapLock);
             wrapper = map->Find(identity);
             if (wrapper)
                 wrapper->AddRef();
         }
 
-        if (wrapper)
-        {
+        if (wrapper) {
             if (Interface &&
-                !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
-            {
+                !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
                 NS_RELEASE(wrapper);
                 NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
                 return rv;
             }
             DEBUG_CheckWrapperThreadSafety(wrapper);
             *resultWrapper = wrapper;
             return NS_OK;
         }
@@ -440,56 +428,51 @@ XPCWrappedNative::GetNewOrUsed(XPCCallCo
     jsval newParentVal = JSVAL_NULL;
     XPCMarkableJSVal newParentVal_markable(&newParentVal);
     AutoMarkingJSVal newParentVal_automarker(ccx, &newParentVal_markable);
     JSBool needsSOW = JS_FALSE;
     JSBool needsCOW = JS_FALSE;
 
     JSAutoEnterCompartment ac;
 
-    if (sciWrapper.GetFlags().WantPreCreate())
-    {
+    if (sciWrapper.GetFlags().WantPreCreate()) {
         JSObject* plannedParent = parent;
         nsresult rv = sciWrapper.GetCallback()->PreCreate(identity, ccx,
                                                           parent, &parent);
         if (NS_FAILED(rv))
             return rv;
 
         if (rv == NS_SUCCESS_CHROME_ACCESS_ONLY)
             needsSOW = JS_TRUE;
         rv = NS_OK;
 
         NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(parent),
                      "Xray wrapper being used to parent XPCWrappedNative?");
 
         if (!ac.enter(ccx, parent))
             return NS_ERROR_FAILURE;
 
-        if (parent != plannedParent)
-        {
+        if (parent != plannedParent) {
             XPCWrappedNativeScope* betterScope =
                 XPCWrappedNativeScope::FindInJSObjectScope(ccx, parent);
             if (betterScope != Scope)
                 return GetNewOrUsed(ccx, helper, betterScope, Interface,
                                     isGlobal, resultWrapper);
 
             newParentVal = OBJECT_TO_JSVAL(parent);
         }
 
         // Take the performance hit of checking the hashtable again in case
         // the preCreate call caused the wrapper to get created through some
         // interesting path (the DOM code tends to make this happen sometimes).
 
-        if (cache)
-        {
+        if (cache) {
             JSObject *cached = cache->GetWrapper();
-            if (cached)
-            {
-                if (IS_SLIM_WRAPPER_OBJECT(cached))
-                {
+            if (cached) {
+                if (IS_SLIM_WRAPPER_OBJECT(cached)) {
                     nsRefPtr<XPCWrappedNative> morphed;
                     if (!XPCWrappedNative::Morph(ccx, cached, Interface, cache,
                                                  getter_AddRefs(morphed)))
                         return NS_ERROR_FAILURE;
 
                     wrapper = morphed.forget().get();
                 } else {
                     wrapper =
@@ -502,71 +485,64 @@ XPCWrappedNative::GetNewOrUsed(XPCCallCo
         else
         {   // scoped lock
             XPCAutoLock lock(mapLock);
             wrapper = map->Find(identity);
             if (wrapper)
                 wrapper->AddRef();
         }
 
-        if (wrapper)
-        {
-            if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
-            {
+        if (wrapper) {
+            if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
                 NS_RELEASE(wrapper);
                 NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
                 return rv;
             }
             DEBUG_CheckWrapperThreadSafety(wrapper);
             *resultWrapper = wrapper;
             return NS_OK;
         }
     }
-    else
-    {
+    else {
         if (!ac.enter(ccx, parent))
             return NS_ERROR_FAILURE;
 
         nsISupports *Object = helper.Object();
-        if (nsXPCWrappedJSClass::IsWrappedJS(Object))
-        {
+        if (nsXPCWrappedJSClass::IsWrappedJS(Object)) {
             nsCOMPtr<nsIXPConnectWrappedJS> wrappedjs(do_QueryInterface(Object));
             JSObject *obj;
             wrappedjs->GetJSObject(&obj);
             if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(obj)) &&
-                !xpc::AccessCheck::isChrome(js::GetObjectCompartment(Scope->GetGlobalJSObject())))
-            {
+                !xpc::AccessCheck::isChrome(js::GetObjectCompartment(Scope->GetGlobalJSObject()))) {
                 needsCOW = JS_TRUE;
             }
         }
     }
 
     AutoMarkingWrappedNativeProtoPtr proto(ccx);
 
     // If there is ClassInfo (and we are not building a wrapper for the
     // nsIClassInfo interface) then we use a wrapper that needs a prototype.
 
     // Note that the security check happens inside FindTearOff - after the
     // wrapper is actually created, but before JS code can see it.
 
-    if (info && !isClassInfo)
-    {
+    if (info && !isClassInfo) {
         proto = XPCWrappedNativeProto::GetNewOrUsed(ccx, Scope, info, &sciProto,
                                                     JS_FALSE, isGlobal);
         if (!proto)
             return NS_ERROR_FAILURE;
 
         proto->CacheOffsets(identity);
 
         wrapper = new XPCWrappedNative(identity, proto);
         if (!wrapper)
             return NS_ERROR_FAILURE;
     }
-    else
-    {
+    else {
         AutoMarkingNativeInterfacePtr iface(ccx, Interface);
         if (!iface)
             iface = XPCNativeInterface::GetISupports(ccx);
 
         AutoMarkingNativeSetPtr set(ccx);
         set = XPCNativeSet::GetNewOrUsed(ccx, nsnull, iface, 0);
 
         if (!set)
@@ -583,24 +559,22 @@ XPCWrappedNative::GetNewOrUsed(XPCCallCo
     // forget about it.
     helper.forgetCanonical();
 
     NS_ADDREF(wrapper);
 
     NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(parent),
                  "Xray wrapper being used to parent XPCWrappedNative?");
 
-    if (!wrapper->Init(ccx, parent, isGlobal, &sciWrapper))
-    {
+    if (!wrapper->Init(ccx, parent, isGlobal, &sciWrapper)) {
         NS_RELEASE(wrapper);
         return NS_ERROR_FAILURE;
     }
 
-    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
-    {
+    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
         // Second reference will be released by the FlatJSObject's finalizer.
         wrapper->Release();
         NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
         return rv;
     }
 
     if (needsSOW)
         wrapper->SetNeedsSOW();
@@ -636,54 +610,48 @@ FinishCreate(XPCCallContext& ccx,
     XPCWrappedNative* wrapperToKill = nsnull;
 
     {   // scoped lock
         XPCAutoLock lock(mapLock);
 
         // Deal with the case where the wrapper got created as a side effect
         // of one of our calls out of this code (or on another thread).
         XPCWrappedNative* wrapper2 = map->Add(wrapper);
-        if (!wrapper2)
-        {
+        if (!wrapper2) {
             NS_ERROR("failed to add our wrapper!");
             wrapperToKill = wrapper;
             wrapper = nsnull;
         }
-        else if (wrapper2 != wrapper)
-        {
+        else if (wrapper2 != wrapper) {
             NS_ADDREF(wrapper2);
             wrapperToKill = wrapper;
             wrapper = wrapper2;
         }
     }
 
-    if (wrapperToKill)
-    {
+    if (wrapperToKill) {
         // Second reference will be released by the FlatJSObject's finializer.
         wrapperToKill->Release();
     }
-    else if (wrapper)
-    {
+    else if (wrapper) {
         JSObject *flat = wrapper->GetFlatJSObject();
         NS_ASSERTION(!cache || !cache->GetWrapperPreserveColor() ||
                      flat == cache->GetWrapperPreserveColor(),
                      "This object has a cached wrapper that's different from "
                      "the JSObject held by its native wrapper?");
 
         if (cache && !cache->GetWrapperPreserveColor())
             cache->SetWrapper(flat);
 
         // Our newly created wrapper is the one that we just added to the table.
         // All is well. Call PostCreate as necessary.
         XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
-        if (si && si->GetFlags().WantPostCreate())
-        {
+        if (si && si->GetFlags().WantPostCreate()) {
             nsresult rv = si->GetCallback()->PostCreate(wrapper, ccx, flat);
-            if (NS_FAILED(rv))
-            {
+            if (NS_FAILED(rv)) {
                 // PostCreate failed and that's Very Bad. We'll remove it from
                 // the map and mark it as invalid, but the PostCreate function
                 // may have handed the partially-constructed-and-now-invalid
                 // wrapper to someone before failing. Or, perhaps worse, the
                 // PostCreate call could have triggered code that reentered
                 // XPConnect and tried to wrap the same object. In that case
                 // *we* hand out the invalid wrapper since it is already in our
                 // map :(
@@ -736,18 +704,17 @@ XPCWrappedNative::Morph(XPCCallContext& 
     // This would cause the mSet to get collected and we'd later crash. I've
     // *seen* this happen.
     AutoMarkingWrappedNativePtr wrapper(ccx);
 
 #if DEBUG
     // FIXME Can't assert this until
     //       https://bugzilla.mozilla.org/show_bug.cgi?id=343141 is fixed.
 #if 0
-    if (proto->GetScriptableInfo()->GetFlags().WantPreCreate())
-    {
+    if (proto->GetScriptableInfo()->GetFlags().WantPreCreate()) {
         JSObject* parent = JS_GetParent(ccx, existingJSObject);
         JSObject* plannedParent = parent;
         nsresult rv =
             proto->GetScriptableInfo()->GetCallback()->PreCreate(identity, ccx,
                                                                  parent,
                                                                  &parent);
         if (NS_FAILED(rv))
             return rv;
@@ -763,25 +730,23 @@ XPCWrappedNative::Morph(XPCCallContext& 
         return NS_ERROR_FAILURE;
 
     NS_ADDREF(wrapper);
 
     NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(js::GetObjectParent(existingJSObject)),
                  "Xray wrapper being used to parent XPCWrappedNative?");
 
     JSAutoEnterCompartment ac;
-    if (!ac.enter(ccx, existingJSObject) || !wrapper->Init(ccx, existingJSObject))
-    {
+    if (!ac.enter(ccx, existingJSObject) || !wrapper->Init(ccx, existingJSObject)) {
         NS_RELEASE(wrapper);
         return NS_ERROR_FAILURE;
     }
 
     nsresult rv;
-    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
-    {
+    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
         // Second reference will be released by the FlatJSObject's finalizer.
         wrapper->Release();
         NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
         return rv;
     }
 
     return FinishCreate(ccx, wrapper->GetScope(), Interface, cache, wrapper,
                         resultWrapper);
@@ -795,60 +760,54 @@ XPCWrappedNative::GetUsedOnly(XPCCallCon
                               XPCNativeInterface* Interface,
                               XPCWrappedNative** resultWrapper)
 {
     NS_ASSERTION(Object, "XPCWrappedNative::GetUsedOnly was called with a null Object");
 
     XPCWrappedNative* wrapper;
     nsWrapperCache* cache = nsnull;
     CallQueryInterface(Object, &cache);
-    if (cache)
-    {
+    if (cache) {
         JSObject *flat = cache->GetWrapper();
         if (flat && IS_SLIM_WRAPPER_OBJECT(flat) && !MorphSlimWrapper(ccx, flat))
            return NS_ERROR_FAILURE;
 
         wrapper = flat ?
                   static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat)) :
                   nsnull;
 
-        if (!wrapper)
-        {
+        if (!wrapper) {
             *resultWrapper = nsnull;
             return NS_OK;
         }
         NS_ADDREF(wrapper);
     }
-    else
-    {
+    else {
         nsCOMPtr<nsISupports> identity = do_QueryInterface(Object);
 
-        if (!identity)
-        {
+        if (!identity) {
             NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
             return NS_ERROR_FAILURE;
         }
 
         Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
 
         {   // scoped lock
             XPCAutoLock lock(Scope->GetRuntime()->GetMapLock());
             wrapper = map->Find(identity);
-            if (!wrapper)
-            {
+            if (!wrapper) {
                 *resultWrapper = nsnull;
                 return NS_OK;
             }
             NS_ADDREF(wrapper);
         }
     }
 
     nsresult rv;
-    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
-    {
+    if (Interface && !wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv)) {
         NS_RELEASE(wrapper);
         NS_ASSERTION(NS_FAILED(rv), "returning NS_OK on failure");
         return rv;
     }
 
     *resultWrapper = wrapper;
     return NS_OK;
 }
@@ -904,53 +863,46 @@ XPCWrappedNative::~XPCWrappedNative()
 
 void
 XPCWrappedNative::Destroy()
 {
     XPCWrappedNativeProto* proto = GetProto();
 
     if (mScriptableInfo &&
         (!HasProto() ||
-         (proto && proto->GetScriptableInfo() != mScriptableInfo)))
-    {
+         (proto && proto->GetScriptableInfo() != mScriptableInfo))) {
         delete mScriptableInfo;
         mScriptableInfo = nsnull;
     }
 
     XPCWrappedNativeScope *scope = GetScope();
-    if (scope)
-    {
+    if (scope) {
         Native2WrappedNativeMap* map = scope->GetWrappedNativeMap();
 
         // scoped lock
         XPCAutoLock lock(GetRuntime()->GetMapLock());
 
         // Post-1.9 we should not remove this wrapper from the map if it is
         // uninitialized.
         map->Remove(this);
     }
 
-    if (mIdentity)
-    {
+    if (mIdentity) {
         XPCJSRuntime* rt = GetRuntime();
-        if (rt && rt->GetDoingFinalization())
-        {
-            if (rt->DeferredRelease(mIdentity))
-            {
+        if (rt && rt->GetDoingFinalization()) {
+            if (rt->DeferredRelease(mIdentity)) {
                 mIdentity = nsnull;
             }
-            else
-            {
+            else {
                 NS_WARNING("Failed to append object for deferred release.");
                 // XXX do we really want to do this???
                 NS_RELEASE(mIdentity);
             }
         }
-        else
-        {
+        else {
             NS_RELEASE(mIdentity);
         }
     }
 
     mMaybeScope = nsnull;
 }
 
 // This is factored out so that it can be called publicly
@@ -959,18 +911,17 @@ void
 XPCWrappedNative::GatherProtoScriptableCreateInfo(nsIClassInfo* classInfo,
                                                   XPCNativeScriptableCreateInfo& sciProto)
 {
     NS_ASSERTION(classInfo, "bad param");
     NS_ASSERTION(!sciProto.GetCallback(), "bad param");
 
     nsXPCClassInfo *classInfoHelper = nsnull;
     CallQueryInterface(classInfo, &classInfoHelper);
-    if (classInfoHelper)
-    {
+    if (classInfoHelper) {
         nsCOMPtr<nsIXPCScriptable> helper =
           dont_AddRef(static_cast<nsIXPCScriptable*>(classInfoHelper));
         JSUint32 flags;
         nsresult rv = classInfoHelper->GetScriptableFlags(&flags);
         if (NS_FAILED(rv))
             flags = 0;
 
         sciProto.SetCallback(helper.forget());
@@ -978,21 +929,19 @@ XPCWrappedNative::GatherProtoScriptableC
         sciProto.SetInterfacesBitmap(classInfoHelper->GetInterfacesBitmap());
 
         return;
     }
 
     nsCOMPtr<nsISupports> possibleHelper;
     nsresult rv = classInfo->GetHelperForLanguage(nsIProgrammingLanguage::JAVASCRIPT,
                                                   getter_AddRefs(possibleHelper));
-    if (NS_SUCCEEDED(rv) && possibleHelper)
-    {
+    if (NS_SUCCEEDED(rv) && possibleHelper) {
         nsCOMPtr<nsIXPCScriptable> helper(do_QueryInterface(possibleHelper));
-        if (helper)
-        {
+        if (helper) {
             JSUint32 flags;
             rv = helper->GetScriptableFlags(&flags);
             if (NS_FAILED(rv))
                 flags = 0;
 
             sciProto.SetCallback(helper.forget());
             sciProto.SetFlags(flags);
         }
@@ -1004,28 +953,26 @@ const XPCNativeScriptableCreateInfo&
 XPCWrappedNative::GatherScriptableCreateInfo(nsISupports* obj,
                                              nsIClassInfo* classInfo,
                                              XPCNativeScriptableCreateInfo& sciProto,
                                              XPCNativeScriptableCreateInfo& sciWrapper)
 {
     NS_ASSERTION(!sciWrapper.GetCallback(), "bad param");
 
     // Get the class scriptable helper (if present)
-    if (classInfo)
-    {
+    if (classInfo) {
         GatherProtoScriptableCreateInfo(classInfo, sciProto);
 
         if (sciProto.GetFlags().DontAskInstanceForScriptable())
             return sciProto;
     }
 
     // Do the same for the wrapper specific scriptable
     nsCOMPtr<nsIXPCScriptable> helper(do_QueryInterface(obj));
-    if (helper)
-    {
+    if (helper) {
         JSUint32 flags;
         nsresult rv = helper->GetScriptableFlags(&flags);
         if (NS_FAILED(rv))
             flags = 0;
 
         sciWrapper.SetCallback(helper.forget());
         sciWrapper.SetFlags(flags);
 
@@ -1095,26 +1042,23 @@ static PRUint32 sMorphedSlimWrappers;
 
 JSBool
 XPCWrappedNative::Init(XPCCallContext& ccx,
                        JSObject* parent, JSBool isGlobal,
                        const XPCNativeScriptableCreateInfo* sci)
 {
     // setup our scriptable info...
 
-    if (sci->GetCallback())
-    {
-        if (HasProto())
-        {
+    if (sci->GetCallback()) {
+        if (HasProto()) {
             XPCNativeScriptableInfo* siProto = GetProto()->GetScriptableInfo();
             if (siProto && siProto->GetCallback() == sci->GetCallback())
                 mScriptableInfo = siProto;
         }
-        if (!mScriptableInfo)
-        {
+        if (!mScriptableInfo) {
             mScriptableInfo =
                 XPCNativeScriptableInfo::Construct(ccx, isGlobal, sci);
 
             if (!mScriptableInfo)
                 return JS_FALSE;
 
             // If we have a one-off proto, then it should share our scriptable.
             // This allows the proto's JSClass callbacks to do the right things
@@ -1125,18 +1069,17 @@ XPCWrappedNative::Init(XPCCallContext& c
         }
     }
     XPCNativeScriptableInfo* si = mScriptableInfo;
 
     // create our flatJSObject
 
     JSClass* jsclazz = si ? si->GetJSClass() : Jsvalify(&XPC_WN_NoHelper_JSClass);
 
-    if (isGlobal)
-    {
+    if (isGlobal) {
         // Resolving a global object's class can cause us to create a global's
         // JS class without the proper global flags. Notice that here and fix
         // the problem.
         if (!(jsclazz->flags & JSCLASS_IS_GLOBAL))
             jsclazz->flags |= XPCONNECT_GLOBAL_FLAGS;
     }
     else
         NS_ASSERTION(!(jsclazz->flags & JSCLASS_IS_GLOBAL),
@@ -1188,40 +1131,37 @@ XPCWrappedNative::Init(XPCCallContext &c
 
 JSBool
 XPCWrappedNative::FinishInit(XPCCallContext &ccx)
 {
     // In the current JS engine JS_SetPrivate can't fail. But if it *did*
     // fail then we would not receive our finalizer call and would not be
     // able to properly cleanup. So, if it fails we null out mFlatJSObject
     // to indicate the invalid state of this object and return false.
-    if (!JS_SetPrivate(ccx, mFlatJSObject, this))
-    {
+    if (!JS_SetPrivate(ccx, mFlatJSObject, this)) {
         mFlatJSObject = nsnull;
         return JS_FALSE;
     }
 
     // This reference will be released when mFlatJSObject is finalized.
     // Since this reference will push the refcount to 2 it will also root
     // mFlatJSObject;
     NS_ASSERTION(1 == mRefCnt, "unexpected refcount value");
     NS_ADDREF(this);
 
     if (mScriptableInfo && mScriptableInfo->GetFlags().WantCreate() &&
         NS_FAILED(mScriptableInfo->GetCallback()->Create(this, ccx,
-                                                         mFlatJSObject)))
-    {
+                                                         mFlatJSObject))) {
         return JS_FALSE;
     }
 
 #ifdef XPC_CHECK_WRAPPER_THREADSAFETY
     NS_ASSERTION(mThread, "Should have been set at construction time!");
 
-    if (HasProto() && GetProto()->ClassIsMainThreadOnly() && !NS_IsMainThread())
-    {
+    if (HasProto() && GetProto()->ClassIsMainThreadOnly() && !NS_IsMainThread()) {
         DEBUG_ReportWrapperThreadSafetyError(ccx,
                                              "MainThread only wrapper created on the wrong thread", this);
         return JS_FALSE;
     }
 #endif
 
     // A hack for bug 517665, increase the probability for GC.
     JS_updateMallocCounter(ccx.GetJSContext(), 2 * sizeof(XPCWrappedNative));
@@ -1299,50 +1239,43 @@ XPCWrappedNative::FlatJSObjectFinalized(
         return;
 
     // Iterate the tearoffs and null out each of their JSObject's privates.
     // This will keep them from trying to access their pointers to the
     // dying tearoff object. We can safely assume that those remaining
     // JSObjects are about to be finalized too.
 
     XPCWrappedNativeTearOffChunk* chunk;
-    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
-    {
+    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
-        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
-        {
+        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
             JSObject* jso = to->GetJSObject();
-            if (jso)
-            {
+            if (jso) {
                 NS_ASSERTION(JS_IsAboutToBeFinalized(cx, jso), "bad!");
                 JS_SetPrivate(cx, jso, nsnull);
                 to->JSObjectFinalized();
             }
 
             // We also need to release any native pointers held...
             nsISupports* obj = to->GetNative();
-            if (obj)
-            {
+            if (obj) {
 #ifdef XP_WIN
                 // Try to detect free'd pointer
                 NS_ASSERTION(*(int*)obj != 0xdddddddd, "bad pointer!");
                 NS_ASSERTION(*(int*)obj != 0,          "bad pointer!");
 #endif
                 XPCJSRuntime* rt = GetRuntime();
-                if (rt)
-                {
-                    if (!rt->DeferredRelease(obj))
-                    {
+                if (rt) {
+                    if (!rt->DeferredRelease(obj)) {
                         NS_WARNING("Failed to append object for deferred release.");
                         // XXX do we really want to do this???
                         obj->Release();
                     }
                 }
-                else
-                {
+                else {
                     obj->Release();
                 }
                 to->SetNative(nsnull);
             }
 
             to->SetInterface(nsnull);
         }
     }
@@ -1357,36 +1290,34 @@ XPCWrappedNative::FlatJSObjectFinalized(
 
     NS_ASSERTION(mIdentity, "bad pointer!");
 #ifdef XP_WIN
     // Try to detect free'd pointer
     NS_ASSERTION(*(int*)mIdentity != 0xdddddddd, "bad pointer!");
     NS_ASSERTION(*(int*)mIdentity != 0,          "bad pointer!");
 #endif
 
-    if (IsWrapperExpired())
-    {
+    if (IsWrapperExpired()) {
         Destroy();
     }
 
     // Note that it's not safe to touch mNativeWrapper here since it's
     // likely that it has already been finalized.
 
     Release();
 }
 
 void
 XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
 {
 #ifdef DEBUG_xpc_hacker
     {
         printf("Removing root for still-live XPCWrappedNative %p wrapping:\n",
                static_cast<void*>(this));
-        for (PRUint16 i = 0, i_end = mSet->GetInterfaceCount(); i < i_end; ++i)
-        {
+        for (PRUint16 i = 0, i_end = mSet->GetInterfaceCount(); i < i_end; ++i) {
             nsXPIDLCString name;
             mSet->GetInterfaceAt(i)->GetInterfaceInfo()
                 ->GetName(getter_Copies(name));
             printf("  %s\n", name.get());
         }
     }
 #endif
     DEBUG_TrackShutdownWrapper(this);
@@ -1406,43 +1337,38 @@ XPCWrappedNative::SystemIsBeingShutDown(
 
     XPCWrappedNativeProto* proto = GetProto();
 
     if (HasProto())
         proto->SystemIsBeingShutDown(cx);
 
     if (mScriptableInfo &&
         (!HasProto() ||
-         (proto && proto->GetScriptableInfo() != mScriptableInfo)))
-    {
+         (proto && proto->GetScriptableInfo() != mScriptableInfo))) {
         delete mScriptableInfo;
     }
 
     // cleanup the tearoffs...
 
     XPCWrappedNativeTearOffChunk* chunk;
-    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk)
-    {
+    for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
-        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++)
-        {
-            if (to->GetJSObject())
-            {
+        for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
+            if (to->GetJSObject()) {
                 JS_SetPrivate(cx, to->GetJSObject(), nsnull);
                 to->SetJSObject(nsnull);
             }
             // We leak the tearoff mNative
             // (for the same reason we leak mIdentity - see above).
             to->SetNative(nsnull);
             to->SetInterface(nsnull);
         }
     }
 
-    if (mFirstChunk.mNextChunk)
-    {
+    if (mFirstChunk.mNextChunk) {
         delete mFirstChunk.mNextChunk;
         mFirstChunk.mNextChunk = nsnull;
     }
 }
 
 /***************************************************************************/
 
 // static
@@ -1461,115 +1387,104 @@ XPCWrappedNative::ReparentWrapperIfFound
         return NS_ERROR_FAILURE;
 
     nsresult rv;
 
     nsRefPtr<XPCWrappedNative> wrapper;
     JSObject *flat;
     nsWrapperCache* cache = nsnull;
     CallQueryInterface(aCOMObj, &cache);
-    if (cache)
-    {
+    if (cache) {
         flat = cache->GetWrapper();
-        if (flat && !IS_SLIM_WRAPPER_OBJECT(flat))
-        {
+        if (flat && !IS_SLIM_WRAPPER_OBJECT(flat)) {
             wrapper = static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(flat));
             NS_ASSERTION(wrapper->GetScope() == aOldScope,
                          "Incorrect scope passed");
         }
     }
-    else
-    {
+    else {
         rv = XPCWrappedNative::GetUsedOnly(ccx, aCOMObj, aOldScope, iface,
                                            getter_AddRefs(wrapper));
         if (NS_FAILED(rv))
             return rv;
 
         flat = wrapper->GetFlatJSObject();
     }
 
-    if (!flat)
-    {
+    if (!flat) {
         *aWrapper = nsnull;
         return NS_OK;
     }
 
     bool crosscompartment = js::GetObjectCompartment(aOldScope->GetGlobalJSObject()) !=
                             js::GetObjectCompartment(aNewScope->GetGlobalJSObject());
 #ifdef DEBUG
-    if (crosscompartment)
-    {
+    if (crosscompartment) {
         NS_ASSERTION(aNewParent, "won't be able to find the new parent");
         NS_ASSERTION(wrapper, "can't transplant slim wrappers");
     }
 #endif
 
     // ReparentWrapperIfFound is really only meant to be called from DOM code
     // which must happen only on the main thread. Bail if we're on some other
     // thread or have a non-main-thread-only wrapper.
     if (!XPCPerThreadData::IsMainThread(ccx) ||
         (wrapper &&
          wrapper->GetProto() &&
-         !wrapper->GetProto()->ClassIsMainThreadOnly()))
-    {
+         !wrapper->GetProto()->ClassIsMainThreadOnly())) {
         return NS_ERROR_FAILURE;
     }
 
     JSAutoEnterCompartment ac;
     if (!ac.enter(ccx, aNewScope->GetGlobalJSObject()))
         return NS_ERROR_FAILURE;
 
-    if (aOldScope != aNewScope)
-    {
+    if (aOldScope != aNewScope) {
         // Oh, so now we need to move the wrapper to a different scope.
         AutoMarkingWrappedNativeProtoPtr oldProto(ccx);
         AutoMarkingWrappedNativeProtoPtr newProto(ccx);
 
         if (!wrapper)
             oldProto = GetSlimWrapperProto(flat);
         else if (wrapper->HasProto())
             oldProto = wrapper->GetProto();
 
-        if (oldProto)
-        {
+        if (oldProto) {
             XPCNativeScriptableInfo *info = oldProto->GetScriptableInfo();
             XPCNativeScriptableCreateInfo ci(*info);
             newProto =
                 XPCWrappedNativeProto::GetNewOrUsed(ccx, aNewScope,
                                                     oldProto->GetClassInfo(),
                                                     &ci,
                                                     !oldProto->IsShared(),
                                                     (info->GetJSClass()->flags & JSCLASS_IS_GLOBAL),
                                                     oldProto->GetOffsetsMasked());
-            if (!newProto)
-            {
+            if (!newProto) {
                 return NS_ERROR_FAILURE;
             }
         }
 
-        if (wrapper)
-        {
+        if (wrapper) {
             Native2WrappedNativeMap* oldMap = aOldScope->GetWrappedNativeMap();
             Native2WrappedNativeMap* newMap = aNewScope->GetWrappedNativeMap();
 
             {   // scoped lock
                 XPCAutoLock lock(aOldScope->GetRuntime()->GetMapLock());
 
                 oldMap->Remove(wrapper);
 
                 if (wrapper->HasProto())
                     wrapper->SetProto(newProto);
 
                 // If the wrapper has no scriptable or it has a non-shared
                 // scriptable, then we don't need to mess with it.
                 // Otherwise...
 
                 if (wrapper->mScriptableInfo &&
-                    wrapper->mScriptableInfo == oldProto->GetScriptableInfo())
-                {
+                    wrapper->mScriptableInfo == oldProto->GetScriptableInfo()) {
                     // The new proto had better have the same JSClass stuff as
                     // the old one! We maintain a runtime wide unique map of
                     // this stuff. So, if these don't match then the caller is
                     // doing something bad here.
 
                     NS_ASSERTION(oldProto->GetScriptableInfo()->GetScriptableShared() ==
                                  newProto->GetScriptableInfo()->GetScriptableShared(),
                                  "Changing proto is also changing JSObject Classname or "
@@ -1582,114 +1497,101 @@ XPCWrappedNative::ReparentWrapperIfFound
                              "wrapper already in new scope!");
 
                 (void) newMap->Add(wrapper);
             }
 
             // We only try to fixup the __proto__ JSObject if the wrapper
             // is directly using that of its XPCWrappedNativeProto.
 
-            if (crosscompartment)
-            {
+            if (crosscompartment) {
                 JSObject *newobj = JS_CloneObject(ccx, flat,
                                                   newProto->GetJSProtoObject(),
                                                   aNewParent);
                 if (!newobj)
                     return NS_ERROR_FAILURE;
 
                 JS_SetPrivate(ccx, flat, nsnull);
 
                 JSObject *propertyHolder =
                     JS_NewObjectWithGivenProto(ccx, NULL, NULL, aNewParent);
                 if (!propertyHolder || !JS_CopyPropertiesFrom(ccx, propertyHolder, flat))
                     return NS_ERROR_OUT_OF_MEMORY;
 
                 JSObject *ww = wrapper->GetWrapper();
-                if (ww)
-                {
+                if (ww) {
                     JSObject *newwrapper;
-                    if (xpc::WrapperFactory::IsLocationObject(flat))
-                    {
+                    if (xpc::WrapperFactory::IsLocationObject(flat)) {
                         newwrapper = xpc::WrapperFactory::WrapLocationObject(ccx, newobj);
                         if (!newwrapper)
                             return NS_ERROR_FAILURE;
                     }
-                    else
-                    {
+                    else {
                         NS_ASSERTION(wrapper->NeedsSOW(), "weird wrapper wrapper");
                         newwrapper = xpc::WrapperFactory::WrapSOWObject(ccx, newobj);
                         if (!newwrapper)
                             return NS_ERROR_FAILURE;
                     }
 
                     ww = js_TransplantObjectWithWrapper(ccx, flat, ww, newobj,
                                                         newwrapper);
                     if (!ww)
                         return NS_ERROR_FAILURE;
                     flat = newobj;
                     wrapper->SetWrapper(ww);
                 }
-                else
-                {
+                else {
                     flat = JS_TransplantObject(ccx, flat, newobj);
                     if (!flat)
                         return NS_ERROR_FAILURE;
                 }
 
                 wrapper->mFlatJSObject = flat;
                 if (cache)
                     cache->SetWrapper(flat);
                 if (!JS_CopyPropertiesFrom(ccx, flat, propertyHolder))
                     return NS_ERROR_FAILURE;
             }
-            else
-            {
+            else {
                 if (wrapper->HasProto() &&
-                    js::GetObjectProto(flat) == oldProto->GetJSProtoObject())
-                {
-                    if (!JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject()))
-                    {
+                    js::GetObjectProto(flat) == oldProto->GetJSProtoObject()) {
+                    if (!JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
                         // this is bad, very bad
                         NS_ERROR("JS_SetPrototype failed");
                         return NS_ERROR_FAILURE;
                     }
                 }
-                else
-                {
+                else {
                     NS_WARNING("Moving XPConnect wrappedNative to new scope, "
                                "but can't fixup __proto__");
                 }
             }
         }
-        else
-        {
+        else {
             if (!JS_SetReservedSlot(ccx, flat, 0,
                                     PRIVATE_TO_JSVAL(newProto.get())) ||
-                !JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject()))
-            {
+                !JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
                 // this is bad, very bad
                 JS_SetReservedSlot(ccx, flat, 0, JSVAL_NULL);
                 NS_ERROR("JS_SetPrototype failed");
                 return NS_ERROR_FAILURE;
             }
         }
     }
 
     // Now we can just fix up the parent and return the wrapper
 
-    if (aNewParent)
-    {
+    if (aNewParent) {
         if (!JS_SetParent(ccx, flat, aNewParent))
             return NS_ERROR_FAILURE;
 
         JSObject *nw;
         if (wrapper &&
             (nw = wrapper->GetWrapper()) &&
-            !JS_SetParent(ccx, nw, JS_GetGlobalForObject(ccx, aNewParent)))
-        {
+            !JS_SetParent(ccx, nw, JS_GetGlobalForObject(ccx, aNewParent))) {
             return NS_ERROR_FAILURE;
         }
     }
 
     *aWrapper = nsnull;
     wrapper.swap(*aWrapper);
 
     return NS_OK;
@@ -1717,78 +1619,69 @@ XPCWrappedNative::GetWrappedNativeOfJSOb
     JSObject* cur;
 
     XPCWrappedNativeProto* proto = nsnull;
     nsIClassInfo* protoClassInfo = nsnull;
 
     // If we were passed a function object then we need to find the correct
     // wrapper out of those that might be in the callee obj's proto chain.
 
-    if (funobj)
-    {
+    if (funobj) {
         JSObject* funObjParent = js::UnwrapObject(js::GetObjectParent(funobj));
         funObjParent = JS_ObjectToInnerObject(cx, funObjParent);
         NS_ASSERTION(funObjParent, "funobj has no parent");
 
         js::Class* funObjParentClass = js::GetObjectClass(funObjParent);
 
-        if (IS_PROTO_CLASS(funObjParentClass))
-        {
+        if (IS_PROTO_CLASS(funObjParentClass)) {
             NS_ASSERTION(js::GetObjectParent(funObjParent), "funobj's parent (proto) is global");
             proto = (XPCWrappedNativeProto*) js::GetObjectPrivate(funObjParent);
             if (proto)
                 protoClassInfo = proto->GetClassInfo();
         }
-        else if (IS_WRAPPER_CLASS(funObjParentClass))
-        {
+        else if (IS_WRAPPER_CLASS(funObjParentClass)) {
             cur = funObjParent;
             goto return_wrapper;
         }
-        else if (IS_TEAROFF_CLASS(funObjParentClass))
-        {
+        else if (IS_TEAROFF_CLASS(funObjParentClass)) {
             NS_ASSERTION(js::GetObjectParent(funObjParent), "funobj's parent (tearoff) is global");
             cur = funObjParent;
             goto return_tearoff;
         }
-        else
-        {
+        else {
             NS_ERROR("function object has parent of unknown class!");
             return nsnull;
         }
     }
 
   restart:
-    for (cur = obj; cur; cur = js::GetObjectProto(cur))
-    {
+    for (cur = obj; cur; cur = js::GetObjectProto(cur)) {
         // this is on two lines to make the compiler happy given the goto.
         js::Class* clazz;
         clazz = js::GetObjectClass(cur);
 
-        if (IS_WRAPPER_CLASS(clazz))
-        {
+        if (IS_WRAPPER_CLASS(clazz)) {
 return_wrapper:
             JSBool isWN = IS_WN_WRAPPER_OBJECT(cur);
             XPCWrappedNative* wrapper =
                 isWN ? (XPCWrappedNative*) js::GetObjectPrivate(cur) : nsnull;
-            if (proto)
-            {
+            if (proto) {
                 XPCWrappedNativeProto* wrapper_proto =
                     isWN ? wrapper->GetProto() : GetSlimWrapperProto(cur);
                 if (proto != wrapper_proto &&
                     (!protoClassInfo || !wrapper_proto ||
                      protoClassInfo != wrapper_proto->GetClassInfo()))
                     continue;
             }
             if (pobj2)
                 *pobj2 = isWN ? nsnull : cur;
             return wrapper;
         }
 
-        if (IS_TEAROFF_CLASS(clazz))
-        {
+        if (IS_TEAROFF_CLASS(clazz)) {
 return_tearoff:
             XPCWrappedNative* wrapper =
                 (XPCWrappedNative*) js::GetObjectPrivate(js::GetObjectParent(cur));
             if (proto && proto != wrapper->GetProto() &&
                 (proto->GetScope() != wrapper->GetScope() ||
                  !protoClassInfo || !wrapper->GetProto() ||
                  protoClassInfo != wrapper->GetProto()->GetClassInfo()))
                 continue;
@@ -1801,35 +1694,33 @@ return_tearoff:
                 *pTearOff = to;
             return wrapper;
         }
 
         // Unwrap any wrapper wrappers.
         JSObject *unsafeObj = cx
                               ? XPCWrapper::Unwrap(cx, cur)
                               : XPCWrapper::UnsafeUnwrapSecurityWrapper(cur);
-        if (unsafeObj)
-        {
+        if (unsafeObj) {
             obj = unsafeObj;
             goto restart;
         }
     }
 
     if (pobj2)
         *pobj2 = nsnull;
     return nsnull;
 }
 
 JSBool
 XPCWrappedNative::ExtendSet(XPCCallContext& ccx, XPCNativeInterface* aInterface)
 {
     // This is only called while locked (during XPCWrappedNative::FindTearOff).
 
-    if (!mSet->HasInterface(aInterface))
-    {
+    if (!mSet->HasInterface(aInterface)) {
         AutoMarkingNativeSetPtr newSet(ccx);
         newSet = XPCNativeSet::GetNewOrUsed(ccx, mSet, aInterface,
                                             mSet->GetInterfaceCount());
         if (!newSet)
             return JS_FALSE;
 
         mSet = newSet;
 
@@ -1841,27 +1732,24 @@ XPCWrappedNative::ExtendSet(XPCCallConte
 XPCWrappedNativeTearOff*
 XPCWrappedNative::LocateTearOff(XPCCallContext& ccx,
                                 XPCNativeInterface* aInterface)
 {
     XPCAutoLock al(GetLock()); // hold the lock throughout
 
     for (XPCWrappedNativeTearOffChunk* chunk = &mFirstChunk;
          chunk != nsnull;
-         chunk = chunk->mNextChunk)
-    {
+         chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* tearOff = chunk->mTearOffs;
         XPCWrappedNativeTearOff* const end = tearOff +
             XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK;
         for (tearOff = chunk->mTearOffs;
              tearOff < end;
-             tearOff++)
-        {
-            if (tearOff->GetInterface() == aInterface)
-            {
+             tearOff++) {
+            if (tearOff->GetInterface() == aInterface) {
                 return tearOff;
             }
         }
     }
     return nsnull;
 }
 
 XPCWrappedNativeTearOff*
@@ -1875,29 +1763,25 @@ XPCWrappedNative::FindTearOff(XPCCallCon
     nsresult rv = NS_OK;
     XPCWrappedNativeTearOff* to;
     XPCWrappedNativeTearOff* firstAvailable = nsnull;
 
     XPCWrappedNativeTearOffChunk* lastChunk;
     XPCWrappedNativeTearOffChunk* chunk;
     for (lastChunk = chunk = &mFirstChunk;
          chunk;
-         lastChunk = chunk, chunk = chunk->mNextChunk)
-    {
+         lastChunk = chunk, chunk = chunk->mNextChunk) {
         to = chunk->mTearOffs;
         XPCWrappedNativeTearOff* const end = chunk->mTearOffs +
             XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK;
         for (to = chunk->mTearOffs;
              to < end;
-             to++)
-        {
-            if (to->GetInterface() == aInterface)
-            {
-                if (needJSObject && !to->GetJSObject())
-                {
+             to++) {
+            if (to->GetInterface() == aInterface) {
+                if (needJSObject && !to->GetJSObject()) {
                     AutoMarkingWrappedNativeTearOffPtr tearoff(ccx, to);
                     JSBool ok = InitTearOffJSObject(ccx, to);
                     // During shutdown, we don't sweep tearoffs.  So make sure
                     // to unmark manually in case the auto-marker marked us.
                     // We shouldn't ever be getting here _during_ our
                     // Mark/Sweep cycle, so this should be safe.
                     to->Unmark();
                     if (!ok) {
@@ -1909,22 +1793,20 @@ XPCWrappedNative::FindTearOff(XPCCallCon
             }
             if (!firstAvailable && to->IsAvailable())
                 firstAvailable = to;
         }
     }
 
     to = firstAvailable;
 
-    if (!to)
-    {
+    if (!to) {
         XPCWrappedNativeTearOffChunk* newChunk =
             new XPCWrappedNativeTearOffChunk();
-        if (!newChunk)
-        {
+        if (!newChunk) {
             rv = NS_ERROR_OUT_OF_MEMORY;
             goto return_result;
         }
         lastChunk->mNextChunk = newChunk;
         to = newChunk->mTearOffs;
     }
 
     {
@@ -1960,41 +1842,37 @@ XPCWrappedNative::InitTearOff(XPCCallCon
     nsISupports* identity = GetIdentityObject();
     nsISupports* obj;
 
     // If the scriptable helper forbids us from reflecting additional
     // interfaces, then don't even try the QI, just fail.
     if (mScriptableInfo &&
         mScriptableInfo->GetFlags().ClassInfoInterfacesOnly() &&
         !mSet->HasInterface(aInterface) &&
-        !mSet->HasInterfaceWithAncestor(aInterface))
-    {
+        !mSet->HasInterfaceWithAncestor(aInterface)) {
         return NS_ERROR_NO_INTERFACE;
     }
 
     // We are about to call out to unlock and other code.
     // So protect our intended tearoff.
 
     aTearOff->SetReserved();
 
     {   // scoped *un*lock
         XPCAutoUnlock unlock(GetLock());
 
-        if (NS_FAILED(identity->QueryInterface(*iid, (void**)&obj)) || !obj)
-        {
+        if (NS_FAILED(identity->QueryInterface(*iid, (void**)&obj)) || !obj) {
             aTearOff->SetInterface(nsnull);
             return NS_ERROR_NO_INTERFACE;
         }
 
         // Guard against trying to build a tearoff for a shared nsIClassInfo.
-        if (iid->Equals(NS_GET_IID(nsIClassInfo)))
-        {
+        if (iid->Equals(NS_GET_IID(nsIClassInfo))) {
             nsCOMPtr<nsISupports> alternate_identity(do_QueryInterface(obj));
-            if (alternate_identity.get() != identity)
-            {
+            if (alternate_identity.get() != identity) {
                 NS_RELEASE(obj);
                 aTearOff->SetInterface(nsnull);
                 return NS_ERROR_NO_INTERFACE;
             }
         }
 
         // Guard against trying to build a tearoff for an interface that is
         // aggregated and is implemented as a nsIXPConnectWrappedJS using this
@@ -2008,22 +1886,20 @@ XPCWrappedNative::InitTearOff(XPCCallCon
         // on *our* JSObject and find the same method and make another call
         // into an infinite loop.
         // see: http://bugzilla.mozilla.org/show_bug.cgi?id=96725
 
         // The code in this block also does a check for the double wrapped
         // nsIPropertyBag case.
 
         nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS(do_QueryInterface(obj));
-        if (wrappedJS)
-        {
+        if (wrappedJS) {
             JSObject* jso = nsnull;
             if (NS_SUCCEEDED(wrappedJS->GetJSObject(&jso)) &&
-                jso == mFlatJSObject)
-            {
+                jso == mFlatJSObject) {
                 // The implementing JSObject is the same as ours! Just say OK
                 // without actually extending the set.
                 //
                 // XXX It is a little cheesy to have FindTearOff return an
                 // 'empty' tearoff. But this is the centralized place to do the
                 // QI activities on the underlying object. *And* most caller to
                 // FindTearOff only look for a non-null result and ignore the
                 // actual tearoff returned. The only callers that do use the
@@ -2035,18 +1911,17 @@ XPCWrappedNative::InitTearOff(XPCCallCon
                 {
                     // I want to make sure this only happens in xbl-like cases.
                     // So, some debug code to verify that there is at least
                     // *some* object between our JSObject and its inital proto.
                     // XXX This is a pretty funky test. Someone might hack it
                     // a bit if false positives start showing up. Note that
                     // this is only going to run for the few people in the
                     // DEBUG_xpc_hacker list.
-                    if (HasProto())
-                    {
+                    if (HasProto()) {
                         JSObject* proto  = nsnull;
                         JSObject* our_proto = GetProto()->GetJSProtoObject();
 
                         proto = jso->getProto();
 
                         NS_ASSERTION(proto && proto != our_proto,
                                      "!!! xpconnect/xbl check - wrapper has no special proto");
 
@@ -2055,18 +1930,17 @@ XPCWrappedNative::InitTearOff(XPCCallCon
                             proto = proto->getProto();
 
                             found_our_proto = proto == our_proto;
                         }
 
                         NS_ASSERTION(found_our_proto,
                                      "!!! xpconnect/xbl check - wrapper has extra proto");
                     }
-                    else
-                    {
+                    else {
                         NS_WARNING("!!! xpconnect/xbl check - wrapper has no proto");
                     }
                 }
 #endif
                 NS_RELEASE(obj);
                 aTearOff->SetInterface(nsnull);
                 return NS_OK;
             }
@@ -2080,51 +1954,47 @@ XPCWrappedNative::InitTearOff(XPCCallCon
             // JSObject wants other JSObjects to be able to see this interface
             // then it must implement QueryInterface and not throw an exception
             // when asked for nsIPropertyBag. It need not actually *implement*
             // nsIPropertyBag - xpconnect will do that work.
 
             nsXPCWrappedJSClass* clazz;
             if (iid->Equals(NS_GET_IID(nsIPropertyBag)) && jso &&
                 NS_SUCCEEDED(nsXPCWrappedJSClass::GetNewOrUsed(ccx,*iid,&clazz))&&
-                clazz)
-            {
+                clazz) {
                 JSObject* answer =
                     clazz->CallQueryInterfaceOnJSObject(ccx, jso, *iid);
                 NS_RELEASE(clazz);
-                if (!answer)
-                {
+                if (!answer) {
                     NS_RELEASE(obj);
                     aTearOff->SetInterface(nsnull);
                     return NS_ERROR_NO_INTERFACE;
                 }
             }
         }
 
         nsIXPCSecurityManager* sm;
            sm = ccx.GetXPCContext()->GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CREATE_WRAPPER);
         if (sm && NS_FAILED(sm->
                             CanCreateWrapper(ccx, *iid, identity,
-                                             GetClassInfo(), GetSecurityInfoAddr())))
-        {
+                                             GetClassInfo(), GetSecurityInfoAddr()))) {
             // the security manager vetoed. It should have set an exception.
             NS_RELEASE(obj);
             aTearOff->SetInterface(nsnull);
             return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
         }
     }
     // We are relocked from here on...
 
     // If this is not already in our set we need to extend our set.
     // Note: we do not cache the result of the previous call to HasInterface()
     // because we unlocked and called out in the interim and the result of the
     // previous call might not be correct anymore.
 
-    if (!mSet->HasInterface(aInterface) && !ExtendSet(ccx, aInterface))
-    {
+    if (!mSet->HasInterface(aInterface) && !ExtendSet(ccx, aInterface)) {
         NS_RELEASE(obj);
         aTearOff->SetInterface(nsnull);
         return NS_ERROR_NO_INTERFACE;
     }
 
     aTearOff->SetInterface(aInterface);
     aTearOff->SetNative(obj);
     if (needJSObject && !InitTearOffJSObject(ccx, aTearOff))
@@ -2270,35 +2140,33 @@ NS_SUPPRESS_STACK_CHECK JSBool
 XPCWrappedNative::CallMethod(XPCCallContext& ccx,
                              CallMode mode /*= CALL_METHOD */)
 {
     XPCContext* xpcc = ccx.GetXPCContext();
     NS_ASSERTION(xpcc->CallerTypeIsJavaScript(),
                  "Native caller for XPCWrappedNative::CallMethod?");
 
     nsresult rv = ccx.CanCallNow();
-    if (NS_FAILED(rv))
-    {
+    if (NS_FAILED(rv)) {
         // If the security manager is complaining then this is not really an
         // internal error in xpconnect. So, no reason to botch the assertion.
         NS_ASSERTION(rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO,
                      "hmm? CanCallNow failed in XPCWrappedNative::CallMethod. "
                      "We are finding out about this late!");
         return Throw(rv, ccx);
     }
 
     DEBUG_TrackWrapperCall(ccx.GetWrapper(), mode);
 
     // set up the method index and do the security check if needed
 
     PRUint32 secFlag;
     PRUint32 secAction;
 
-    switch (mode)
-    {
+    switch (mode) {
         case CALL_METHOD:
             secFlag   = nsIXPCSecurityManager::HOOK_CALL_METHOD;
             secAction = nsIXPCSecurityManager::ACCESS_CALL_METHOD;
             break;
         case CALL_GETTER:
             secFlag   = nsIXPCSecurityManager::HOOK_GET_PROPERTY;
             secAction = nsIXPCSecurityManager::ACCESS_GET_PROPERTY;
             break;
@@ -2313,40 +2181,37 @@ XPCWrappedNative::CallMethod(XPCCallCont
 
     nsIXPCSecurityManager* sm =
         xpcc->GetAppropriateSecurityManager(secFlag);
     if (sm && NS_FAILED(sm->CanAccess(secAction, &ccx, ccx,
                                       ccx.GetFlattenedJSObject(),
                                       ccx.GetWrapper()->GetIdentityObject(),
                                       ccx.GetWrapper()->GetClassInfo(),
                                       ccx.GetMember()->GetName(),
-                                      ccx.GetWrapper()->GetSecurityInfoAddr())))
-    {
+                                      ccx.GetWrapper()->GetSecurityInfoAddr()))) {
         // the security manager vetoed. It should have set an exception.
         return JS_FALSE;
     }
 
     return CallMethodHelper(ccx).Call();
 }
 
 JSBool
 CallMethodHelper::Call()
 {
     mCallContext.SetRetVal(JSVAL_VOID);
 
     mCallContext.GetThreadData()->SetException(nsnull);
     mCallContext.GetXPCContext()->SetLastResult(NS_ERROR_UNEXPECTED);
 
-    if (mVTableIndex == 0)
-    {
+    if (mVTableIndex == 0) {
         return QueryInterfaceFastPath();
     }
 
-    if (!mMethodInfo)
-    {
+    if (!mMethodInfo) {
         Throw(NS_ERROR_XPC_CANT_GET_METHOD_INFO, mCallContext);
         return JS_FALSE;
     }
 
     if (!InitializeDispatchParams())
         return JS_FALSE;
 
     // Iterate through the params doing conversions of independent params only.
@@ -2359,78 +2224,69 @@ CallMethodHelper::Call()
 
     if (foundDependentParam && !ConvertDependentParams())
         return JS_FALSE;
 
     nsresult invokeResult = Invoke();
 
     mCallContext.GetXPCContext()->SetLastResult(invokeResult);
 
-    if (NS_FAILED(invokeResult))
-    {
+    if (NS_FAILED(invokeResult)) {
         ThrowBadResult(invokeResult, mCallContext);
         return JS_FALSE;
     }
 
-    if (JS_IsExceptionPending(mCallContext))
-    {
+    if (JS_IsExceptionPending(mCallContext)) {
         return JS_FALSE;
     }
 
     return GatherAndConvertResults();
 }
 
 CallMethodHelper::~CallMethodHelper()
 {
     uint8 paramCount = mMethod