Bug 1145162 - Prevent Tooltip class from relaying show/hide events that aren't its own; r=miker
authorPatrick Brosset <pbrosset@mozilla.com>
Thu, 19 Mar 2015 15:34:37 +0100
changeset 235171 35d17c53d9d13304b2555168491d4d883c9db423
parent 235170 844a5d08948ff09177c1e239003da04b51f16f38
child 235172 ad46c4efdc6ba27cb029adc5a5c926be7366f012
push id57353
push userkwierso@gmail.com
push dateMon, 23 Mar 2015 23:51:33 +0000
treeherdermozilla-inbound@7f5abc27fd53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker
bugs1145162
milestone39.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 1145162 - Prevent Tooltip class from relaying show/hide events that aren't its own; r=miker
browser/devtools/shared/widgets/Tooltip.js
--- a/browser/devtools/shared/widgets/Tooltip.js
+++ b/browser/devtools/shared/widgets/Tooltip.js
@@ -184,23 +184,27 @@ function Tooltip(doc, options) {
     noAutoFocus: true,
     closeOnEvents: []
   }, options);
   this.panel = PanelFactory.get(doc, this.options);
 
   // Used for namedTimeouts in the mouseover handling
   this.uid = "tooltip-" + Date.now();
 
-  // Emit show/hide events
-  for (let event of POPUP_EVENTS) {
-    this["_onPopup" + event] = ((e) => {
-      return () => this.emit(e);
-    })(event);
-    this.panel.addEventListener("popup" + event,
-      this["_onPopup" + event], false);
+  // Emit show/hide events when the panel does.
+  for (let eventName of POPUP_EVENTS) {
+    this["_onPopup" + eventName] = (name => {
+      return e => {
+        if (e.target === this.panel) {
+          this.emit(name);
+        }
+      };
+    })(eventName);
+    this.panel.addEventListener("popup" + eventName,
+      this["_onPopup" + eventName], false);
   }
 
   // Listen to keypress events to close the tooltip if configured to do so
   let win = this.doc.querySelector("window");
   this._onKeyPress = event => {
     if (this.panel.hidden) {
       return;
     }
@@ -298,19 +302,19 @@ Tooltip.prototype = {
   },
 
   /**
    * Get rid of references and event listeners
    */
   destroy: function () {
     this.hide();
 
-    for (let event of POPUP_EVENTS) {
-      this.panel.removeEventListener("popup" + event,
-        this["_onPopup" + event], false);
+    for (let eventName of POPUP_EVENTS) {
+      this.panel.removeEventListener("popup" + eventName,
+        this["_onPopup" + eventName], false);
     }
 
     let win = this.doc.querySelector("window");
     win.removeEventListener("keypress", this._onKeyPress, false);
 
     let closeOnEvents = this.options.get("closeOnEvents");
     for (let {emitter, event, useCapture} of closeOnEvents) {
       for (let remove of ["removeEventListener", "off"]) {