Bug 1089000 - UITour: Remove broken code for detaching a tab to a new window. r=Unfocused, a=sledru
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 21 Jan 2015 17:27:47 -0800
changeset 243686 fe2ce463edba
parent 243685 ba8e83fca8f2
child 243687 b005871a2349
push id4436
push usermozilla@noorenberghe.ca
push date2015-02-05 02:33 +0000
treeherdermozilla-beta@5690b3943d75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, sledru
bugs1089000
milestone36.0
Bug 1089000 - UITour: Remove broken code for detaching a tab to a new window. r=Unfocused, a=sledru
browser/base/content/tabbrowser.xml
browser/modules/UITour.jsm
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2566,25 +2566,16 @@
       <method name="replaceTabWithWindow">
         <parameter name="aTab"/>
         <parameter name="aOptions"/>
         <body>
           <![CDATA[
             if (this.tabs.length == 1)
               return null;
 
-            let event = new CustomEvent("TabBecomingWindow", {
-              bubbles: true,
-              cancelable: true
-            });
-            aTab.dispatchEvent(event);
-            if (event.defaultPrevented) {
-              return null;
-            }
-
             var options = "chrome,dialog=no,all";
             for (var name in aOptions)
               options += "," + name + "=" + aOptions[name];
 
             // tell a new window to take the "dropped" tab
             return window.openDialog(getBrowserURL(), "_blank", options, aTab);
           ]]>
         </body>
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -70,20 +70,17 @@ this.UITour = {
   seenPageIDs: null,
   pageIDSourceBrowsers: new WeakMap(),
   /* Map from browser chrome windows to a Set of <browser>s in which a tour is open (both visible and hidden) */
   tourBrowsersByWindow: new WeakMap(),
   urlbarCapture: new WeakMap(),
   appMenuOpenForAnnotation: new Set(),
   availableTargetsCache: new WeakMap(),
 
-  _detachingTab: false,
   _annotationPanelMutationObservers: new WeakMap(),
-  _queuedEvents: [],
-  _pendingDoc: null,
 
   highlightEffects: ["random", "wobble", "zoom", "color"],
   targets: new Map([
     ["accountStatus", {
       query: (aDocument) => {
         let statusButton = aDocument.getElementById("PanelUI-fxa-status");
         return aDocument.getAnonymousElementByAttribute(statusButton,
                                                         "class",
@@ -364,28 +361,16 @@ this.UITour = {
       return false;
     }
 
     // Do this before bailing if there's no tab, so later we can pick up the pieces:
     window.gBrowser.tabContainer.addEventListener("TabSelect", this);
 
     if (!window.gMultiProcessBrowser) { // Non-e10s. See bug 1089000.
       contentDocument = browser.contentWindow.document;
-      if (!tab) {
-        // This should only happen while detaching a tab:
-        if (this._detachingTab) {
-          log.debug("Got event while detatching a tab");
-          this._queuedEvents.push(aEvent);
-          this._pendingDoc = Cu.getWeakReference(contentDocument);
-          return;
-        }
-        log.error("Discarding tabless UITour event (" + action + ") while not detaching a tab." +
-                       "This shouldn't happen!");
-        return;
-      }
     }
 
     switch (action) {
       case "registerPageID": {
         // This is only relevant if Telemtry is enabled.
         if (!UITelemetry.enabled) {
           log.debug("registerPageID: Telemery disabled, not doing anything");
           break;
@@ -648,80 +633,54 @@ this.UITour = {
       }
     }
 
     if (!this.tourBrowsersByWindow.has(window)) {
       this.tourBrowsersByWindow.set(window, new Set());
     }
     this.tourBrowsersByWindow.get(window).add(browser);
 
-    // We don't have a tab if it's being detached or we're in a <browser> without a tab.
+    // We don't have a tab if we're in a <browser> without a tab.
     if (tab) {
       tab.addEventListener("TabClose", this);
-      if (!window.gMultiProcessBrowser) {
-        tab.addEventListener("TabBecomingWindow", this);
-      }
     }
 
     window.addEventListener("SSWindowClosing", this);
 
     return true;
   },
 
   handleEvent: function(aEvent) {
     log.debug("handleEvent: type =", aEvent.type, "event =", aEvent);
     switch (aEvent.type) {
       case "pagehide": {
         let window = this.getChromeWindow(aEvent.target);
         this.teardownTourForWindow(window);
         break;
       }
 
-      case "TabBecomingWindow":
-        this._detachingTab = true;
-        // Fall through
       case "TabClose": {
         let tab = aEvent.target;
         let window = tab.ownerDocument.defaultView;
         this.teardownTourForBrowser(window, tab.linkedBrowser, true);
         break;
       }
 
       case "TabSelect": {
         let window = aEvent.target.ownerDocument.defaultView;
 
+        // Teardown the browser of the tab we just switched away from.
         if (aEvent.detail && aEvent.detail.previousTab) {
           let previousTab = aEvent.detail.previousTab;
           let openTourWindows = this.tourBrowsersByWindow.get(window);
           if (openTourWindows.has(previousTab.linkedBrowser)) {
             this.teardownTourForBrowser(window, previousTab.linkedBrowser, false);
           }
         }
 
-        let pendingDoc;
-        if (this._detachingTab && this._pendingDoc && (pendingDoc = this._pendingDoc.get())) {
-          let selectedTab = window.gBrowser.selectedTab;
-          if (selectedTab.linkedBrowser.contentDocument == pendingDoc) {
-            if (!this.tourBrowsersByWindow.get(window)) {
-              this.tourBrowsersByWindow.set(window, new Set());
-            }
-            this.tourBrowsersByWindow.get(window).add(selectedTab.linkedBrowser);
-            this.pendingDoc = null;
-            this._detachingTab = false;
-            while (this._queuedEvents.length) {
-              try {
-                this.onPageEvent(this._queuedEvents.shift());
-              } catch (ex) {
-                log.error(ex);
-              }
-            }
-            break;
-          }
-        }
-
         break;
       }
 
       case "SSWindowClosing": {
         let window = aEvent.target;
         this.teardownTourForWindow(window);
         break;
       }
@@ -768,17 +727,16 @@ this.UITour = {
       this.setExpiringTelemetryBucket(pageID, aTourPageClosing ? "closed" : "inactive");
     }
 
     let openTourBrowsers = this.tourBrowsersByWindow.get(aWindow);
     if (aTourPageClosing) {
       let tab = aWindow.gBrowser.getTabForBrowser(aBrowser);
       if (tab) { // Handle standalone <browser>
         tab.removeEventListener("TabClose", this);
-        tab.removeEventListener("TabBecomingWindow", this);
         if (openTourBrowsers) {
           openTourBrowsers.delete(aBrowser);
         }
       }
     }
 
     this.hideHighlight(aWindow);
     this.hideInfo(aWindow);