Bug 748531 - Fix indentation and minor cleanup in AndroidBridge.cpp. r=blassey a=mfinkle
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 04 May 2012 11:08:45 -0400
changeset 95709 1e06f6c5ed3873b451179177bb5f67ac74112db4
parent 95708 039532eb1c0dec1cc9232896b624e1392636e2d2
child 95710 853dce95eac252c22e068b984f77b655fd8fe89d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, mfinkle
bugs748531
milestone14.0a2
Bug 748531 - Fix indentation and minor cleanup in AndroidBridge.cpp. r=blassey a=mfinkle
widget/android/AndroidBridge.cpp
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -255,33 +255,33 @@ AndroidBridge::SetMainThread(void *thr)
     return true;
 }
 
 void
 AndroidBridge::NotifyIME(int aType, int aState)
 {
     ALOG_BRIDGE("AndroidBridge::NotifyIME");
 
-    JNIEnv *env = AndroidBridge::GetJNIEnv();
+    JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
     env->CallStaticVoidMethod(sBridge->mGeckoAppShellClass, 
                               sBridge->jNotifyIME,  aType, aState);
 }
 
 void
 AndroidBridge::NotifyIMEEnabled(int aState, const nsAString& aTypeHint,
                                 const nsAString& aActionHint)
 {
     ALOG_BRIDGE("AndroidBridge::NotifyIMEEnabled");
     if (!sBridge)
         return;
 
-    JNIEnv *env = AndroidBridge::GetJNIEnv();
+    JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
     nsPromiseFlatString typeHint(aTypeHint);
     nsPromiseFlatString actionHint(aActionHint);
 
     jvalue args[4];
     AutoLocalJNIFrame jniFrame(env, 1);
@@ -317,17 +317,17 @@ void
 AndroidBridge::NotifyIMEChange(const PRUnichar *aText, PRUint32 aTextLen,
                                int aStart, int aEnd, int aNewEnd)
 {
     ALOG_BRIDGE("AndroidBridge::NotifyIMEChange");
     if (!sBridge) {
         return;
     }
 
-    JNIEnv *env = AndroidBridge::GetJNIEnv();
+    JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
     jvalue args[4];
     AutoLocalJNIFrame jniFrame(env, 1);
     args[0].l = env->NewString(aText, aTextLen);
     args[1].i = aStart;
     args[2].i = aEnd;
@@ -874,17 +874,17 @@ AndroidBridge::Vibrate(const nsTArray<PR
     // java junk, so dodges the GC.
     if (len == 1) {
         jlong d = aPattern[0];
         if (d < 0) {
             ALOG_BRIDGE("  invalid vibration duration < 0");
             return;
         }
         env->CallStaticVoidMethod(mGeckoAppShellClass, jVibrate1, d);
-       return;
+        return;
     }
 
     // First element of the array vibrate() expects is how long to wait
     // *before* vibrating.  For us, this is always 0.
 
     jlongArray array = env->NewLongArray(len + 1);
     if (!array) {
         ALOG_BRIDGE("  failed to allocate array");
@@ -1252,17 +1252,17 @@ AndroidBridge::CreateShortcut(const nsAS
     jstring jstrTitle = env->NewString(nsPromiseFlatString(aTitle).get(), aTitle.Length());
     jstring jstrURI = env->NewString(nsPromiseFlatString(aURI).get(), aURI.Length());
     jstring jstrIconData = env->NewString(nsPromiseFlatString(aIconData).get(), aIconData.Length());
     jstring jstrIntent = env->NewString(nsPromiseFlatString(aIntent).get(), aIntent.Length());
   
     if (!jstrURI || !jstrTitle || !jstrIconData)
         return;
     
-  env->CallStaticVoidMethod(mGeckoAppShellClass, jCreateShortcut, jstrTitle, jstrURI, jstrIconData, jstrIntent);
+    env->CallStaticVoidMethod(mGeckoAppShellClass, jCreateShortcut, jstrTitle, jstrURI, jstrIconData, jstrIntent);
 }
 
 void
 AndroidBridge::PostToJavaThread(JNIEnv *env, nsIRunnable* aRunnable, bool aMainThread)
 {
     mRunnableQueue.AppendObject(aRunnable);
 
     AutoLocalJNIFrame jniFrame(env);
@@ -1698,22 +1698,22 @@ AndroidBridge::CreateMessageList(const d
 
     JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env); 
 
     jobjectArray numbers =
-      (jobjectArray)env->NewObjectArray(aFilter.numbers().Length(),
+        (jobjectArray)env->NewObjectArray(aFilter.numbers().Length(),
                                         jStringClass,
                                         env->NewStringUTF(""));
 
     for (PRUint32 i = 0; i < aFilter.numbers().Length(); ++i) {
-      env->SetObjectArrayElement(numbers, i,
+        env->SetObjectArrayElement(numbers, i,
                                    env->NewStringUTF(NS_ConvertUTF16toUTF8(aFilter.numbers()[i]).get()));
     }
 
     env->CallStaticVoidMethod(mGeckoAppShellClass, jCreateMessageList,
                                 aFilter.startDate(), aFilter.endDate(),
                                 numbers, aFilter.numbers().Length(),
                                 aFilter.delivery(), aReverse, aRequestId,
                                 aProcessId);
@@ -2086,44 +2086,44 @@ extern "C" {
         return jEnv;
     }
 }
 
 jobject
 AndroidBridge::CreateSurface()
 {
 #ifndef MOZ_JAVA_COMPOSITOR
-  return NULL;
+    return NULL;
 #else
-  JNIEnv* env = GetJNIEnv();
-  if (!env)
-    return nsnull;
+    JNIEnv* env = GetJNIEnv();
+    if (!env)
+        return nsnull;
 
-  AutoLocalJNIFrame frame(env);
+    AutoLocalJNIFrame frame(env);
 
-  jobject surface = env->CallStaticObjectMethod(mGeckoAppShellClass, jCreateSurface);
-  if (surface)
-   surface =  env->NewGlobalRef(surface);
+    jobject surface = env->CallStaticObjectMethod(mGeckoAppShellClass, jCreateSurface);
+    if (surface)
+        surface =  env->NewGlobalRef(surface);
   
-  return surface;
+    return surface;
 #endif
 }
 
 void
 AndroidBridge::DestroySurface(jobject surface)
 {
 #ifdef MOZ_JAVA_COMPOSITOR
-  JNIEnv* env = GetJNIEnv();
-  if (!env)
-    return;
+    JNIEnv* env = GetJNIEnv();
+    if (!env)
+        return;
 
-  AutoLocalJNIFrame frame(env);
+    AutoLocalJNIFrame frame(env);
 
-  env->CallStaticVoidMethod(mGeckoAppShellClass, jDestroySurface, surface);
-  env->DeleteGlobalRef(surface);
+    env->CallStaticVoidMethod(mGeckoAppShellClass, jDestroySurface, surface);
+    env->DeleteGlobalRef(surface);
 #endif
 }
 
 void
 AndroidBridge::ShowSurface(jobject surface, const gfxRect& aRect, bool aInverted, bool aBlend)
 {
 #ifdef MOZ_JAVA_COMPOSITOR
     JNIEnv* env = GetJNIEnv();
@@ -2172,25 +2172,25 @@ AndroidBridge::DisableScreenOrientationN
 {
     ALOG_BRIDGE("AndroidBridge::DisableScreenOrientationNotifications");
     mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
 }
 
 void
 AndroidBridge::LockScreenOrientation(const dom::ScreenOrientationWrapper& aOrientation)
 {
-  ALOG_BRIDGE("AndroidBridge::LockScreenOrientation");
-  mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, aOrientation.orientation);
+    ALOG_BRIDGE("AndroidBridge::LockScreenOrientation");
+    mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, aOrientation.orientation);
 }
 
 void
 AndroidBridge::UnlockScreenOrientation()
 {
-  ALOG_BRIDGE("AndroidBridge::UnlockScreenOrientation");
-  mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jUnlockScreenOrientation);
+    ALOG_BRIDGE("AndroidBridge::UnlockScreenOrientation");
+    mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jUnlockScreenOrientation);
 }
 
 void
 AndroidBridge::PumpMessageLoop()
 {
 #if MOZ_JAVA_COMPOSITOR
     JNIEnv* env = GetJNIEnv();
     if (!env)
@@ -2216,41 +2216,41 @@ NS_IMETHODIMP nsAndroidBridge::SetBrowse
 {
     if (nsAppShell::gAppShell)
         nsAppShell::gAppShell->SetBrowserApp(aBrowserApp);
     return NS_OK;
 }
 
 void
 AndroidBridge::AddPluginView(jobject view, const gfxRect& rect) {
-    JNIEnv *env = AndroidBridge::GetJNIEnv();
+    JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
-    AndroidBridge::AutoLocalJNIFrame frame(env);
+    AutoLocalJNIFrame frame(env);
 
 #if MOZ_JAVA_COMPOSITOR
     env->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
                               sBridge->jAddPluginView, view,
                               (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
 #else
     env->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
                               sBridge->jAddPluginView, view,
                               rect.x, rect.y, rect.width, rect.height);
 #endif
 }
 
 void
 AndroidBridge::RemovePluginView(jobject view) {
-  JNIEnv *env = GetJNIEnv();
-  if (!env)
-    return;
+    JNIEnv *env = GetJNIEnv();
+    if (!env)
+        return;
 
-  AndroidBridge::AutoLocalJNIFrame frame(env);
-  env->CallStaticVoidMethod(mGeckoAppShellClass, jRemovePluginView, view);
+    AutoLocalJNIFrame frame(env);
+    env->CallStaticVoidMethod(mGeckoAppShellClass, jRemovePluginView, view);
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
 jobject JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(JNIEnv *jenv, jclass, jlong size);
 
 
@@ -2270,17 +2270,17 @@ nsresult AndroidBridge::TakeScreenshot(n
     nsIPresShell* presShell = presContext->PresShell();
     PRUint32 renderDocFlags = (nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
                                nsIPresShell::RENDER_DOCUMENT_RELATIVE);
     nsRect r(nsPresContext::CSSPixelsToAppUnits(srcX / scale),
              nsPresContext::CSSPixelsToAppUnits(srcY / scale),
              nsPresContext::CSSPixelsToAppUnits(srcW / scale),
              nsPresContext::CSSPixelsToAppUnits(srcH / scale));
 
-    JNIEnv* jenv = AndroidBridge::GetJNIEnv();
+    JNIEnv* jenv = GetJNIEnv();
     if (!jenv)
         return NS_OK;
 
     PRUint32 stride = dstW * 2;
     PRUint32 bufferSize = dstH * stride;
 
     jobject buffer = Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(jenv, NULL, bufferSize);
     if (!buffer)
@@ -2288,21 +2288,21 @@ nsresult AndroidBridge::TakeScreenshot(n
 
     void* data = jenv->GetDirectBufferAddress(buffer);
     memset(data, 0, bufferSize);
     nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(static_cast<unsigned char*>(data), nsIntSize(dstW, dstH), stride, gfxASurface::ImageFormatRGB16_565);
     nsRefPtr<gfxContext> context = new gfxContext(surf);
     context->Scale(scale * dstW / srcW, scale * dstH / srcH);
     nsresult rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context);
     NS_ENSURE_SUCCESS(rv, rv);
-    AndroidBridge::AutoLocalJNIFrame jniFrame(jenv, 1);
+    AutoLocalJNIFrame jniFrame(jenv, 1);
     jenv->CallStaticVoidMethod(AndroidBridge::Bridge()->mGeckoAppShellClass, AndroidBridge::Bridge()->jNotifyScreenShot, buffer, tabId, srcX * dstW / srcW , srcY * dstH / srcH, dstW, dstH, token);
     return NS_OK;
 }
 
 void
 AndroidBridge::NotifyPaintedRect(float top, float left, float bottom, float right)
 {
-    JNIEnv* jenv = AndroidBridge::GetJNIEnv();
+    JNIEnv* jenv = GetJNIEnv();
     if (!jenv)
         return;
     jenv->CallStaticVoidMethod(AndroidBridge::Bridge()->mGeckoAppShellClass, AndroidBridge::Bridge()->jNotifyPaintedRect, top, left, bottom, right);
 }