Bug 1442058 - Fold tabbrowser-browser-* bindings into browser binding. r=Gijs, jryans draft
authorTim Nguyen <ntim.bugs@gmail.com>
Thu, 01 Mar 2018 00:29:47 +0000
changeset 761384 aeb33e789f6c0bd9fa38218b4f2b188bda88e3dc
parent 761344 17e47288c2249ac21bd2d0585b19c835984ed32b
push id100951
push userbmo:ntim.bugs@gmail.com
push dateThu, 01 Mar 2018 00:30:19 +0000
reviewersGijs, jryans
bugs1442058
milestone60.0a1
Bug 1442058 - Fold tabbrowser-browser-* bindings into browser binding. r=Gijs, jryans MozReview-Commit-ID: LmzEsyh4wZL
browser/base/content/browser.css
browser/base/content/tabbrowser.js
browser/base/content/tabbrowser.xml
devtools/client/responsive.html/browser/tunnel.js
toolkit/content/widgets/browser.xml
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -48,24 +48,16 @@ searchbar {
 }
 
 /* Prevent shrinking the page content to 0 height and width */
 .browserStack > browser {
   min-height: 25px;
   min-width: 25px;
 }
 
-.browserStack > browser {
-  -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-browser");
-}
-
-.browserStack > browser[remote="true"] {
-  -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-remote-browser");
-}
-
 toolbar[customizable="true"] {
   -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar");
 }
 
 %ifdef XP_MACOSX
 #toolbar-menubar {
   -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-menubar-stub");
 }
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -2266,16 +2266,17 @@ class TabBrowser {
     // Supported parameters:
     // userContextId, remote, remoteType, isPreloadBrowser,
     // uriIsAboutBlank, sameProcessAsFrameLoader
 
     const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
     let b = document.createElementNS(NS_XUL, "browser");
     b.permanentKey = {};
+    b.setAttribute("tabbrowser", "true");
     b.setAttribute("type", "content");
     b.setAttribute("message", "true");
     b.setAttribute("messagemanagergroup", "browsers");
     b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
     b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
 
     if (aParams.userContextId) {
       b.setAttribute("usercontextid", aParams.userContextId);
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -26,17 +26,17 @@
                   flex="1" eventnode="document" xbl:inherits="tabcontainer"
                   onselect="if (event.target.localName == 'tabpanels') gBrowser.updateCurrentBrowser();">
         <xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
           <xul:notificationbox flex="1" notificationside="top">
             <xul:hbox flex="1" class="browserSidebarContainer">
               <xul:vbox flex="1" class="browserContainer">
                 <xul:stack flex="1" class="browserStack" anonid="browserStack">
                   <xul:browser anonid="initialBrowser" type="content" message="true" messagemanagergroup="browsers"
-                               primary="true" blank="true"
+                               primary="true" blank="true" tabbrowser="true"
                                xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup,selectmenulist,datetimepicker"/>
                 </xul:stack>
               </xul:vbox>
             </xul:hbox>
           </xul:notificationbox>
         </xul:tabpanels>
       </xul:tabbox>
       <children/>
@@ -2365,69 +2365,9 @@
 
           return val;
         ]]>
         </setter>
       </property>
     </implementation>
   </binding>
 
-  <binding id="tabbrowser-browser"
-           extends="chrome://global/content/bindings/browser.xml#browser">
-    <implementation>
-      <field name="tabModalPromptBox">null</field>
-
-      <!-- throws exception for unknown schemes -->
-      <method name="loadURIWithFlags">
-        <parameter name="aURI"/>
-        <parameter name="aFlags"/>
-        <parameter name="aReferrerURI"/>
-        <parameter name="aCharset"/>
-        <parameter name="aPostData"/>
-        <body>
-          <![CDATA[
-            var params = arguments[1];
-            if (typeof(params) == "number") {
-              params = {
-                flags: aFlags,
-                referrerURI: aReferrerURI,
-                charset: aCharset,
-                postData: aPostData,
-              };
-            }
-            _loadURIWithFlags(this, aURI, params);
-          ]]>
-        </body>
-      </method>
-    </implementation>
-  </binding>
-
-  <binding id="tabbrowser-remote-browser"
-           extends="chrome://global/content/bindings/remote-browser.xml#remote-browser">
-    <implementation>
-      <field name="tabModalPromptBox">null</field>
-
-      <!-- throws exception for unknown schemes -->
-      <method name="loadURIWithFlags">
-        <parameter name="aURI"/>
-        <parameter name="aFlags"/>
-        <parameter name="aReferrerURI"/>
-        <parameter name="aCharset"/>
-        <parameter name="aPostData"/>
-        <body>
-          <![CDATA[
-            var params = arguments[1];
-            if (typeof(params) == "number") {
-              params = {
-                flags: aFlags,
-                referrerURI: aReferrerURI,
-                charset: aCharset,
-                postData: aPostData,
-              };
-            }
-            _loadURIWithFlags(this, aURI, params);
-          ]]>
-        </body>
-      </method>
-    </implementation>
-  </binding>
-
 </bindings>
--- a/devtools/client/responsive.html/browser/tunnel.js
+++ b/devtools/client/responsive.html/browser/tunnel.js
@@ -166,23 +166,16 @@ function tunnelToInnerBrowser(outer, inn
       // remoteness of the inner browser.
       outer.setAttribute("remote", "true");
       outer.setAttribute("remoteType", inner.remoteType);
 
       // Clear out any cached state that references the current non-remote XBL binding,
       // such as form fill controllers.  Otherwise they will remain in place and leak the
       // outer docshell.
       outer.destroy();
-      // The XBL binding for remote browsers uses the message manager for many actions in
-      // the UI and that works well here, since it gives us one main thing we need to
-      // route to the inner browser (the messages), instead of having to tweak many
-      // different browser properties.  It is safe to alter a XBL binding dynamically.
-      // The content within is not reloaded.
-      outer.style.MozBinding = "url(chrome://browser/content/tabbrowser.xml" +
-                               "#tabbrowser-remote-browser)";
 
       // The constructor of the new XBL binding is run asynchronously and there is no
       // event to signal its completion.  Spin an event loop to watch for properties that
       // are set by the contructor.
       Services.tm.spinEventLoopUntil(() => {
         return outer._remoteWebNavigation;
       });
 
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -8,16 +8,17 @@
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <binding id="browser" extends="xul:browser" role="outerdoc">
     <content clickthrough="never">
       <children/>
     </content>
     <implementation type="application/javascript" implements="nsIObserver, nsIDOMEventListener, nsIMessageListener, nsIBrowser">
+
       <property name="autoscrollEnabled">
         <getter>
           <![CDATA[
             if (this.getAttribute("autoscroll") == "false")
               return false;
 
             return this.mPrefs.getBoolPref("general.autoScroll", true);
           ]]>
@@ -119,24 +120,38 @@
       <method name="loadURIWithFlags">
         <parameter name="aURI"/>
         <parameter name="aFlags"/>
         <parameter name="aReferrerURI"/>
         <parameter name="aCharset"/>
         <parameter name="aPostData"/>
         <body>
           <![CDATA[
+            var params = arguments[1];
+
+            // Use global _loadURIWithFlags if this is a tab browser
+            if (this.isTabBrowser) {
+              if (typeof(params) == "number") {
+                params = {
+                  flags: aFlags,
+                  referrerURI: aReferrerURI,
+                  charset: aCharset,
+                  postData: aPostData,
+                };
+              }
+              return _loadURIWithFlags(this, aURI, params);
+            }
+
             if (!aURI)
               aURI = "about:blank";
 
             var aReferrerPolicy = Ci.nsIHttpChannel.REFERRER_POLICY_UNSET;
             var aTriggeringPrincipal;
 
             // Check for loadURIWithFlags(uri, { ... });
-            var params = arguments[1];
             if (params && typeof(params) == "object") {
               aFlags = params.flags;
               aReferrerURI = params.referrerURI;
               if ("referrerPolicy" in params) {
                 aReferrerPolicy = params.referrerPolicy;
               }
               if ("triggeringPrincipal" in params) {
                 aTriggeringPrincipal = params.triggeringPrincipal;
@@ -1668,16 +1683,26 @@
               name: aLinks[i + 1],
               type: aLinks[i + 2],
             });
           }
           this.droppedLinkHandler(null, links, aTriggeringPrincipal);
           return true;
         ]]></body>
       </method>
+
+      <!-- Tab browser specific fields -->
+      <field name="tabModalPromptBox">null</field>
+      <property name="isTabBrowser">
+        <getter>
+          <![CDATA[
+            return this.getAttribute("tabbrowser") == "true";
+          ]]>
+        </getter>
+      </property>
     </implementation>
 
     <handlers>
       <handler event="keypress" keycode="VK_F7" group="system">
         <![CDATA[
           if (event.defaultPrevented || !event.isTrusted)
             return;