Bug 1155819 - Tablet: anchor doorhanger under back button. r=ally, a=lmandel
authorChenxia Liu <liuche@mozilla.com>
Fri, 17 Apr 2015 17:08:26 -0700
changeset 265713 54478022f462a228b12e07263969db038d94e4ca
parent 265712 ad5bc581bfc5ef5e44b46f328f0370b7808e0a90
child 265714 42b0638603a05e0d449bdd00595e5ba30e09234e
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally, lmandel
bugs1155819
milestone39.0a2
Bug 1155819 - Tablet: anchor doorhanger under back button. r=ally, a=lmandel
mobile/android/base/toolbar/BrowserToolbarTabletBase.java
mobile/android/base/widget/AnchoredPopup.java
--- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
+++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
@@ -137,16 +137,21 @@ abstract class BrowserToolbarTabletBase 
         backButton.setPrivateMode(isPrivate);
         forwardButton.setPrivateMode(isPrivate);
         for (int i = 0; i < actionItemBar.getChildCount(); ++i) {
             final MenuItemActionBar child = (MenuItemActionBar) actionItemBar.getChildAt(i);
             child.setPrivateMode(isPrivate);
         }
     }
 
+    @Override
+    public View getDoorHangerAnchor() {
+        return backButton;
+    }
+
     protected boolean canDoBack(final Tab tab) {
         return (tab.canDoBack() && !isEditing());
     }
 
     protected boolean canDoForward(final Tab tab) {
         return (tab.canDoForward() && !isEditing());
     }
 
--- a/mobile/android/base/widget/AnchoredPopup.java
+++ b/mobile/android/base/widget/AnchoredPopup.java
@@ -95,18 +95,20 @@ public abstract class AnchoredPopup exte
             offsetY = mContext.getResources().getDimensionPixelOffset(R.dimen.doorhanger_GB_offsetY);
             if (mAnchor == null) {
               mAnchor = decorView;
             }
             showAsDropDown(mAnchor, 0, -offsetY);
             return;
         }
 
-        // If the anchor is null or out of the window bounds, just show the popup at the top of the
-        // root view.
-        if (mAnchor == null || anchorLocation[1] < 0) {
-            showAtLocation(decorView, Gravity.NO_GRAVITY, 0, offsetY);
-            return;
+        if (HardwareUtils.isTablet()) {
+            showAsDropDown(mAnchor, 0, 0);
+        } else {
+            // If the anchor is null or out of the window bounds, just show the popup at the top of the
+            // root view.
+            final boolean validAnchor = (mAnchor != null) && (anchorLocation[1] > 0);
+            final View anchor = validAnchor ? mAnchor : decorView;
+
+            showAtLocation(anchor, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);
         }
-
-        showAtLocation(mAnchor, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY);
     }
 }