Bug 1577801 - Stop messing with aria-activedescendant when mousing over one-off search buttons. r=mak
authorDão Gottwald <dao@mozilla.com>
Fri, 30 Aug 2019 15:07:31 +0000
changeset 554645 d116943004375716e43e6863d8a4b375821c7eaa
parent 554644 39b55da47051eb9be3f4ad663ee1c4deb1c51245
child 554646 9a59db93153408008285cac6cb17bf9d84b86aca
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1577801
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577801 - Stop messing with aria-activedescendant when mousing over one-off search buttons. r=mak Differential Revision: https://phabricator.services.mozilla.com/D44162
browser/components/search/content/search-one-offs.js
--- a/browser/components/search/content/search-one-offs.js
+++ b/browser/components/search/content/search-one-offs.js
@@ -109,21 +109,19 @@ class SearchOneOffs {
     this.addEventListener("contextmenu", this);
 
     // Prevent popup events from the context menu from reaching the autocomplete
     // binding (or other listeners).
     let listener = aEvent => aEvent.stopPropagation();
     this.contextMenuPopup.addEventListener("popupshowing", listener);
     this.contextMenuPopup.addEventListener("popuphiding", listener);
     this.contextMenuPopup.addEventListener("popupshown", aEvent => {
-      this._ignoreMouseEvents = true;
       aEvent.stopPropagation();
     });
     this.contextMenuPopup.addEventListener("popuphidden", aEvent => {
-      this._ignoreMouseEvents = false;
       aEvent.stopPropagation();
     });
 
     // Add weak referenced observers to invalidate our cached list of engines.
     this.QueryInterface = ChromeUtils.generateQI([
       Ci.nsIObserver,
       Ci.nsISupportsWeakReference,
     ]);
@@ -298,17 +296,25 @@ class SearchOneOffs {
     let previousButton = this._selectedButton;
     if (previousButton) {
       previousButton.removeAttribute("selected");
     }
     if (val) {
       val.setAttribute("selected", "true");
     }
     this._selectedButton = val;
-    this._updateStateForButton(null);
+
+    if (this.textbox) {
+      if (val) {
+        this.textbox.setAttribute("aria-activedescendant", val.id);
+      } else {
+        this.textbox.removeAttribute("aria-activedescendant");
+      }
+    }
+
     if (val && !val.engine) {
       // If the button doesn't have an engine, then clear the popup's
       // selection to indicate that pressing Return while the button is
       // selected will do the button's command, not search.
       this.selectedAutocompleteIndex = -1;
     }
     let event = new CustomEvent("SelectedOneOffButtonChanged", {
       previousSelectedButton: previousButton,
@@ -644,39 +650,16 @@ class SearchOneOffs {
     return name.replace(/ /g, "-");
   }
 
   _buttonForEngine(engine) {
     let id = this._buttonIDForEngine(engine);
     return document.getElementById(id);
   }
 
-  /**
-   * Updates the popup and textbox for the currently selected or moused-over
-   * button.
-   *
-   * @param {DOMElement} mousedOverButton
-   *        The currently moused-over button, or null if there isn't one.
-   */
-  _updateStateForButton(mousedOverButton) {
-    let button = mousedOverButton;
-
-    // If there's no moused-over button, then the one-offs should reflect
-    // the selected button, if any.
-    button = button || this.selectedButton;
-
-    if (this.textbox) {
-      if (!button) {
-        this.textbox.removeAttribute("aria-activedescendant");
-      } else {
-        this.textbox.setAttribute("aria-activedescendant", button.id);
-      }
-    }
-  }
-
   getSelectableButtons(aIncludeNonEngineButtons) {
     let buttons = [];
     for (
       let oneOff = this.buttons.firstElementChild;
       oneOff;
       oneOff = oneOff.nextElementSibling
     ) {
       buttons.push(oneOff);
@@ -1075,67 +1058,33 @@ class SearchOneOffs {
     let target = event.originalTarget;
 
     // Handle mouseover on the add-engine menu button and its popup items.
     if (
       (target.localName == "menuitem" &&
         target.classList.contains("addengine-item")) ||
       target.classList.contains("addengine-menu-button")
     ) {
-      let menuButton = this.querySelector(".addengine-menu-button");
-      this._updateStateForButton(menuButton);
       this._addEngineMenuShouldBeOpen = true;
       this._resetAddEngineMenuTimeout();
-      return;
-    }
-
-    if (target.localName != "button") {
-      return;
-    }
-
-    // Ignore mouse events when the context menu is open.
-    if (this._ignoreMouseEvents) {
-      return;
-    }
-
-    let isOneOff = target.classList.contains("searchbar-engine-one-off-item");
-    if (
-      isOneOff ||
-      target.classList.contains("addengine-item") ||
-      target.classList.contains("search-setting-button")
-    ) {
-      this._updateStateForButton(target);
     }
   }
 
   _on_mouseout(event) {
     let target = event.originalTarget;
 
     // Handle mouseout on the add-engine menu button and its popup items.
     if (
       (target.localName == "menuitem" &&
         target.classList.contains("addengine-item")) ||
       target.classList.contains("addengine-menu-button")
     ) {
-      this._updateStateForButton(null);
       this._addEngineMenuShouldBeOpen = false;
       this._resetAddEngineMenuTimeout();
-      return;
     }
-
-    if (target.localName != "button") {
-      return;
-    }
-
-    // Don't update the mouseover state if the context menu is open.
-    if (this._ignoreMouseEvents) {
-      return;
-    }
-
-    this._updateStateForButton(null);
   }
 
   _on_click(event) {
     if (event.button == 2) {
       return; // ignore right clicks.
     }
 
     let button = event.originalTarget;