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

[tor-commits] [tor-browser/tor-browser-68.1.0esr-9.0-3] Bug 31920: Fix Security Level panel when its toolbar button moves to overflow



commit ec6ab177fd17a27ee6c7305c5433870d8d097097
Author: Richard Pospesel <richard@xxxxxxxxxxxxxx>
Date:   Wed Oct 16 15:06:54 2019 -0700

    Bug 31920: Fix Security Level panel when its toolbar button moves to overflow
    
    Simply removed the 'clever' caching of the underlying toolbar button
    element. Now, each time the button is needed it is queried from the
    underlying document.
    
    A correct, but more complicated, fix would be to determine when the
    toolbar button had been moved to the overflow menu and then update our
    cached reference. However, this would be super brittle and would
    break once another way to move the toolbar button is added in the
    future.
    
    In the end, caching something so infrequently queried is not worth the
    complexity.
---
 .../securitylevel/content/securityLevel.js         | 23 +++++-----------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/browser/components/securitylevel/content/securityLevel.js b/browser/components/securitylevel/content/securityLevel.js
index 7f307c5df43a..11dac5667e61 100644
--- a/browser/components/securitylevel/content/securityLevel.js
+++ b/browser/components/securitylevel/content/securityLevel.js
@@ -62,8 +62,6 @@ const SecurityLevelPrefs = {
 
 const SecurityLevelButton = {
   _securityPrefsBranch : null,
-  _button : null,
-  _anchor : null,
 
   _populateXUL : function(securityLevelButton) {
     if (securityLevelButton != null) {
@@ -95,23 +93,14 @@ const SecurityLevelButton = {
   },
 
   get button() {
-    if (this._button) {
-      return this._button;
-    }
-
     let button = document.getElementById("security-level-button");
     if (!button) {
       return null;
     }
-
-    return this._button = button;
+    return button;
   },
 
   get anchor() {
-    if (this._anchor) {
-      return this._anchor;
-    }
-
     let anchor = document.getAnonymousElementByAttribute(this.button, "class",
                                                    "toolbarbutton-icon");
     if (!anchor) {
@@ -119,13 +108,14 @@ const SecurityLevelButton = {
     }
 
     anchor.setAttribute("consumeanchor", SecurityLevelButton.button.id);
-    return this._anchor = anchor;
+    return anchor;
   },
 
   init : function() {
     // set the initial class based off of the current pref
-    this._populateXUL(this.button);
-    this._configUIFromPrefs(this.button);
+    let button = this.button;
+    this._populateXUL(button);
+    this._configUIFromPrefs(button);
 
     this._securityPrefsBranch = Services.prefs.getBranch("extensions.torbutton.");
     this._securityPrefsBranch.addObserver("", this, false);
@@ -167,9 +157,6 @@ const SecurityLevelButton = {
     if (aNode.id == "security-level-button" && !aWasRemoval) {
       this._populateXUL(aNode);
       this._configUIFromPrefs(aNode);
-      // clear out our cached elements as they seem to be recreated when the UI is customized
-      delete this._button;
-      delete this._anchor;
     }
   },
 

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