[tbb-commits] [tor-launcher/master] Bug 29197: Remove use of overlays (ESR68 compatibility).

gk at torproject.org gk at torproject.org
Wed Aug 7 18:45:42 UTC 2019


commit 8bc4a8869936cfc782d1f4c749f7608ead6ddf18
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Tue Jul 30 16:34:27 2019 -0400

    Bug 29197: Remove use of overlays (ESR68 compatibility).
    
    Use the window.MozXULElement.parseXULToFragment() function to
    parse shared XUL.
---
 src/chrome/content/localePicker.xul                |  4 +-
 ...ings-overlay.xul => network-settings-shared.js} | 48 +++++++++++-----------
 src/chrome/content/network-settings-wizard.xul     | 10 ++---
 src/chrome/content/network-settings.js             | 36 ++++++++++++++++
 src/chrome/content/network-settings.xul            | 18 ++++----
 5 files changed, 76 insertions(+), 40 deletions(-)

diff --git a/src/chrome/content/localePicker.xul b/src/chrome/content/localePicker.xul
index 6030468..1d0987c 100644
--- a/src/chrome/content/localePicker.xul
+++ b/src/chrome/content/localePicker.xul
@@ -9,9 +9,7 @@
 <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
                  type="text/css"?>
 
-<!DOCTYPE overlay SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
-
-<?xul-overlay href="chrome://torlauncher/content/network-settings-overlay.xul"?>
+<!DOCTYPE wizard SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
 
 <wizard id="TorLauncherLocalePicker"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
diff --git a/src/chrome/content/network-settings-overlay.xul b/src/chrome/content/network-settings-shared.js
similarity index 91%
rename from src/chrome/content/network-settings-overlay.xul
rename to src/chrome/content/network-settings-shared.js
index 35b9fc7..206872b 100644
--- a/src/chrome/content/network-settings-overlay.xul
+++ b/src/chrome/content/network-settings-shared.js
@@ -1,16 +1,9 @@
-<?xml version="1.0"?>
-<!--
-   - Copyright (c) 2018, The Tor Project, Inc.
-   - See LICENSE for licensing information.
-   - vim: set sw=2 sts=2 ts=8 et syntax=xml:
-  -->
-
-<!DOCTYPE overlay SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
-
-<overlay id="TorNetworkSettingsOverlay"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        xmlns:html="http://www.w3.org/1999/xhtml">
+// Copyright (c) 2019, The Tor Project, Inc.
+// See LICENSE for licensing information.
+//
+// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
 
+var proxySettings = `
   <vbox id="proxySettings">
     <hbox align="center">
       <checkbox id="useProxy" groupboxID="proxySpecificSettings"
@@ -73,20 +66,16 @@
       </grid>
     </groupbox>
   </vbox>
+`;
 
-  <vbox id="proxyHelpContent">
+var proxyHelpContent = `
+  <vbox id="proxyHelpContent" hidden="true">
     <hbox align="middle"><label>&torsettings.proxyHelpTitle;</label></hbox>
     <description>&torsettings.proxyHelp1;</description>
   </vbox>
+`;
 
-  <groupbox id="firewallSpecificSettings">
-    <hbox align="center">
-      <label value="&torsettings.firewall.allowedPorts;"
-             control="firewallAllowedPorts"/>
-      <textbox id="firewallAllowedPorts" value="80,443"/>
-    </hbox>
-  </groupbox>
-
+var bridgeSettings = `
   <vbox id="bridgeSettings">
     <checkbox id="useBridges" groupboxID="bridgeSpecificSettings"
                 label="&torsettings.useBridges.checkbox;"
@@ -139,13 +128,17 @@
       </vbox>
     </groupbox>
   </vbox>
+`;
 
-  <vbox id="bridgeHelpContent">
+var bridgeHelpContent = `
+  <vbox id="bridgeHelpContent" hidden="true">
     <hbox align="middle"><label>&torsettings.bridgeHelpTitle;</label></hbox>
     <description>&torsettings.bridgeHelp1;</description>
     <description>&torsettings.bridgeHelp2;</description>
   </vbox>
+`;
 
+var progressContent = `
   <vbox id="progressContent">
     <hbox class="tbb-header" pack="center">
       <image class="tbb-logo"/>
@@ -159,7 +152,9 @@
              value="&torsettings.reconfigTor;"/>
     </vbox>
   </vbox>
+`;
 
+var restartContent = `
   <vbox id="restartContent">
     <hbox pack="center">
       <description id="restartPanelMessage" flex="1"/>
@@ -170,7 +165,9 @@
               oncommand="onRestartTor()"/>
     </hbox>
   </vbox>
+`;
 
+var bridgeDBRequestOverlayContent = `
   <vbox id="bridgeDBRequestOverlayContent" align="center">
     <vbox>
       <label id="bridgeDBPrompt"/>
@@ -200,7 +197,9 @@
       </hbox>
     </vbox>
   </vbox>
+`;
 
+var errorOverlayContent = `
   <vbox id="errorOverlayContent">
     <hbox pack="center">
       <description errorElemId="message" flex="1"/>
@@ -211,10 +210,11 @@
               oncommand="onDismissErrorOverlay()"/>
     </hbox>
   </vbox>
+`;
 
+var copyLogFeedbackPanel = `
   <panel id="copyLogFeedbackPanel" type="arrow" fade="slow"
          onclick="closeCopyLogFeedbackPanel()">
      <description flex="1"/>
   </panel>
-</overlay>
-
+`;
diff --git a/src/chrome/content/network-settings-wizard.xul b/src/chrome/content/network-settings-wizard.xul
index 00145a8..2eb6d6d 100644
--- a/src/chrome/content/network-settings-wizard.xul
+++ b/src/chrome/content/network-settings-wizard.xul
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-   - Copyright (c) 2018, The Tor Project, Inc.
+   - Copyright (c) 2019, The Tor Project, Inc.
    - See LICENSE for licensing information.
    - vim: set sw=2 sts=2 ts=8 et syntax=xml:
   -->
@@ -9,9 +9,7 @@
 <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
                  type="text/css"?>
 
-<!DOCTYPE overlay SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
-
-<?xul-overlay href="chrome://torlauncher/content/network-settings-overlay.xul"?>
+<!DOCTYPE wizard SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
 
 <wizard id="TorNetworkSettings"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -127,8 +125,8 @@
 
   <wizardpage class="help" pageid="helpPanel" next="notUsed"
               onpageadvanced="closeHelp(); return false;">
-    <vbox id="bridgeHelpContent" hidden="true"/>
-    <vbox id="proxyHelpContent" hidden="true"/>
+    <vbox id="bridgeHelpContent"/>
+    <vbox id="proxyHelpContent"/>
   </wizardpage>
 
   <hbox pack="start">
diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index b39a194..85dade2 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -10,6 +10,7 @@ const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
+Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
                           "resource://torlauncher/modules/tl-util.jsm");
@@ -116,6 +117,8 @@ var gBridgeDBRequestEventListeners = [];
 
 function initDialogCommon()
 {
+  loadSharedXUL();
+
   gObsService = Cc["@mozilla.org/observer-service;1"]
                   .getService(Ci.nsIObserverService);
 
@@ -158,6 +161,39 @@ function initDialogCommon()
 }
 
 
+function loadSharedXUL()
+{
+  let ctxt = {};
+  Services.scriptloader.loadSubScript(
+    "chrome://torlauncher/content/network-settings-shared.js", ctxt);
+
+  let elementIDs =
+  [
+     "proxySettings",
+     "proxyHelpContent",
+     "bridgeSettings",
+     "bridgeHelpContent",
+     "progressContent",
+     "restartContent",
+     "bridgeDBRequestOverlayContent",
+     "errorOverlayContent",
+     "copyLogFeedbackPanel",
+  ];
+
+  let entityURLs = ["chrome://torlauncher/locale/network-settings.dtd"];
+  elementIDs.forEach(aID =>
+  {
+    let node = document.getElementById(aID);
+    if (node)
+    {
+      let xulStr = ctxt[aID];
+      let frag = window.MozXULElement.parseXULToFragment(xulStr, entityURLs);
+      node.parentNode.replaceChild(frag, node);
+    }
+  });
+}
+
+
 function resizeDialogToFitContent()
 {
   // Resize this window to fit content.  sizeToContent() alone will not do
diff --git a/src/chrome/content/network-settings.xul b/src/chrome/content/network-settings.xul
index 6f95183..2ba0741 100644
--- a/src/chrome/content/network-settings.xul
+++ b/src/chrome/content/network-settings.xul
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-   - Copyright (c) 2018, The Tor Project, Inc.
+   - Copyright (c) 2019, The Tor Project, Inc.
    - See LICENSE for licensing information.
    - vim: set sw=2 sts=2 ts=8 et syntax=xml:
   -->
@@ -9,9 +9,7 @@
 <?xml-stylesheet href="chrome://torlauncher/skin/network-settings.css"
                  type="text/css"?>
 
-<!DOCTYPE overlay SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
-
-<?xul-overlay href="chrome://torlauncher/content/network-settings-overlay.xul"?>
+<!DOCTYPE dialog SYSTEM "chrome://torlauncher/locale/network-settings.dtd">
 
 <dialog id="TorNetworkSettings"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -41,7 +39,13 @@
                       groupboxID="firewallSpecificSettings"
                       label="&torsettings.firewall.checkbox;"
                       oncommand="toggleElemUI(this)"/>
-            <groupbox id="firewallSpecificSettings"/>
+            <groupbox id="firewallSpecificSettings">
+              <hbox align="center">
+                <label value="&torsettings.firewall.allowedPorts;"
+                       control="firewallAllowedPorts"/>
+                <textbox id="firewallAllowedPorts" value="80,443"/>
+              </hbox>
+            </groupbox>
           </vbox>
         </vbox>
 
@@ -60,8 +64,8 @@
         </vbox>
 
         <vbox id="helpPanel" class="help">
-          <vbox id="bridgeHelpContent" hidden="true"/>
-          <vbox id="proxyHelpContent" hidden="true"/>
+          <vbox id="bridgeHelpContent"/>
+          <vbox id="proxyHelpContent"/>
         </vbox>
 
         <vbox id="restartPanel" class="messagePanel" pack="center">





More information about the tbb-commits mailing list