[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] Bug 31300: Modify Tor Launcher so it is compatible with ESR68



commit 1af54380f289426fea9dfa24c4fd6cf171046723
Author: Kathy Brade <brade@xxxxxxxxxxxxxxxxx>
Date:   Fri Aug 2 10:23:31 2019 -0400

    Bug 31300: Modify Tor Launcher so it is compatible with ESR68
    
    Replace some wizard and dialog "on" attributes with event handlers.
    Replace the XUL listbox element (which was removed by Mozilla) with
      richlistbox.
    Replace the XUL progressmeter element (which was removed by Mozilla) with
      an HTML progress element.
    Define our own CSS rules for groupbox elements (Mozilla removed the
      built-in styles).
    Fix some minor CSS incompatibilities.
---
 src/chrome/content/localePicker.xul            |  6 +-
 src/chrome/content/network-settings-shared.js  |  8 +--
 src/chrome/content/network-settings-wizard.xul | 24 +++-----
 src/chrome/content/network-settings.js         | 76 +++++++++++++++++++++++---
 src/chrome/content/network-settings.xul        |  3 -
 src/chrome/skin/network-settings.css           | 14 +++--
 6 files changed, 92 insertions(+), 39 deletions(-)

diff --git a/src/chrome/content/localePicker.xul b/src/chrome/content/localePicker.xul
index 1d0987c..152b54c 100644
--- a/src/chrome/content/localePicker.xul
+++ b/src/chrome/content/localePicker.xul
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-   - Copyright (c) 2017, 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:
   -->
@@ -16,8 +16,6 @@
         title="&torlauncher.localePicker.title;"
         windowtype="TorLauncher:LocalePicker"
         persist="screenX screenY"
-        onwizardfinish="return setLocale();"
-        onwizardcancel="return onCancel();"
         onload="initLocaleDialog();">
 
   <script type="application/x-javascript"
@@ -31,7 +29,7 @@
     <vbox>
       <label class="question">&torlauncher.localePicker.prompt;</label>
       <separator/>
-      <listbox id="localeList" ondblclick="onLocaleListDoubleClick()"/>
+      <richlistbox id="localeList" ondblclick="onLocaleListDoubleClick()"/>
     </vbox>
   </wizardpage>
 
diff --git a/src/chrome/content/network-settings-shared.js b/src/chrome/content/network-settings-shared.js
index 206872b..f1bdb91 100644
--- a/src/chrome/content/network-settings-shared.js
+++ b/src/chrome/content/network-settings-shared.js
@@ -20,7 +20,7 @@ var proxySettings = `
         <rows>
           <row align="center">
             <label value="&torsettings.useProxy.type;" control="proxyType"
-                   style="text-align:right"/>
+                   class="rightAlign"/>
             <hbox align="center">
               <menulist id="proxyType" sizetopopup="always"
                         placeholder="&torsettings.useProxy.type.placeholder;"
@@ -38,7 +38,7 @@ var proxySettings = `
           </row>
           <row align="center">
             <label value="&torsettings.useProxy.address;" control="proxyAddr"
-                   style="text-align:right"/>
+                   class="rightAlign"/>
             <hbox align="center">
               <textbox id="proxyAddr" size="20" flex="1"
                        placeholder="&torsettings.useProxy.address.placeholder;"/>
@@ -50,7 +50,7 @@ var proxySettings = `
           <row align="center">
             <label id="proxyUsernameLabel"
                    value="&torsettings.useProxy.username;"
-                   control="proxyUsername" style="text-align:right"/>
+                   control="proxyUsername" class="rightAlign"/>
             <hbox align="center">
               <textbox id="proxyUsername" size="14" flex="1"
                        placeholder="&torsettings.optional;"/>
@@ -146,7 +146,7 @@ var progressContent = `
     <vbox flex="1">
       <description id="progressPleaseWait"
                    hidden="true">&torprogress.pleaseWait;</description>
-      <progressmeter id="progressMeter" mode="determined" value="0"/>
+      <html:progress id="progressMeter" value="0" max="100"/>
       <description id="progressDesc" errorElemId="message"/>
       <label id="progressReconfigureLabel" hidden="true"
              value="&torsettings.reconfigTor;"/>
diff --git a/src/chrome/content/network-settings-wizard.xul b/src/chrome/content/network-settings-wizard.xul
index 2eb6d6d..ec48bd0 100644
--- a/src/chrome/content/network-settings-wizard.xul
+++ b/src/chrome/content/network-settings-wizard.xul
@@ -1,4 +1,3 @@
-<?xml version="1.0"?>
 <!--
    - Copyright (c) 2019, The Tor Project, Inc.
    - See LICENSE for licensing information.
@@ -17,15 +16,13 @@
         windowtype="TorLauncher:NetworkSettings"
         persist="screenX screenY"
         buttonlabelextra2="&torsettings.copyLog;"
-        onwizardfinish="return onWizardFinish();"
-        onwizardcancel="return onCancel();"
         onload="initDialog();"
         onunload="deinitDialog();">
 
   <script type="application/x-javascript"
           src="chrome://torlauncher/content/network-settings.js"/>
 
-  <wizardpage pageid="first" next="configureSettings" onextra2="onCopyLog();"
+  <wizardpage pageid="first" next="configureSettings"
               torShowNavButtons="false">
     <hbox class="tbb-header" pack="center">
       <image class="tbb-logo"/>
@@ -44,7 +41,7 @@
     </vbox>
   </wizardpage>
 
-  <wizardpage pageid="configureSettings" onextra2="onCopyLog();"
+  <wizardpage pageid="configureSettings"
               windowtitle="&torsettings.wizard.title.configure;"
               torShowNavButtons="true">
     <stack flex="1">
@@ -63,11 +60,9 @@
     </stack>
   </wizardpage>
 
-  <wizardpage pageid="progress" onextra2="onCopyLog();"
+  <wizardpage pageid="progress"
               windowtitle="&torsettings.wizard.title.connecting;"
-              torShowNavButtons="false"
-              onpageshow="onShowProgressPanel();"
-              onpagehide="return resetProgressNavButtons();">
+              torShowNavButtons="false">
     <vbox id="progressContent"/>
   </wizardpage>
 
@@ -86,12 +81,12 @@
   </wizardpage>
 
   <wizardpage pageid="restartPanel" class="messagePanel" next="notUsed"
-              pack="center" torShowNavButtons="false" onextra2="onCopyLog();">
+              pack="center" torShowNavButtons="false">
     <vbox id="restartContent"/>
   </wizardpage>
 
   <wizardpage pageid="errorPanel" class="messagePanel" next="notUsed"
-              torShowNavButtons="false" onextra2="onCopyLog();">
+              torShowNavButtons="false">
     <spring flex="1"/>
     <hbox pack="center">
       <description errorElemId="message" flex="1"/>
@@ -104,8 +99,8 @@
     <spring flex="1"/>
   </wizardpage>
 
-  <wizardpage pageid="discardSettings" next="notUsed" torShowNavButtons="false"
-              onextra2="onCopyLog();">
+  <wizardpage pageid="discardSettings" next="notUsed"
+              torShowNavButtons="false">
     <hbox class="tbb-header" pack="center">
       <image class="tbb-logo"/>
     </hbox>
@@ -123,8 +118,7 @@
     <spring flex="1"/>
   </wizardpage>
 
-  <wizardpage class="help" pageid="helpPanel" next="notUsed"
-              onpageadvanced="closeHelp(); return false;">
+  <wizardpage class="help" pageid="helpPanel" next="notUsed">
     <vbox id="bridgeHelpContent"/>
     <vbox id="proxyHelpContent"/>
   </wizardpage>
diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index 85dade2..a4f2866 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -157,6 +157,51 @@ function initDialogCommon()
                 .getService(Ci.nsIEnvironment);
     if (env.exists("TOR_HIDE_BROWSER_LOGO"))
       wizardElem.setAttribute("tor_hide_browser_logo", true);
+
+    // Add wizard event listeners.
+    document.addEventListener("wizardcancel", (aEvent) => {
+      if (!onCancel())
+        aEvent.preventDefault();
+    });
+
+    document.addEventListener("pageadvanced", (aEvent) => {
+      if ("helpPanel" == wizardElem.currentPage.pageid)
+      {
+        closeHelp();
+        aEvent.preventDefault();
+      }
+    });
+
+    document.addEventListener("pageshow", (aEvent) => {
+      if (kWizardProgressPageID == wizardElem.currentPage.pageid)
+        onShowProgressPanel();
+    });
+
+    document.addEventListener("pagehide", (aEvent) => {
+      if (kWizardProgressPageID == wizardElem.currentPage.pageid)
+        resetProgressNavButtons();
+    });
+
+    document.addEventListener("extra2", (aEvent) => {
+      onCopyLog();
+    });
+  }
+  else
+  {
+    // Add network settings dialog event listeners.
+    document.addEventListener("dialogaccept", (aEvent) => {
+      if (!onNetworkSettingsFinish())
+        aEvent.preventDefault();
+    });
+
+    document.addEventListener("dialogcancel", (aEvent) => {
+      if (!onCancel())
+        aEvent.preventDefault();
+    });
+
+    document.addEventListener("dialogextra2", (aEvent) => {
+      onCopyLog();
+    });
   }
 }
 
@@ -239,6 +284,12 @@ function initDialog()
   let haveWizard = (wizardElem != null);
   if (haveWizard)
   {
+    // Add wizardfinish event handler.
+    document.addEventListener("wizardfinish", (aEvent) => {
+      if (!onWizardFinish())
+        aEvent.preventDefault();
+    });
+
     // Relabel the accept button to be "Connect"
     let okBtn = document.documentElement.getButton("accept");
     if (okBtn)
@@ -316,6 +367,11 @@ function initLocaleDialog()
 {
   initDialogCommon();
 
+  // Add wizardfinish event handler.
+  document.addEventListener("wizardfinish", (aEvent) => {
+    setLocale();
+  });
+
   // Replace the finish button's label ("Done") with the next button's
   // label ("Next" or "Continue").
   let nextBtn = document.documentElement.getButton("next");
@@ -324,7 +380,8 @@ function initLocaleDialog()
     doneBtn.label = nextBtn.label;
 
   let { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
-  AddonManager.getAddonsByTypes(["locale"], function(aLangPackAddons)
+  let addonsPromise = AddonManager.getAddonsByTypes(["locale"]);
+  addonsPromise.then(aLangPackAddons =>
       {
         populateLocaleList(aLangPackAddons);
         resizeDialogToFitContent();
@@ -421,13 +478,15 @@ function populateLocaleList(aLangPackAddons)
   langInfo.splice(0, 0,
                   { langCode: code, langName: name, isSelected: isSelected });
 
-  // Populate the XUL listbox.
+  // Populate the XUL richlistbox.
   let localeList = document.getElementById(kLocaleList);
   for (let infoObj of langInfo)
   {
-    let listItem = document.createElement("listitem");
+    let listItem = document.createElement("richlistitem");
     listItem.setAttribute("value", infoObj.langCode);
-    listItem.setAttribute("label", infoObj.langName);
+    let label = document.createElement("label");
+    label.value = infoObj.langName;
+    listItem.appendChild(label);
     localeList.appendChild(listItem);
     if (infoObj.isSelected)
       localeList.selectedItem = listItem;
@@ -807,7 +866,6 @@ function resetProgressNavButtons()
 
   restoreButtonLabel("finish");
   showOrHideButton("cancel", true, false);
-  return true;
 }
 
 
@@ -905,7 +963,7 @@ function updateBootstrapProgress(aStatusObj)
   let meter = document.getElementById("progressMeter");
   if (meter)
   {
-    meter.value = percentComplete;
+    meter.setAttribute("value", percentComplete);
     showProgressMeterIfNoError();
   }
 
@@ -1968,7 +2026,7 @@ function showProgressPanel()
   let meter = document.getElementById("progressMeter");
   if (meter)
   {
-    meter.value = 0;
+    meter.setAttribute("value", 0);
     meter.style.visibility = "hidden";
   }
 
@@ -2428,7 +2486,7 @@ function setElemValue(aID, aValue)
         }
         // fallthru
       case "menulist":
-      case "listbox":
+      case "richlistbox":
       case "label":
         elem.value = (val) ? val : "";
         break;
@@ -2482,7 +2540,7 @@ function getElemValue(aID, aDefaultValue)
         break;
       case "textbox":
       case "menulist":
-      case "listbox":
+      case "richlistbox":
         rv = elem.value;
         break;
     }
diff --git a/src/chrome/content/network-settings.xul b/src/chrome/content/network-settings.xul
index 2ba0741..6a8fac4 100644
--- a/src/chrome/content/network-settings.xul
+++ b/src/chrome/content/network-settings.xul
@@ -18,9 +18,6 @@
         persist="screenX screenY"
         buttons="accept,cancel,extra2"
         buttonlabelextra2="&torsettings.copyLog;"
-        ondialogaccept="return onNetworkSettingsFinish();"
-        ondialogcancel="return onCancel();"
-        ondialogextra2="onCopyLog();"
         onload="initDialog();"
         onunload="deinitDialog();">
 
diff --git a/src/chrome/skin/network-settings.css b/src/chrome/skin/network-settings.css
index 40ca0f0..9fed4f2 100644
--- a/src/chrome/skin/network-settings.css
+++ b/src/chrome/skin/network-settings.css
@@ -1,5 +1,5 @@
 /*
- * 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=css:
@@ -47,8 +47,14 @@ wizard label {
   margin: 0px;
 }
 
-wizard radiogroup {
-  margin: 5px 0px 8px 25px;
+.rightAlign {
+  text-align: right;
+}
+
+groupbox {
+  margin-left: 16px;
+  padding: 8px;
+  border: 1px solid GrayText;
 }
 
 .tbb-header groupbox {
@@ -57,7 +63,7 @@ wizard radiogroup {
   margin-bottom: 0px;
 }
 
-.firstResponses label {
+.firstResponses > label {
   text-align: center;
   margin-top: 1.2em;
 }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits