richard pushed to branch tor-browser-115.2.0esr-13.0-1 at The Tor Project / Applications / Tor Browser

Commits:

4 changed files:

Changes:

  • browser/components/torpreferences/content/connectionPane.js
    ... ... @@ -99,7 +99,6 @@ const gConnectionPane = (function () {
    99 99
           currentHeader: "#torPreferences-currentBridges-header",
    
    100 100
           currentDescription: "#torPreferences-currentBridges-description",
    
    101 101
           currentDescriptionText: "#torPreferences-currentBridges-descriptionText",
    
    102
    -      switchLabel: "#torPreferences-currentBridges-enableAll-label",
    
    103 102
           switch: "#torPreferences-currentBridges-switch",
    
    104 103
           cards: "#torPreferences-currentBridges-cards",
    
    105 104
           cardTemplate: "#torPreferences-bridgeCard-template",
    
    ... ... @@ -391,11 +390,10 @@ const gConnectionPane = (function () {
    391 390
             selectors.bridges.currentHeader
    
    392 391
           );
    
    393 392
           bridgeHeader.textContent = TorStrings.settings.bridgeCurrent;
    
    394
    -      prefpane.querySelector(selectors.bridges.switchLabel).textContent =
    
    395
    -        TorStrings.settings.allBridgesEnabled;
    
    396 393
           const bridgeSwitch = prefpane.querySelector(selectors.bridges.switch);
    
    397
    -      bridgeSwitch.addEventListener("change", () => {
    
    398
    -        TorSettings.bridges.enabled = bridgeSwitch.checked;
    
    394
    +      bridgeSwitch.setAttribute("label", TorStrings.settings.allBridgesEnabled);
    
    395
    +      bridgeSwitch.addEventListener("toggle", () => {
    
    396
    +        TorSettings.bridges.enabled = bridgeSwitch.pressed;
    
    399 397
             TorSettings.saveToPrefs();
    
    400 398
             TorSettings.applySettings().then(result => {
    
    401 399
               this._populateBridgeCards();
    
    ... ... @@ -525,7 +523,7 @@ const gConnectionPane = (function () {
    525 523
                     strings.splice(index, 1);
    
    526 524
                   }
    
    527 525
                   TorSettings.bridges.enabled =
    
    528
    -                bridgeSwitch.checked && !!strings.length;
    
    526
    +                bridgeSwitch.pressed && !!strings.length;
    
    529 527
                   TorSettings.bridges.bridge_strings = strings.join("\n");
    
    530 528
                   TorSettings.saveToPrefs();
    
    531 529
                   TorSettings.applySettings().then(result => {
    
    ... ... @@ -642,7 +640,9 @@ const gConnectionPane = (function () {
    642 640
             bridgeHeader.hidden = false;
    
    643 641
             bridgeDescription.hidden = false;
    
    644 642
             bridgeCards.hidden = false;
    
    645
    -        bridgeSwitch.checked = TorSettings.bridges.enabled;
    
    643
    +        // Changing the pressed property on moz-toggle should not trigger its
    
    644
    +        // "toggle" event.
    
    645
    +        bridgeSwitch.pressed = TorSettings.bridges.enabled;
    
    646 646
             bridgeCards.classList.toggle("disabled", !TorSettings.bridges.enabled);
    
    647 647
             bridgeCards.classList.toggle("single-card", numBridges === 1);
    
    648 648
     
    

  • browser/components/torpreferences/content/connectionPane.xhtml
    ... ... @@ -108,16 +108,10 @@
    108 108
           <html:span id="torPreferences-currentBridges-descriptionText" />
    
    109 109
         </description>
    
    110 110
         <hbox align="center">
    
    111
    -      <html:input
    
    112
    -        type="checkbox"
    
    111
    +      <html:moz-toggle
    
    113 112
             id="torPreferences-currentBridges-switch"
    
    114
    -        class="toggle-button"
    
    113
    +        label-align-after=""
    
    115 114
           />
    
    116
    -      <html:label
    
    117
    -        id="torPreferences-currentBridges-enableAll-label"
    
    118
    -        for="torPreferences-currentBridges-switch"
    
    119
    -      >
    
    120
    -      </html:label>
    
    121 115
           <spacer flex="1" />
    
    122 116
           <button id="torPreferences-currentBridges-removeAll" />
    
    123 117
         </hbox>
    

  • browser/components/torpreferences/content/torPreferences.css
    ... ... @@ -5,11 +5,6 @@
    5 5
       list-style-image: url("chrome://browser/content/torconnect/tor-connect.svg");
    
    6 6
     }
    
    7 7
     
    
    8
    -html:dir(rtl) input[type="checkbox"].toggle-button::before {
    
    9
    -  /* For some reason, the rule from toggle-button.css is not applied... */
    
    10
    -  scale: -1;
    
    11
    -}
    
    12
    -
    
    13 8
     /* Status */
    
    14 9
     
    
    15 10
     #torPreferences-status-box {
    
    ... ... @@ -83,12 +78,6 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before {
    83 78
       font-weight: 700;
    
    84 79
     }
    
    85 80
     
    
    86
    -#torPreferences-currentBridges-enableAll-label {
    
    87
    -  /* Block display to work with parent's xul box layout. */
    
    88
    -  display: block;
    
    89
    -  margin-inline: 6px;
    
    90
    -}
    
    91
    -
    
    92 81
     /* Bridge cards */
    
    93 82
     :root {
    
    94 83
       --bridgeCard-animation-time: 0.25s;
    

  • toolkit/content/widgets/moz-toggle/moz-toggle.mjs
    ... ... @@ -36,6 +36,8 @@ export default class MozToggle extends MozLitElement {
    36 36
         accessKey: { type: String, attribute: "accesskey" },
    
    37 37
         // Extension for tor-browser. Used for tor-browser#41333.
    
    38 38
         title: { type: String, attribute: "title" },
    
    39
    +    // Extension for tor-browser. Used for tor-browser#40837.
    
    40
    +    labelAlignAfter: { type: Boolean, attribute: "label-align-after" },
    
    39 41
       };
    
    40 42
     
    
    41 43
       static get queries() {
    
    ... ... @@ -119,9 +121,13 @@ export default class MozToggle extends MozLitElement {
    119 121
         // accessible name derived from the label.
    
    120 122
         const label = ariaLabel || this.label;
    
    121 123
         const ariaDescription = label === this.title ? undefined : this.title;
    
    124
    +    // For tor-browser, we want to be able to place the label after the toggle
    
    125
    +    // as well.
    
    126
    +    // Used for the enable-bridges switch tor-browser#40837.
    
    127
    +    const labelAlignAfter = this.labelAlignAfter;
    
    122 128
         return html`
    
    123 129
           <link rel="stylesheet" href=${this.constructor.stylesheetUrl} />
    
    124
    -      ${this.labelTemplate()}
    
    130
    +      ${labelAlignAfter ? "" : this.labelTemplate()}
    
    125 131
           <button
    
    126 132
             id="moz-toggle-button"
    
    127 133
             part="button"
    
    ... ... @@ -136,6 +142,7 @@ export default class MozToggle extends MozLitElement {
    136 142
             )}
    
    137 143
             @click=${handleClick}
    
    138 144
           ></button>
    
    145
    +      ${labelAlignAfter ? this.labelTemplate() : ""}
    
    139 146
           ${this.descriptionTemplate()}
    
    140 147
         `;
    
    141 148
       }