Bug 748469 - (Part 2) Clean up FormAssist.positionAndShowPopup. r=wesj
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 01 Mar 2013 17:06:00 -0800
changeset 123530 39b225c258501e3a1c1b1faa29a633d31a4f842c
parent 123529 7e5af7df02b7681b8d5cbc568884721470167f3f
child 123531 00d6250f12e815067b0459834de3a75ef0c78065
push id24385
push usergszorc@mozilla.com
push dateSat, 02 Mar 2013 21:28:09 +0000
treeherdermozilla-central@0f0745beec38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs748469
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 748469 - (Part 2) Clean up FormAssist.positionAndShowPopup. r=wesj
mobile/android/base/FormAssistPopup.java
--- a/mobile/android/base/FormAssistPopup.java
+++ b/mobile/android/base/FormAssistPopup.java
@@ -47,17 +47,17 @@ public class FormAssistPopup extends Rel
 
     private static int sAutoCompleteMinWidth = 0;
     private static int sAutoCompleteRowHeight = 0;
     private static int sValidationMessageHeight = 0;
     private static int sValidationTextMarginTop = 0;
     private static RelativeLayout.LayoutParams sValidationTextLayoutNormal;
     private static RelativeLayout.LayoutParams sValidationTextLayoutInverted;
 
-    private static final String LOGTAG = "FormAssistPopup";
+    private static final String LOGTAG = "GeckoFormAssistPopup";
 
     // The blocklist is so short that ArrayList is probably cheaper than HashSet.
     private static final Collection<String> sInputMethodBlocklist = Arrays.asList(new String[] {
                                             InputMethods.METHOD_GOOGLE_JAPANESE_INPUT, // bug 775850
                                             InputMethods.METHOD_OPENWNN_PLUS,          // bug 768108
                                             InputMethods.METHOD_SIMEJI,                // bug 768108
                                             InputMethods.METHOD_SWYPE,                 // bug 755909
                                             InputMethods.METHOD_SWYPE_BETA,            // bug 755909
@@ -179,28 +179,22 @@ public class FormAssistPopup extends Rel
         mValidationMessageText.setText(validationMessage);
 
         // We need to set the text as selected for the marquee text to work.
         mValidationMessageText.setSelected(true);
 
         positionAndShowPopup(rect, false);
     }
 
-    // Returns true if the popup is successfully shown, false otherwise
-    private boolean positionAndShowPopup(JSONObject rect, boolean isAutoComplete) {
+    private void positionAndShowPopup(JSONObject rect, boolean isAutoComplete) {
         // Don't show the form assist popup when using fullscreen VKB
         InputMethodManager imm =
                 (InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
         if (imm.isFullscreenMode())
-            return false;
-
-        if (!isShown()) {
-            setVisibility(VISIBLE);
-            startAnimation(mAnimation);
-        }
+            return;
 
         // Hide/show the appropriate popup contents
         if (mAutoCompleteList != null)
             mAutoCompleteList.setVisibility(isAutoComplete ? VISIBLE : GONE);
         if (mValidationMessage != null)
             mValidationMessage.setVisibility(isAutoComplete ? GONE : VISIBLE);
 
         if (sAutoCompleteMinWidth == 0) {
@@ -220,17 +214,21 @@ public class FormAssistPopup extends Rel
         int width = 0;
         int height = 0;
 
         try {
             left = (int) (rect.getDouble("x") * zoom - viewportMetrics.viewportRectLeft);
             top = (int) (rect.getDouble("y") * zoom - viewportMetrics.viewportRectTop);
             width = (int) (rect.getDouble("w") * zoom);
             height = (int) (rect.getDouble("h") * zoom);
-        } catch (JSONException e) { } 
+        } catch (JSONException e) {
+            // Bail if we can't get the correct dimensions for the popup.
+            Log.e(LOGTAG, "Error getting FormAssistPopup dimensions", e);
+            return;
+        }
 
         int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT;
         int popupLeft = left < 0 ? 0 : left;
 
         FloatSize viewport = viewportMetrics.getSize();
 
         // For autocomplete suggestions, if the input is smaller than the screen-width,
         // shrink the popup's width. Otherwise, keep it as FILL_PARENT.
@@ -287,17 +285,20 @@ public class FormAssistPopup extends Rel
         }
 
         RelativeLayout.LayoutParams layoutParams =
                 new RelativeLayout.LayoutParams(popupWidth, popupHeight);
         layoutParams.setMargins(popupLeft, popupTop, 0, 0);
         setLayoutParams(layoutParams);
         requestLayout();
 
-        return true;
+        if (!isShown()) {
+            setVisibility(VISIBLE);
+            startAnimation(mAnimation);
+        }
     }
 
     public void hide() {
         if (isShown()) {
             setVisibility(GONE);
             broadcastGeckoEvent("FormAssist:Hidden", null);
         }
     }