[tbb-commits] [tor-browser/tor-browser-68.1.0esr-9.0-3] Bug 31749: Fix security level panel spawning events
gk at torproject.org
gk at torproject.org
Thu Oct 17 10:23:03 UTC 2019
commit 071eea2a3b95c686b4a044481a975131a3261a34
Author: Richard Pospesel <richard at torproject.org>
Date: Wed Oct 16 15:35:33 2019 -0700
Bug 31749: Fix security level panel spawning events
Fixed logic for when the Security Level panel is spawned based on input
to mirror behavior of Downloads, Library and Hamburger menus. The panel
now spawns on left-mouse button down, and on keyboard activation when
user presses 'space' or 'enter'.
---
.../components/securitylevel/content/securityLevel.js | 19 ++++++++++++++++---
.../securitylevel/content/securityLevelButton.inc.xul | 3 ++-
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/browser/components/securitylevel/content/securityLevel.js b/browser/components/securitylevel/content/securityLevel.js
index 11dac5667e61..698af8f7297f 100644
--- a/browser/components/securitylevel/content/securityLevel.js
+++ b/browser/components/securitylevel/content/securityLevel.js
@@ -160,12 +160,25 @@ const SecurityLevelButton = {
}
},
- // when toolbar button is pressed
- onCommand : function(event) {
+ // for when the toolbar button needs to be activated and display the Security Level panel
+ //
+ // In the toolbarbutton xul you'll notice we register this callback for both onkeypress and
+ // onmousedown. We do this so match the behavior of other panel spawning buttons such as Downloads,
+ // Library, and the Hamburger menus. Using oncommand alone would result in only getting fired
+ // after onclick, which is mousedown followed by mouseup.
+ onCommand : function(aEvent) {
+ // snippet stolen from /browser/components/downloads/indicator.js DownloadsIndicatorView.onCommand(evt)
+ if (
+ (aEvent.type == "mousedown" && aEvent.button != 0) ||
+ (aEvent.type == "keypress" && aEvent.key != " " && aEvent.key != "Enter")
+ ) {
+ return;
+ }
+
// we need to set this attribute for the button to be shaded correctly to look like it is pressed
// while the security level panel is open
this.button.setAttribute("open", "true");
- SecurityLevelPanel.show(event);
+ SecurityLevelPanel.show();
},
}; /* Security Level Button */
diff --git a/browser/components/securitylevel/content/securityLevelButton.inc.xul b/browser/components/securitylevel/content/securityLevelButton.inc.xul
index 579a55f46d4a..d55aacb5c5d4 100644
--- a/browser/components/securitylevel/content/securityLevelButton.inc.xul
+++ b/browser/components/securitylevel/content/securityLevelButton.inc.xul
@@ -1,5 +1,6 @@
<toolbarbutton id="security-level-button" class="toolbarbutton-1 chromeclass-toolbar-additional badged-button"
removable="true"
- onmousedown="SecurityLevelButton.onCommand();"
+ onmousedown="SecurityLevelButton.onCommand(event);"
+ onkeypress="SecurityLevelButton.onCommand(event);"
closemenu="none"
cui-areatype="toolbar"/>
More information about the tbb-commits
mailing list