Bug 510302 Provide an overlay for content tab elements. r=asuth
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 13 Aug 2009 14:40:54 -0700
changeset 3299 6c421b0b5d95dae3b25ba2f2dced971e903d9f09
parent 3298 35844f7e72018e42cd50be1ea8023d49d50e20da
child 3300 6d6b3150eafe426211d4f230353a4daec1d472b8
push idunknown
push userunknown
push dateunknown
reviewersasuth
bugs510302
Bug 510302 Provide an overlay for content tab elements. r=asuth
mail/base/content/messenger.xul
mail/base/content/specialTabs.js
mail/base/content/specialTabs.xul
mail/base/jar.mn
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -42,16 +42,17 @@
 <?xml-stylesheet href="chrome://messenger/skin/mailWindow1.css" type="text/css"?>
 
 <?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/msgHdrViewOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/mailWindowOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/extraCustomizeItems.xul"?>
 <?xul-overlay href="chrome://messenger/content/mailOverlay.xul"?>
 <?xul-overlay href="chrome://messenger/content/editContactOverlay.xul"?>
+<?xul-overlay href="chrome://messenger/content/specialTabs.xul"?>
 
 <!DOCTYPE window [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
 %customizeToolbarDTD;
@@ -397,16 +398,17 @@
                   </vbox>
                 </vbox>
               </box>
             </vbox>
           </box>
         </box> <!-- end of mailContent -->
       </tabpanels>
     </tabmail>
+    <vbox id="contentTab"/>
   </hbox>
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
 #ifdef MOZILLA_1_9_1_BRANCH
             chromedir="&locale.dir;"
 #endif
             hidden="true"/>
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -84,69 +84,70 @@ var specialTabs = {
       // to re-use the same tab.
       let regEx = new RegExp("#.*");
 
       let contentUrl = aContentPage.replace(regEx, "");
 
       for (let selectedIndex = 0; selectedIndex < tabInfo.length;
            ++selectedIndex) {
         if (tabInfo[selectedIndex].mode.name == this.name &&
-            tabInfo[selectedIndex].panel.firstChild
+            tabInfo[selectedIndex].browser
                                   .getAttribute("src")
                                   .replace(regEx, "") == contentUrl) {
           // Ensure we go to the correct location on the page.
-          tabInfo[selectedIndex].panel.firstChild
+          tabInfo[selectedIndex].browser
                                 .setAttribute("src", aContentPage);
           return selectedIndex;
         }
       }
       return -1;
     },
     openTab: function onTabOpened(aTab, {contentPage: aContentPage}) {
-      // You can't dynamically change an iframe from a non-content to a content
-      // type, therefore we dynamically create the element instead.
-      let iframe = document.createElement("browser");
-      iframe.setAttribute("type", "content-primary");
-      iframe.setAttribute("flex", "1");
-      iframe.setAttribute("autocompleteenabled", false);
-      iframe.setAttribute("disablehistory", true);
-      iframe.setAttribute("id", "contentTabType" + this.lastBrowserId);
+      let clone = document.getElementById("contentTab").firstChild.cloneNode(true);
+
+      clone.setAttribute("id", "contentTab" + this.lastBrowserId);
+      clone.setAttribute("collapsed", false);
+      clone.setAttribute("type", "content-primary");
+
+      aTab.panel.appendChild(clone);
+
+      aTab.browser = aTab.panel.getElementsByTagName("browser")[0];
+
+      aTab.browser.setAttribute("id", "contentTabBrowser" + this.lastBrowserId);
 
       function onDOMTitleChanged(aEvent) {
         document.getElementById("tabmail").setTabTitle(aTab);
       }
       // Save the function we'll use as listener so we can remove it later.
       aTab.contentTabType = { titleListener: onDOMTitleChanged };
       // Add the listener.
-      iframe.addEventListener("DOMTitleChanged",
-                              aTab.contentTabType.titleListener, true);
+      aTab.browser.addEventListener("DOMTitleChanged",
+                                    aTab.contentTabType.titleListener, true);
 
       aTab.title = this.loadingTabString;
 
-      aTab.panel.appendChild(iframe);
-
-      iframe.setAttribute("src", aContentPage);
+      aTab.browser.setAttribute("src", aContentPage);
 
-      let findbar = document.createElement("findbar");
-      findbar.setAttribute("browserid", "contentTabType" + this.lastBrowserId);
-      aTab.panel.appendChild(findbar);
+      aTab.findbar = aTab.panel.getElementsByTagName("findbar")[0];
+      aTab.findbar.setAttribute("browserid",
+                                "contentTabBrowser" + this.lastBrowserId);
       this.lastBrowserId++;
     },
     closeTab: function onTabClosed(aTab) {
-      aTab.panel.firstChild.removeEventListener("DOMTitleChanged",
+      aTab.browser.removeEventListener("DOMTitleChanged",
                                                 aTab.contentTabType.titleListener, true);
     },
     saveTabState: function onSaveTabState(aTab) {
-      aTab.panel.firstChild.setAttribute("type", "content-targetable");
+      aTab.browser.setAttribute("type", "content-targetable");
     },
     showTab: function onShowTab(aTab) {
-      aTab.panel.firstChild.setAttribute("type", "content-primary");
+      aTab.browser.setAttribute("type", "content-primary");
     },
     onTitleChanged: function onTitleChanged(aTab) {
-      aTab.title = aTab.panel.firstChild.contentDocument.title;
+      aTab.title = aTab.browser.contentDocument.title;
     },
     supportsCommand: function supportsCommand(aTab, aCommand) {
       switch (aCommand) {
         case "cmd_fullZoomReduce":
         case "cmd_fullZoomEnlarge":
         case "cmd_fullZoomReset":
         case "cmd_fullZoomToggle":
         case "cmd_find":
@@ -212,17 +213,17 @@ var specialTabs = {
           break;
         // XXX print preview not currently supported - bug 497994 to implement.
         //case "cmd_printpreview":
         //  PrintUtils.printPreview();
         //  break;
       }
     },
     getBrowser: function getBrowser(aTab) {
-      return aTab.panel.firstChild;
+      return aTab.browser;
     }
   },
 
   /**
    * Tests whether the application has been upgraded
    * or not. Updates the pref with the latest version,
    * returns true if upgraded, false otherwise.
    */
new file mode 100644
--- /dev/null
+++ b/mail/base/content/specialTabs.xul
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is Thunderbird Special Tabs.
+   -
+   - The Initial Developer of the Original Code is
+   - Mozilla Messaging.
+   - Portions created by the Initial Developer are Copyright (C) 2009
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -   Mark Banner <bugzilla@standard8.plus.com>
+   -
+   - Alternatively, the contents of this file may be used under the terms of
+   - either the GNU General Public License Version 2 or later (the "GPL"), or
+   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+   - in which case the provisions of the GPL or the LGPL are applicable instead
+   - of those above. If you wish to allow use of your version of this file only
+   - under the terms of either the GPL or the LGPL, and not to allow others to
+   - use your version of this file under the terms of the MPL, indicate your
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
+
+<overlay id="specialTabs"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <vbox id="contentTab" collapsed="true">
+    <vbox flex="1">
+      <browser type="content-targetable" flex="1" disablehistory="true"/>
+      <findbar/>
+    </vbox>
+  </vbox>
+</overlay>
+
--- a/mail/base/jar.mn
+++ b/mail/base/jar.mn
@@ -37,16 +37,17 @@ messenger.jar:
     content/messenger/widgetglue.js                 (content/widgetglue.js)
 *   content/messenger/SearchDialog.xul              (content/SearchDialog.xul)
     content/messenger/SearchDialog.js               (content/SearchDialog.js)
 *   content/messenger/ABSearchDialog.xul            (content/ABSearchDialog.xul)
 *   content/messenger/ABSearchDialog.js             (content/ABSearchDialog.js)
 *   content/messenger/FilterListDialog.xul          (content/FilterListDialog.xul)
 *   content/messenger/FilterListDialog.js           (content/FilterListDialog.js)
     content/messenger/specialTabs.js                (content/specialTabs.js)
+    content/messenger/specialTabs.xul               (content/specialTabs.xul)
 *   content/messenger/subscribe.xul                 (content/subscribe.xul)
     content/messenger/subscribe.js                  (content/subscribe.js)
 *   content/messenger/aboutDialog.xul               (content/aboutDialog.xul)
 *   content/messenger/aboutDialog.js                (content/aboutDialog.js)
 *   content/messenger/aboutRights.xhtml             (content/aboutRights.xhtml)
 *   content/messenger/systemIntegrationDialog.xul   (content/systemIntegrationDialog.xul)
 *   content/messenger/systemIntegrationDialog.js    (content/systemIntegrationDialog.js)
     content/messenger/folderPane.js                 (content/folderPane.js)