Bug 648101 Links opened in the foreground aren't inserting after the current tab r=misak
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 07 Apr 2011 19:36:05 +0100
changeset 7520 a44d9edd4600a278376f323e280378d14b47a679
parent 7519 d8a5c55ca78bb68eafd625469e2bf86c3172ca94
child 7521 0c36ce76850c9fa5834ada53debc83c72ababc00
push idunknown
push userunknown
push dateunknown
reviewersmisak
bugs648101
Bug 648101 Links opened in the foreground aren't inserting after the current tab r=misak
suite/browser/tabbrowser.xml
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -1494,49 +1494,49 @@
               if (aFromExternal)
                 flags |= nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
               try {
                 b.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset, aPostData);
               }
               catch (ex) { }
             }
 
+            // Check if we're opening a tab related to the current tab and
+            // move it to after the current tab.
+            // aReferrerURI is null or undefined if the tab is opened from
+            // an external application or bookmark, i.e. somewhere other
+            // than the current tab.
+            if ((aRelatedToCurrent || aReferrerURI) &&
+                this.mPrefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
+              var lastRelatedIndex = this.mLastRelatedIndex ||
+                                     this.tabContainer.selectedIndex;
+              this.moveTabTo(t, ++lastRelatedIndex);
+              this.mLastRelatedIndex = lastRelatedIndex;
+            }
+
             if (aFocusNewTab) {
               var parentTab = this.selectedTab;
               this.selectedTab = t;
               this.mPreviousTab = parentTab;
             }
             else {
               // We start our browsers out as inactive, and then maintain
               // activeness in the tab switcher.
               b.docShell.isActive = false;
 
               // The user opened a background tab, so updateCurrentBrowser
               // won't be called.  Explicitly clear the previous tab.
               this.mPreviousTab = null;
             }
+            this.tabContainer._handleNewTab(t);
 
             var evt = document.createEvent("Events");
             evt.initEvent("TabOpen", true, false);
             t.dispatchEvent(evt);
 
-            // Check if we're opening a tab related to the current tab and
-            // move it to after the current tab.
-            // aReferrerURI is null or undefined if the tab is opened from
-            // an external application or bookmark, i.e. somewhere other
-            // than the current tab.
-            if ((aRelatedToCurrent || aReferrerURI) &&
-                this.mPrefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
-              var lastRelatedIndex = this.mLastRelatedIndex ||
-                                     this.tabContainer.selectedIndex;
-              this.moveTabTo(t, ++lastRelatedIndex);
-              this.mLastRelatedIndex = lastRelatedIndex;
-            }
-            this.tabContainer._handleNewTab(t);
-
             return t;
           ]]>
         </body>
       </method>
 
       <method name="removeAllTabsBut">
         <parameter name="aTab"/>
         <body>