Bug 677670 - Make the new tab popup work on tablets. r=mbrubeck
authorWes Johnston <wjohnston@mozilla.com>
Mon, 26 Sep 2011 18:28:54 -0700
changeset 78905 1f800c226837a386f47b17c50e79d0a061df13db
parent 78904 ca14a168605ba05b9d1240b6e984908091905b61
child 78906 cf6245609f485683aca3c56d1dae303d551a1d6c
child 78962 e2f5052798cc825f726ac083ed438724a5ef57b5
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs677670
milestone9.0a1
first release with
nightly linux32
1f800c226837 / 9.0a1 / 20110927030845 / files
nightly linux64
1f800c226837 / 9.0a1 / 20110927030845 / files
nightly mac
1f800c226837 / 9.0a1 / 20110927030845 / files
nightly win32
1f800c226837 / 9.0a1 / 20110927030845 / files
nightly win64
1f800c226837 / 9.0a1 / 20110927030845 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 677670 - Make the new tab popup work on tablets. r=mbrubeck
mobile/chrome/content/bindings/arrowbox.xml
mobile/chrome/content/browser.xul
mobile/chrome/content/common-ui.js
mobile/themes/core/honeycomb/platform.css
--- a/mobile/chrome/content/bindings/arrowbox.xml
+++ b/mobile/chrome/content/bindings/arrowbox.xml
@@ -113,29 +113,37 @@
               let anchorClass = "";
               let hideArrow = false;
               if (horizPos == 0) {
                 container.orient = "vertical";
                 arrowbox.orient = "";
                 if (vertPos == 0) {
                   hideArrow = true;
                 } else {
-                  arrowbox.style.marginLeft = ((targetRect.left - popupRect.left) + (targetRect.width / 2) - HALF_ARROW_WIDTH) + "px";
+                  let anchorPosX = 0.5;
+                  // check for hasAttribute because, in some cases, anchorNode is actually a rect
+                  if (this.anchorNode && this.anchorNode.hasAttribute && this.anchorNode.hasAttribute("anchorPosX"))
+                     anchorPosX = parseFloat(this.anchorNode.getAttribute("anchorPosX")) || 0.5;
+                  arrowbox.style.marginLeft = ((targetRect.left - popupRect.left) + (targetRect.width * anchorPosX) - HALF_ARROW_WIDTH) + "px";
                   if (vertPos == 1) {
                     container.dir = "normal"; 
                     anchorClass = "top";
                   } else if (vertPos == -1) {
                     container.dir = "reverse"; 
                     anchorClass = "bottom";
                   }
                 }
               } else if (vertPos == 0) {
                 container.orient = "";
                 arrowbox.orient = "vertical";
-                arrowbox.style.marginTop = ((targetRect.top - popupRect.top) + (targetRect.height / 2) - HALF_ARROW_WIDTH) + "px";
+                  let anchorPosY = 0.5;
+                  // check for hasAttribute because, in some cases, anchorNode is actually a rect
+                  if (this.anchorNode && this.anchorNode.hasAttribute && this.anchorNode.hasAttribute("anchorPosY"))
+                     anchorPosY = parseFloat(this.anchorNode.getAttribute("anchorPosY")) || 0.5;
+                arrowbox.style.marginTop = ((targetRect.top - popupRect.top) + (targetRect.height * anchorPosY) - HALF_ARROW_WIDTH) + "px";
                 if (horizPos == 1) {
                   container.dir = "ltr"; 
                   anchorClass = "left";
                 } else if (horizPos == -1) {
                   container.dir = "rtl";
                   anchorClass = "right";
                 }
               } else {
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -216,17 +216,17 @@
       <!-- Page Area -->
       <stack id="page-stack" observes="bcast_urlbarState">
         <scrollbox id="page-scrollbox">
           <vbox>
             <!-- Main Toolbar -->
             <box id="toolbar-container" class="panel-dark toolbar-height">
               <box id="toolbar-moveable-container" observes="bcast_uidiscovery">
                 <toolbar id="toolbar-main" class="panel-dark viewable-width" observes="bcast_urlbarState">
-                  <toolbarbutton id="tool-tabs" class="button-actionbar" command="cmd_showTabs"/>
+                  <toolbarbutton id="tool-tabs" class="button-actionbar" command="cmd_showTabs" anchorPosX="0.3"/>
                   <toolbarbutton id="tool-back2" class="tool-back button-actionbar" command="cmd_back"/>
                   <toolbarbutton id="tool-forward2" class="tool-forward button-actionbar" command="cmd_forward"/>
 #ifdef MOZ_PLATFORM_MAEMO
 #if MOZ_PLATFORM_MAEMO != 6
                   <toolbarbutton id="tool-app-switch" oncommand="BrowserUI.switchTask();"/>
 #endif
 #endif
                   <hbox id="urlbar-container" flex="1" observes="bcast_urlbarState">
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -196,16 +196,19 @@ var NewTabPopup = {
     }
 
     this._tabs = [];
     this.box.hidden = true;
     BrowserUI.popPopup(this);
   },
 
   show: function nt_show(aTab) {
+    if (Util.isTablet() && TabsPopup.visible)
+      return;
+
     BrowserUI.pushPopup(this, this.box);
 
     this._tabs.push(aTab);
     this._updateLabel();
 
     this.box.hidden = false;
     let tabRect = aTab.getBoundingClientRect();
     this.box.top = tabRect.top + (tabRect.height / 2);
@@ -214,17 +217,20 @@ var NewTabPopup = {
     setTimeout((function() {
       let boxRect = this.box.getBoundingClientRect();
       this.box.top = tabRect.top + (tabRect.height / 2) - (boxRect.height / 2);
 
       // We don't use anchorTo() here because the tab
       // being anchored to might be overflowing the tabs
       // scrollbox which confuses the dynamic arrow direction
       // calculation (see bug 662520).
-      if (Elements.tabList.getBoundingClientRect().left < 0)
+      if (Util.isTablet()) {
+        let toolbarbutton = document.getElementById("tool-tabs");
+        this.box.anchorTo(toolbarbutton, "after_start");
+      } else if (Elements.tabList.getBoundingClientRect().left < 0)
         this.box.pointLeftAt(aTab);
       else
         this.box.pointRightAt(aTab);
     }).bind(this), 0);
 
     if (this._timeout)
       clearTimeout(this._timeout);
 
--- a/mobile/themes/core/honeycomb/platform.css
+++ b/mobile/themes/core/honeycomb/platform.css
@@ -575,18 +575,17 @@ arrowbox {
 dialog,
 .arrowbox-dark .panel-arrowcontent,
 .panel-dark,
 .dialog-dark {
   color: @color_text_default@;
   background: @color_background_default@;
 }
 
-dialog,
-.arrowbox-dark .panel-arrowcontent {
+dialog {
   border: @border_width_small@ solid @color_dialog_border@;
   box-shadow: 0 0 @shadow_width_tiny@ @shadow_width_medium@ @color_shadow_light@;
 }
 
 dialog,
 .dialog-dark {
   margin: @margin_xxxnormal@ !important;
 }