Bug 1039506 - speed up _getTabForContentWindow. r=ttaubert
authorDão Gottwald <dao@mozilla.com>
Sat, 26 Jul 2014 21:34:50 +0200
changeset 196304 a51c22a0fbf0603323b345adad3d36c9dc734f5c
parent 196303 2b5e76962106455ac98106fb15d63f06a65f1c27
child 196305 29b357a370f340c74744ad6f05ede59d1b2061f1
push id27209
push usercbook@mozilla.com
push dateMon, 28 Jul 2014 13:49:10 +0000
treeherdermozilla-central@d77f6a96ff96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1039506
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1039506 - speed up _getTabForContentWindow. r=ttaubert
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -356,16 +356,27 @@
           ]]>
         </body>
       </method>
 
       <method name="_getTabForContentWindow">
         <parameter name="aWindow"/>
         <body>
         <![CDATA[
+          // When not using remote browsers, we can take a fast path by getting
+          // directly from the content window to the browser without looping
+          // over all browsers.
+          if (!gMultiProcessBrowser) {
+            let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
+                                 .getInterface(Ci.nsIWebNavigation)
+                                 .QueryInterface(Ci.nsIDocShell)
+                                 .chromeEventHandler;
+            return this._getTabForBrowser(browser);
+          }
+
           for (let i = 0; i < this.browsers.length; i++) {
             if (this.browsers[i].contentWindow == aWindow)
               return this.tabs[i];
           }
           return null;
         ]]>
         </body>
       </method>