Bug 1404423 - Fix DOMi for Gecko 57 and up. r=IanN default
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 11 Dec 2017 18:45:54 +0100
changeset 1983 cd76a940d86d0168be0c4b4155b545b3cf88fb30
parent 1948 9b13e3ad66cf993b30ba6e40e144a7d6428f43c0
push id816
push userfrgrahl@gmx.net
push dateMon, 11 Dec 2017 17:46:12 +0000
reviewersIanN
bugs1404423
Bug 1404423 - Fix DOMi for Gecko 57 and up. r=IanN
Makefile.in
install.rdf
resources/content/Flasher.js
resources/content/jsutil/system/PrefUtils.js
--- a/Makefile.in
+++ b/Makefile.in
@@ -6,17 +6,17 @@
 
 DEPTH = ../..
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DOMi_VERSION = 2.0.17.1
+DOMi_VERSION = 2.0.17.2
 
 XPI_NAME               = inspector
 INSTALL_EXTENSION_ID   = inspector@mozilla.org
 XPI_PKGNAME            = inspector-$(DOMi_VERSION)
 
 DIST_FILES = install.rdf
 
 DEFINES += -DDOMi_VERSION=$(DOMi_VERSION)
--- a/install.rdf
+++ b/install.rdf
@@ -5,16 +5,17 @@
 
 #filter substitution
 
 <RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:em="http://www.mozilla.org/2004/em-rdf#">
   <Description about="urn:mozilla:install-manifest">
     <em:id>inspector@mozilla.org</em:id>
     <em:version>@DOMi_VERSION@</em:version>
+    <em:type>2</em:type>
     <em:multiprocessCompatible>false</em:multiprocessCompatible>
 
     <!-- DOM Inspector supports Gecko 2.0.0 and higher.
          All applications listed below are the subset of supported versions
          which also use an appropriate version of Gecko. -->
     <!-- For maxVersion of applications that follow the rapid cycle pattern,
          use '(x)a1' (*-central) on default,
          and '(x-1).*' (*-aurora/beta/release) for branches. -->
@@ -47,17 +48,17 @@
          2.0 is Gecko 1.9.1
          2.1 is Gecko 2.0
          2.2 is Gecko 5.0
          2.x is Gecko (x+3).0, where x is greater than 2 -->
     <em:targetApplication>
       <Description>
         <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
         <em:minVersion>2.1</em:minVersion>
-        <em:maxVersion>2.54</em:maxVersion>
+        <em:maxVersion>2.56</em:maxVersion>
       </Description>
     </em:targetApplication>
 
     <!-- Pale Moon -->
     <em:targetApplication>
       <Description>
         <em:id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</em:id>
         <em:minVersion>25.0</em:minVersion>
@@ -78,27 +79,27 @@
          3.0 is Gecko 1.9.1
          3.1 is Gecko 1.9.2
          5.0 is Gecko 5.0
          x.0 is Gecko x.0, where x is greater than 5 -->
     <em:targetApplication>
       <Description>
         <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
         <em:minVersion>4.0</em:minVersion>
-        <em:maxVersion>57.0</em:maxVersion>
+        <em:maxVersion>59.0</em:maxVersion>
       </Description>
     </em:targetApplication>
 
     <!-- Gecko Toolkit
          version 2.0.0 and higher -->
     <em:targetApplication>
       <Description>
         <em:id>toolkit@mozilla.org</em:id>
         <em:minVersion>2.0</em:minVersion>
-        <em:maxVersion>57.0</em:maxVersion>
+        <em:maxVersion>59.0</em:maxVersion>
       </Description>
     </em:targetApplication>
 
     <!-- front-end metadata -->
     <em:name>DOM Inspector</em:name>
     <em:description>Inspects the structure and properties of a window and its contents.</em:description>
     <em:creator>mozilla.org</em:creator>
     <em:homepageURL>http://www.mozilla.org/projects/inspector/</em:homepageURL>
--- a/resources/content/Flasher.js
+++ b/resources/content/Flasher.js
@@ -1,41 +1,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /***************************************************************
 * Flasher ---------------------------------------------------
-*   Object for controlling a timed flashing animation which 
+*   Object for controlling a timed flashing animation which
 *   paints a border around an element.
-* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
+* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 * REQUIRED IMPORTS:
 ****************************************************************/
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 //////////// global variables /////////////////////
 
 //////////// global constants ////////////////////
 
-const HIGHLIGHTED_PSEUDO_CLASS = ":-moz-devtools-highlighted";
+const isGecko58plus = Services.vc.compare(Services.appinfo.platformVersion, "58.0a1") >= 0;
+
+const HIGHLIGHTED_PSEUDO_CLASS = isGecko58plus? ":target" : ":-moz-devtools-highlighted";
 const INVERT = "filter: url(\"data:image/svg+xml;charset=utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='invert'><feColorMatrix in='SourceGraphic' type='matrix' values='-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0'/></filter></svg>%23invert\") !important; "
 
 ////////////////////////////////////////////////////////////////////////////
 //// class Flasher
 
 function Flasher(aColor, aThickness, aDuration, aSpeed, aInvert)
 {
   document.querySelector(HIGHLIGHTED_PSEUDO_CLASS);
   this.mIOService = XPCU.getService("@mozilla.org/network/io-service;1", "nsIIOService");
   this.mDOMUtils = XPCU.getService("@mozilla.org/inspector/dom-utils;1", "inIDOMUtils");
   this.mShell = XPCU.getService("@mozilla.org/inspector/flasher;1", "inIFlasher") || this.mDOMUtils;
   this.color = aColor;
   this.thickness = aThickness;
   this.invert = aInvert;
   this.duration = aDuration;
-  this.mSpeed = aSpeed;
+  this.speed = aSpeed;
 }
 
 Flasher.prototype =
 {
   ////////////////////////////////////////////////////////////////////////////
   //// Initialization
 
   mFlashTimeout: null,
@@ -187,24 +190,24 @@ LegacyFlasher.prototype =
   mStartTime: 0,
   mDuration: 0,
   mSpeed: 0,
 
   ////////////////////////////////////////////////////////////////////////////
   //// Properties
 
   get flashing() { return this.mFlashTimeout != null; },
-  
+
   get element() { return this.mElement; },
-  set element(val) 
-  { 
+  set element(val)
+  {
     if (val && val.nodeType == Node.ELEMENT_NODE) {
-      this.mElement = val; 
+      this.mElement = val;
       this.mShell.scrollElementIntoView(val);
-    } else 
+    } else
       throw "Invalid node type.";
   },
 
   get color() { return this.mShell.color; },
   set color(aVal)
   {
     try {
       this.mShell.color = aVal;
@@ -339,20 +342,21 @@ DOMIFlasher.prototype =
     PrefUtils.removeObserver("inspector.blink.", this);
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// Private
 
   init: function DOMIFlasher_init()
   {
-    try {
+    // See Bug 368608 comment 43. Flasher should work in Gecko 25 and up.
+    if (Services.vc.compare(Services.appinfo.platformVersion, "25.0a2") >= 0) {
       this.mFlasher = new Flasher(this.color, this.thickness, this.duration,
                                   this.speed, this.invert);
-    } catch (e) {
+    } else {
       this.mFlasher = new LegacyFlasher(this.color, this.thickness,
                                         this.duration, this.speed, this.invert);
     }
 
     PrefUtils.addObserver("inspector.blink.", this);
 
     this.updateFlashOnSelectCommand();
   },
--- a/resources/content/jsutil/system/PrefUtils.js
+++ b/resources/content/jsutil/system/PrefUtils.js
@@ -1,32 +1,32 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /***************************************************************
 * PrefUtils -------------------------------------------------
 *  Utility for easily using the Mozilla preferences system.
-* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
+* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 * REQUIRED IMPORTS:
 ****************************************************************/
+Components.utils.import("resource://gre/modules/Services.jsm");
 
-//////////// global variables /////////////////////
+//////////// global variables ////////////////////
 
 //////////// global constants ////////////////////
-
 const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
 
 ////////////////////////////////////////////////////////////////////////////
 //// class PrefUtils
 
-var PrefUtils = 
+var PrefUtils =
 {
   mPrefs: null,
-  
+
   init: function()
   {
     var prefService = XPCU.getService("@mozilla.org/preferences-service;1", "nsIPrefService");
     this.mPrefs = prefService.getBranch(null);
   },
 
   addObserver: function addObserver(aDomain, aFunction)
   {
@@ -44,24 +44,28 @@ var PrefUtils =
     var pbi = XPCU.QI(this.mPrefs, "nsIPrefBranch");
     if (pbi)
       pbi.removeObserver(aDomain, aFunction);
   },
 
   setPref: function(aName, aValue)
   {
     if (!this.mPrefs) this.init();
-    
+
     var type = this.mPrefs.getPrefType(aName);
     try {
       if (type == nsIPrefBranch.PREF_STRING) {
-        var str = Components.classes["@mozilla.org/supports-string;1"]
-                            .createInstance(Components.interfaces.nsISupportsString);
-        str.data = aValue;
-        this.mPrefs.setComplexValue(aName, Components.interfaces.nsISupportsString, str);
+        if (Services.vc.compare(Services.appinfo.platformVersion, "55.0a1") >= 0) {
+          this.mPrefs.setStringPref(aName, aValue);
+        } else {
+          var str = Components.classes["@mozilla.org/supports-string;1"]
+                              .createInstance(Components.interfaces.nsISupportsString);
+          str.data = aValue;
+          this.mPrefs.setComplexValue(aName, Components.interfaces.nsISupportsString, str);
+        }
       } else if (type == nsIPrefBranch.PREF_BOOL) {
         this.mPrefs.setBoolPref(aName, aValue);
       } else if (type == nsIPrefBranch.PREF_INT) {
         this.mPrefs.setIntPref(aName, aValue);
       }
     } catch(ex) {
       debug("ERROR: Unable to write pref \"" + aName + "\".\n");
     }
@@ -69,22 +73,23 @@ var PrefUtils =
 
   getPref: function(aName)
   {
     if (!this.mPrefs) this.init();
 
     var type = this.mPrefs.getPrefType(aName);
     try {
       if (type == nsIPrefBranch.PREF_STRING) {
+        if (Services.vc.compare(Services.appinfo.platformVersion, "55.0a1") >= 0) {
+          return this.mPrefs.getStringPref(aName);
+        }
         return this.mPrefs.getComplexValue(aName, Components.interfaces.nsISupportsString).data;
       } else if (type == nsIPrefBranch.PREF_BOOL) {
         return this.mPrefs.getBoolPref(aName);
       } else if (type == nsIPrefBranch.PREF_INT) {
         return this.mPrefs.getIntPref(aName);
       }
     } catch(ex) {
       debug("ERROR: Unable to read pref \"" + aName + "\".\n");
     }
     return null;
   }
-  
 };
-