From 9b1cea50c2717fce9448531afc6fa2e78ff52aa2 Mon Sep 17 00:00:00 2001 From: Razvan Caliman Date: Tue, 15 Oct 2019 13:24:21 +0000 Subject: [PATCH] Bug 1581850 - Ensure target elements are highlighted when hovering selectors in DevTools Style Editor. r=pbro Differential Revision: https://phabricator.services.mozilla.com/D46155 --HG-- extra : moz-landing-system : lando --- .../client/styleeditor/StyleSheetEditor.jsm | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/devtools/client/styleeditor/StyleSheetEditor.jsm b/devtools/client/styleeditor/StyleSheetEditor.jsm index 55b530951124..54a6d8d28c38 100644 --- a/devtools/client/styleeditor/StyleSheetEditor.jsm +++ b/devtools/client/styleeditor/StyleSheetEditor.jsm @@ -493,8 +493,16 @@ StyleSheetEditor.prototype = { this._state.selection.end ); - if (this.highlighter && this.walker) { - sourceEditor.container.addEventListener("mousemove", this._onMouseMove); + if ( + this.highlighter && + this.walker && + sourceEditor.container && + sourceEditor.container.contentWindow + ) { + sourceEditor.container.contentWindow.addEventListener( + "mousemove", + this._onMouseMove + ); } // Add the commands controller for the source-editor. @@ -836,8 +844,13 @@ StyleSheetEditor.prototype = { this._sourceEditor.off("dirty-change", this._onPropertyChange); this._sourceEditor.off("saveRequested", this.saveToFile); this._sourceEditor.off("change", this.updateStyleSheet); - if (this.highlighter && this.walker && this._sourceEditor.container) { - this._sourceEditor.container.removeEventListener( + if ( + this.highlighter && + this.walker && + this._sourceEditor.container && + this._sourceEditor.container.contentWindow + ) { + this._sourceEditor.container.contentWindow.removeEventListener( "mousemove", this._onMouseMove );