Bug 1180295 - Update the FormAssistPopup to account for the new dynamic toolbar model. r=rbarker
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 18 Aug 2015 14:27:20 -0400
changeset 258279 64c4d2d55f1582d694bce8d19a414942a360d5d3
parent 258278 3afafc10b12a3f05b4626d6e04efdf01be4aa15a
child 258280 bece031080d6664332029fb02923ca71d3adc3de
push id29249
push userryanvm@gmail.com
push dateWed, 19 Aug 2015 11:17:27 +0000
treeherdermozilla-central@706b23a03d1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker
bugs1180295
milestone43.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 1180295 - Update the FormAssistPopup to account for the new dynamic toolbar model. r=rbarker
mobile/android/base/BrowserApp.java
mobile/android/base/FormAssistPopup.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -1547,26 +1547,31 @@ public class BrowserApp extends GeckoApp
         ViewHelper.setTranslationY(browserChrome, -aToolbarTranslation);
         ViewHelper.setTranslationY(layerView, mToolbarHeight - aLayerViewTranslation);
 
         // Stop the progressView from moving all the way up so that we can still see a good chunk of it
         // when the chrome is offscreen.
         final float offset = getResources().getDimensionPixelOffset(R.dimen.progress_bar_scroll_offset);
         final float progressTranslationY = Math.min(aToolbarTranslation, mToolbarHeight - offset);
         ViewHelper.setTranslationY(progressView, -progressTranslationY);
+
+        if (mFormAssistPopup != null) {
+            mFormAssistPopup.onTranslationChanged();
+        }
     }
 
     @Override
     public void onMetricsChanged(ImmutableViewportMetrics aMetrics) {
         if (isHomePagerVisible() || mBrowserChrome == null) {
             return;
         }
 
-        if (mFormAssistPopup != null)
+        if (mFormAssistPopup != null) {
             mFormAssistPopup.onMetricsChanged(aMetrics);
+        }
     }
 
     @Override
     public void onPanZoomStopped() {
         if (!mDynamicToolbar.isEnabled() || isHomePagerVisible() ||
             mBrowserChrome.getVisibility() != View.VISIBLE) {
             return;
         }
--- a/mobile/android/base/FormAssistPopup.java
+++ b/mobile/android/base/FormAssistPopup.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
+import org.mozilla.gecko.animation.ViewHelper;
 import org.mozilla.gecko.gfx.FloatSize;
 import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.widget.SwipeDismissListViewTouchListener;
 import org.mozilla.gecko.widget.SwipeDismissListViewTouchListener.OnDismissCallback;
 
 import org.json.JSONArray;
@@ -279,22 +280,21 @@ public class FormAssistPopup extends Rel
         if (sAutoCompleteMinWidth == 0) {
             Resources res = mContext.getResources();
             sAutoCompleteMinWidth = (int) (res.getDimension(R.dimen.autocomplete_min_width));
             sAutoCompleteRowHeight = (int) (res.getDimension(R.dimen.autocomplete_row_height));
             sValidationMessageHeight = (int) (res.getDimension(R.dimen.validation_message_height));
         }
 
         float zoom = aMetrics.zoomFactor;
-        PointF offset = aMetrics.getMarginOffset();
 
         // These values correspond to the input box for which we want to
         // display the FormAssistPopup.
-        int left = (int) (mX * zoom - aMetrics.viewportRectLeft + offset.x);
-        int top = (int) (mY * zoom - aMetrics.viewportRectTop + offset.y);
+        int left = (int) (mX * zoom - aMetrics.viewportRectLeft);
+        int top = (int) (mY * zoom - aMetrics.viewportRectTop + ViewHelper.getTranslationY(GeckoAppShell.getLayerView()));
         int width = (int) (mW * zoom);
         int height = (int) (mH * zoom);
 
         int popupWidth = LayoutParams.MATCH_PARENT;
         int popupLeft = left < 0 ? 0 : left;
 
         FloatSize viewport = aMetrics.getSize();
 
@@ -378,16 +378,24 @@ public class FormAssistPopup extends Rel
         }
     }
 
     void onInputMethodChanged(String newInputMethod) {
         boolean blocklisted = sInputMethodBlocklist.contains(newInputMethod);
         broadcastGeckoEvent("FormAssist:Blocklisted", String.valueOf(blocklisted));
     }
 
+    void onTranslationChanged() {
+        ThreadUtils.assertOnUiThread();
+        if (!isShown()) {
+            return;
+        }
+        positionAndShowPopup();
+    }
+
     void onMetricsChanged(final ImmutableViewportMetrics aMetrics) {
         if (!isShown()) {
             return;
         }
 
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {